forked from BGmot/BGShellBB10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmymenu.cpp
143 lines (131 loc) · 3.9 KB
/
mymenu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* Copyright (C) 2012 BGmot <[email protected]>
*/
#include <fcntl.h>
#include "mymenu.h"
#include "qtermwidget.h"
extern int masterFdG;
extern QTermWidget *console;
extern bool bCtrlFlag;
CMyMenu::CMyMenu(QWidget *parent) :
QWidget(parent)
{
}
// There is nothing to comment here, all button names tell you what they do
int CMyMenu::MenuInit(){
btnCtrlC = new QToolButton(this);
btnCtrlC->setObjectName(QString::fromUtf8("btnCtrlC"));
btnCtrlC->setText(QString("Ctrl+"));
btnTab = new QToolButton(this);
btnTab->setObjectName(QString::fromUtf8("btnTab"));
btnTab->setText(QString("Tab"));
btnLeft = new QToolButton(this);
btnLeft->setObjectName(QString::fromUtf8("btnLeft"));
btnLeft->setText(QString("<"));
btnRight = new QToolButton(this);
btnRight->setObjectName(QString::fromUtf8("btnRight"));
btnRight->setText(QString(">"));
btnUp = new QToolButton(this);
btnUp->setObjectName(QString::fromUtf8("btnUp"));
btnUp->setText(QString("^"));
btnDown = new QToolButton(this);
btnDown->setObjectName(QString::fromUtf8("btnDown"));
btnDown->setText(QString("v"));
btnEsc = new QToolButton(this);
btnEsc->setObjectName(QString::fromUtf8("btnEsc"));
btnEsc->setText(QString("Esc"));
QMetaObject::connectSlotsByName(this);
#ifndef BBQ10
QRect r = QApplication::desktop()->screenGeometry(0); // Landscape 1023x599
if (r.width() > 800)
SetGeometryLandscape();
else
SetGeometryPortrait();
#else
SetGeometryPortrait();
#endif
return 0;
}
void CMyMenu::SetGeometryPortrait(){
QRect r = QApplication::desktop()->screenGeometry(0);
#ifndef BBQ10
this->setGeometry(0, 0, r.width(), 103);
btnCtrlC->setGeometry(QRect(2, 1, 110, 101));
btnTab ->setGeometry(QRect(112, 1, 100, 101));
btnLeft ->setGeometry(QRect(112+1*100+1*2, 1, 100, 101));
btnRight->setGeometry(QRect(112+2*100+2*2, 1, 100, 101));
btnUp ->setGeometry(QRect(112+3*100+3*2, 1, 100, 101));
btnDown ->setGeometry(QRect(112+4*100+4*2, 1, 100, 101));
btnEsc ->setGeometry(QRect(112+5*100+5*2, 1, 100, 101));
#else
int nW = r.width();
int nH = r.height();
this->setGeometry(0, nH-103, nW, 103);
btnCtrlC->setGeometry(QRect(2, 1, 110, 101));
btnTab ->setGeometry(QRect(112, 1, 100, 101));
btnLeft ->setGeometry(QRect(112+1*100+1*2, 1, 100, 101));
btnRight->setGeometry(QRect(112+2*100+2*2, 1, 100, 101));
btnUp ->setGeometry(QRect(112+3*100+3*2, 1, 100, 101));
btnDown ->setGeometry(QRect(112+4*100+4*2, 1, 100, 101));
btnEsc ->setGeometry(QRect(112+5*100+5*2, 1, 100, 101));
#endif
}
void CMyMenu::SetGeometryLandscape(){
this->setGeometry(1206, 0, 73, 357);
btnCtrlC->setGeometry(QRect(1, 1, 71, 51));
btnTab->setGeometry(QRect(1, 52, 71, 51));
btnLeft->setGeometry(QRect(1, 103, 71, 51));
btnRight->setGeometry(QRect(1, 154, 71, 51));
btnUp->setGeometry(QRect(1, 205, 71, 51));
btnDown->setGeometry(QRect(1, 256, 71, 51));
btnEsc->setGeometry(QRect(1, 307, 71, 50));
}
void CMyMenu::on_btnCtrlC_clicked(){
// Now it is not Ctrl+C, it is CTRL+something, so let's wait for the next key or reset this flag
if (bCtrlFlag == false){
bCtrlFlag = true;
btnCtrlC->setDown(true);
}
else{
bCtrlFlag = false;
btnCtrlC->setDown(false);
}
console->setFocus();
return;
}
void CMyMenu::on_btnTab_clicked(){
char c = 9;
write(masterFdG, &c, 1);
console->setFocus();
return;
}
void CMyMenu::on_btnLeft_clicked(){
char c[] = {0x1B,0x5B,'D'};
write(masterFdG, c, 3);
console->setFocus();
return;
}
void CMyMenu::on_btnRight_clicked(){
char c[] = {0x1B,0x5B,'C'};
write(masterFdG, c, 3);
console->setFocus();
return;
}
void CMyMenu::on_btnUp_clicked(){
char c[] = {0x1B,0x5B,'A'};
write(masterFdG, c, 3);
console->setFocus();
return;
}
void CMyMenu::on_btnDown_clicked(){
char c[] = {0x1B,0x5B,'B'};
write(masterFdG, c, 3);
console->setFocus();
return;
}
void CMyMenu::on_btnEsc_clicked(){
char c = 0x1B;
write(masterFdG, &c, 1);
console->setFocus();
return;
}