author | hash <hash> | 2002-10-15 16:26:14 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-15 16:26:14 (UTC) |
commit | 9861ca46526e65ecb00641008b9e8c1105ba1dc9 (patch) (unidiff) | |
tree | 457e4a90667bbc1c133b9eca91f31f7e641b1e4c | |
parent | d0cd09e4a68ca8dc3acf50c13a0acce39cd36b55 (diff) | |
download | opie-9861ca46526e65ecb00641008b9e8c1105ba1dc9.zip opie-9861ca46526e65ecb00641008b9e8c1105ba1dc9.tar.gz opie-9861ca46526e65ecb00641008b9e8c1105ba1dc9.tar.bz2 |
still trying to figure out how to get those events out wihtout crashing the damn thing
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 24 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 6 |
2 files changed, 23 insertions, 7 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index a5b19c0..ac35d1c 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -1,27 +1,28 @@ | |||
1 | #include "function_keyboard.h" | 1 | #include "function_keyboard.h" |
2 | #include <qsizepolicy.h> | 2 | #include <qsizepolicy.h> |
3 | #include <qevent.h> | 3 | #include <qevent.h> |
4 | #include <qwindowsystem_qws.h> | ||
4 | #include <qapplication.h> | 5 | #include <qapplication.h> |
5 | 6 | ||
6 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | 7 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : |
7 | QFrame(parent), numRows(1), numCols(11), | 8 | QFrame(parent), numRows(1), numCols(11), |
8 | pressedRow(0), pressedCol(0) { | 9 | pressedRow(0), pressedCol(0) { |
9 | 10 | ||
10 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); | 11 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); |
11 | 12 | ||
12 | Config conf("opie-console-keys"); | 13 | Config conf("opie-console-keys"); |
13 | conf.setGroup("keys"); | 14 | conf.setGroup("keys"); |
14 | for (int r = 0; r < numRows; r++) | 15 | for (int r = 0; r < numRows; r++) |
15 | for (int c = 0; c < numCols; c++) { | 16 | for (int c = 0; c < numCols; c++) { |
16 | 17 | ||
17 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 18 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
18 | QStringList value_list = conf.readListEntry( handle, '|'); | 19 | QStringList value_list = conf.readListEntry( handle, '|'); |
19 | 20 | ||
20 | if (value_list.isEmpty()) continue; | 21 | if (value_list.isEmpty()) continue; |
21 | 22 | ||
22 | keys.insert( | 23 | keys.insert( |
23 | 24 | ||
24 | handle, | 25 | handle, |
25 | FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort()) | 26 | FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort()) |
26 | ); | 27 | ); |
27 | } | 28 | } |
@@ -78,65 +79,74 @@ void FunctionKeyboard::paintKey(int row, int col) { | |||
78 | 79 | ||
79 | QPainter p(this); | 80 | QPainter p(this); |
80 | 81 | ||
81 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), | 82 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), |
82 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), | 83 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), |
83 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); | 84 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); |
84 | p.drawText( | 85 | p.drawText( |
85 | col * keyWidth + 1, row * keyHeight + 1, | 86 | col * keyWidth + 1, row * keyHeight + 1, |
86 | keyWidth, keyHeight, | 87 | keyWidth, keyHeight, |
87 | Qt::AlignHCenter | Qt::AlignVCenter, | 88 | Qt::AlignHCenter | Qt::AlignVCenter, |
88 | keys["r" + QString::number(row) + "c" + QString::number(col)].getL() | 89 | keys["r" + QString::number(row) + "c" + QString::number(col)].getL() |
89 | ); | 90 | ); |
90 | 91 | ||
91 | } | 92 | } |
92 | 93 | ||
93 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 94 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
94 | 95 | ||
95 | pressedRow = e->y() / keyHeight; | 96 | pressedRow = e->y() / keyHeight; |
96 | pressedCol = (int) (e->x() / keyWidth); | 97 | pressedCol = (int) (e->x() / keyWidth); |
97 | 98 | ||
98 | paintKey(pressedRow, pressedCol); | 99 | paintKey(pressedRow, pressedCol); |
99 | 100 | ||
100 | // emit that sucker! | 101 | // emit that sucker! |
101 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 102 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
102 | //QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0); | 103 | emit keyPressed(k.getU(), k.getQ(), 0, 1, 0); |
103 | //qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0); | 104 | /* |
104 | //qwsServer->sendKeyEvent(0x41, 0, 0, 1, 0); | 105 | * |
106 | QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0); | ||
107 | qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0); | ||
108 | qwsServer->sendKeyEvent(0x41, 0, 0, 1, 0); | ||
105 | 109 | ||
106 | QKeyEvent ke(QEvent::KeyPress, k.getQ(), k.getU(), 0); | 110 | QKeyEvent ke(QEvent::KeyPress, k.getQ(), k.getU(), 0); |
107 | QApplication::sendEvent(this, &ke); | 111 | QApplication::sendEvent((QObject *)parent, &ke); |
112 | */ | ||
108 | 113 | ||
109 | } | 114 | } |
110 | 115 | ||
111 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 116 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
112 | 117 | ||
113 | if (pressedRow != -1 && pressedRow != -1) { | 118 | if (pressedRow != -1 && pressedRow != -1) { |
114 | 119 | ||
115 | int row = pressedRow; pressedRow = -1; | 120 | int row = pressedRow; pressedRow = -1; |
116 | int col = pressedCol; pressedCol = -1; | 121 | int col = pressedCol; pressedCol = -1; |
117 | paintKey(row, col); | 122 | paintKey(row, col); |
118 | 123 | ||
119 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 124 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
120 | //QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0); | 125 | emit keyPressed(k.getU(), k.getQ(), 0, 0, 0); |
121 | //qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0); | 126 | |
127 | /* | ||
128 | QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0); | ||
129 | qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0); | ||
130 | |||
122 | QKeyEvent ke(QEvent::KeyRelease, k.getQ(), k.getU(), 0); | 131 | QKeyEvent ke(QEvent::KeyRelease, k.getQ(), k.getU(), 0); |
123 | QApplication::sendEvent(this, &ke); | 132 | QApplication::sendEvent((QObject *)parent, &ke); |
133 | */ | ||
124 | } | 134 | } |
125 | 135 | ||
126 | } | 136 | } |
127 | 137 | ||
128 | 138 | ||
129 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 139 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
130 | 140 | ||
131 | /* set he default font height/width */ | 141 | /* set he default font height/width */ |
132 | QFontMetrics fm=fontMetrics(); | 142 | QFontMetrics fm=fontMetrics(); |
133 | keyHeight = fm.lineSpacing() + 2; | 143 | keyHeight = fm.lineSpacing() + 2; |
134 | keyWidth = (double)width()/numCols; | 144 | keyWidth = (double)width()/numCols; |
135 | 145 | ||
136 | } | 146 | } |
137 | 147 | ||
138 | QSize FunctionKeyboard::sizeHint() const { | 148 | QSize FunctionKeyboard::sizeHint() const { |
139 | 149 | ||
140 | return QSize(width(), keyHeight * numRows + 1); | 150 | return QSize(width(), keyHeight * numRows + 1); |
141 | } | 151 | } |
142 | 152 | ||
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index bc3e25c..b8420ae 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h | |||
@@ -20,39 +20,45 @@ public: | |||
20 | private: | 20 | private: |
21 | 21 | ||
22 | QString label; | 22 | QString label; |
23 | ushort qcode; | 23 | ushort qcode; |
24 | ushort unicode; | 24 | ushort unicode; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | class FunctionKeyboard : public QFrame { | 27 | class FunctionKeyboard : public QFrame { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | FunctionKeyboard(QWidget *parent = 0); | 31 | FunctionKeyboard(QWidget *parent = 0); |
32 | ~FunctionKeyboard(); | 32 | ~FunctionKeyboard(); |
33 | 33 | ||
34 | void paintEvent(QPaintEvent *); | 34 | void paintEvent(QPaintEvent *); |
35 | void paintKey(int, int); | 35 | void paintKey(int, int); |
36 | void mousePressEvent(QMouseEvent*); | 36 | void mousePressEvent(QMouseEvent*); |
37 | void mouseReleaseEvent(QMouseEvent*); | 37 | void mouseReleaseEvent(QMouseEvent*); |
38 | void resizeEvent(QResizeEvent*); | 38 | void resizeEvent(QResizeEvent*); |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | QSize sizeHint() const; | 42 | QSize sizeHint() const; |
43 | 43 | ||
44 | signals: | ||
45 | |||
46 | void keyPressed(ushort, ushort, bool, bool, bool); | ||
47 | |||
44 | private: | 48 | private: |
45 | 49 | ||
46 | // thie key for the map is the row/col | 50 | // thie key for the map is the row/col |
47 | QMap<QString, FKey> keys; | 51 | QMap<QString, FKey> keys; |
48 | 52 | ||
49 | uint numRows; | 53 | uint numRows; |
50 | uint numCols; | 54 | uint numCols; |
51 | uint keyHeight; | 55 | uint keyHeight; |
52 | double keyWidth; // decimal point matters! | 56 | double keyWidth; // decimal point matters! |
53 | 57 | ||
54 | int pressedRow, pressedCol; | 58 | int pressedRow, pressedCol; |
55 | 59 | ||
60 | QObject *parent; | ||
61 | |||
56 | }; | 62 | }; |
57 | 63 | ||
58 | #endif | 64 | #endif |