Diffstat (limited to 'noncore/apps/opie-console/function_keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index c232d89..eb32551 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -167,231 +167,231 @@ void FunctionKeyboard::paintKey(uint row, uint col) { | |||
167 | 167 | ||
168 | // sometimes it doesnt draw the last line | 168 | // sometimes it doesnt draw the last line |
169 | 169 | ||
170 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, | 170 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, |
171 | (col+1) * keyWidth -1, (row + 1) * keyHeight | 171 | (col+1) * keyWidth -1, (row + 1) * keyHeight |
172 | ); | 172 | ); |
173 | } | 173 | } |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 177 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
178 | 178 | ||
179 | pressedRow = e->y() / keyHeight; | 179 | pressedRow = e->y() / keyHeight; |
180 | pressedCol = (int) (e->x() / keyWidth); | 180 | pressedCol = (int) (e->x() / keyWidth); |
181 | 181 | ||
182 | paintKey(pressedRow, pressedCol); | 182 | paintKey(pressedRow, pressedCol); |
183 | 183 | ||
184 | // emit that sucker! | 184 | // emit that sucker! |
185 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 185 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
186 | emit keyPressed(k, pressedRow, pressedCol, 1); | 186 | emit keyPressed(k, pressedRow, pressedCol, 1); |
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 190 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
191 | 191 | ||
192 | if (pressedRow != -1 && pressedRow != -1) { | 192 | if (pressedRow != -1 && pressedRow != -1) { |
193 | 193 | ||
194 | int row = pressedRow; pressedRow = -1; | 194 | int row = pressedRow; pressedRow = -1; |
195 | int col = pressedCol; pressedCol = -1; | 195 | int col = pressedCol; pressedCol = -1; |
196 | paintKey(row, col); | 196 | paintKey(row, col); |
197 | 197 | ||
198 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 198 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
199 | emit keyPressed(k, row, col, 0); | 199 | emit keyPressed(k, row, col, 0); |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 205 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
206 | 206 | ||
207 | /* set he default font height/width */ | 207 | /* set he default font height/width */ |
208 | QFontMetrics fm=fontMetrics(); | 208 | QFontMetrics fm=fontMetrics(); |
209 | keyHeight = fm.lineSpacing() + 2; | 209 | keyHeight = fm.lineSpacing() + 2; |
210 | keyWidth = (double)width()/numCols; | 210 | keyWidth = (double)width()/numCols; |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | QSize FunctionKeyboard::sizeHint() const { | 214 | QSize FunctionKeyboard::sizeHint() const { |
215 | 215 | ||
216 | return QSize(width(), keyHeight * numRows + 1); | 216 | return QSize(width(), keyHeight * numRows + 1); |
217 | } | 217 | } |
218 | 218 | ||
219 | void FunctionKeyboard::loadDefaults() { | 219 | void FunctionKeyboard::loadDefaults() { |
220 | 220 | ||
221 | numRows = DEFAULT_ROWS; | 221 | numRows = DEFAULT_ROWS; |
222 | numCols = DEFAULT_COLS; | 222 | numCols = DEFAULT_COLS; |
223 | keyWidth = (double)width()/numCols; // have to reset this thing too | 223 | keyWidth = (double)width()/numCols; // have to reset this thing too |
224 | 224 | ||
225 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); | 225 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); |
226 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); | 226 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); |
227 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); | 227 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); |
228 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); | 228 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); |
229 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); | 229 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); |
230 | 230 | ||
231 | keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); | 231 | keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); |
232 | keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); | 232 | keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); |
233 | keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); | 233 | keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); |
234 | keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); | 234 | keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); |
235 | keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); | 235 | keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); |
236 | 236 | ||
237 | keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); | 237 | keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); |
238 | keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); | 238 | keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); |
239 | keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); | 239 | keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); |
240 | keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); | 240 | keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); |
241 | keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); | 241 | keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); |
242 | keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); | 242 | keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); |
243 | keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); | 243 | keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); |
244 | keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); | 244 | keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); |
245 | keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); | 245 | keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); |
246 | keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); | 246 | keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); |
247 | keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); | 247 | keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); |
248 | keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); | 248 | keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); |
249 | 249 | ||
250 | 250 | ||
251 | } | 251 | } |
252 | 252 | ||
253 | /* FunctionKeyboardConfig {{{1 */ | 253 | /* FunctionKeyboardConfig {{{1 */ |
254 | 254 | ||
255 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) | 255 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
256 | : ProfileDialogKeyWidget(name, parent, na), | 256 | : ProfileDialogKeyWidget(name, parent, na), |
257 | selectedRow(0), selectedCol(0) | 257 | selectedRow(0), selectedCol(0) |
258 | { | 258 | { |
259 | qWarning("FunctionKeyboardConfig"); | 259 | qWarning("FunctionKeyboardConfig"); |
260 | 260 | ||
261 | 261 | ||
262 | kb = new FunctionKeyboard(this); | 262 | kb = new FunctionKeyboard(this); |
263 | connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 263 | connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
264 | this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); | 264 | this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); |
265 | 265 | ||
266 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); | 266 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); |
267 | QLabel *l = new QLabel("Rows", dimentions); | 267 | QLabel *l = new QLabel("Rows", dimentions); |
268 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); | 268 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); |
269 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | 269 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); |
270 | l = new QLabel("Columns", dimentions); | 270 | l = new QLabel("Columns", dimentions); |
271 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | 271 | m_colBox = new QSpinBox(1, 15, 1, dimentions); |
272 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | 272 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); |
273 | 273 | ||
274 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 274 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
275 | l = new QLabel("Label", editKey); | 275 | l = new QLabel("Label", editKey); |
276 | m_labels = new QComboBox(true, editKey); | 276 | m_labels = new QComboBox(true, editKey); |
277 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); | 277 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); |
278 | m_labels->insertItem(""); | 278 | m_labels->insertItem(""); |
279 | 279 | ||
280 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 280 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
281 | 281 | ||
282 | for (uint i = 0; i < files.count(); i++) { | 282 | for (uint i = 0; i < files.count(); i++) { |
283 | 283 | ||
284 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); | 284 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); |
285 | } | 285 | } |
286 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | 286 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); |
287 | connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); | 287 | connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); |
288 | 288 | ||
289 | l = new QLabel("Q Keycode", editKey); | 289 | l = new QLabel("Q Keycode", editKey); |
290 | m_qvalues = new QComboBox(true, editKey); | 290 | m_qvalues = new QComboBox(true, editKey); |
291 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); | 291 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); |
292 | m_qvalues->setDuplicatesEnabled(false); | 292 | m_qvalues->setDuplicatesEnabled(false); |
293 | m_qvalues->insertItem(""); | 293 | m_qvalues->insertItem(""); |
294 | connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&))); | 294 | connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); |
295 | 295 | ||
296 | l = new QLabel("Unicode Value", editKey); | 296 | l = new QLabel("Unicode Value", editKey); |
297 | m_uniValues = new QComboBox(true, editKey); | 297 | m_uniValues = new QComboBox(true, editKey); |
298 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); | 298 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); |
299 | m_uniValues->setDuplicatesEnabled(false); | 299 | m_uniValues->setDuplicatesEnabled(false); |
300 | m_uniValues->insertItem(""); | 300 | m_uniValues->insertItem(""); |
301 | connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); | 301 | connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); |
302 | 302 | ||
303 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 303 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
304 | root->addWidget(kb); | 304 | root->addWidget(kb); |
305 | root->addWidget(dimentions); | 305 | root->addWidget(dimentions); |
306 | root->addWidget(editKey); | 306 | root->addWidget(editKey); |
307 | } | 307 | } |
308 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { | 308 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { |
309 | 309 | ||
310 | } | 310 | } |
311 | void FunctionKeyboardConfig::load (const Profile& prof) { | 311 | void FunctionKeyboardConfig::load (const Profile& prof) { |
312 | 312 | ||
313 | kb->keys.clear(); | 313 | kb->keys.clear(); |
314 | kb->loadDefaults(); | 314 | kb->loadDefaults(); |
315 | 315 | ||
316 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); | 316 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); |
317 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); | 317 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); |
318 | 318 | ||
319 | /* load all the keys to the keyboard */ | 319 | /* load all the keys to the keyboard */ |
320 | for (int i = 0; i <= m_rowBox->value() -1; i++) | 320 | for (int i = 0; i <= m_rowBox->value() -1; i++) |
321 | for (int j = 0; j <= m_colBox->value() -1; j++) { | 321 | for (int j = 0; j <= m_colBox->value() -1; j++) { |
322 | 322 | ||
323 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | 323 | QString h = "r" + QString::number(i) + "c" + QString::number(j); |
324 | QString values = prof.readEntry("keb_" + h); | 324 | QString values = prof.readEntry("keb_" + h); |
325 | 325 | ||
326 | if (!values.isEmpty()) { | 326 | if (!values.isEmpty()) { |
327 | 327 | ||
328 | QStringList l = QStringList::split(QChar('|'), values, TRUE); | 328 | QStringList l = QStringList::split(QChar('|'), values, TRUE); |
329 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); | 329 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); |
330 | 330 | ||
331 | // load pixmap if used | 331 | // load pixmap if used |
332 | if (!l[1].isEmpty()) { | 332 | if (!l[1].isEmpty()) { |
333 | 333 | ||
334 | kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); | 334 | kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | } | 339 | } |
340 | void FunctionKeyboardConfig::save (Profile& prof) { | 340 | void FunctionKeyboardConfig::save (Profile& prof) { |
341 | 341 | ||
342 | prof.writeEntry("keb_rows", m_rowBox->value()); | 342 | prof.writeEntry("keb_rows", m_rowBox->value()); |
343 | prof.writeEntry("keb_cols", m_colBox->value()); | 343 | prof.writeEntry("keb_cols", m_colBox->value()); |
344 | 344 | ||
345 | QMap<QString, FKey>::Iterator it; | 345 | QMap<QString, FKey>::Iterator it; |
346 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { | 346 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { |
347 | 347 | ||
348 | FKey k = it.data(); | 348 | FKey k = it.data(); |
349 | QString entry = k.label + "|" | 349 | QString entry = k.label + "|" |
350 | + k.pixFile + "|" | 350 | + k.pixFile + "|" |
351 | + QString::number(k.qcode) + "|" | 351 | + QString::number(k.qcode) + "|" |
352 | + QString::number(k.unicode); | 352 | + QString::number(k.unicode); |
353 | 353 | ||
354 | prof.writeEntry("keb_" + it.key(), entry); | 354 | prof.writeEntry("keb_" + it.key(), entry); |
355 | 355 | ||
356 | } | 356 | } |
357 | 357 | ||
358 | } | 358 | } |
359 | void FunctionKeyboardConfig::slotChangeRows(int r) { | 359 | void FunctionKeyboardConfig::slotChangeRows(int r) { |
360 | 360 | ||
361 | kb->changeRows(r); | 361 | kb->changeRows(r); |
362 | 362 | ||
363 | } | 363 | } |
364 | void FunctionKeyboardConfig::slotChangeCols(int c) { | 364 | void FunctionKeyboardConfig::slotChangeCols(int c) { |
365 | 365 | ||
366 | kb->changeCols(c); | 366 | kb->changeCols(c); |
367 | } | 367 | } |
368 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { | 368 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { |
369 | 369 | ||
370 | if (!pressed) return; | 370 | if (!pressed) return; |
371 | 371 | ||
372 | selectedHandle = "r" + QString::number(r) + | 372 | selectedHandle = "r" + QString::number(r) + |
373 | "c" + QString::number(c); | 373 | "c" + QString::number(c); |
374 | selectedRow = r; | 374 | selectedRow = r; |
375 | selectedCol = c; | 375 | selectedCol = c; |
376 | 376 | ||
377 | if (k.pixFile.isEmpty()) { | 377 | if (k.pixFile.isEmpty()) { |
378 | 378 | ||
379 | m_labels->setEditable(true); | 379 | m_labels->setEditable(true); |
380 | m_labels->setCurrentItem(0); | 380 | m_labels->setCurrentItem(0); |
381 | m_labels->changeItem(k.label, 0); | 381 | m_labels->changeItem(k.label, 0); |
382 | 382 | ||
383 | } else { | 383 | } else { |
384 | 384 | ||
385 | // any better way to select the pixmap? | 385 | // any better way to select the pixmap? |
386 | m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); | 386 | m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); |
387 | m_labels->setEditable(false); | 387 | m_labels->setEditable(false); |
388 | } | 388 | } |
389 | m_qvalues->changeItem(QString::number(k.qcode), 0); | 389 | m_qvalues->changeItem(QString::number(k.qcode), 0); |
390 | m_uniValues->changeItem(QString::number(k.unicode), 0); | 390 | m_uniValues->changeItem(QString::number(k.unicode), 0); |
391 | } | 391 | } |
392 | void FunctionKeyboardConfig::slotChangeIcon(int index) { | 392 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
393 | 393 | ||
394 | if (index == 0) { | 394 | if (index == 0) { |
395 | 395 | ||
396 | // is text | 396 | // is text |
397 | m_labels->setEditable(true); | 397 | m_labels->setEditable(true); |