80 // ============================================================================= |
80 // ============================================================================= |
81 // ----------------------------------------------------------------------------- |
81 // ----------------------------------------------------------------------------- |
82 ConfigDialog::ConfigDialog (ConfigDialog::Tab deftab, QWidget* parent, Qt::WindowFlags f) : |
82 ConfigDialog::ConfigDialog (ConfigDialog::Tab deftab, QWidget* parent, Qt::WindowFlags f) : |
83 QDialog (parent, f) |
83 QDialog (parent, f) |
84 { |
84 { |
|
85 assert (g_win); |
85 ui = new Ui_ConfigUI; |
86 ui = new Ui_ConfigUI; |
86 ui->setupUi (this); |
87 ui->setupUi (this); |
87 |
88 |
88 initMainTab(); |
89 // Interface tab: |
89 initShortcutsTab(); |
|
90 initQuickColorTab(); |
|
91 initGridTab(); |
|
92 initExtProgTab(); |
|
93 |
|
94 ui->downloadPath->setText (net_downloadpath); |
|
95 ui->guessNetPaths->setChecked (net_guesspaths); |
|
96 ui->autoCloseNetPrompt->setChecked (net_autoclose); |
|
97 connect (ui->findDownloadPath, SIGNAL (clicked(bool)), this, SLOT (slot_findDownloadFolder())); |
|
98 |
|
99 ui->m_profileName->setText (ld_defaultname); |
|
100 ui->m_profileUsername->setText (ld_defaultuser); |
|
101 ui->m_profileLicense->setCurrentIndex (ld_defaultlicense); |
|
102 |
|
103 ui->tabs->setCurrentIndex (deftab); |
|
104 } |
|
105 |
|
106 // ============================================================================= |
|
107 // ----------------------------------------------------------------------------- |
|
108 ConfigDialog::~ConfigDialog() { |
|
109 delete ui; |
|
110 } |
|
111 |
|
112 // ============================================================================= |
|
113 // ----------------------------------------------------------------------------- |
|
114 void ConfigDialog::initMainTab() { |
|
115 // Init color stuff |
|
116 setButtonBackground (ui->backgroundColorButton, gl_bgcolor); |
90 setButtonBackground (ui->backgroundColorButton, gl_bgcolor); |
117 connect (ui->backgroundColorButton, SIGNAL (clicked()), |
91 connect (ui->backgroundColorButton, SIGNAL (clicked()), |
118 this, SLOT (slot_setGLBackground())); |
92 this, SLOT (slot_setGLBackground())); |
119 |
93 |
120 setButtonBackground (ui->mainColorButton, gl_maincolor.value); |
94 setButtonBackground (ui->mainColorButton, gl_maincolor.value); |
121 connect (ui->mainColorButton, SIGNAL (clicked()), |
95 connect (ui->mainColorButton, SIGNAL (clicked()), |
122 this, SLOT (slot_setGLForeground())); |
96 this, SLOT (slot_setGLForeground())); |
123 |
97 |
124 // Sliders |
|
125 ui->mainColorAlpha->setValue (gl_maincolor_alpha * 10.0f); |
98 ui->mainColorAlpha->setValue (gl_maincolor_alpha * 10.0f); |
126 ui->lineThickness->setValue (gl_linethickness); |
99 ui->lineThickness->setValue (gl_linethickness); |
127 |
|
128 // Checkboxes |
|
129 ui->colorizeObjects->setChecked (lv_colorize); |
100 ui->colorizeObjects->setChecked (lv_colorize); |
130 ui->colorBFC->setChecked (gl_colorbfc); |
101 ui->colorBFC->setChecked (gl_colorbfc); |
131 ui->blackEdges->setChecked (gl_blackedges); |
102 ui->blackEdges->setChecked (gl_blackedges); |
132 // ui->scemanticInlining->setChecked (edit_schemanticinline); |
|
133 ui->implicitFiles->setChecked (gui_implicitfiles); |
103 ui->implicitFiles->setChecked (gui_implicitfiles); |
134 ui->m_logostuds->setChecked (gl_logostuds); |
104 ui->m_logostuds->setChecked (gl_logostuds); |
135 } |
105 |
136 |
|
137 // ============================================================================= |
|
138 // ----------------------------------------------------------------------------- |
|
139 void ConfigDialog::initShortcutsTab() { |
|
140 ulong i = 0; |
106 ulong i = 0; |
141 |
|
142 #define act(N) addShortcut (key_##N, ACTION(N), i); |
107 #define act(N) addShortcut (key_##N, ACTION(N), i); |
143 #include "actions.h" |
108 #include "actions.h" |
144 |
109 |
145 ui->shortcutsList->setSortingEnabled (true); |
110 ui->shortcutsList->setSortingEnabled (true); |
146 ui->shortcutsList->sortItems(); |
111 ui->shortcutsList->sortItems(); |
147 |
112 |
148 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
113 connect (ui->shortcut_set, SIGNAL (clicked()), this, SLOT (slot_setShortcut())); |
149 connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut())); |
114 connect (ui->shortcut_reset, SIGNAL (clicked()), this, SLOT (slot_resetShortcut())); |
150 connect (ui->shortcut_clear, SIGNAL (clicked()), this, SLOT (slot_clearShortcut())); |
115 connect (ui->shortcut_clear, SIGNAL (clicked()), this, SLOT (slot_clearShortcut())); |
151 } |
116 |
152 |
|
153 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i) { |
|
154 ShortcutListItem* item = new ShortcutListItem; |
|
155 item->setIcon (act->icon()); |
|
156 item->setKeyConfig (&cfg); |
|
157 item->setAction (act); |
|
158 setShortcutText (item); |
|
159 |
|
160 // If the action doesn't have a valid icon, use an empty one |
|
161 // so that the list is kept aligned. |
|
162 if (act->icon().isNull()) |
|
163 item->setIcon (getIcon ("empty")); |
|
164 |
|
165 ui->shortcutsList->insertItem (i++, item); |
|
166 } |
|
167 |
|
168 // ============================================================================= |
|
169 // ----------------------------------------------------------------------------- |
|
170 void ConfigDialog::initQuickColorTab() { |
|
171 quickColors = quickColorsFromConfig(); |
117 quickColors = quickColorsFromConfig(); |
172 updateQuickColorList(); |
118 updateQuickColorList(); |
173 |
119 |
174 connect (ui->quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
120 connect (ui->quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
175 connect (ui->quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor())); |
121 connect (ui->quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor())); |
176 connect (ui->quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
122 connect (ui->quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
177 connect (ui->quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator())); |
123 connect (ui->quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator())); |
178 connect (ui->quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
124 connect (ui->quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
179 connect (ui->quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
125 connect (ui->quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
180 connect (ui->quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors())); |
126 connect (ui->quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors())); |
181 } |
127 |
182 |
128 ui->downloadPath->setText (net_downloadpath); |
183 // ============================================================================= |
129 ui->guessNetPaths->setChecked (net_guesspaths); |
184 // ----------------------------------------------------------------------------- |
130 ui->autoCloseNetPrompt->setChecked (net_autoclose); |
185 void ConfigDialog::initGridTab() { |
131 connect (ui->findDownloadPath, SIGNAL (clicked(bool)), this, SLOT (slot_findDownloadFolder())); |
|
132 |
|
133 ui->m_profileName->setText (ld_defaultname); |
|
134 ui->m_profileUsername->setText (ld_defaultuser); |
|
135 ui->m_profileLicense->setCurrentIndex (ld_defaultlicense); |
|
136 ui->tabs->setCurrentIndex (deftab); |
|
137 |
|
138 initGrids(); |
|
139 initExtProgs(); |
|
140 |
|
141 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), |
|
142 this, SLOT (buttonClicked(QAbstractButton*))); |
|
143 } |
|
144 |
|
145 // ============================================================================= |
|
146 // ----------------------------------------------------------------------------- |
|
147 ConfigDialog::~ConfigDialog() { |
|
148 delete ui; |
|
149 } |
|
150 |
|
151 // ============================================================================= |
|
152 // ----------------------------------------------------------------------------- |
|
153 void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i) { |
|
154 ShortcutListItem* item = new ShortcutListItem; |
|
155 item->setIcon (act->icon()); |
|
156 item->setKeyConfig (&cfg); |
|
157 item->setAction (act); |
|
158 setShortcutText (item); |
|
159 |
|
160 // If the action doesn't have a valid icon, use an empty one |
|
161 // so that the list is kept aligned. |
|
162 if (act->icon().isNull()) |
|
163 item->setIcon (getIcon ("empty")); |
|
164 |
|
165 ui->shortcutsList->insertItem (i++, item); |
|
166 } |
|
167 |
|
168 // ============================================================================= |
|
169 // ----------------------------------------------------------------------------- |
|
170 void ConfigDialog::initGrids() { |
186 QGridLayout* gridlayout = new QGridLayout; |
171 QGridLayout* gridlayout = new QGridLayout; |
187 QLabel* xlabel = new QLabel ("X"), |
172 QLabel* xlabel = new QLabel ("X"), |
188 *ylabel = new QLabel ("Y"), |
173 *ylabel = new QLabel ("Y"), |
189 *zlabel = new QLabel ("Z"), |
174 *zlabel = new QLabel ("Z"), |
190 *anglabel = new QLabel ("Angle"); |
175 *anglabel = new QLabel ("Angle"); |
277 pathsLayout->addWidget (wineBox, row, 4); |
262 pathsLayout->addWidget (wineBox, row, 4); |
278 #endif |
263 #endif |
279 |
264 |
280 ++row; |
265 ++row; |
281 } |
266 } |
282 |
267 |
283 ui->extProgs->setLayout (pathsLayout); |
268 ui->extProgs->setLayout (pathsLayout); |
|
269 } |
|
270 |
|
271 // ============================================================================= |
|
272 // ----------------------------------------------------------------------------- |
|
273 void ConfigDialog::applySettings() { |
|
274 // Apply configuration |
|
275 lv_colorize = ui->colorizeObjects->isChecked(); |
|
276 gl_colorbfc = ui->colorBFC->isChecked(); |
|
277 // edit_schemanticinline = ui->scemanticInlining->isChecked(); |
|
278 gl_blackedges = ui->blackEdges->isChecked(); |
|
279 gl_maincolor_alpha = ((double) ui->mainColorAlpha->value()) / 10.0f; |
|
280 gl_linethickness = ui->lineThickness->value(); |
|
281 gui_implicitfiles = ui->implicitFiles->isChecked(); |
|
282 net_downloadpath = ui->downloadPath->text(); |
|
283 net_guesspaths = ui->guessNetPaths->isChecked(); |
|
284 net_autoclose = ui->autoCloseNetPrompt->isChecked(); |
|
285 gl_logostuds = ui->m_logostuds->isChecked(); |
|
286 ld_defaultuser = ui->m_profileUsername->text(); |
|
287 ld_defaultname = ui->m_profileName->text(); |
|
288 ld_defaultlicense = ui->m_profileLicense->currentIndex(); |
|
289 |
|
290 if (net_downloadpath.value.right (1) != DIRSLASH) |
|
291 net_downloadpath += DIRSLASH; |
|
292 |
|
293 // Rebuild the quick color toolbar |
|
294 g_win->setQuickColors (quickColors); |
|
295 gui_colortoolbar = quickColorString(); |
|
296 |
|
297 // Set the grid settings |
|
298 for (int i = 0; i < g_NumGrids; ++i) |
|
299 for (int j = 0; j < 4; ++j) |
|
300 g_GridInfo[i].confs[j]->value = dsb_gridData[i][j]->value(); |
|
301 |
|
302 // Apply key shortcuts |
|
303 #define act(N) ACTION(N)->setShortcut (key_##N); |
|
304 #include "actions.h" |
|
305 |
|
306 // Ext program settings |
|
307 for (const extProgInfo & info : g_extProgInfo) { |
|
308 *info.path = info.input->text(); |
|
309 |
|
310 #ifndef _WIN32 |
|
311 *info.wine = info.wineBox->isChecked(); |
|
312 #endif // _WIN32 |
|
313 } |
|
314 |
|
315 Config::save(); |
|
316 reloadAllSubfiles(); |
|
317 loadLogoedStuds(); |
|
318 g_win->R()->setBackground(); |
|
319 g_win->fullRefresh(); |
|
320 g_win->updateToolBars(); |
|
321 g_win->updateFileList(); |
|
322 } |
|
323 |
|
324 // ============================================================================= |
|
325 // ----------------------------------------------------------------------------- |
|
326 void ConfigDialog::buttonClicked (QAbstractButton* button) { |
|
327 typedef QDialogButtonBox QDDB; |
|
328 QDialogButtonBox* dbb = ui->buttonBox; |
|
329 |
|
330 if (button == dbb->button (QDDB::Ok)) { |
|
331 applySettings(); |
|
332 accept(); |
|
333 } elif (button == dbb->button (QDDB::Apply)) { |
|
334 applySettings(); |
|
335 } elif (button == dbb->button (QDDB::Cancel)) { |
|
336 reject(); |
|
337 } |
284 } |
338 } |
285 |
339 |
286 // ============================================================================= |
340 // ============================================================================= |
287 // ----------------------------------------------------------------------------- |
341 // ----------------------------------------------------------------------------- |
288 void ConfigDialog::updateQuickColorList (LDQuickColor* sel) { |
342 void ConfigDialog::updateQuickColorList (LDQuickColor* sel) { |
570 } |
624 } |
571 |
625 |
572 return val; |
626 return val; |
573 } |
627 } |
574 |
628 |
575 // ============================================================================= |
|
576 // ----------------------------------------------------------------------------- |
|
577 const Ui_ConfigUI* ConfigDialog::getUI() const { |
|
578 return ui; |
|
579 } |
|
580 |
|
581 // ============================================================================= |
|
582 // ----------------------------------------------------------------------------- |
|
583 float ConfigDialog::getGridValue (int i, int j) const { |
|
584 return dsb_gridData[i][j]->value(); |
|
585 } |
|
586 |
|
587 // ============================================================================= |
|
588 // ----------------------------------------------------------------------------- |
|
589 void ConfigDialog::staticDialog() { |
|
590 ConfigDialog dlg (InterfaceTab, g_win); |
|
591 |
|
592 if (dlg.exec()) { |
|
593 const alias ui = *dlg.getUI(); |
|
594 |
|
595 // Apply configuration |
|
596 lv_colorize = ui.colorizeObjects->isChecked(); |
|
597 gl_colorbfc = ui.colorBFC->isChecked(); |
|
598 // edit_schemanticinline = ui.scemanticInlining->isChecked(); |
|
599 gl_blackedges = ui.blackEdges->isChecked(); |
|
600 gl_maincolor_alpha = ((double) ui.mainColorAlpha->value()) / 10.0f; |
|
601 gl_linethickness = ui.lineThickness->value(); |
|
602 gui_implicitfiles = ui.implicitFiles->isChecked(); |
|
603 net_downloadpath = ui.downloadPath->text(); |
|
604 net_guesspaths = ui.guessNetPaths->isChecked(); |
|
605 net_autoclose = ui.autoCloseNetPrompt->isChecked(); |
|
606 gl_logostuds = ui.m_logostuds->isChecked(); |
|
607 ld_defaultuser = ui.m_profileUsername->text(); |
|
608 ld_defaultname = ui.m_profileName->text(); |
|
609 ld_defaultlicense = ui.m_profileLicense->currentIndex(); |
|
610 |
|
611 if (net_downloadpath.value.right (1) != DIRSLASH) |
|
612 net_downloadpath += DIRSLASH; |
|
613 |
|
614 // Rebuild the quick color toolbar |
|
615 g_win->setQuickColors (dlg.quickColors); |
|
616 gui_colortoolbar = dlg.quickColorString(); |
|
617 |
|
618 // Set the grid settings |
|
619 for (int i = 0; i < g_NumGrids; ++i) |
|
620 for (int j = 0; j < 4; ++j) |
|
621 g_GridInfo[i].confs[j]->value = dlg.getGridValue (i, j); |
|
622 |
|
623 // Apply key shortcuts |
|
624 #define act(N) ACTION(N)->setShortcut (key_##N); |
|
625 #include "actions.h" |
|
626 |
|
627 // Ext program settings |
|
628 for (const extProgInfo & info : g_extProgInfo) { |
|
629 *info.path = info.input->text(); |
|
630 |
|
631 #ifndef _WIN32 |
|
632 *info.wine = info.wineBox->isChecked(); |
|
633 #endif // _WIN32 |
|
634 } |
|
635 |
|
636 Config::save(); |
|
637 reloadAllSubfiles(); |
|
638 loadLogoedStuds(); |
|
639 g_win->R()->setBackground(); |
|
640 g_win->fullRefresh(); |
|
641 g_win->updateToolBars(); |
|
642 g_win->updateFileList(); |
|
643 } |
|
644 } |
|
645 |
|
646 // ========================================================================================================================= |
629 // ========================================================================================================================= |
647 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
630 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
648 // ========================================================================================================================= |
631 // ========================================================================================================================= |
649 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
632 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
650 // ========================================================================================================================= |
633 // ========================================================================================================================= |