summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index d29109a..3e39415 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -268,196 +268,193 @@ QStringList ConfigDlg::loadSw()
268 } 268 }
269 /* Update sw_maps from default_maps */ 269 /* Update sw_maps from default_maps */
270 for (uint i = 0; i < d_maps.count(); ++i) { 270 for (uint i = 0; i < d_maps.count(); ++i) {
271 if (s_maps.find(d_maps[i]) == s_maps.end()) { 271 if (s_maps.find(d_maps[i]) == s_maps.end()) {
272 s_maps.append(d_maps[i]); 272 s_maps.append(d_maps[i]);
273 } 273 }
274 } 274 }
275 /* Update sw_maps from custom_maps */ 275 /* Update sw_maps from custom_maps */
276 for (uint i = 0; i < c_maps.count(); ++i) { 276 for (uint i = 0; i < c_maps.count(); ++i) {
277 if (s_maps.find(c_maps[i]) == s_maps.end()) { 277 if (s_maps.find(c_maps[i]) == s_maps.end()) {
278 s_maps.append(c_maps[i]); 278 s_maps.append(c_maps[i]);
279 } 279 }
280 } 280 }
281 } 281 }
282 282
283 return s_maps; 283 return s_maps;
284} 284}
285 285
286void ConfigDlg::accept() 286void ConfigDlg::accept()
287{ 287{
288 /* Writing all stuffs to config */ 288 /* Writing all stuffs to config */
289 Config *config = new Config("multikey"); 289 Config *config = new Config("multikey");
290 config->setGroup("general"); 290 config->setGroup("general");
291 config->writeEntry("usePickboard", pick_button->isChecked()); // default closed 291 config->writeEntry("usePickboard", pick_button->isChecked()); // default closed
292 config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed 292 config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed
293 293
294 config->setGroup("keymaps"); 294 config->setGroup("keymaps");
295 config->writeEntry("sw", sw_maps, QChar('|')); 295 config->writeEntry("sw", sw_maps, QChar('|'));
296 config->writeEntry("maps", custom_maps, QChar('|')); 296 config->writeEntry("maps", custom_maps, QChar('|'));
297 delete config; 297 delete config;
298 298
299 int index = keymaps->currentItem(); 299 int index = keymaps->currentItem();
300 if (index == 0) { 300 if (index == 0) {
301 301
302 remove_button->setDisabled(true); 302 remove_button->setDisabled(true);
303 emit setMapToDefault(); 303 emit setMapToDefault();
304 } 304 }
305 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { 305 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) {
306 306
307 remove_button->setDisabled(true); 307 remove_button->setDisabled(true);
308 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); 308 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]);
309 309
310 } else { 310 } else {
311 311
312 remove_button->setEnabled(true); 312 remove_button->setEnabled(true);
313 emit setMapToFile(sw_maps[index - 1]); 313 emit setMapToFile(sw_maps[index - 1]);
314 } 314 }
315 315
316 emit pickboardToggled(pick_button->isChecked()); 316 emit pickboardToggled(pick_button->isChecked());
317 emit repeatToggled(repeat_button->isChecked()); 317 emit repeatToggled(repeat_button->isChecked());
318 emit reloadSw(); 318 emit reloadSw();
319 319
320 QDialog::accept(); 320 QDialog::accept();
321 emit configDlgClosed(); 321 emit configDlgClosed();
322} 322}
323 323
324void ConfigDlg::moveSelectedUp() 324void ConfigDlg::moveSelectedUp()
325{ 325{
326 int i = keymaps->currentItem(); 326 int i = keymaps->currentItem();
327 /* Ignore Current Language */ 327 /* Ignore Current Language */
328 if (i > 1) { 328 if (i > 1) {
329 QString t = sw_maps[i-1]; 329 QString t = sw_maps[i-1];
330 sw_maps[i-1] = sw_maps[i-2]; 330 sw_maps[i-1] = sw_maps[i-2];
331 sw_maps[i-2] = t; 331 sw_maps[i-2] = t;
332 332
333 QString item = keymaps->currentText(); 333 QString item = keymaps->currentText();
334 keymaps->removeItem(i); 334 keymaps->removeItem(i);
335 keymaps->insertItem(item, i-1); 335 keymaps->insertItem(item, i-1);
336 keymaps->setCurrentItem(i-1); 336 keymaps->setCurrentItem(i-1);
337 } 337 }
338} 338}
339 339
340void ConfigDlg::moveSelectedDown() 340void ConfigDlg::moveSelectedDown()
341{ 341{
342 int i = keymaps->currentItem(); 342 int i = keymaps->currentItem();
343 /* Ignore Current Language */ 343 /* Ignore Current Language */
344 if (i > 0 && i < (int)keymaps->count() - 1) { 344 if (i > 0 && i < (int)keymaps->count() - 1) {
345 QString t = sw_maps[i-1]; 345 QString t = sw_maps[i-1];
346 sw_maps[i-1] = sw_maps[i]; 346 sw_maps[i-1] = sw_maps[i];
347 sw_maps[i] = t; 347 sw_maps[i] = t;
348 348
349 QString item = keymaps->currentText(); 349 QString item = keymaps->currentText();
350 keymaps->removeItem(i); 350 keymaps->removeItem(i);
351 keymaps->insertItem(item, i+1); 351 keymaps->insertItem(item, i+1);
352 keymaps->setCurrentItem(i+1); 352 keymaps->setCurrentItem(i+1);
353 } 353 }
354} 354}
355 355
356void ConfigDlg::closeEvent(QCloseEvent *) { 356void ConfigDlg::closeEvent(QCloseEvent *) {
357 357
358 // tell the parent it was closed, so delete me 358 // tell the parent it was closed, so delete me
359 emit configDlgClosed(); 359 emit configDlgClosed();
360} 360}
361 361
362void ConfigDlg::setMap(int index) { 362void ConfigDlg::setMap(int index) {
363 363
364 if (index == 0) { 364 if (index == 0 || default_maps.find(sw_maps[index-1]) != default_maps.end()) {
365 remove_button->setDisabled(true);
366 }
367 else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) {
368 remove_button->setDisabled(true); 365 remove_button->setDisabled(true);
369 } else { 366 } else {
370 remove_button->setEnabled(true); 367 remove_button->setEnabled(true);
371 } 368 }
372} 369}
373 370
374// ConfigDlg::addMap() {{{1 371// ConfigDlg::addMap() {{{1
375void ConfigDlg::addMap() { 372void ConfigDlg::addMap() {
376 373
377 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 374 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
378 375
379 if (map.isNull()) return; 376 if (map.isNull()) return;
380 377
381 Config config ("multikey"); 378 Config config ("multikey");
382 config.setGroup("keymaps"); 379 config.setGroup("keymaps");
383 QStringList maps = config.readListEntry("maps", QChar('|')); 380 QStringList maps = config.readListEntry("maps", QChar('|'));
384 maps.append(map); 381 maps.append(map);
385 custom_maps.append(map); 382 custom_maps.append(map);
386 if (sw_maps.find(map) == sw_maps.end()) 383 if (sw_maps.find(map) == sw_maps.end())
387 sw_maps.append(map); 384 sw_maps.append(map);
388 385
389 QFile map_file (map); 386 QFile map_file (map);
390 if (map_file.open(IO_ReadOnly)) { 387 if (map_file.open(IO_ReadOnly)) {
391 388
392 QString line; bool found = 0; 389 QString line; bool found = 0;
393 390
394 map_file.readLine(line, 1024); 391 map_file.readLine(line, 1024);
395 while (!map_file.atEnd()) { 392 while (!map_file.atEnd()) {
396 393
397 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { 394 if (line.find(QRegExp("^title\\s*=\\s*")) != -1) {
398 395
399 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); 396 keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
400 found = 1; 397 found = 1;
401 break; 398 break;
402 } 399 }
403 map_file.readLine(line, 1024); 400 map_file.readLine(line, 1024);
404 } 401 }
405 if (!found) keymaps->insertItem(map); 402 if (!found) keymaps->insertItem(map);
406 403
407 map_file.close(); 404 map_file.close();
408 } 405 }
409 406
410 keymaps->setSelected(keymaps->count() - 1, true); 407 keymaps->setSelected(keymaps->count() - 1, true);
411} 408}
412 409
413// ConfigDlg::removeMap() {{{1 410// ConfigDlg::removeMap() {{{1
414void ConfigDlg::removeMap() { 411void ConfigDlg::removeMap() {
415 412
416 // move selection up one 413 // move selection up one
417 keymaps->setSelected(keymaps->currentItem() - 1, true); 414 keymaps->setSelected(keymaps->currentItem() - 1, true);
418 // delete the next selected item cus you just moved it up 415 // delete the next selected item cus you just moved it up
419 keymaps->removeItem(keymaps->currentItem() + 1); 416 keymaps->removeItem(keymaps->currentItem() + 1);
420 417
421 custom_maps.remove(sw_maps[keymaps->currentItem()]); 418 custom_maps.remove(sw_maps[keymaps->currentItem()]);
422 sw_maps.remove(sw_maps.at(keymaps->currentItem())); 419 sw_maps.remove(sw_maps.at(keymaps->currentItem()));
423} 420}
424 421
425/* ConfigDlg::slots for the color buttons {{{1 422/* ConfigDlg::slots for the color buttons {{{1
426 * 423 *
427 * these four slots are almost the same, except for the names. i was thinking 424 * these four slots are almost the same, except for the names. i was thinking
428 * of making a map with pointers to the buttons and names of the configEntry 425 * of making a map with pointers to the buttons and names of the configEntry
429 * so it could be one slot, but then there would be no way of telling which 426 * so it could be one slot, but then there would be no way of telling which
430 * of the buttons was clicked if they all connect to the same slot. 427 * of the buttons was clicked if they all connect to the same slot.
431 * 428 *
432 */ 429 */
433 430
434void ConfigDlg::keyColorClicked() { 431void ConfigDlg::keyColorClicked() {
435 432
436 Config config ("multikey"); 433 Config config ("multikey");
437 config.setGroup ("colors"); 434 config.setGroup ("colors");
438 435
439 QStringList color = config.readListEntry("keycolor", QChar(',')); 436 QStringList color = config.readListEntry("keycolor", QChar(','));
440 437
441 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 438 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
442 439
443 color[0].setNum(newcolor.red()); 440 color[0].setNum(newcolor.red());
444 color[1].setNum(newcolor.green()); 441 color[1].setNum(newcolor.green());
445 color[2].setNum(newcolor.blue()); 442 color[2].setNum(newcolor.blue());
446 443
447 config.writeEntry("keycolor", color, QChar(',')); 444 config.writeEntry("keycolor", color, QChar(','));
448 config.write(); 445 config.write();
449 446
450 keycolor_button->setPalette(QPalette(newcolor)); 447 keycolor_button->setPalette(QPalette(newcolor));
451 emit reloadKeyboard(); 448 emit reloadKeyboard();
452} 449}
453void ConfigDlg::keyColorPressedClicked() { 450void ConfigDlg::keyColorPressedClicked() {
454 451
455 Config config ("multikey"); 452 Config config ("multikey");
456 config.setGroup ("colors"); 453 config.setGroup ("colors");
457 454
458 QStringList color = config.readListEntry("keycolor_pressed", QChar(',')); 455 QStringList color = config.readListEntry("keycolor_pressed", QChar(','));
459 456
460 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())); 457 QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
461 458
462 color[0].setNum(newcolor.red()); 459 color[0].setNum(newcolor.red());
463 color[1].setNum(newcolor.green()); 460 color[1].setNum(newcolor.green());