355 |
355 |
356 // Init table items |
356 // Init table items |
357 for (LDQuickColor& entry : quickColors) { |
357 for (LDQuickColor& entry : quickColors) { |
358 QListWidgetItem* item = new QListWidgetItem; |
358 QListWidgetItem* item = new QListWidgetItem; |
359 |
359 |
360 if (entry.isSeparator) { |
360 if (entry.isSeparator()) { |
361 item->setText ("--------"); |
361 item->setText ("--------"); |
362 item->setIcon (getIcon ("empty")); |
362 item->setIcon (getIcon ("empty")); |
363 } else { |
363 } else { |
364 LDColor* col = entry.col; |
364 LDColor* col = entry.color(); |
365 |
365 |
366 if (col == null) { |
366 if (col == null) { |
367 item->setText ("[[unknown color]]"); |
367 item->setText ("[[unknown color]]"); |
368 item->setIcon (getIcon ("error")); |
368 item->setIcon (getIcon ("error")); |
369 } else { |
369 } else { |
373 } |
373 } |
374 |
374 |
375 ui->quickColorList->addItem (item); |
375 ui->quickColorList->addItem (item); |
376 quickColorItems << item; |
376 quickColorItems << item; |
377 |
377 |
378 if (sel && &entry == sel) { |
378 if (sel &&& entry == sel) { |
379 ui->quickColorList->setCurrentItem (item); |
379 ui->quickColorList->setCurrentItem (item); |
380 ui->quickColorList->scrollToItem (item); |
380 ui->quickColorList->scrollToItem (item); |
381 } |
381 } |
382 } |
382 } |
383 } |
383 } |
397 return; |
397 return; |
398 |
398 |
399 ulong i = getItemRow (item, quickColorItems); |
399 ulong i = getItemRow (item, quickColorItems); |
400 entry = &quickColors[i]; |
400 entry = &quickColors[i]; |
401 |
401 |
402 if (entry->isSeparator == true) |
402 if (entry->isSeparator() == true) |
403 return; // don't color separators |
403 return; // don't color separators |
404 } |
404 } |
405 |
405 |
406 short defval = entry ? entry->col->index : -1; |
406 short defval = entry ? entry->color()->index : -1; |
407 short val; |
407 short val; |
408 |
408 |
409 if (ColorSelector::getColor (val, defval, this) == false) |
409 if (ColorSelector::getColor (val, defval, this) == false) |
410 return; |
410 return; |
411 |
411 |
412 if (entry) |
412 if (entry) |
413 entry->col = getColor (val); |
413 entry->setColor (getColor (val)); |
414 else { |
414 else { |
415 LDQuickColor entry = {getColor (val), null, false}; |
415 LDQuickColor entry (getColor (val), null); |
416 |
416 |
417 item = getSelectedQuickColor(); |
417 item = getSelectedQuickColor(); |
418 ulong idx; |
418 ulong idx; |
419 |
419 |
420 if (item) |
420 if (item) |
466 |
466 |
467 // ============================================================================= |
467 // ============================================================================= |
468 // Add a separator to quick colors |
468 // Add a separator to quick colors |
469 // ----------------------------------------------------------------------------- |
469 // ----------------------------------------------------------------------------- |
470 void ConfigDialog::slot_addColorSeparator() { |
470 void ConfigDialog::slot_addColorSeparator() { |
471 quickColors << LDQuickColor ({null, null, true}); |
471 quickColors << LDQuickColor::getSeparator(); |
472 updateQuickColorList (&quickColors[quickColors.size() - 1]); |
472 updateQuickColorList (&quickColors[quickColors.size() - 1]); |
473 } |
473 } |
474 |
474 |
475 // ============================================================================= |
475 // ============================================================================= |
476 // Clear all quick colors |
476 // Clear all quick colors |
636 // Gets the configuration string of the quick color toolbar |
636 // Gets the configuration string of the quick color toolbar |
637 // ----------------------------------------------------------------------------- |
637 // ----------------------------------------------------------------------------- |
638 str ConfigDialog::quickColorString() { |
638 str ConfigDialog::quickColorString() { |
639 str val; |
639 str val; |
640 |
640 |
641 for (LDQuickColor entry : quickColors) { |
641 for (const LDQuickColor& entry : quickColors) { |
642 if (val.length() > 0) |
642 if (val.length() > 0) |
643 val += ':'; |
643 val += ':'; |
644 |
644 |
645 if (entry.isSeparator) |
645 if (entry.isSeparator()) |
646 val += '|'; |
646 val += '|'; |
647 else |
647 else |
648 val += fmt ("%1", entry.col->index); |
648 val += fmt ("%1", entry.color()->index); |
649 } |
649 } |
650 |
650 |
651 return val; |
651 return val; |
652 } |
652 } |
653 |
653 |