summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console
authorhash <hash>2002-10-24 08:14:54 (UTC)
committer hash <hash>2002-10-24 08:14:54 (UTC)
commit541035d4308ca1931d5068ced83b0cb5350b0766 (patch) (unidiff)
tree6f236ae8499f4aefcb7405d8beaed59230155276 /noncore/apps/opie-console
parent7c670be31a6a60e03e7dba4e366aa8f3e02bae6c (diff)
downloadopie-541035d4308ca1931d5068ced83b0cb5350b0766.zip
opie-541035d4308ca1931d5068ced83b0cb5350b0766.tar.gz
opie-541035d4308ca1931d5068ced83b0cb5350b0766.tar.bz2
editing/loading/saving works. now the keyboard in mainwidget needs to load the right profile when the tab is switched
Diffstat (limited to 'noncore/apps/opie-console') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp151
-rw-r--r--noncore/apps/opie-console/function_keyboard.h5
2 files changed, 108 insertions, 48 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index 9d58383..538bed4 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -10,2 +10,3 @@
10#include <qspinbox.h> 10#include <qspinbox.h>
11#include <qlistbox.h>
11#include <qlabel.h> 12#include <qlabel.h>
@@ -22,2 +23,7 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
22 23
24 /*
25 * all the saving/loading is now done in a profile. downside is that you cant modify
26 * the keyboard for all profiles, but must do it on a profile-basis
27 *
28
23 Config conf("opie-console-keys"); 29 Config conf("opie-console-keys");
@@ -39,2 +45,3 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
39 //qWarning("loaded %d keys", keys.count()); 45 //qWarning("loaded %d keys", keys.count());
46 */
40 if (keys.isEmpty()) loadDefaults(); 47 if (keys.isEmpty()) loadDefaults();
@@ -61,9 +68,2 @@ void FunctionKeyboard::changeCols(int c) {
61 68
62/*
63Key getKey(int row, int col) {
64
65 return keys[ "r" + QString::number(row) + "c" + QString::number(col) ];
66}
67*/
68
69void FunctionKeyboard::paintEvent(QPaintEvent *e) { 69void FunctionKeyboard::paintEvent(QPaintEvent *e) {
@@ -96,4 +96,4 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
96 96
97 p.drawText( 97 if (keys[handle].pixFile.isEmpty())
98 c * keyWidth + 1, r * keyHeight + 1, 98 p.drawText( c * keyWidth + 1, r * keyHeight + 1,
99 keyWidth, keyHeight, 99 keyWidth, keyHeight,
@@ -101,3 +101,9 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
101 keys[handle].label 101 keys[handle].label
102 ); 102 );
103 else {
104
105 ushort centerX = c *keyWidth + (keyWidth - keys[handle].pix->width()) / 2;
106 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
107 p.drawPixmap(centerX, centerY, *keys[handle].pix);
108 }
103 } 109 }
@@ -114,3 +120,6 @@ void FunctionKeyboard::paintKey(uint row, uint col) {
114 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); 120 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
115 p.drawText( 121
122 QString handle ("r" + QString::number(row) + "c" + QString::number(col));
123 if (keys[handle].pixFile.isEmpty())
124 p.drawText(
116 col * keyWidth + 1, row * keyHeight + 1, 125 col * keyWidth + 1, row * keyHeight + 1,
@@ -118,10 +127,17 @@ void FunctionKeyboard::paintKey(uint row, uint col) {
118 Qt::AlignHCenter | Qt::AlignVCenter, 127 Qt::AlignHCenter | Qt::AlignVCenter,
119 keys["r" + QString::number(row) + "c" + QString::number(col)].label 128 keys[handle].label
120 ); 129 );
130 else {
131
132 ushort centerX = col *keyWidth + (keyWidth - keys[handle].pix->width()) / 2;
133 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
134 p.drawPixmap(centerX, centerY, *keys[handle].pix);
135 }
121 136
122 if (row == numRows) { 137 if (col == numCols - 1) {
123 138
124 // sometimes it doesnt draw the last line 139 // sometimes it doesnt draw the last line
125 p.drawLine((col+1) * keyWidth -2, row * keyHeight, 140
126 (col+1) * keyWidth -2, (row + 1) * keyHeight 141 p.drawLine((col+1) * keyWidth -1, row * keyHeight,
142 (col+1) * keyWidth -1, (row + 1) * keyHeight
127 ); 143 );
@@ -175,20 +191,25 @@ void FunctionKeyboard::loadDefaults() {
175 191
176 /* what keys should be default? 192 keys.insert( "r0c0", FKey ("Enter", "enter.png", Qt::Key_Enter, 0));
177 keys.insert( "r0c0", FKey ("F1", 0, 4144, 0)); 193 keys.insert( "r0c1", FKey ("Space", "space.png", Qt::Key_Space, Qt::Key_Space));
178 keys.insert( "r0c1", FKey ("F2", 0, 4145, 0)); 194 keys.insert( "r0c2", FKey ("Tab", "tab.png", Qt::Key_Tab, 0));
179 keys.insert( "r0c2", FKey ("F3", 0, 4146, 0)); 195 keys.insert( "r0c3", FKey ("Up", "up.png", Qt::Key_Up, 0));
180 keys.insert( "r0c3", FKey ("F4", 0, 4147, 0)); 196 keys.insert( "r0c4", FKey ("Down", "down.png", Qt::Key_Down, 0));
181 keys.insert( "r0c4", FKey ("F5", 0, 4148, 0)); 197
182 keys.insert( "r0c5", FKey ("F6", 0, 4149, 0)); 198 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
183 keys.insert( "r0c6", FKey ("F7", 0, 4150, 0)); 199 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
184 keys.insert( "r0c7", FKey ("F8", 0, 4151, 0)); 200 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0));
185 keys.insert( "r0c8", FKey ("F9", 0, 4152, 0)); 201 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0));
186 keys.insert( "r0c9", FKey ("F10", 0, 4153, 0)); 202
187 keys.insert( "r0c10", FKey ("F11", 0, 4154, 0)); 203 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
188 204 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
189 keys.insert( "r1c7", FKey ("Ho", 0, 4112, 0)); 205 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
190 keys.insert( "r1c8", FKey ("End", 0, 4113, 0)); 206 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
191 keys.insert( "r1c9", FKey ("PU", 0, 4118, 0)); 207 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
192 keys.insert( "r1c10", FKey ("PD", 0, 4119, 0)); 208 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
193 */ 209 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
210 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
211 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
212 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
213 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
214
194 215
@@ -199,4 +220,4 @@ void FunctionKeyboard::loadDefaults() {
199FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 220FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
200 : ProfileDialogKeyWidget(name, parent, na), 221 : ProfileDialogKeyWidget(name, parent, na),
201 selectedRow(0), selectedCol(0) 222 selectedRow(0), selectedCol(0)
202{ 223{
@@ -221,3 +242,3 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
221 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 242 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
222 m_labels->insertItem("custom"); 243 m_labels->insertItem("");
223 244
@@ -227,3 +248,3 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
227 248
228 m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); 249 m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i]), files[i]);
229 } 250 }
@@ -232,6 +253,15 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
232 253
233 l = new QLabel("KeyValue", editKey); 254 l = new QLabel("Q Keycode", editKey);
234 m_qvalues = new QComboBox(false, editKey); 255 m_qvalues = new QComboBox(true, editKey);
235 m_qvalues->setInsertionPolicy(QComboBox::AtCurrent); 256 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
236 m_qvalues->insertItem("custom"); 257 m_qvalues->setDuplicatesEnabled(false);
258 m_qvalues->insertItem("");
259 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&)));
260
261 l = new QLabel("Unicode Value", editKey);
262 m_uniValues = new QComboBox(true, editKey);
263 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
264 m_uniValues->setDuplicatesEnabled(false);
265 m_uniValues->insertItem("");
266 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&)));
237 267
@@ -261,3 +291,8 @@ void FunctionKeyboardConfig::load (const Profile& prof) {
261 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 291 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
262 //qWarning("loading key... %s %s %s %d %d", values.ascii(), l[0].ascii(), l[1].ascii(), l[2].toInt(), l[3].toInt()); 292
293 // load pixmap if used
294 if (!l[1].isEmpty()) {
295
296 kb->keys[h].pix = new QPixmap(QPEApplication::qpeDir() + "pics/console/keys/" + l[1]);
297 }
263 } 298 }
@@ -300,3 +335,6 @@ void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pre
300 335
301 selectedRow = r, selectedCol = c; 336 selectedHandle = "r" + QString::number(r) +
337 "c" + QString::number(c);
338 selectedRow = r;
339 selectedCol = c;
302 340
@@ -304,8 +342,14 @@ void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pre
304 342
343 m_labels->setEditable(true);
305 m_labels->setCurrentItem(0); 344 m_labels->setCurrentItem(0);
306 m_labels->changeItem(k.label, 0); 345 m_labels->changeItem(k.label, 0);
307 m_labels->setEditable(true);
308 346
347 } else {
348
349 // any better way to select the pixmap?
350 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
351 m_labels->setEditable(false);
309 } 352 }
310 m_qvalues->changeItem(QString::number(k.qcode), 0); 353 m_qvalues->changeItem(QString::number(k.qcode), 0);
354 m_uniValues->changeItem(QString::number(k.unicode), 0);
311} 355}
@@ -320,2 +364,5 @@ void FunctionKeyboardConfig::slotChangeIcon(int index) {
320 364
365 kb->keys[selectedHandle].pixFile = "";
366 delete kb->keys[selectedHandle].pix;
367
321 } else { 368 } else {
@@ -324,3 +371,6 @@ void FunctionKeyboardConfig::slotChangeIcon(int index) {
324 m_labels->setEditable(false); 371 m_labels->setEditable(false);
372 kb->keys[selectedHandle].pixFile = m_labels->currentText();
373 kb->keys[selectedHandle].pix = new QPixmap(QPEApplication::qpeDir() + "pics/console/keys/" + m_labels->currentText());
325 } 374 }
375 kb->paintKey(selectedRow, selectedCol);
326} 376}
@@ -328,4 +378,3 @@ void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
328 378
329 kb->keys["r" + QString::number(selectedRow) + 379 kb->keys[selectedHandle].label = label;
330 "c" + QString::number(selectedCol)].label = label;
331 380
@@ -333 +382,9 @@ void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
333} 382}
383void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) {
384
385 kb->keys[selectedHandle].qcode = qcode.toUInt();
386}
387void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) {
388
389 kb->keys[selectedHandle].unicode = uni.toUInt();
390}
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h
index 496d932..7f313d6 100644
--- a/noncore/apps/opie-console/function_keyboard.h
+++ b/noncore/apps/opie-console/function_keyboard.h
@@ -100,2 +100,4 @@ private slots:
100 void slotChangeLabelText(const QString &); 100 void slotChangeLabelText(const QString &);
101 void slotChangeQCode(const QString &);
102 void slotChangeUnicode(const QString &);
101 103
@@ -103,2 +105,3 @@ private:
103 105
106 QString selectedHandle;
104 ushort selectedRow, selectedCol; 107 ushort selectedRow, selectedCol;
@@ -107,3 +110,3 @@ private:
107 QSpinBox *m_rowBox, *m_colBox; 110 QSpinBox *m_rowBox, *m_colBox;
108 QComboBox *m_labels, *m_qvalues; 111 QComboBox *m_labels, *m_qvalues, *m_uniValues;
109 112