| 161 connect (ui->m_pagelist, SIGNAL (currentRowChanged (int)), |
161 connect (ui->m_pagelist, SIGNAL (currentRowChanged (int)), |
| 162 this, SLOT (selectPage (int))); |
162 this, SLOT (selectPage (int))); |
| 163 } |
163 } |
| 164 |
164 |
| 165 // ============================================================================= |
165 // ============================================================================= |
| 166 // ----------------------------------------------------------------------------- |
166 // ============================================================================= |
| 167 ConfigDialog::~ConfigDialog() |
167 ConfigDialog::~ConfigDialog() |
| 168 { |
168 { |
| 169 delete ui; |
169 delete ui; |
| 170 } |
170 } |
| 171 |
171 |
| 172 // ============================================================================= |
172 // ============================================================================= |
| 173 // ----------------------------------------------------------------------------- |
173 // ============================================================================= |
| 174 void ConfigDialog::selectPage (int row) |
174 void ConfigDialog::selectPage (int row) |
| 175 { |
175 { |
| 176 ui->m_pagelist->setCurrentRow (row); |
176 ui->m_pagelist->setCurrentRow (row); |
| 177 ui->m_pages->setCurrentIndex (row); |
177 ui->m_pages->setCurrentIndex (row); |
| 178 } |
178 } |
| 179 |
179 |
| 180 // ============================================================================= |
180 // ============================================================================= |
| 181 // Adds a shortcut entry to the list of shortcuts. |
181 // Adds a shortcut entry to the list of shortcuts. |
| 182 // ----------------------------------------------------------------------------- |
182 // ============================================================================= |
| 183 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, int& i) |
183 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, int& i) |
| 184 { |
184 { |
| 185 ShortcutListItem* item = new ShortcutListItem; |
185 ShortcutListItem* item = new ShortcutListItem; |
| 186 item->setIcon (act->icon()); |
186 item->setIcon (act->icon()); |
| 187 item->setKeyConfig (&cfg); |
187 item->setKeyConfig (&cfg); |
| 196 ui->shortcutsList->insertItem (i++, item); |
196 ui->shortcutsList->insertItem (i++, item); |
| 197 } |
197 } |
| 198 |
198 |
| 199 // ============================================================================= |
199 // ============================================================================= |
| 200 // Initializes the table of grid stuff |
200 // Initializes the table of grid stuff |
| 201 // ----------------------------------------------------------------------------- |
201 // ============================================================================= |
| 202 void ConfigDialog::initGrids() |
202 void ConfigDialog::initGrids() |
| 203 { |
203 { |
| 204 QGridLayout* gridlayout = new QGridLayout; |
204 QGridLayout* gridlayout = new QGridLayout; |
| 205 QLabel* xlabel = new QLabel ("X"), |
205 QLabel* xlabel = new QLabel ("X"), |
| 206 *ylabel = new QLabel ("Y"), |
206 *ylabel = new QLabel ("Y"), |
| 207 *zlabel = new QLabel ("Z"), |
207 *zlabel = new QLabel ("Z"), |
| 208 *anglabel = new QLabel ("Angle"); |
208 *anglabel = new QLabel ("Angle"); |
| 209 int i = 1; |
209 int i = 1; |
| 210 |
210 |
| 211 for (QLabel* label : initlist<QLabel*> ({xlabel, ylabel, zlabel, anglabel})) |
211 for (QLabel* label : QList<QLabel*> ({xlabel, ylabel, zlabel, anglabel})) |
| 212 { |
212 { |
| 213 label->setAlignment (Qt::AlignCenter); |
213 label->setAlignment (Qt::AlignCenter); |
| 214 gridlayout->addWidget (label, 0, i++); |
214 gridlayout->addWidget (label, 0, i++); |
| 215 } |
215 } |
| 216 |
216 |
| 217 for (int i = 0; i < g_NumGrids; ++i) |
217 for (int i = 0; i < g_NumGrids; ++i) |
| 218 { |
218 { |
| 219 // Icon |
219 // Icon |
| 220 lb_gridIcons[i] = new QLabel; |
220 lb_gridIcons[i] = new QLabel; |
| 221 lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%1", QString (g_GridInfo[i].name).toLower()))); |
221 lb_gridIcons[i]->setPixmap (getIcon (format ("grid-%1", QString (g_GridInfo[i].name).toLower()))); |
| 222 |
222 |
| 223 // Text label |
223 // Text label |
| 224 lb_gridLabels[i] = new QLabel (fmt ("%1:", g_GridInfo[i].name)); |
224 lb_gridLabels[i] = new QLabel (format ("%1:", g_GridInfo[i].name)); |
| 225 |
225 |
| 226 QHBoxLayout* labellayout = new QHBoxLayout; |
226 QHBoxLayout* labellayout = new QHBoxLayout; |
| 227 labellayout->addWidget (lb_gridIcons[i]); |
227 labellayout->addWidget (lb_gridIcons[i]); |
| 228 labellayout->addWidget (lb_gridLabels[i]); |
228 labellayout->addWidget (lb_gridLabels[i]); |
| 229 gridlayout->addLayout (labellayout, i + 1, 0); |
229 gridlayout->addLayout (labellayout, i + 1, 0); |
| 315 ui->extProgs->setLayout (pathsLayout); |
315 ui->extProgs->setLayout (pathsLayout); |
| 316 } |
316 } |
| 317 |
317 |
| 318 // ============================================================================= |
318 // ============================================================================= |
| 319 // Set the settings based on widget data. |
319 // Set the settings based on widget data. |
| 320 // ----------------------------------------------------------------------------- |
320 // ============================================================================= |
| 321 void ConfigDialog::applySettings() |
321 void ConfigDialog::applySettings() |
| 322 { |
322 { |
| 323 // Apply configuration |
323 // Apply configuration |
| 324 lv_colorize = ui->colorizeObjects->isChecked(); |
324 lv_colorize = ui->colorizeObjects->isChecked(); |
| 325 gl_colorbfc = ui->colorBFC->isChecked(); |
325 gl_colorbfc = ui->colorBFC->isChecked(); |
| 362 Config::save(); |
362 Config::save(); |
| 363 reloadAllSubfiles(); |
363 reloadAllSubfiles(); |
| 364 loadLogoedStuds(); |
364 loadLogoedStuds(); |
| 365 g_win->R()->setBackground(); |
365 g_win->R()->setBackground(); |
| 366 g_win->doFullRefresh(); |
366 g_win->doFullRefresh(); |
| 367 g_win->updateToolBars(); |
|
| 368 g_win->updateDocumentList(); |
367 g_win->updateDocumentList(); |
| 369 } |
368 } |
| 370 |
369 |
| 371 // ============================================================================= |
370 // ============================================================================= |
| 372 // A dialog button was clicked |
371 // A dialog button was clicked |
| 373 // ----------------------------------------------------------------------------- |
372 // ============================================================================= |
| 374 void ConfigDialog::buttonClicked (QAbstractButton* button) |
373 void ConfigDialog::buttonClicked (QAbstractButton* button) |
| 375 { |
374 { |
| 376 typedef QDialogButtonBox QDDB; |
375 typedef QDialogButtonBox QDDB; |
| 377 QDialogButtonBox* dbb = ui->buttonBox; |
376 QDialogButtonBox* dbb = ui->buttonBox; |
| 378 |
377 |
| 436 } |
435 } |
| 437 } |
436 } |
| 438 |
437 |
| 439 // ============================================================================= |
438 // ============================================================================= |
| 440 // Quick colors: add or edit button was clicked. |
439 // Quick colors: add or edit button was clicked. |
| 441 // ----------------------------------------------------------------------------- |
440 // ============================================================================= |
| 442 void ConfigDialog::slot_setColor() |
441 void ConfigDialog::slot_setColor() |
| 443 { |
442 { |
| 444 LDQuickColor* entry = null; |
443 LDQuickColor* entry = null; |
| 445 QListWidgetItem* item = null; |
444 QListWidgetItem* item = null; |
| 446 const bool isNew = static_cast<QPushButton*> (sender()) == ui->quickColor_add; |
445 const bool isNew = static_cast<QPushButton*> (sender()) == ui->quickColor_add; |
| 494 updateQuickColorList(); |
493 updateQuickColorList(); |
| 495 } |
494 } |
| 496 |
495 |
| 497 // ============================================================================= |
496 // ============================================================================= |
| 498 // Move a quick color up/down |
497 // Move a quick color up/down |
| 499 // ----------------------------------------------------------------------------- |
498 // ============================================================================= |
| 500 void ConfigDialog::slot_moveColor() |
499 void ConfigDialog::slot_moveColor() |
| 501 { |
500 { |
| 502 const bool up = (static_cast<QPushButton*> (sender()) == ui->quickColor_moveUp); |
501 const bool up = (static_cast<QPushButton*> (sender()) == ui->quickColor_moveUp); |
| 503 |
502 |
| 504 if (ui->quickColorList->selectedItems().isEmpty()) |
503 if (ui->quickColorList->selectedItems().isEmpty()) |
| 517 |
516 |
| 518 updateQuickColorList (&quickColors[dest]); |
517 updateQuickColorList (&quickColors[dest]); |
| 519 } |
518 } |
| 520 |
519 |
| 521 // ============================================================================= |
520 // ============================================================================= |
| |
521 // |
| 522 // Add a separator to quick colors |
522 // Add a separator to quick colors |
| 523 // ----------------------------------------------------------------------------- |
523 // |
| 524 void ConfigDialog::slot_addColorSeparator() |
524 void ConfigDialog::slot_addColorSeparator() |
| 525 { |
525 { |
| 526 quickColors << LDQuickColor::getSeparator(); |
526 quickColors << LDQuickColor::getSeparator(); |
| 527 updateQuickColorList (&quickColors[quickColors.size() - 1]); |
527 updateQuickColorList (&quickColors[quickColors.size() - 1]); |
| 528 } |
528 } |
| 529 |
529 |
| 530 // ============================================================================= |
530 // ============================================================================= |
| |
531 // |
| 531 // Clear all quick colors |
532 // Clear all quick colors |
| 532 // ----------------------------------------------------------------------------- |
533 // |
| 533 void ConfigDialog::slot_clearColors() |
534 void ConfigDialog::slot_clearColors() |
| 534 { |
535 { |
| 535 quickColors.clear(); |
536 quickColors.clear(); |
| 536 updateQuickColorList(); |
537 updateQuickColorList(); |
| 537 } |
538 } |
| 538 |
539 |
| 539 // ============================================================================= |
540 // ============================================================================= |
| |
541 // |
| 540 // Pick a color and set the appropriate configuration option. |
542 // Pick a color and set the appropriate configuration option. |
| 541 // ----------------------------------------------------------------------------- |
543 // |
| 542 void ConfigDialog::pickColor (QString& conf, QPushButton* button) |
544 void ConfigDialog::pickColor (QString& conf, QPushButton* button) |
| 543 { |
545 { |
| 544 QColor col = QColorDialog::getColor (QColor (conf)); |
546 QColor col = QColorDialog::getColor (QColor (conf)); |
| 545 |
547 |
| 546 if (col.isValid()) |
548 if (col.isValid()) |
| 555 setButtonBackground (button, colname); |
557 setButtonBackground (button, colname); |
| 556 } |
558 } |
| 557 } |
559 } |
| 558 |
560 |
| 559 // ============================================================================= |
561 // ============================================================================= |
| 560 // ----------------------------------------------------------------------------- |
562 // ============================================================================= |
| 561 void ConfigDialog::slot_setGLBackground() |
563 void ConfigDialog::slot_setGLBackground() |
| 562 { |
564 { |
| 563 pickColor (gl_bgcolor, ui->backgroundColorButton); |
565 pickColor (gl_bgcolor, ui->backgroundColorButton); |
| 564 } |
566 } |
| 565 |
567 |
| 566 // ============================================================================= |
568 // ============================================================================= |
| 567 // ----------------------------------------------------------------------------- |
569 // ============================================================================= |
| 568 void ConfigDialog::slot_setGLForeground() |
570 void ConfigDialog::slot_setGLForeground() |
| 569 { |
571 { |
| 570 pickColor (gl_maincolor, ui->mainColorButton); |
572 pickColor (gl_maincolor, ui->mainColorButton); |
| 571 } |
573 } |
| 572 |
574 |
| 573 // ============================================================================= |
575 // ============================================================================= |
| 574 // ----------------------------------------------------------------------------- |
576 // ============================================================================= |
| 575 void ConfigDialog::slot_setGLSelectColor() |
577 void ConfigDialog::slot_setGLSelectColor() |
| 576 { |
578 { |
| 577 pickColor (gl_selectcolor, ui->selColorButton); |
579 pickColor (gl_selectcolor, ui->selColorButton); |
| 578 } |
580 } |
| 579 |
581 |
| 580 // ============================================================================= |
582 // ============================================================================= |
| 581 // Sets background color of a given button. |
583 // Sets background color of a given button. |
| 582 // ----------------------------------------------------------------------------- |
584 // ============================================================================= |
| 583 void ConfigDialog::setButtonBackground (QPushButton* button, QString value) |
585 void ConfigDialog::setButtonBackground (QPushButton* button, QString value) |
| 584 { |
586 { |
| 585 button->setIcon (getIcon ("colorselect")); |
587 button->setIcon (getIcon ("colorselect")); |
| 586 button->setAutoFillBackground (true); |
588 button->setAutoFillBackground (true); |
| 587 button->setStyleSheet (fmt ("background-color: %1", value)); |
589 button->setStyleSheet (format ("background-color: %1", value)); |
| 588 } |
590 } |
| 589 |
591 |
| 590 // ============================================================================= |
592 // ============================================================================= |
| 591 // Finds the given list widget item in the list of widget items given. |
593 // Finds the given list widget item in the list of widget items given. |
| 592 // ----------------------------------------------------------------------------- |
594 // ============================================================================= |
| 593 int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack) |
595 int ConfigDialog::getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack) |
| 594 { |
596 { |
| 595 int i = 0; |
597 int i = 0; |
| 596 |
598 |
| 597 for (QListWidgetItem* it : haystack) |
599 for (QListWidgetItem* it : haystack) |
| 605 return -1; |
607 return -1; |
| 606 } |
608 } |
| 607 |
609 |
| 608 // ============================================================================= |
610 // ============================================================================= |
| 609 // Which quick color is currently selected? |
611 // Which quick color is currently selected? |
| 610 // ----------------------------------------------------------------------------- |
612 // ============================================================================= |
| 611 QListWidgetItem* ConfigDialog::getSelectedQuickColor() |
613 QListWidgetItem* ConfigDialog::getSelectedQuickColor() |
| 612 { |
614 { |
| 613 if (ui->quickColorList->selectedItems().isEmpty()) |
615 if (ui->quickColorList->selectedItems().isEmpty()) |
| 614 return null; |
616 return null; |
| 615 |
617 |
| 616 return ui->quickColorList->selectedItems() [0]; |
618 return ui->quickColorList->selectedItems() [0]; |
| 617 } |
619 } |
| 618 |
620 |
| 619 // ============================================================================= |
621 // ============================================================================= |
| 620 // Get the list of shortcuts selected |
622 // Get the list of shortcuts selected |
| 621 // ----------------------------------------------------------------------------- |
623 // ============================================================================= |
| 622 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() |
624 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() |
| 623 { |
625 { |
| 624 QList<ShortcutListItem*> out; |
626 QList<ShortcutListItem*> out; |
| 625 |
627 |
| 626 for (QListWidgetItem* entry : ui->shortcutsList->selectedItems()) |
628 for (QListWidgetItem* entry : ui->shortcutsList->selectedItems()) |
| 629 return out; |
631 return out; |
| 630 } |
632 } |
| 631 |
633 |
| 632 // ============================================================================= |
634 // ============================================================================= |
| 633 // Edit the shortcut of a given action. |
635 // Edit the shortcut of a given action. |
| 634 // ----------------------------------------------------------------------------- |
636 // ============================================================================= |
| 635 void ConfigDialog::slot_setShortcut() |
637 void ConfigDialog::slot_setShortcut() |
| 636 { |
638 { |
| 637 QList<ShortcutListItem*> sel = getShortcutSelection(); |
639 QList<ShortcutListItem*> sel = getShortcutSelection(); |
| 638 |
640 |
| 639 if (sel.size() < 1) |
641 if (sel.size() < 1) |
| 640 return; |
642 return; |
| 641 |
643 |
| 642 ShortcutListItem* item = sel[0]; |
644 ShortcutListItem* item = sel[0]; |
| 643 |
645 |
| 644 if (KeySequenceDialog::staticDialog (item->getKeyConfig(), this)) |
646 if (KeySequenceDialog::staticDialog (item->keyConfig(), this)) |
| 645 setShortcutText (item); |
647 setShortcutText (item); |
| 646 } |
648 } |
| 647 |
649 |
| 648 // ============================================================================= |
650 // ============================================================================= |
| 649 // Reset a shortcut to defaults |
651 // Reset a shortcut to defaults |
| 650 // ----------------------------------------------------------------------------- |
652 // ============================================================================= |
| 651 void ConfigDialog::slot_resetShortcut() |
653 void ConfigDialog::slot_resetShortcut() |
| 652 { |
654 { |
| 653 QList<ShortcutListItem*> sel = getShortcutSelection(); |
655 QList<ShortcutListItem*> sel = getShortcutSelection(); |
| 654 |
656 |
| 655 for (ShortcutListItem* item : sel) |
657 for (ShortcutListItem* item : sel) |
| 656 { |
658 { |
| 657 item->getKeyConfig()->reset(); |
659 item->keyConfig()->reset(); |
| 658 setShortcutText (item); |
660 setShortcutText (item); |
| 659 } |
661 } |
| 660 } |
662 } |
| 661 |
663 |
| 662 // ============================================================================= |
664 // ============================================================================= |
| 663 // Remove the shortcut of an action. |
665 // Remove the shortcut of an action. |
| 664 // ----------------------------------------------------------------------------- |
666 // ============================================================================= |
| 665 void ConfigDialog::slot_clearShortcut() |
667 void ConfigDialog::slot_clearShortcut() |
| 666 { |
668 { |
| 667 QList<ShortcutListItem*> sel = getShortcutSelection(); |
669 QList<ShortcutListItem*> sel = getShortcutSelection(); |
| 668 |
670 |
| 669 for (ShortcutListItem* item : sel) |
671 for (ShortcutListItem* item : sel) |
| 670 { |
672 { |
| 671 item->getKeyConfig()->setValue (QKeySequence()); |
673 item->keyConfig()->setValue (QKeySequence()); |
| 672 setShortcutText (item); |
674 setShortcutText (item); |
| 673 } |
675 } |
| 674 } |
676 } |
| 675 |
677 |
| 676 // ============================================================================= |
678 // ============================================================================= |
| 677 // Set the path of an external program |
679 // Set the path of an external program |
| 678 // ----------------------------------------------------------------------------- |
680 // ============================================================================= |
| 679 void ConfigDialog::slot_setExtProgPath() |
681 void ConfigDialog::slot_setExtProgPath() |
| 680 { |
682 { |
| 681 const LDExtProgInfo* info = null; |
683 const LDExtProgInfo* info = null; |
| 682 |
684 |
| 683 for (const LDExtProgInfo& it : g_LDExtProgInfo) |
685 for (const LDExtProgInfo& it : g_LDExtProgInfo) |
| 688 break; |
690 break; |
| 689 } |
691 } |
| 690 } |
692 } |
| 691 |
693 |
| 692 assert (info != null); |
694 assert (info != null); |
| 693 QString fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), *info->path, g_extProgPathFilter); |
695 QString fpath = QFileDialog::getOpenFileName (this, format ("Path to %1", info->name), *info->path, g_extProgPathFilter); |
| 694 |
696 |
| 695 if (fpath.isEmpty()) |
697 if (fpath.isEmpty()) |
| 696 return; |
698 return; |
| 697 |
699 |
| 698 info->input->setText (fpath); |
700 info->input->setText (fpath); |
| 699 } |
701 } |
| 700 |
702 |
| 701 // ============================================================================= |
703 // ============================================================================= |
| |
704 // |
| 702 // '...' button pressed for the download path |
705 // '...' button pressed for the download path |
| 703 // ----------------------------------------------------------------------------- |
706 // |
| 704 void ConfigDialog::slot_findDownloadFolder() |
707 void ConfigDialog::slot_findDownloadFolder() |
| 705 { |
708 { |
| 706 QString dpath = QFileDialog::getExistingDirectory(); |
709 QString dpath = QFileDialog::getExistingDirectory(); |
| 707 ui->downloadPath->setText (dpath); |
710 ui->downloadPath->setText (dpath); |
| 708 } |
711 } |
| 709 |
712 |
| 710 // ============================================================================= |
713 // ============================================================================= |
| |
714 // |
| 711 // Updates the text string for a given shortcut list item |
715 // Updates the text string for a given shortcut list item |
| 712 // ----------------------------------------------------------------------------- |
716 // |
| 713 void ConfigDialog::setShortcutText (ShortcutListItem* item) |
717 void ConfigDialog::setShortcutText (ShortcutListItem* item) |
| 714 { |
718 { |
| 715 QAction* act = item->getAction(); |
719 QAction* act = item->action(); |
| 716 QString label = act->iconText(); |
720 QString label = act->iconText(); |
| 717 QString keybind = item->getKeyConfig()->getValue().toString(); |
721 QString keybind = item->keyConfig()->getValue().toString(); |
| 718 item->setText (fmt ("%1 (%2)", label, keybind)); |
722 item->setText (format ("%1 (%2)", label, keybind)); |
| 719 } |
723 } |
| 720 |
724 |
| 721 // ============================================================================= |
725 // ============================================================================= |
| 722 // Gets the configuration string of the quick color toolbar |
726 // Gets the configuration string of the quick color toolbar |
| 723 // ----------------------------------------------------------------------------- |
727 // ============================================================================= |
| 724 QString ConfigDialog::quickColorString() |
728 QString ConfigDialog::quickColorString() |
| 725 { |
729 { |
| 726 QString val; |
730 QString val; |
| 727 |
731 |
| 728 for (const LDQuickColor& entry : quickColors) |
732 for (const LDQuickColor& entry : quickColors) |
| 776 cfg->setValue (dlg.seq); |
780 cfg->setValue (dlg.seq); |
| 777 return true; |
781 return true; |
| 778 } |
782 } |
| 779 |
783 |
| 780 // ============================================================================= |
784 // ============================================================================= |
| 781 // ----------------------------------------------------------------------------- |
785 // ============================================================================= |
| 782 void KeySequenceDialog::updateOutput() |
786 void KeySequenceDialog::updateOutput() |
| 783 { |
787 { |
| 784 QString shortcut = seq.toString(); |
788 QString shortcut = seq.toString(); |
| 785 |
789 |
| 786 if (seq == QKeySequence()) |
790 if (seq == QKeySequence()) |
| 787 shortcut = "<empty>"; |
791 shortcut = "<empty>"; |
| 788 |
792 |
| 789 QString text = fmt ("<center><b>%1</b></center>", shortcut); |
793 QString text = format ("<center><b>%1</b></center>", shortcut); |
| 790 lb_output->setText (text); |
794 lb_output->setText (text); |
| 791 } |
795 } |
| 792 |
796 |
| 793 // ============================================================================= |
797 // ============================================================================= |
| 794 // ----------------------------------------------------------------------------- |
798 // ============================================================================= |
| 795 void KeySequenceDialog::keyPressEvent (QKeyEvent* ev) |
799 void KeySequenceDialog::keyPressEvent (QKeyEvent* ev) |
| 796 { |
800 { |
| 797 seq = ev->key() + ev->modifiers(); |
801 seq = ev->key() + ev->modifiers(); |
| 798 updateOutput(); |
802 updateOutput(); |
| 799 } |
803 } |