This repository has been archived by the owner on May 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmymenu.cpp
122 lines (107 loc) · 3.02 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
/*
* 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);
SetGeometryPortrait(0);
return 0;
}
void CMyMenu::SetGeometryPortrait(int nKBHeight){
QRect r = QApplication::desktop()->screenGeometry(0);
int nW = r.width();
int nH = r.height();
int btnW = nW/7;
this->setGeometry(0, nH-103-nKBHeight, nW, 103);
btnCtrlC->setGeometry(QRect(2, 1, btnW-1, 101));
btnTab ->setGeometry(QRect(1*btnW+1, 1, btnW-1, 101));
btnLeft ->setGeometry(QRect(2*btnW+1, 1, btnW-1, 101));
btnRight->setGeometry(QRect(3*btnW+1, 1, btnW-1, 101));
btnUp ->setGeometry(QRect(4*btnW+1, 1, btnW-1, 101));
btnDown ->setGeometry(QRect(5*btnW+1, 1, btnW-1, 101));
btnEsc ->setGeometry(QRect(6*btnW+1, 1, btnW-1, 101));
}
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'};
if(bCtrlFlag)
c[2] = 'd';
write(masterFdG, c, 3);
console->setFocus();
return;
}
void CMyMenu::on_btnRight_clicked(){
char c[] = {0x1B,0x5B,'C'};
if(bCtrlFlag)
c[2] = '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;
}