summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index ce65052..5f3b5ec 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,67 +1,70 @@
1#include "function_keyboard.h" 1#include "function_keyboard.h"
2 2
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qsizepolicy.h> 5#include <qsizepolicy.h>
6#include <qevent.h> 6#include <qevent.h>
7#include <qwindowsystem_qws.h> 7#include <qwindowsystem_qws.h>
8#include <qapplication.h> 8#include <qapplication.h>
9#include <qlayout.h> 9#include <qlayout.h>
10#include <qspinbox.h> 10#include <qspinbox.h>
11#include <qlistbox.h> 11#include <qlistbox.h>
12#include <qlabel.h> 12#include <qlabel.h>
13#include <qcombobox.h> 13#include <qcombobox.h>
14#include <qdir.h> 14#include <qdir.h>
15 15
16#define DEFAULT_ROWS 2
17#define DEFAULT_COLS 11
18
16/* FunctionKeyboard {{{1 */ 19/* FunctionKeyboard {{{1 */
17 20
18FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 21FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
19 QFrame(parent), numRows(2), numCols(11), 22 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS),
20 pressedRow(0), pressedCol(0) { 23 pressedRow(0), pressedCol(0) {
21 24
22 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 25 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
23 26
24 /* 27 /*
25 * all the saving/loading is now done in a profile. downside is that you cant modify 28 * 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 29 * the keyboard for all profiles, but must do it on a profile-basis
27 * 30 *
28 31
29 Config conf("opie-console-keys"); 32 Config conf("opie-console-keys");
30 conf.setGroup("keys"); 33 conf.setGroup("keys");
31 for (uint r = 0; r < numRows; r++) 34 for (uint r = 0; r < numRows; r++)
32 for (uint c = 0; c < numCols; c++) { 35 for (uint c = 0; c < numCols; c++) {
33 36
34 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 37 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
35 QStringList value_list = conf.readListEntry( handle, '|'); 38 QStringList value_list = conf.readListEntry( handle, '|');
36 39
37 if (value_list.isEmpty()) continue; 40 if (value_list.isEmpty()) continue;
38 41
39 keys.insert( 42 keys.insert(
40 43
41 handle, 44 handle,
42 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) 45 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
43 ); 46 );
44 } 47 }
45 //qWarning("loaded %d keys", keys.count()); 48 //qWarning("loaded %d keys", keys.count());
46 */ 49 */
47 if (keys.isEmpty()) loadDefaults(); 50 if (keys.isEmpty()) loadDefaults();
48 51
49 52
50 53
51} 54}
52 55
53FunctionKeyboard::~FunctionKeyboard() {} 56FunctionKeyboard::~FunctionKeyboard() {}
54 57
55void FunctionKeyboard::changeRows(int r) { 58void FunctionKeyboard::changeRows(int r) {
56 59
57 numRows = r; 60 numRows = r;
58 61
59 // have to do this so the whole thing gets redrawn 62 // have to do this so the whole thing gets redrawn
60 hide(); show(); 63 hide(); show();
61} 64}
62void FunctionKeyboard::changeCols(int c) { 65void FunctionKeyboard::changeCols(int c) {
63 66
64 numCols = c; 67 numCols = c;
65 keyWidth = (double)width()/numCols; // have to reset this thing too 68 keyWidth = (double)width()/numCols; // have to reset this thing too
66 repaint(false); 69 repaint(false);
67} 70}
@@ -178,96 +181,100 @@ void FunctionKeyboard::paintKey(uint row, uint col) {
178 } 181 }
179 182
180} 183}
181 184
182void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 185void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
183 186
184 pressedRow = e->y() / keyHeight; 187 pressedRow = e->y() / keyHeight;
185 pressedCol = (int) (e->x() / keyWidth); 188 pressedCol = (int) (e->x() / keyWidth);
186 189
187 paintKey(pressedRow, pressedCol); 190 paintKey(pressedRow, pressedCol);
188 191
189 // emit that sucker! 192 // emit that sucker!
190 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 193 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
191 emit keyPressed(k, pressedRow, pressedCol, 1); 194 emit keyPressed(k, pressedRow, pressedCol, 1);
192 195
193} 196}
194 197
195void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 198void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
196 199
197 if (pressedRow != -1 && pressedRow != -1) { 200 if (pressedRow != -1 && pressedRow != -1) {
198 201
199 int row = pressedRow; pressedRow = -1; 202 int row = pressedRow; pressedRow = -1;
200 int col = pressedCol; pressedCol = -1; 203 int col = pressedCol; pressedCol = -1;
201 paintKey(row, col); 204 paintKey(row, col);
202 205
203 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 206 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
204 emit keyPressed(k, row, col, 0); 207 emit keyPressed(k, row, col, 0);
205 } 208 }
206 209
207} 210}
208 211
209 212
210void FunctionKeyboard::resizeEvent(QResizeEvent*) { 213void FunctionKeyboard::resizeEvent(QResizeEvent*) {
211 214
212 /* set he default font height/width */ 215 /* set he default font height/width */
213 QFontMetrics fm=fontMetrics(); 216 QFontMetrics fm=fontMetrics();
214 keyHeight = fm.lineSpacing() + 2; 217 keyHeight = fm.lineSpacing() + 2;
215 keyWidth = (double)width()/numCols; 218 keyWidth = (double)width()/numCols;
216 219
217} 220}
218 221
219QSize FunctionKeyboard::sizeHint() const { 222QSize FunctionKeyboard::sizeHint() const {
220 223
221 return QSize(width(), keyHeight * numRows + 1); 224 return QSize(width(), keyHeight * numRows + 1);
222} 225}
223 226
224void FunctionKeyboard::loadDefaults() { 227void FunctionKeyboard::loadDefaults() {
225 228
229 numRows = DEFAULT_ROWS;
230 numCols = DEFAULT_COLS;
231 keyWidth = (double)width()/numCols; // have to reset this thing too
232
226 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); 233 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
227 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); 234 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
228 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); 235 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
229 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); 236 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
230 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); 237 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
231 238
232 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); 239 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
233 keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); 240 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
234 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0)); 241 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0));
235 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0)); 242 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0));
236 243
237 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); 244 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
238 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); 245 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
239 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); 246 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
240 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); 247 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
241 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); 248 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
242 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); 249 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
243 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); 250 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
244 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); 251 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
245 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); 252 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
246 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); 253 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
247 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); 254 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
248 255
249 256
250} 257}
251 258
252/* FunctionKeyboardConfig {{{1 */ 259/* FunctionKeyboardConfig {{{1 */
253 260
254FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 261FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
255 : ProfileDialogKeyWidget(name, parent, na), 262 : ProfileDialogKeyWidget(name, parent, na),
256 selectedRow(0), selectedCol(0) 263 selectedRow(0), selectedCol(0)
257{ 264{
258 qWarning("FunctionKeyboardConfig"); 265 qWarning("FunctionKeyboardConfig");
259 266
260 267
261 kb = new FunctionKeyboard(this); 268 kb = new FunctionKeyboard(this);
262 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 269 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
263 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); 270 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
264 271
265 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); 272 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this);
266 QLabel *l = new QLabel("Rows", dimentions); 273 QLabel *l = new QLabel("Rows", dimentions);
267 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 274 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
268 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 275 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
269 l = new QLabel("Columns", dimentions); 276 l = new QLabel("Columns", dimentions);
270 m_colBox = new QSpinBox(1, 15, 1, dimentions); 277 m_colBox = new QSpinBox(1, 15, 1, dimentions);
271 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 278 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
272 279
273 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 280 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);