143 addShortcut (act); |
143 addShortcut (act); |
144 }); |
144 }); |
145 |
145 |
146 ui->shortcutsList->setSortingEnabled (true); |
146 ui->shortcutsList->setSortingEnabled (true); |
147 ui->shortcutsList->sortItems(); |
147 ui->shortcutsList->sortItems(); |
148 quickColors = quickColorsFromConfig(); |
148 quickColors = LoadQuickColorList(); |
149 updateQuickColorList(); |
149 updateQuickColorList(); |
150 initExtProgs(); |
150 initExtProgs(); |
151 selectPage (deftab); |
151 selectPage (deftab); |
152 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
152 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
153 connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut())); |
153 connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut())); |
193 setShortcutText (item); |
193 setShortcutText (item); |
194 |
194 |
195 // If the action doesn't have a valid icon, use an empty one |
195 // If the action doesn't have a valid icon, use an empty one |
196 // so that the list is kept aligned. |
196 // so that the list is kept aligned. |
197 if (act->icon().isNull()) |
197 if (act->icon().isNull()) |
198 item->setIcon (getIcon ("empty")); |
198 item->setIcon (GetIcon ("empty")); |
199 |
199 |
200 ui->shortcutsList->insertItem (ui->shortcutsList->count(), item); |
200 ui->shortcutsList->insertItem (ui->shortcutsList->count(), item); |
201 } |
201 } |
202 |
202 |
203 // |
203 // |
213 QLabel* icon = new QLabel, |
213 QLabel* icon = new QLabel, |
214 *progLabel = new QLabel (info.name); |
214 *progLabel = new QLabel (info.name); |
215 QLineEdit* input = new QLineEdit; |
215 QLineEdit* input = new QLineEdit; |
216 QPushButton* setPathButton = new QPushButton; |
216 QPushButton* setPathButton = new QPushButton; |
217 |
217 |
218 icon->setPixmap (getIcon (info.iconname)); |
218 icon->setPixmap (GetIcon (info.iconname)); |
219 input->setText (*info.path); |
219 input->setText (*info.path); |
220 setPathButton->setIcon (getIcon ("folder")); |
220 setPathButton->setIcon (GetIcon ("folder")); |
221 info.input = input; |
221 info.input = input; |
222 info.setPathButton = setPathButton; |
222 info.setPathButton = setPathButton; |
223 |
223 |
224 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath())); |
224 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath())); |
225 |
225 |
240 } |
240 } |
241 |
241 |
242 ui->extProgs->setLayout (pathsLayout); |
242 ui->extProgs->setLayout (pathsLayout); |
243 } |
243 } |
244 |
244 |
245 void ConfigDialog::_applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func) |
245 void ConfigDialog::m_applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func) |
246 { |
246 { |
247 // Apply configuration |
247 // Apply configuration |
248 for (QWidget* widget : findChildren<QWidget*>()) |
248 for (QWidget* widget : findChildren<QWidget*>()) |
249 { |
249 { |
250 if (not widget->objectName().startsWith ("config")) |
250 if (not widget->objectName().startsWith ("config")) |
266 // |
266 // |
267 // Set the settings based on widget data. |
267 // Set the settings based on widget data. |
268 // |
268 // |
269 void ConfigDialog::applySettings() |
269 void ConfigDialog::applySettings() |
270 { |
270 { |
271 _applyToWidgetOptions ([&](QWidget* widget, AbstractConfigEntry* conf) |
271 m_applyToWidgetOptions ([&](QWidget* widget, AbstractConfigEntry* conf) |
272 { |
272 { |
273 QVariant value (conf->toVariant()); |
273 QVariant value (conf->toVariant()); |
274 QLineEdit* le; |
274 QLineEdit* le; |
275 QSpinBox* spinbox; |
275 QSpinBox* spinbox; |
276 QDoubleSpinBox* doublespinbox; |
276 QDoubleSpinBox* doublespinbox; |
287 elif ((slider = qobject_cast<QSlider*> (widget)) != null) |
287 elif ((slider = qobject_cast<QSlider*> (widget)) != null) |
288 value = slider->value(); |
288 value = slider->value(); |
289 elif ((checkbox = qobject_cast<QCheckBox*> (widget)) != null) |
289 elif ((checkbox = qobject_cast<QCheckBox*> (widget)) != null) |
290 value = checkbox->isChecked(); |
290 value = checkbox->isChecked(); |
291 elif ((button = qobject_cast<QPushButton*> (widget)) != null) |
291 elif ((button = qobject_cast<QPushButton*> (widget)) != null) |
292 value = _buttonColors[button]; |
292 value = m_buttonColors[button]; |
293 else |
293 else |
294 print ("Unknown widget of type %1\n", widget->metaObject()->className()); |
294 print ("Unknown widget of type %1\n", widget->metaObject()->className()); |
295 |
295 |
296 conf->loadFromVariant (value); |
296 conf->loadFromVariant (value); |
297 }); |
297 }); |
315 auto item = static_cast<ShortcutListItem*> (ui->shortcutsList->item (i)); |
315 auto item = static_cast<ShortcutListItem*> (ui->shortcutsList->item (i)); |
316 item->action()->setShortcut (item->sequence()); |
316 item->action()->setShortcut (item->sequence()); |
317 } |
317 } |
318 |
318 |
319 Config::Save(); |
319 Config::Save(); |
320 reloadAllSubfiles(); |
320 ReloadAllSubfiles(); |
321 loadLogoedStuds(); |
321 LoadLogoStuds(); |
322 g_win->R()->setBackground(); |
322 g_win->R()->setBackground(); |
323 g_win->doFullRefresh(); |
323 g_win->doFullRefresh(); |
324 g_win->updateDocumentList(); |
324 g_win->updateDocumentList(); |
325 } |
325 } |
326 |
326 |
362 QListWidgetItem* item = new QListWidgetItem; |
362 QListWidgetItem* item = new QListWidgetItem; |
363 |
363 |
364 if (entry.isSeparator()) |
364 if (entry.isSeparator()) |
365 { |
365 { |
366 item->setText ("<hr />"); |
366 item->setText ("<hr />"); |
367 item->setIcon (getIcon ("empty")); |
367 item->setIcon (GetIcon ("empty")); |
368 } |
368 } |
369 else |
369 else |
370 { |
370 { |
371 LDColor col (entry.color()); |
371 LDColor col (entry.color()); |
372 |
372 |
373 if (col == null) |
373 if (col == null) |
374 { |
374 { |
375 item->setText ("[[unknown color]]"); |
375 item->setText ("[[unknown color]]"); |
376 item->setIcon (getIcon ("error")); |
376 item->setIcon (GetIcon ("error")); |
377 } |
377 } |
378 else |
378 else |
379 { |
379 { |
380 item->setText (col.name()); |
380 item->setText (col.name()); |
381 item->setIcon (makeColorIcon (col, 16)); |
381 item->setIcon (MakeColorIcon (col, 16)); |
382 } |
382 } |
383 } |
383 } |
384 |
384 |
385 ui->quickColorList->addItem (item); |
385 ui->quickColorList->addItem (item); |
386 quickColorItems << item; |
386 quickColorItems << item; |
517 // |
517 // |
518 // Sets background color of a given button. |
518 // Sets background color of a given button. |
519 // |
519 // |
520 void ConfigDialog::setButtonBackground (QPushButton* button, QString value) |
520 void ConfigDialog::setButtonBackground (QPushButton* button, QString value) |
521 { |
521 { |
522 button->setIcon (getIcon ("colorselect")); |
522 button->setIcon (GetIcon ("colorselect")); |
523 button->setAutoFillBackground (true); |
523 button->setAutoFillBackground (true); |
524 button->setStyleSheet (format ("background-color: %1", value)); |
524 button->setStyleSheet (format ("background-color: %1", value)); |
525 _buttonColors[button] = QColor (value); |
525 m_buttonColors[button] = QColor (value); |
526 } |
526 } |
527 |
527 |
528 // |
528 // |
529 // Finds the given list widget item in the list of widget items given. |
529 // Finds the given list widget item in the list of widget items given. |
530 // |
530 // |