-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 68 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 25 |
2 files changed, 88 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index a3da5b2..9b036f3 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -2,8 +2,29 @@ | |||
2 | #include <qsizepolicy.h> | 2 | #include <qsizepolicy.h> |
3 | #include <qwindowsystem_qws.h> | ||
3 | 4 | ||
4 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | 5 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : |
5 | QFrame(parent), numRows(2), numCols(15), | 6 | QFrame(parent), numRows(1), numCols(11), |
6 | pressedRow(0), pressedCol(0) { | 7 | pressedRow(0), pressedCol(0) { |
7 | 8 | ||
8 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 9 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); |
10 | |||
11 | Config conf("opie-console-keys"); | ||
12 | conf.setGroup("keys"); | ||
13 | for (int r = 0; r < numRows; r++) | ||
14 | for (int c = 0; c < numCols; c++) { | ||
15 | |||
16 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | ||
17 | QStringList value_list = conf.readListEntry( handle, '|'); | ||
18 | |||
19 | if (value_list.isEmpty()) continue; | ||
20 | |||
21 | keys.insert( | ||
22 | |||
23 | handle, | ||
24 | FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort()) | ||
25 | ); | ||
26 | } | ||
27 | qWarning("loaded %d keys", keys.count()); | ||
28 | |||
29 | |||
9 | 30 | ||
@@ -21,2 +42,4 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
21 | 42 | ||
43 | p.setPen(QColor(0,0,0)); | ||
44 | |||
22 | /* those decimals do count! becomes short if use plain int */ | 45 | /* those decimals do count! becomes short if use plain int */ |
@@ -24,3 +47,2 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
24 | 47 | ||
25 | p.setPen(QColor(0,0,0)); | ||
26 | p.drawLine((int)i, 0, (int)i, height()); | 48 | p.drawLine((int)i, 0, (int)i, height()); |
@@ -28,5 +50,7 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
28 | 50 | ||
29 | for (int i = 0; i <= height(); i += height()/numRows) { | 51 | // sometimes the last line doesnt get drawn |
52 | p.drawLine(width() -1, 0, width() -1, height()); | ||
53 | |||
54 | for (int i = 0; i <= height(); i += keyHeight) { | ||
30 | 55 | ||
31 | p.setPen(QColor(0,0,0)); | ||
32 | p.drawLine(0, i, width(), i); | 56 | p.drawLine(0, i, width(), i); |
@@ -34,2 +58,17 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
34 | 58 | ||
59 | for (int r = 0; r < numRows; r++) { | ||
60 | for (int c = 0; c < numCols; c++) { | ||
61 | |||
62 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | ||
63 | if (keys.contains(handle)) { | ||
64 | |||
65 | p.drawText( | ||
66 | c * keyWidth + 1, r * keyHeight + 1, | ||
67 | keyWidth, keyHeight, | ||
68 | Qt::AlignHCenter | Qt::AlignVCenter, | ||
69 | keys[handle].getL() | ||
70 | ); | ||
71 | } | ||
72 | } | ||
73 | } | ||
35 | } | 74 | } |
@@ -39,2 +78,3 @@ void FunctionKeyboard::paintKey(int row, int col) { | |||
39 | QPainter p(this); | 78 | QPainter p(this); |
79 | |||
40 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), | 80 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), |
@@ -42,2 +82,9 @@ void FunctionKeyboard::paintKey(int row, int col) { | |||
42 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); | 82 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); |
83 | p.drawText( | ||
84 | col * keyWidth + 1, row * keyHeight + 1, | ||
85 | keyWidth, keyHeight, | ||
86 | Qt::AlignHCenter | Qt::AlignVCenter, | ||
87 | keys["r" + QString::number(row) + "c" + QString::number(col)].getL() | ||
88 | ); | ||
89 | |||
43 | } | 90 | } |
@@ -50,2 +97,8 @@ void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | |||
50 | paintKey(pressedRow, pressedCol); | 97 | paintKey(pressedRow, pressedCol); |
98 | |||
99 | // emit that sucker! | ||
100 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | ||
101 | //QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0); | ||
102 | //qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0); | ||
103 | qwsServer->sendKeyEvent(0x41, 0, 0, 1, 0); | ||
51 | } | 104 | } |
@@ -59,3 +112,8 @@ void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | |||
59 | paintKey(row, col); | 112 | paintKey(row, col); |
113 | |||
114 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | ||
115 | //QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0); | ||
116 | //qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0); | ||
60 | } | 117 | } |
118 | |||
61 | } | 119 | } |
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index f1ca037..bc3e25c 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h | |||
@@ -3,4 +3,24 @@ | |||
3 | 3 | ||
4 | #include <qpe/config.h> | ||
4 | #include <qframe.h> | 5 | #include <qframe.h> |
5 | #include <qpainter.h> | 6 | #include <qpainter.h> |
7 | #include <qmap.h> | ||
8 | |||
9 | class FKey { | ||
10 | |||
11 | public: | ||
12 | |||
13 | FKey(): qcode(0), unicode(0) {}; | ||
14 | FKey(const QString &l, ushort q, ushort u): label(l), qcode(q), unicode(u) {}; | ||
15 | |||
16 | QString getL() { return label; } | ||
17 | ushort getQ() { return qcode; } | ||
18 | ushort getU() { return unicode; } | ||
19 | |||
20 | private: | ||
21 | |||
22 | QString label; | ||
23 | ushort qcode; | ||
24 | ushort unicode; | ||
25 | }; | ||
6 | 26 | ||
@@ -19,2 +39,3 @@ public: | |||
19 | 39 | ||
40 | |||
20 | 41 | ||
@@ -23,2 +44,6 @@ public: | |||
23 | private: | 44 | private: |
45 | |||
46 | // thie key for the map is the row/col | ||
47 | QMap<QString, FKey> keys; | ||
48 | |||
24 | uint numRows; | 49 | uint numRows; |