108 ui->linelengths->setChecked (gl_linelengths); |
108 ui->linelengths->setChecked (gl_linelengths); |
109 |
109 |
110 int i = 0; |
110 int i = 0; |
111 |
111 |
112 for (QAction* act : g_win->findChildren<QAction*>()) |
112 for (QAction* act : g_win->findChildren<QAction*>()) |
113 if (!act->objectName().isEmpty()) |
113 { KeySequenceConfig* cfg = g_win->shortcutForAction (act); |
114 addShortcut (g_win->shortcutForAction (act), act, i); |
114 |
|
115 if (cfg) |
|
116 addShortcut (*cfg, act, i); |
|
117 } |
115 |
118 |
116 ui->shortcutsList->setSortingEnabled (true); |
119 ui->shortcutsList->setSortingEnabled (true); |
117 ui->shortcutsList->sortItems(); |
120 ui->shortcutsList->sortItems(); |
118 |
121 |
119 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
122 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
220 |
223 |
221 // Set the maximum angle |
224 // Set the maximum angle |
222 if (j == 3) |
225 if (j == 3) |
223 dsb_gridData[i][j]->setMaximum (360); |
226 dsb_gridData[i][j]->setMaximum (360); |
224 |
227 |
225 dsb_gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value); |
228 dsb_gridData[i][j]->setValue (*g_GridInfo[i].confs[j]); |
226 gridlayout->addWidget (dsb_gridData[i][j], i + 1, j + 1); |
229 gridlayout->addWidget (dsb_gridData[i][j], i + 1, j + 1); |
227 } |
230 } |
228 } |
231 } |
229 |
232 |
230 ui->grids->setLayout (gridlayout); |
233 ui->grids->setLayout (gridlayout); |
231 } |
234 } |
232 |
235 |
233 // ============================================================================= |
236 // ============================================================================= |
234 // ----------------------------------------------------------------------------- |
237 // ----------------------------------------------------------------------------- |
235 static const struct LDExtProgInfo |
238 static struct LDExtProgInfo |
236 { const str name, iconname; |
239 { const str name, |
237 StringConfig* const path; |
240 iconname; |
238 mutable QLineEdit* input; |
241 str* const path; |
239 mutable QPushButton* setPathButton; |
242 QLineEdit* input; |
|
243 QPushButton* setPathButton; |
240 #ifndef _WIN32 |
244 #ifndef _WIN32 |
241 BoolConfig* const wine; |
245 bool* const wine; |
242 mutable QCheckBox* wineBox; |
246 QCheckBox* wineBox; |
243 #endif // _WIN32 |
247 #endif // _WIN32 |
244 } g_LDExtProgInfo[] = |
248 } g_LDExtProgInfo[] = |
245 { |
249 { |
246 #ifndef _WIN32 |
250 #ifndef _WIN32 |
247 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null }, |
251 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null }, |
262 // ----------------------------------------------------------------------------- |
266 // ----------------------------------------------------------------------------- |
263 void ConfigDialog::initExtProgs() |
267 void ConfigDialog::initExtProgs() |
264 { QGridLayout* pathsLayout = new QGridLayout; |
268 { QGridLayout* pathsLayout = new QGridLayout; |
265 int row = 0; |
269 int row = 0; |
266 |
270 |
267 for (const LDExtProgInfo& info : g_LDExtProgInfo) |
271 for (LDExtProgInfo& info : g_LDExtProgInfo) |
268 { QLabel* icon = new QLabel, |
272 { QLabel* icon = new QLabel, |
269 *progLabel = new QLabel (info.name); |
273 *progLabel = new QLabel (info.name); |
270 QLineEdit* input = new QLineEdit; |
274 QLineEdit* input = new QLineEdit; |
271 QPushButton* setPathButton = new QPushButton; |
275 QPushButton* setPathButton = new QPushButton; |
272 |
276 |
273 icon->setPixmap (getIcon (info.iconname)); |
277 icon->setPixmap (getIcon (info.iconname)); |
274 input->setText (info.path->value); |
278 input->setText (*info.path); |
275 setPathButton->setIcon (getIcon ("folder")); |
279 setPathButton->setIcon (getIcon ("folder")); |
276 info.input = input; |
280 info.input = input; |
277 info.setPathButton = setPathButton; |
281 info.setPathButton = setPathButton; |
278 |
282 |
279 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath())); |
283 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath())); |
322 gui_colortoolbar = quickColorString(); |
326 gui_colortoolbar = quickColorString(); |
323 |
327 |
324 // Set the grid settings |
328 // Set the grid settings |
325 for (int i = 0; i < g_NumGrids; ++i) |
329 for (int i = 0; i < g_NumGrids; ++i) |
326 for (int j = 0; j < 4; ++j) |
330 for (int j = 0; j < 4; ++j) |
327 g_GridInfo[i].confs[j]->value = dsb_gridData[i][j]->value(); |
331 *g_GridInfo[i].confs[j] = dsb_gridData[i][j]->value(); |
328 |
332 |
329 // Apply key shortcuts |
333 // Apply key shortcuts |
330 g_win->updateActionShortcuts(); |
334 g_win->updateActionShortcuts(); |
331 |
335 |
332 // Ext program settings |
336 // Ext program settings |
498 } |
502 } |
499 |
503 |
500 // ============================================================================= |
504 // ============================================================================= |
501 // Pick a color and set the appropriate configuration option. |
505 // Pick a color and set the appropriate configuration option. |
502 // ----------------------------------------------------------------------------- |
506 // ----------------------------------------------------------------------------- |
503 void ConfigDialog::pickColor (StringConfig& conf, QPushButton* button) |
507 void ConfigDialog::pickColor (str& conf, QPushButton* button) |
504 { QColor col = QColorDialog::getColor (QColor (conf)); |
508 { QColor col = QColorDialog::getColor (QColor (conf)); |
505 |
509 |
506 if (col.isValid()) |
510 if (col.isValid()) |
507 { uchar r = col.red(), |
511 { int r = col.red(), |
508 g = col.green(), |
512 g = col.green(), |
509 b = col.blue(); |
513 b = col.blue(); |
510 conf.value.sprintf ("#%.2X%.2X%.2X", r, g, b); |
514 |
511 setButtonBackground (button, conf.value); |
515 str colname; |
|
516 colname.sprintf ("#%.2X%.2X%.2X", r, g, b); |
|
517 conf = colname; |
|
518 setButtonBackground (button, colname); |
512 } |
519 } |
513 } |
520 } |
514 |
521 |
515 // ============================================================================= |
522 // ============================================================================= |
516 // ----------------------------------------------------------------------------- |
523 // ----------------------------------------------------------------------------- |
603 // ----------------------------------------------------------------------------- |
610 // ----------------------------------------------------------------------------- |
604 void ConfigDialog::slot_clearShortcut() |
611 void ConfigDialog::slot_clearShortcut() |
605 { QList<ShortcutListItem*> sel = getShortcutSelection(); |
612 { QList<ShortcutListItem*> sel = getShortcutSelection(); |
606 |
613 |
607 for (ShortcutListItem* item : sel) |
614 for (ShortcutListItem* item : sel) |
608 { item->getKeyConfig()->value = QKeySequence(); |
615 { item->getKeyConfig()->setValue (QKeySequence()); |
609 setShortcutText (item); |
616 setShortcutText (item); |
610 } |
617 } |
611 } |
618 } |
612 |
619 |
613 // ============================================================================= |
620 // ============================================================================= |
644 // Updates the text string for a given shortcut list item |
651 // Updates the text string for a given shortcut list item |
645 // ----------------------------------------------------------------------------- |
652 // ----------------------------------------------------------------------------- |
646 void ConfigDialog::setShortcutText (ShortcutListItem* item) |
653 void ConfigDialog::setShortcutText (ShortcutListItem* item) |
647 { QAction* act = item->getAction(); |
654 { QAction* act = item->getAction(); |
648 str label = act->iconText(); |
655 str label = act->iconText(); |
649 str keybind = item->getKeyConfig()->value.toString(); |
656 str keybind = item->getKeyConfig()->getValue().toString(); |
650 item->setText (fmt ("%1 (%2)", label, keybind)); |
657 item->setText (fmt ("%1 (%2)", label, keybind)); |
651 } |
658 } |
652 |
659 |
653 // ============================================================================= |
660 // ============================================================================= |
654 // Gets the configuration string of the quick color toolbar |
661 // Gets the configuration string of the quick color toolbar |
694 } |
701 } |
695 |
702 |
696 // ============================================================================= |
703 // ============================================================================= |
697 // ----------------------------------------------------------------------------- |
704 // ----------------------------------------------------------------------------- |
698 bool KeySequenceDialog::staticDialog (KeySequenceConfig* cfg, QWidget* parent) |
705 bool KeySequenceDialog::staticDialog (KeySequenceConfig* cfg, QWidget* parent) |
699 { KeySequenceDialog dlg (cfg->value, parent); |
706 { KeySequenceDialog dlg (cfg->getValue(), parent); |
700 |
707 |
701 if (dlg.exec() == false) |
708 if (dlg.exec() == false) |
702 return false; |
709 return false; |
703 |
710 |
704 cfg->value = dlg.seq; |
711 cfg->setValue (dlg.seq); |
705 return true; |
712 return true; |
706 } |
713 } |
707 |
714 |
708 // ============================================================================= |
715 // ============================================================================= |
709 // ----------------------------------------------------------------------------- |
716 // ----------------------------------------------------------------------------- |