summaryrefslogtreecommitdiff
authorhash <hash>2002-10-24 17:56:48 (UTC)
committer hash <hash>2002-10-24 17:56:48 (UTC)
commit3773cd825129f1cc6fa7a4ecb4129634f5189984 (patch) (unidiff)
treed10cc2c4e45e2b47eddcae5534f59ce8f90092b1
parentb01703c4b1de7006c88aa814ca00472b966b2464 (diff)
downloadopie-3773cd825129f1cc6fa7a4ecb4129634f5189984.zip
opie-3773cd825129f1cc6fa7a4ecb4129634f5189984.tar.gz
opie-3773cd825129f1cc6fa7a4ecb4129634f5189984.tar.bz2
closing a session returns keyboard to default better now
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,417 +1,424 @@
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}
68void FunctionKeyboard::load (const Profile& prof) { 71void FunctionKeyboard::load (const Profile& prof) {
69 72
70 keys.clear(); 73 keys.clear();
71 74
72 numRows = prof.readNumEntry("keb_rows", 2); 75 numRows = prof.readNumEntry("keb_rows", 2);
73 numCols = prof.readNumEntry("keb_cols", 10); 76 numCols = prof.readNumEntry("keb_cols", 10);
74 keyWidth = (double)width()/numCols; // have to reset this thing too 77 keyWidth = (double)width()/numCols; // have to reset this thing too
75 78
76 /* load all the keys to the keyboard */ 79 /* load all the keys to the keyboard */
77 for (ushort i = 0; i <= numRows - 1; i++) 80 for (ushort i = 0; i <= numRows - 1; i++)
78 for (ushort j = 0; j <= numCols - 1; j++) { 81 for (ushort j = 0; j <= numCols - 1; j++) {
79 82
80 QString h = "r" + QString::number(i) + "c" + QString::number(j); 83 QString h = "r" + QString::number(i) + "c" + QString::number(j);
81 QString values = prof.readEntry("keb_" + h); 84 QString values = prof.readEntry("keb_" + h);
82 85
83 if (!values.isEmpty()) { 86 if (!values.isEmpty()) {
84 87
85 QStringList l = QStringList::split(QChar('|'), values, TRUE); 88 QStringList l = QStringList::split(QChar('|'), values, TRUE);
86 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());
87 90
88 // load pixmap if used 91 // load pixmap if used
89 if (!l[1].isEmpty()) { 92 if (!l[1].isEmpty()) {
90 93
91 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 94 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
92 } 95 }
93 } 96 }
94 } 97 }
95 98
96 if (keys.isEmpty()) loadDefaults(); 99 if (keys.isEmpty()) loadDefaults();
97 100
98 hide(); 101 hide();
99 show(); 102 show();
100 103
101} 104}
102 105
103void FunctionKeyboard::paintEvent(QPaintEvent *e) { 106void FunctionKeyboard::paintEvent(QPaintEvent *e) {
104 107
105 QPainter p(this); 108 QPainter p(this);
106 p.setClipRect(e->rect()); 109 p.setClipRect(e->rect());
107 p.fillRect(0, 0, width(), height(), QColor(255,255,255)); 110 p.fillRect(0, 0, width(), height(), QColor(255,255,255));
108 111
109 p.setPen(QColor(0,0,0)); 112 p.setPen(QColor(0,0,0));
110 113
111 /* those decimals do count! becomes short if use plain int */ 114 /* those decimals do count! becomes short if use plain int */
112 for (double i = 0; i <= width(); i += keyWidth) { 115 for (double i = 0; i <= width(); i += keyWidth) {
113 116
114 p.drawLine((int)i, 0, (int)i, height()); 117 p.drawLine((int)i, 0, (int)i, height());
115 } 118 }
116 119
117 // sometimes the last line doesnt get drawn 120 // sometimes the last line doesnt get drawn
118 p.drawLine(width() -1, 0, width() -1, height()); 121 p.drawLine(width() -1, 0, width() -1, height());
119 122
120 for (int i = 0; i <= height(); i += keyHeight) { 123 for (int i = 0; i <= height(); i += keyHeight) {
121 124
122 p.drawLine(0, i, width(), i); 125 p.drawLine(0, i, width(), i);
123 } 126 }
124 127
125 for (uint r = 0; r < numRows; r++) { 128 for (uint r = 0; r < numRows; r++) {
126 for (uint c = 0; c < numCols; c++) { 129 for (uint c = 0; c < numCols; c++) {
127 130
128 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 131 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
129 if (keys.contains(handle)) { 132 if (keys.contains(handle)) {
130 133
131 if (keys[handle].pixFile.isEmpty()) 134 if (keys[handle].pixFile.isEmpty())
132 p.drawText( c * keyWidth + 1, r * keyHeight + 1, 135 p.drawText( c * keyWidth + 1, r * keyHeight + 1,
133 keyWidth, keyHeight, 136 keyWidth, keyHeight,
134 Qt::AlignHCenter | Qt::AlignVCenter, 137 Qt::AlignHCenter | Qt::AlignVCenter,
135 keys[handle].label 138 keys[handle].label
136 ); 139 );
137 else { 140 else {
138 141
139 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;
140 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 143 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
141 p.drawPixmap(centerX, centerY, *keys[handle].pix); 144 p.drawPixmap(centerX, centerY, *keys[handle].pix);
142 } 145 }
143 } 146 }
144 } 147 }
145 } 148 }
146} 149}
147 150
148void FunctionKeyboard::paintKey(uint row, uint col) { 151void FunctionKeyboard::paintKey(uint row, uint col) {
149 152
150 QPainter p(this); 153 QPainter p(this);
151 154
152 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 155 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
153 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 156 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
154 (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));
155 158
156 QString handle ("r" + QString::number(row) + "c" + QString::number(col)); 159 QString handle ("r" + QString::number(row) + "c" + QString::number(col));
157 if (keys[handle].pixFile.isEmpty()) 160 if (keys[handle].pixFile.isEmpty())
158 p.drawText( 161 p.drawText(
159 col * keyWidth + 1, row * keyHeight + 1, 162 col * keyWidth + 1, row * keyHeight + 1,
160 keyWidth, keyHeight, 163 keyWidth, keyHeight,
161 Qt::AlignHCenter | Qt::AlignVCenter, 164 Qt::AlignHCenter | Qt::AlignVCenter,
162 keys[handle].label 165 keys[handle].label
163 ); 166 );
164 else { 167 else {
165 168
166 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;
167 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 170 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
168 p.drawPixmap(centerX, centerY, *keys[handle].pix); 171 p.drawPixmap(centerX, centerY, *keys[handle].pix);
169 } 172 }
170 173
171 if (col == numCols - 1) { 174 if (col == numCols - 1) {
172 175
173 // sometimes it doesnt draw the last line 176 // sometimes it doesnt draw the last line
174 177
175 p.drawLine((col+1) * keyWidth -1, row * keyHeight, 178 p.drawLine((col+1) * keyWidth -1, row * keyHeight,
176 (col+1) * keyWidth -1, (row + 1) * keyHeight 179 (col+1) * keyWidth -1, (row + 1) * keyHeight
177 ); 180 );
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);
274 l = new QLabel("Label", editKey); 281 l = new QLabel("Label", editKey);
275 m_labels = new QComboBox(true, editKey); 282 m_labels = new QComboBox(true, editKey);
276 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 283 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
277 m_labels->insertItem(""); 284 m_labels->insertItem("");
278 285
279 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 286 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
280 287
281 for (uint i = 0; i < files.count(); i++) { 288 for (uint i = 0; i < files.count(); i++) {
282 289
283 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); 290 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
284 } 291 }
285 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 292 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
286 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); 293 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&)));
287 294
288 l = new QLabel("Q Keycode", editKey); 295 l = new QLabel("Q Keycode", editKey);
289 m_qvalues = new QComboBox(true, editKey); 296 m_qvalues = new QComboBox(true, editKey);
290 m_qvalues->setInsertionPolicy(QComboBox::AtTop); 297 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
291 m_qvalues->setDuplicatesEnabled(false); 298 m_qvalues->setDuplicatesEnabled(false);
292 m_qvalues->insertItem(""); 299 m_qvalues->insertItem("");
293 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&))); 300 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&)));
294 301
295 l = new QLabel("Unicode Value", editKey); 302 l = new QLabel("Unicode Value", editKey);
296 m_uniValues = new QComboBox(true, editKey); 303 m_uniValues = new QComboBox(true, editKey);
297 m_uniValues->setInsertionPolicy(QComboBox::AtTop); 304 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
298 m_uniValues->setDuplicatesEnabled(false); 305 m_uniValues->setDuplicatesEnabled(false);
299 m_uniValues->insertItem(""); 306 m_uniValues->insertItem("");
300 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); 307 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&)));
301 308
302 QVBoxLayout *root = new QVBoxLayout(this, 2); 309 QVBoxLayout *root = new QVBoxLayout(this, 2);
303 root->addWidget(kb); 310 root->addWidget(kb);
304 root->addWidget(dimentions); 311 root->addWidget(dimentions);
305 root->addWidget(editKey); 312 root->addWidget(editKey);
306} 313}
307FunctionKeyboardConfig::~FunctionKeyboardConfig() { 314FunctionKeyboardConfig::~FunctionKeyboardConfig() {
308 315
309} 316}
310void FunctionKeyboardConfig::load (const Profile& prof) { 317void FunctionKeyboardConfig::load (const Profile& prof) {
311 318
312 kb->keys.clear(); 319 kb->keys.clear();
313 kb->loadDefaults(); 320 kb->loadDefaults();
314 321
315 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); 322 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
316 m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); 323 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
317 324
318 /* load all the keys to the keyboard */ 325 /* load all the keys to the keyboard */
319 for (int i = 0; i <= m_rowBox->value() -1; i++) 326 for (int i = 0; i <= m_rowBox->value() -1; i++)
320 for (int j = 0; j <= m_colBox->value() -1; j++) { 327 for (int j = 0; j <= m_colBox->value() -1; j++) {
321 328
322 QString h = "r" + QString::number(i) + "c" + QString::number(j); 329 QString h = "r" + QString::number(i) + "c" + QString::number(j);
323 QString values = prof.readEntry("keb_" + h); 330 QString values = prof.readEntry("keb_" + h);
324 331
325 if (!values.isEmpty()) { 332 if (!values.isEmpty()) {
326 333
327 QStringList l = QStringList::split(QChar('|'), values, TRUE); 334 QStringList l = QStringList::split(QChar('|'), values, TRUE);
328 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 335 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
329 336
330 // load pixmap if used 337 // load pixmap if used
331 if (!l[1].isEmpty()) { 338 if (!l[1].isEmpty()) {
332 339
333 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 340 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
334 } 341 }
335 } 342 }
336 } 343 }
337 344
338} 345}
339void FunctionKeyboardConfig::save (Profile& prof) { 346void FunctionKeyboardConfig::save (Profile& prof) {
340 347
341 prof.writeEntry("keb_rows", m_rowBox->value()); 348 prof.writeEntry("keb_rows", m_rowBox->value());
342 prof.writeEntry("keb_cols", m_colBox->value()); 349 prof.writeEntry("keb_cols", m_colBox->value());
343 350
344 QMap<QString, FKey>::Iterator it; 351 QMap<QString, FKey>::Iterator it;
345 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { 352 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
346 353
347 FKey k = it.data(); 354 FKey k = it.data();
348 QString entry = k.label + "|" 355 QString entry = k.label + "|"
349 + k.pixFile + "|" 356 + k.pixFile + "|"
350 + QString::number(k.qcode) + "|" 357 + QString::number(k.qcode) + "|"
351 + QString::number(k.unicode); 358 + QString::number(k.unicode);
352 359
353 prof.writeEntry("keb_" + it.key(), entry); 360 prof.writeEntry("keb_" + it.key(), entry);
354 361
355 } 362 }
356 363
357} 364}
358void FunctionKeyboardConfig::slotChangeRows(int r) { 365void FunctionKeyboardConfig::slotChangeRows(int r) {
359 366
360 kb->changeRows(r); 367 kb->changeRows(r);
361 368
362} 369}
363void FunctionKeyboardConfig::slotChangeCols(int c) { 370void FunctionKeyboardConfig::slotChangeCols(int c) {
364 371
365 kb->changeCols(c); 372 kb->changeCols(c);
366} 373}
367void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { 374void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
368 375
369 if (!pressed) return; 376 if (!pressed) return;
370 377
371 selectedHandle = "r" + QString::number(r) + 378 selectedHandle = "r" + QString::number(r) +
372 "c" + QString::number(c); 379 "c" + QString::number(c);
373 selectedRow = r; 380 selectedRow = r;
374 selectedCol = c; 381 selectedCol = c;
375 382
376 if (k.pixFile.isEmpty()) { 383 if (k.pixFile.isEmpty()) {
377 384
378 m_labels->setEditable(true); 385 m_labels->setEditable(true);
379 m_labels->setCurrentItem(0); 386 m_labels->setCurrentItem(0);
380 m_labels->changeItem(k.label, 0); 387 m_labels->changeItem(k.label, 0);
381 388
382 } else { 389 } else {
383 390
384 // any better way to select the pixmap? 391 // any better way to select the pixmap?
385 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); 392 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
386 m_labels->setEditable(false); 393 m_labels->setEditable(false);
387 } 394 }
388 m_qvalues->changeItem(QString::number(k.qcode), 0); 395 m_qvalues->changeItem(QString::number(k.qcode), 0);
389 m_uniValues->changeItem(QString::number(k.unicode), 0); 396 m_uniValues->changeItem(QString::number(k.unicode), 0);
390} 397}
391void FunctionKeyboardConfig::slotChangeIcon(int index) { 398void FunctionKeyboardConfig::slotChangeIcon(int index) {
392 399
393 if (index == 0) { 400 if (index == 0) {
394 401
395 // is text 402 // is text
396 m_labels->setEditable(true); 403 m_labels->setEditable(true);
397 // why tf does the text get erased unless i do this? 404 // why tf does the text get erased unless i do this?
398 m_labels->changeItem(m_labels->text(0), 0); 405 m_labels->changeItem(m_labels->text(0), 0);
399 406
400 kb->keys[selectedHandle].pixFile = ""; 407 kb->keys[selectedHandle].pixFile = "";
401 delete kb->keys[selectedHandle].pix; 408 delete kb->keys[selectedHandle].pix;
402 409
403 } else { 410 } else {
404 411
405 // is a pixmap 412 // is a pixmap
406 m_labels->setEditable(false); 413 m_labels->setEditable(false);
407 kb->keys[selectedHandle].pixFile = m_labels->currentText(); 414 kb->keys[selectedHandle].pixFile = m_labels->currentText();
408 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); 415 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) );
409 } 416 }
410 kb->paintKey(selectedRow, selectedCol); 417 kb->paintKey(selectedRow, selectedCol);
411} 418}
412void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { 419void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
413 420
414 kb->keys[selectedHandle].label = label; 421 kb->keys[selectedHandle].label = label;
415 422
416 kb->paintKey(selectedRow, selectedCol); 423 kb->paintKey(selectedRow, selectedCol);
417} 424}