summaryrefslogtreecommitdiff
authorhash <hash>2002-10-31 18:18:41 (UTC)
committer hash <hash>2002-10-31 18:18:41 (UTC)
commit1004c5930b3dfdb37e4d8ea2e143b4a3d0246f7a (patch) (unidiff)
tree50ca8adbad6632d8f6dbd2846b2e4cae47928b8f
parentf567e3bfc77cf2c28f0b195ed5f7a4ae5b9610d4 (diff)
downloadopie-1004c5930b3dfdb37e4d8ea2e143b4a3d0246f7a.zip
opie-1004c5930b3dfdb37e4d8ea2e143b4a3d0246f7a.tar.gz
opie-1004c5930b3dfdb37e4d8ea2e143b4a3d0246f7a.tar.bz2
added esc and F12 in default configuration
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index 5f3b5ec..e7f3c21 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,432 +1,434 @@
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 16#define DEFAULT_ROWS 2
17#define DEFAULT_COLS 11 17#define DEFAULT_COLS 12
18 18
19/* FunctionKeyboard {{{1 */ 19/* FunctionKeyboard {{{1 */
20 20
21FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 21FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
22 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), 22 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS),
23 pressedRow(0), pressedCol(0) { 23 pressedRow(0), pressedCol(0) {
24 24
25 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 25 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
26 26
27 /* 27 /*
28 * 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
29 * 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
30 * 30 *
31 31
32 Config conf("opie-console-keys"); 32 Config conf("opie-console-keys");
33 conf.setGroup("keys"); 33 conf.setGroup("keys");
34 for (uint r = 0; r < numRows; r++) 34 for (uint r = 0; r < numRows; r++)
35 for (uint c = 0; c < numCols; c++) { 35 for (uint c = 0; c < numCols; c++) {
36 36
37 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 37 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
38 QStringList value_list = conf.readListEntry( handle, '|'); 38 QStringList value_list = conf.readListEntry( handle, '|');
39 39
40 if (value_list.isEmpty()) continue; 40 if (value_list.isEmpty()) continue;
41 41
42 keys.insert( 42 keys.insert(
43 43
44 handle, 44 handle,
45 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())
46 ); 46 );
47 } 47 }
48 //qWarning("loaded %d keys", keys.count()); 48 //qWarning("loaded %d keys", keys.count());
49 */ 49 */
50 if (keys.isEmpty()) loadDefaults(); 50 if (keys.isEmpty()) loadDefaults();
51 51
52 52
53 53
54} 54}
55 55
56FunctionKeyboard::~FunctionKeyboard() {} 56FunctionKeyboard::~FunctionKeyboard() {}
57 57
58void FunctionKeyboard::changeRows(int r) { 58void FunctionKeyboard::changeRows(int r) {
59 59
60 numRows = r; 60 numRows = r;
61 61
62 // have to do this so the whole thing gets redrawn 62 // have to do this so the whole thing gets redrawn
63 hide(); show(); 63 hide(); show();
64} 64}
65void FunctionKeyboard::changeCols(int c) { 65void FunctionKeyboard::changeCols(int c) {
66 66
67 numCols = c; 67 numCols = c;
68 keyWidth = (double)width()/numCols; // have to reset this thing too 68 keyWidth = (double)width()/numCols; // have to reset this thing too
69 repaint(false); 69 repaint(false);
70} 70}
71void FunctionKeyboard::load (const Profile& prof) { 71void FunctionKeyboard::load (const Profile& prof) {
72 72
73 keys.clear(); 73 keys.clear();
74 74
75 numRows = prof.readNumEntry("keb_rows", 2); 75 numRows = prof.readNumEntry("keb_rows", 2);
76 numCols = prof.readNumEntry("keb_cols", 10); 76 numCols = prof.readNumEntry("keb_cols", 10);
77 keyWidth = (double)width()/numCols; // have to reset this thing too 77 keyWidth = (double)width()/numCols; // have to reset this thing too
78 78
79 /* load all the keys to the keyboard */ 79 /* load all the keys to the keyboard */
80 for (ushort i = 0; i <= numRows - 1; i++) 80 for (ushort i = 0; i <= numRows - 1; i++)
81 for (ushort j = 0; j <= numCols - 1; j++) { 81 for (ushort j = 0; j <= numCols - 1; j++) {
82 82
83 QString h = "r" + QString::number(i) + "c" + QString::number(j); 83 QString h = "r" + QString::number(i) + "c" + QString::number(j);
84 QString values = prof.readEntry("keb_" + h); 84 QString values = prof.readEntry("keb_" + h);
85 85
86 if (!values.isEmpty()) { 86 if (!values.isEmpty()) {
87 87
88 QStringList l = QStringList::split(QChar('|'), values, TRUE); 88 QStringList l = QStringList::split(QChar('|'), values, TRUE);
89 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 89 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
90 90
91 // load pixmap if used 91 // load pixmap if used
92 if (!l[1].isEmpty()) { 92 if (!l[1].isEmpty()) {
93 93
94 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 94 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 if (keys.isEmpty()) loadDefaults(); 99 if (keys.isEmpty()) loadDefaults();
100 100
101 hide(); 101 hide();
102 show(); 102 show();
103 103
104} 104}
105 105
106void FunctionKeyboard::paintEvent(QPaintEvent *e) { 106void FunctionKeyboard::paintEvent(QPaintEvent *e) {
107 107
108 QPainter p(this); 108 QPainter p(this);
109 p.setClipRect(e->rect()); 109 p.setClipRect(e->rect());
110 p.fillRect(0, 0, width(), height(), QColor(255,255,255)); 110 p.fillRect(0, 0, width(), height(), QColor(255,255,255));
111 111
112 p.setPen(QColor(0,0,0)); 112 p.setPen(QColor(0,0,0));
113 113
114 /* those decimals do count! becomes short if use plain int */ 114 /* those decimals do count! becomes short if use plain int */
115 for (double i = 0; i <= width(); i += keyWidth) { 115 for (double i = 0; i <= width(); i += keyWidth) {
116 116
117 p.drawLine((int)i, 0, (int)i, height()); 117 p.drawLine((int)i, 0, (int)i, height());
118 } 118 }
119 119
120 // sometimes the last line doesnt get drawn 120 // sometimes the last line doesnt get drawn
121 p.drawLine(width() -1, 0, width() -1, height()); 121 p.drawLine(width() -1, 0, width() -1, height());
122 122
123 for (int i = 0; i <= height(); i += keyHeight) { 123 for (int i = 0; i <= height(); i += keyHeight) {
124 124
125 p.drawLine(0, i, width(), i); 125 p.drawLine(0, i, width(), i);
126 } 126 }
127 127
128 for (uint r = 0; r < numRows; r++) { 128 for (uint r = 0; r < numRows; r++) {
129 for (uint c = 0; c < numCols; c++) { 129 for (uint c = 0; c < numCols; c++) {
130 130
131 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 131 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
132 if (keys.contains(handle)) { 132 if (keys.contains(handle)) {
133 133
134 if (keys[handle].pixFile.isEmpty()) 134 if (keys[handle].pixFile.isEmpty())
135 p.drawText( c * keyWidth + 1, r * keyHeight + 1, 135 p.drawText( c * keyWidth + 1, r * keyHeight + 1,
136 keyWidth, keyHeight, 136 keyWidth, keyHeight,
137 Qt::AlignHCenter | Qt::AlignVCenter, 137 Qt::AlignHCenter | Qt::AlignVCenter,
138 keys[handle].label 138 keys[handle].label
139 ); 139 );
140 else { 140 else {
141 141
142 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; 142 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
143 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 143 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
144 p.drawPixmap(centerX, centerY, *keys[handle].pix); 144 p.drawPixmap(centerX, centerY, *keys[handle].pix);
145 } 145 }
146 } 146 }
147 } 147 }
148 } 148 }
149} 149}
150 150
151void FunctionKeyboard::paintKey(uint row, uint col) { 151void FunctionKeyboard::paintKey(uint row, uint col) {
152 152
153 QPainter p(this); 153 QPainter p(this);
154 154
155 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 155 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
156 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 156 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
157 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); 157 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
158 158
159 QString handle ("r" + QString::number(row) + "c" + QString::number(col)); 159 QString handle ("r" + QString::number(row) + "c" + QString::number(col));
160 if (keys[handle].pixFile.isEmpty()) 160 if (keys[handle].pixFile.isEmpty())
161 p.drawText( 161 p.drawText(
162 col * keyWidth + 1, row * keyHeight + 1, 162 col * keyWidth + 1, row * keyHeight + 1,
163 keyWidth, keyHeight, 163 keyWidth, keyHeight,
164 Qt::AlignHCenter | Qt::AlignVCenter, 164 Qt::AlignHCenter | Qt::AlignVCenter,
165 keys[handle].label 165 keys[handle].label
166 ); 166 );
167 else { 167 else {
168 168
169 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; 169 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
170 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 170 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
171 p.drawPixmap(centerX, centerY, *keys[handle].pix); 171 p.drawPixmap(centerX, centerY, *keys[handle].pix);
172 } 172 }
173 173
174 if (col == numCols - 1) { 174 if (col == numCols - 1) {
175 175
176 // sometimes it doesnt draw the last line 176 // sometimes it doesnt draw the last line
177 177
178 p.drawLine((col+1) * keyWidth -1, row * keyHeight, 178 p.drawLine((col+1) * keyWidth -1, row * keyHeight,
179 (col+1) * keyWidth -1, (row + 1) * keyHeight 179 (col+1) * keyWidth -1, (row + 1) * keyHeight
180 ); 180 );
181 } 181 }
182 182
183} 183}
184 184
185void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 185void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
186 186
187 pressedRow = e->y() / keyHeight; 187 pressedRow = e->y() / keyHeight;
188 pressedCol = (int) (e->x() / keyWidth); 188 pressedCol = (int) (e->x() / keyWidth);
189 189
190 paintKey(pressedRow, pressedCol); 190 paintKey(pressedRow, pressedCol);
191 191
192 // emit that sucker! 192 // emit that sucker!
193 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 193 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
194 emit keyPressed(k, pressedRow, pressedCol, 1); 194 emit keyPressed(k, pressedRow, pressedCol, 1);
195 195
196} 196}
197 197
198void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 198void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
199 199
200 if (pressedRow != -1 && pressedRow != -1) { 200 if (pressedRow != -1 && pressedRow != -1) {
201 201
202 int row = pressedRow; pressedRow = -1; 202 int row = pressedRow; pressedRow = -1;
203 int col = pressedCol; pressedCol = -1; 203 int col = pressedCol; pressedCol = -1;
204 paintKey(row, col); 204 paintKey(row, col);
205 205
206 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 206 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
207 emit keyPressed(k, row, col, 0); 207 emit keyPressed(k, row, col, 0);
208 } 208 }
209 209
210} 210}
211 211
212 212
213void FunctionKeyboard::resizeEvent(QResizeEvent*) { 213void FunctionKeyboard::resizeEvent(QResizeEvent*) {
214 214
215 /* set he default font height/width */ 215 /* set he default font height/width */
216 QFontMetrics fm=fontMetrics(); 216 QFontMetrics fm=fontMetrics();
217 keyHeight = fm.lineSpacing() + 2; 217 keyHeight = fm.lineSpacing() + 2;
218 keyWidth = (double)width()/numCols; 218 keyWidth = (double)width()/numCols;
219 219
220} 220}
221 221
222QSize FunctionKeyboard::sizeHint() const { 222QSize FunctionKeyboard::sizeHint() const {
223 223
224 return QSize(width(), keyHeight * numRows + 1); 224 return QSize(width(), keyHeight * numRows + 1);
225} 225}
226 226
227void FunctionKeyboard::loadDefaults() { 227void FunctionKeyboard::loadDefaults() {
228 228
229 numRows = DEFAULT_ROWS; 229 numRows = DEFAULT_ROWS;
230 numCols = DEFAULT_COLS; 230 numCols = DEFAULT_COLS;
231 keyWidth = (double)width()/numCols; // have to reset this thing too 231 keyWidth = (double)width()/numCols; // have to reset this thing too
232 232
233 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); 233 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
234 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));
235 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); 235 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
236 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); 236 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
237 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); 237 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
238 238
239 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); 239 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
240 keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); 240 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
241 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0)); 241 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0));
242 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0)); 242 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0));
243 keys.insert( "r0c11", FKey ("esc", 0, Qt::Key_Escape, 0xfff));
243 244
244 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); 245 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
245 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); 246 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
246 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); 247 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
247 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); 248 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
248 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); 249 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
249 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); 250 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
250 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); 251 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
251 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); 252 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
252 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); 253 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
253 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); 254 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
254 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); 255 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
256 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0));
255 257
256 258
257} 259}
258 260
259/* FunctionKeyboardConfig {{{1 */ 261/* FunctionKeyboardConfig {{{1 */
260 262
261FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 263FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
262 : ProfileDialogKeyWidget(name, parent, na), 264 : ProfileDialogKeyWidget(name, parent, na),
263 selectedRow(0), selectedCol(0) 265 selectedRow(0), selectedCol(0)
264{ 266{
265 qWarning("FunctionKeyboardConfig"); 267 qWarning("FunctionKeyboardConfig");
266 268
267 269
268 kb = new FunctionKeyboard(this); 270 kb = new FunctionKeyboard(this);
269 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 271 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
270 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); 272 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
271 273
272 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); 274 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this);
273 QLabel *l = new QLabel("Rows", dimentions); 275 QLabel *l = new QLabel("Rows", dimentions);
274 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 276 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
275 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 277 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
276 l = new QLabel("Columns", dimentions); 278 l = new QLabel("Columns", dimentions);
277 m_colBox = new QSpinBox(1, 15, 1, dimentions); 279 m_colBox = new QSpinBox(1, 15, 1, dimentions);
278 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 280 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
279 281
280 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 282 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
281 l = new QLabel("Label", editKey); 283 l = new QLabel("Label", editKey);
282 m_labels = new QComboBox(true, editKey); 284 m_labels = new QComboBox(true, editKey);
283 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 285 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
284 m_labels->insertItem(""); 286 m_labels->insertItem("");
285 287
286 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 288 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
287 289
288 for (uint i = 0; i < files.count(); i++) { 290 for (uint i = 0; i < files.count(); i++) {
289 291
290 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); 292 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
291 } 293 }
292 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 294 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
293 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); 295 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&)));
294 296
295 l = new QLabel("Q Keycode", editKey); 297 l = new QLabel("Q Keycode", editKey);
296 m_qvalues = new QComboBox(true, editKey); 298 m_qvalues = new QComboBox(true, editKey);
297 m_qvalues->setInsertionPolicy(QComboBox::AtTop); 299 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
298 m_qvalues->setDuplicatesEnabled(false); 300 m_qvalues->setDuplicatesEnabled(false);
299 m_qvalues->insertItem(""); 301 m_qvalues->insertItem("");
300 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&))); 302 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&)));
301 303
302 l = new QLabel("Unicode Value", editKey); 304 l = new QLabel("Unicode Value", editKey);
303 m_uniValues = new QComboBox(true, editKey); 305 m_uniValues = new QComboBox(true, editKey);
304 m_uniValues->setInsertionPolicy(QComboBox::AtTop); 306 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
305 m_uniValues->setDuplicatesEnabled(false); 307 m_uniValues->setDuplicatesEnabled(false);
306 m_uniValues->insertItem(""); 308 m_uniValues->insertItem("");
307 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); 309 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&)));
308 310
309 QVBoxLayout *root = new QVBoxLayout(this, 2); 311 QVBoxLayout *root = new QVBoxLayout(this, 2);
310 root->addWidget(kb); 312 root->addWidget(kb);
311 root->addWidget(dimentions); 313 root->addWidget(dimentions);
312 root->addWidget(editKey); 314 root->addWidget(editKey);
313} 315}
314FunctionKeyboardConfig::~FunctionKeyboardConfig() { 316FunctionKeyboardConfig::~FunctionKeyboardConfig() {
315 317
316} 318}
317void FunctionKeyboardConfig::load (const Profile& prof) { 319void FunctionKeyboardConfig::load (const Profile& prof) {
318 320
319 kb->keys.clear(); 321 kb->keys.clear();
320 kb->loadDefaults(); 322 kb->loadDefaults();
321 323
322 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); 324 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
323 m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); 325 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
324 326
325 /* load all the keys to the keyboard */ 327 /* load all the keys to the keyboard */
326 for (int i = 0; i <= m_rowBox->value() -1; i++) 328 for (int i = 0; i <= m_rowBox->value() -1; i++)
327 for (int j = 0; j <= m_colBox->value() -1; j++) { 329 for (int j = 0; j <= m_colBox->value() -1; j++) {
328 330
329 QString h = "r" + QString::number(i) + "c" + QString::number(j); 331 QString h = "r" + QString::number(i) + "c" + QString::number(j);
330 QString values = prof.readEntry("keb_" + h); 332 QString values = prof.readEntry("keb_" + h);
331 333
332 if (!values.isEmpty()) { 334 if (!values.isEmpty()) {
333 335
334 QStringList l = QStringList::split(QChar('|'), values, TRUE); 336 QStringList l = QStringList::split(QChar('|'), values, TRUE);
335 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 337 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
336 338
337 // load pixmap if used 339 // load pixmap if used
338 if (!l[1].isEmpty()) { 340 if (!l[1].isEmpty()) {
339 341
340 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 342 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
341 } 343 }
342 } 344 }
343 } 345 }
344 346
345} 347}
346void FunctionKeyboardConfig::save (Profile& prof) { 348void FunctionKeyboardConfig::save (Profile& prof) {
347 349
348 prof.writeEntry("keb_rows", m_rowBox->value()); 350 prof.writeEntry("keb_rows", m_rowBox->value());
349 prof.writeEntry("keb_cols", m_colBox->value()); 351 prof.writeEntry("keb_cols", m_colBox->value());
350 352
351 QMap<QString, FKey>::Iterator it; 353 QMap<QString, FKey>::Iterator it;
352 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { 354 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
353 355
354 FKey k = it.data(); 356 FKey k = it.data();
355 QString entry = k.label + "|" 357 QString entry = k.label + "|"
356 + k.pixFile + "|" 358 + k.pixFile + "|"
357 + QString::number(k.qcode) + "|" 359 + QString::number(k.qcode) + "|"
358 + QString::number(k.unicode); 360 + QString::number(k.unicode);
359 361
360 prof.writeEntry("keb_" + it.key(), entry); 362 prof.writeEntry("keb_" + it.key(), entry);
361 363
362 } 364 }
363 365
364} 366}
365void FunctionKeyboardConfig::slotChangeRows(int r) { 367void FunctionKeyboardConfig::slotChangeRows(int r) {
366 368
367 kb->changeRows(r); 369 kb->changeRows(r);
368 370
369} 371}
370void FunctionKeyboardConfig::slotChangeCols(int c) { 372void FunctionKeyboardConfig::slotChangeCols(int c) {
371 373
372 kb->changeCols(c); 374 kb->changeCols(c);
373} 375}
374void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { 376void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
375 377
376 if (!pressed) return; 378 if (!pressed) return;
377 379
378 selectedHandle = "r" + QString::number(r) + 380 selectedHandle = "r" + QString::number(r) +
379 "c" + QString::number(c); 381 "c" + QString::number(c);
380 selectedRow = r; 382 selectedRow = r;
381 selectedCol = c; 383 selectedCol = c;
382 384
383 if (k.pixFile.isEmpty()) { 385 if (k.pixFile.isEmpty()) {
384 386
385 m_labels->setEditable(true); 387 m_labels->setEditable(true);
386 m_labels->setCurrentItem(0); 388 m_labels->setCurrentItem(0);
387 m_labels->changeItem(k.label, 0); 389 m_labels->changeItem(k.label, 0);
388 390
389 } else { 391 } else {
390 392
391 // any better way to select the pixmap? 393 // any better way to select the pixmap?
392 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); 394 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
393 m_labels->setEditable(false); 395 m_labels->setEditable(false);
394 } 396 }
395 m_qvalues->changeItem(QString::number(k.qcode), 0); 397 m_qvalues->changeItem(QString::number(k.qcode), 0);
396 m_uniValues->changeItem(QString::number(k.unicode), 0); 398 m_uniValues->changeItem(QString::number(k.unicode), 0);
397} 399}
398void FunctionKeyboardConfig::slotChangeIcon(int index) { 400void FunctionKeyboardConfig::slotChangeIcon(int index) {
399 401
400 if (index == 0) { 402 if (index == 0) {
401 403
402 // is text 404 // is text
403 m_labels->setEditable(true); 405 m_labels->setEditable(true);
404 // why tf does the text get erased unless i do this? 406 // why tf does the text get erased unless i do this?
405 m_labels->changeItem(m_labels->text(0), 0); 407 m_labels->changeItem(m_labels->text(0), 0);
406 408
407 kb->keys[selectedHandle].pixFile = ""; 409 kb->keys[selectedHandle].pixFile = "";
408 delete kb->keys[selectedHandle].pix; 410 delete kb->keys[selectedHandle].pix;
409 411
410 } else { 412 } else {
411 413
412 // is a pixmap 414 // is a pixmap
413 m_labels->setEditable(false); 415 m_labels->setEditable(false);
414 kb->keys[selectedHandle].pixFile = m_labels->currentText(); 416 kb->keys[selectedHandle].pixFile = m_labels->currentText();
415 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); 417 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) );
416 } 418 }
417 kb->paintKey(selectedRow, selectedCol); 419 kb->paintKey(selectedRow, selectedCol);
418} 420}
419void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { 421void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
420 422
421 kb->keys[selectedHandle].label = label; 423 kb->keys[selectedHandle].label = label;
422 424
423 kb->paintKey(selectedRow, selectedCol); 425 kb->paintKey(selectedRow, selectedCol);
424} 426}
425void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) { 427void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) {
426 428
427 kb->keys[selectedHandle].qcode = qcode.toUInt(); 429 kb->keys[selectedHandle].qcode = qcode.toUInt();
428} 430}
429void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) { 431void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) {
430 432
431 kb->keys[selectedHandle].unicode = uni.toUInt(); 433 kb->keys[selectedHandle].unicode = uni.toUInt();
432} 434}