-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 139 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 33 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 3 |
4 files changed, 136 insertions, 51 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index b2f1c78..71cdea8 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -34,5 +34,5 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | |||
34 | 34 | ||
35 | handle, | 35 | handle, |
36 | FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort()) | 36 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) |
37 | ); | 37 | ); |
38 | } | 38 | } |
@@ -60,4 +60,11 @@ void FunctionKeyboard::changeCols(int c) { | |||
60 | } | 60 | } |
61 | 61 | ||
62 | /* | ||
63 | Key getKey(int row, int col) { | ||
64 | |||
65 | return keys[ "r" + QString::number(row) + "c" + QString::number(col) ]; | ||
66 | } | ||
67 | */ | ||
68 | |||
62 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { | 69 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { |
63 | 70 | ||
@@ -92,5 +99,5 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
92 | keyWidth, keyHeight, | 99 | keyWidth, keyHeight, |
93 | Qt::AlignHCenter | Qt::AlignVCenter, | 100 | Qt::AlignHCenter | Qt::AlignVCenter, |
94 | keys[handle].getL() | 101 | keys[handle].label |
95 | ); | 102 | ); |
96 | } | 103 | } |
@@ -99,5 +106,5 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
99 | } | 106 | } |
100 | 107 | ||
101 | void FunctionKeyboard::paintKey(int row, int col) { | 108 | void FunctionKeyboard::paintKey(uint row, uint col) { |
102 | 109 | ||
103 | QPainter p(this); | 110 | QPainter p(this); |
@@ -110,5 +117,5 @@ void FunctionKeyboard::paintKey(int row, int col) { | |||
110 | keyWidth, keyHeight, | 117 | keyWidth, keyHeight, |
111 | Qt::AlignHCenter | Qt::AlignVCenter, | 118 | Qt::AlignHCenter | Qt::AlignVCenter, |
112 | keys["r" + QString::number(row) + "c" + QString::number(col)].getL() | 119 | keys["r" + QString::number(row) + "c" + QString::number(col)].label |
113 | ); | 120 | ); |
114 | 121 | ||
@@ -132,5 +139,5 @@ void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | |||
132 | // emit that sucker! | 139 | // emit that sucker! |
133 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 140 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
134 | emit keyPressed(k.getU(), k.getQ(), 0, 1, 0, pressedRow, pressedCol); | 141 | emit keyPressed(k, pressedRow, pressedCol, 1); |
135 | 142 | ||
136 | } | 143 | } |
@@ -145,5 +152,5 @@ void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | |||
145 | 152 | ||
146 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 153 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
147 | emit keyPressed(k.getU(), k.getQ(), 0, 0, 0, pressedRow, pressedCol); | 154 | emit keyPressed(k, row, col, 0); |
148 | } | 155 | } |
149 | 156 | ||
@@ -167,21 +174,22 @@ QSize FunctionKeyboard::sizeHint() const { | |||
167 | void FunctionKeyboard::loadDefaults() { | 174 | void FunctionKeyboard::loadDefaults() { |
168 | 175 | ||
169 | /* what keys should be default? */ | 176 | /* what keys should be default? |
170 | keys.insert( "r0c0", FKey ("F1", 4144, 0)); | 177 | keys.insert( "r0c0", FKey ("F1", 0, 4144, 0)); |
171 | keys.insert( "r0c1", FKey ("F2", 4145, 0)); | 178 | keys.insert( "r0c1", FKey ("F2", 0, 4145, 0)); |
172 | keys.insert( "r0c2", FKey ("F3", 4145, 0)); | 179 | keys.insert( "r0c2", FKey ("F3", 0, 4146, 0)); |
173 | keys.insert( "r0c3", FKey ("F4", 4146, 0)); | 180 | keys.insert( "r0c3", FKey ("F4", 0, 4147, 0)); |
174 | keys.insert( "r0c4", FKey ("F5", 4147, 0)); | 181 | keys.insert( "r0c4", FKey ("F5", 0, 4148, 0)); |
175 | keys.insert( "r0c5", FKey ("F6", 4148, 0)); | 182 | keys.insert( "r0c5", FKey ("F6", 0, 4149, 0)); |
176 | keys.insert( "r0c6", FKey ("F7", 4149, 0)); | 183 | keys.insert( "r0c6", FKey ("F7", 0, 4150, 0)); |
177 | keys.insert( "r0c7", FKey ("F8", 4150, 0)); | 184 | keys.insert( "r0c7", FKey ("F8", 0, 4151, 0)); |
178 | keys.insert( "r0c8", FKey ("F9", 4151, 0)); | 185 | keys.insert( "r0c8", FKey ("F9", 0, 4152, 0)); |
179 | keys.insert( "r0c9", FKey ("F10", 4152, 0)); | 186 | keys.insert( "r0c9", FKey ("F10", 0, 4153, 0)); |
180 | keys.insert( "r0c10", FKey ("F11", 4153, 0)); | 187 | keys.insert( "r0c10", FKey ("F11", 0, 4154, 0)); |
181 | 188 | ||
182 | keys.insert( "r1c7", FKey ("Ho", 4112, 0)); | 189 | keys.insert( "r1c7", FKey ("Ho", 0, 4112, 0)); |
183 | keys.insert( "r1c8", FKey ("End", 4113, 0)); | 190 | keys.insert( "r1c8", FKey ("End", 0, 4113, 0)); |
184 | keys.insert( "r1c9", FKey ("PU", 4118, 0)); | 191 | keys.insert( "r1c9", FKey ("PU", 0, 4118, 0)); |
185 | keys.insert( "r1c10", FKey ("PD", 4119, 0)); | 192 | keys.insert( "r1c10", FKey ("PD", 0, 4119, 0)); |
193 | */ | ||
186 | 194 | ||
187 | } | 195 | } |
@@ -189,10 +197,19 @@ void FunctionKeyboard::loadDefaults() { | |||
189 | /* FunctionKeyboardConfig {{{1 */ | 197 | /* FunctionKeyboardConfig {{{1 */ |
190 | 198 | ||
199 | <<<<<<< function_keyboard.cpp | ||
200 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) : | ||
201 | ProfileDialogKeyWidget(name, parent), | ||
202 | selectedRow(0), selectedCol(0) | ||
203 | { | ||
204 | ======= | ||
191 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) | 205 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
192 | : ProfileDialogKeyWidget(name, parent, na) { | 206 | : ProfileDialogKeyWidget(name, parent, na) { |
193 | qWarning("FunctionKeyboardConfig"); | 207 | qWarning("FunctionKeyboardConfig"); |
208 | >>>>>>> 1.11 | ||
194 | 209 | ||
195 | 210 | ||
196 | kb = new FunctionKeyboard(this); | 211 | kb = new FunctionKeyboard(this); |
212 | connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | ||
213 | this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); | ||
197 | 214 | ||
198 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); | 215 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); |
@@ -206,7 +223,7 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par | |||
206 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 223 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
207 | l = new QLabel("Label", editKey); | 224 | l = new QLabel("Label", editKey); |
208 | /* | 225 | m_labels = new QComboBox(true, editKey); |
209 | m_labels = new QComboBox(false, editKey); | 226 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); |
210 | labels->insertItem("text"); | 227 | m_labels->insertItem("custom"); |
211 | 228 | ||
212 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 229 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
@@ -217,5 +234,10 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par | |||
217 | } | 234 | } |
218 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | 235 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); |
219 | */ | 236 | connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); |
237 | |||
238 | l = new QLabel("KeyValue", editKey); | ||
239 | m_qvalues = new QComboBox(false, editKey); | ||
240 | m_qvalues->setInsertionPolicy(QComboBox::AtCurrent); | ||
241 | m_qvalues->insertItem("custom"); | ||
220 | 242 | ||
221 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 243 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
@@ -228,10 +250,41 @@ FunctionKeyboardConfig::~FunctionKeyboardConfig() { | |||
228 | } | 250 | } |
229 | void FunctionKeyboardConfig::load (const Profile& prof) { | 251 | void FunctionKeyboardConfig::load (const Profile& prof) { |
230 | //int i = prof.readNumEntry("keb_rows", 1); | 252 | |
231 | m_rowBox->setValue( 2 ); | 253 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); |
254 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); | ||
255 | |||
256 | /* load all the keys to the keyboard */ | ||
257 | for (int i = 0; i <= m_rowBox->value() -1; i++) | ||
258 | for (int j = 0; j <= m_colBox->value() -1; j++) { | ||
259 | |||
260 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | ||
261 | QString values = prof.readEntry("keb_" + h); | ||
262 | |||
263 | if (!values.isEmpty()) { | ||
264 | |||
265 | QStringList l = QStringList::split(QChar('|'), values, TRUE); | ||
266 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); | ||
267 | //qWarning("loading key... %s %s %s %d %d", values.ascii(), l[0].ascii(), l[1].ascii(), l[2].toInt(), l[3].toInt()); | ||
268 | } | ||
269 | } | ||
270 | |||
232 | } | 271 | } |
233 | void FunctionKeyboardConfig::save (Profile& prof) { | 272 | void FunctionKeyboardConfig::save (Profile& prof) { |
234 | 273 | ||
235 | prof.writeEntry("keb_rows", m_rowBox->value()); | 274 | prof.writeEntry("keb_rows", m_rowBox->value()); |
275 | prof.writeEntry("keb_cols", m_colBox->value()); | ||
276 | |||
277 | QMap<QString, FKey>::Iterator it; | ||
278 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { | ||
279 | |||
280 | FKey k = it.data(); | ||
281 | QString entry = k.label + "|" | ||
282 | + k.pixFile + "|" | ||
283 | + QString::number(k.qcode) + "|" | ||
284 | + QString::number(k.unicode); | ||
285 | |||
286 | prof.writeEntry("keb_" + it.key(), entry); | ||
287 | |||
288 | } | ||
236 | 289 | ||
237 | } | 290 | } |
@@ -247,6 +300,18 @@ void FunctionKeyboardConfig::slotChangeCols(int c) { | |||
247 | kb->changeCols(c); | 300 | kb->changeCols(c); |
248 | } | 301 | } |
249 | void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) { | 302 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { |
303 | |||
304 | if (!pressed) return; | ||
250 | 305 | ||
306 | selectedRow = r, selectedCol = c; | ||
307 | |||
308 | if (k.pixFile.isEmpty()) { | ||
309 | |||
310 | m_labels->setCurrentItem(0); | ||
311 | m_labels->changeItem(k.label, 0); | ||
312 | m_labels->setEditable(true); | ||
313 | |||
314 | } | ||
315 | m_qvalues->changeItem(QString::number(k.qcode), 0); | ||
251 | } | 316 | } |
252 | void FunctionKeyboardConfig::slotChangeIcon(int index) { | 317 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
@@ -255,9 +320,19 @@ void FunctionKeyboardConfig::slotChangeIcon(int index) { | |||
255 | 320 | ||
256 | // is text | 321 | // is text |
257 | //if(!labels->editable()) labels->setEditable(true); | 322 | m_labels->setEditable(true); |
323 | // why tf does the text get erased unless i do this? | ||
324 | m_labels->changeItem(m_labels->text(0), 0); | ||
325 | |||
258 | } else { | 326 | } else { |
259 | 327 | ||
260 | // is a pixmap | 328 | // is a pixmap |
261 | //if (labels->editable()) labels->setEditable(false); | 329 | m_labels->setEditable(false); |
330 | } | ||
262 | } | 331 | } |
332 | void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { | ||
333 | |||
334 | kb->keys["r" + QString::number(selectedRow) + | ||
335 | "c" + QString::number(selectedCol)].label = label; | ||
336 | |||
337 | kb->paintKey(selectedRow, selectedCol); | ||
263 | } | 338 | } |
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index 05b991d..496d932 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h | |||
@@ -3,4 +3,5 @@ | |||
3 | 3 | ||
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qpeapplication.h> | ||
5 | #include <qframe.h> | 6 | #include <qframe.h> |
6 | #include <qpainter.h> | 7 | #include <qpainter.h> |
@@ -13,19 +14,20 @@ | |||
13 | 14 | ||
14 | 15 | ||
15 | class FKey { | 16 | struct FKey { |
16 | |||
17 | public: | ||
18 | 17 | ||
19 | FKey(): qcode(0), unicode(0) {}; | 18 | FKey(): qcode(0), unicode(0) {}; |
20 | FKey(const QString &l, ushort q, ushort u): label(l), qcode(q), unicode(u) {}; | 19 | FKey(const QString &l, const QString &f, ushort q, ushort u): |
20 | label(l), pixFile(f), qcode(q), unicode(u) { | ||
21 | 21 | ||
22 | QString getL() { return label; } | 22 | if (!f.isEmpty()) { |
23 | ushort getQ() { return qcode; } | ||
24 | ushort getU() { return unicode; } | ||
25 | 23 | ||
24 | pix = new QPixmap (QPEApplication::qpeDir() + "pics/console/keys/" + f); | ||
26 | 25 | ||
27 | private: | 26 | } |
27 | }; | ||
28 | 28 | ||
29 | QString label; | 29 | QString label; |
30 | QPixmap *pix; | ||
31 | QString pixFile; | ||
30 | ushort qcode; | 32 | ushort qcode; |
31 | ushort unicode; | 33 | ushort unicode; |
@@ -39,9 +41,13 @@ public: | |||
39 | ~FunctionKeyboard(); | 41 | ~FunctionKeyboard(); |
40 | 42 | ||
43 | friend class FunctionKeyboardConfig; | ||
44 | |||
41 | void changeRows(int); | 45 | void changeRows(int); |
42 | void changeCols(int); | 46 | void changeCols(int); |
43 | 47 | ||
48 | //Key getKey(int, int); | ||
49 | |||
44 | void paintEvent(QPaintEvent *); | 50 | void paintEvent(QPaintEvent *); |
45 | void paintKey(int, int); | 51 | void paintKey(uint, uint); |
46 | void mousePressEvent(QMouseEvent*); | 52 | void mousePressEvent(QMouseEvent*); |
47 | void mouseReleaseEvent(QMouseEvent*); | 53 | void mouseReleaseEvent(QMouseEvent*); |
@@ -51,5 +57,5 @@ public: | |||
51 | signals: | 57 | signals: |
52 | 58 | ||
53 | void keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort); | 59 | void keyPressed(FKey, ushort, ushort, bool); |
54 | 60 | ||
55 | private: | 61 | private: |
@@ -88,14 +94,17 @@ public: | |||
88 | private slots: | 94 | private slots: |
89 | 95 | ||
90 | void slotKeyPressed(ushort, ushort, bool, bool, bool, ushort, ushort); | 96 | void slotKeyPressed(FKey, ushort, ushort, bool); |
91 | void slotChangeRows(int); | 97 | void slotChangeRows(int); |
92 | void slotChangeCols(int); | 98 | void slotChangeCols(int); |
93 | void slotChangeIcon(int); | 99 | void slotChangeIcon(int); |
100 | void slotChangeLabelText(const QString &); | ||
94 | 101 | ||
95 | private: | 102 | private: |
96 | 103 | ||
104 | ushort selectedRow, selectedCol; | ||
105 | |||
97 | FunctionKeyboard *kb; | 106 | FunctionKeyboard *kb; |
98 | QSpinBox *m_rowBox, *m_colBox; | 107 | QSpinBox *m_rowBox, *m_colBox; |
99 | QComboBox *m_labels; | 108 | QComboBox *m_labels, *m_qvalues; |
100 | 109 | ||
101 | }; | 110 | }; |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index c1020fa..8e529a3 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -209,6 +209,6 @@ void MainWindow::initUI() { | |||
209 | 209 | ||
210 | m_kb = new FunctionKeyboard(m_keyBar); | 210 | m_kb = new FunctionKeyboard(m_keyBar); |
211 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort)), | 211 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
212 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool, ushort, ushort))); | 212 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
213 | 213 | ||
214 | m_buttonBar = new QToolBar( this ); | 214 | m_buttonBar = new QToolBar( this ); |
@@ -217,7 +217,9 @@ void MainWindow::initUI() { | |||
217 | m_buttonBar->hide(); | 217 | m_buttonBar->hide(); |
218 | 218 | ||
219 | /* | ||
219 | m_qb = new QuickButton( m_buttonBar ); | 220 | m_qb = new QuickButton( m_buttonBar ); |
220 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 221 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
221 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 222 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
223 | */ | ||
222 | 224 | ||
223 | 225 | ||
@@ -521,7 +523,5 @@ void MainWindow::slotFullscreen() { | |||
521 | 523 | ||
522 | 524 | ||
523 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool, ushort, ushort) { | 525 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
524 | |||
525 | //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); | ||
526 | 526 | ||
527 | if ( m_curSession ) { | 527 | if ( m_curSession ) { |
@@ -532,5 +532,5 @@ void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool, u | |||
532 | else state = QEvent::KeyRelease; | 532 | else state = QEvent::KeyRelease; |
533 | 533 | ||
534 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); | 534 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
535 | 535 | ||
536 | // where should i send this event? doesnt work sending it here | 536 | // where should i send this event? doesnt work sending it here |
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 68f6fa8..0f52e76 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -21,4 +21,5 @@ class ProfileManager; | |||
21 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | 22 | class FunctionKeyboard; |
23 | class FKey; | ||
23 | class QuickButton; | 24 | class QuickButton; |
24 | 25 | ||
@@ -68,5 +69,5 @@ private slots: | |||
68 | void slotFullscreen(); | 69 | void slotFullscreen(); |
69 | void slotSessionChanged( Session* ); | 70 | void slotSessionChanged( Session* ); |
70 | void slotKeyReceived(ushort, ushort, bool, bool, bool, ushort, ushort); | 71 | void slotKeyReceived(FKey, ushort, ushort, bool); |
71 | 72 | ||
72 | private: | 73 | private: |