src/gui.cpp

changeset 395
5210bcb1d7e0
parent 393
01fffd08c25a
child 399
13d24c6eb423
equal deleted inserted replaced
394:298958ce1b54 395:5210bcb1d7e0
50 #include "ui_ldforge.h" 50 #include "ui_ldforge.h"
51 51
52 static bool g_bSelectionLocked = false; 52 static bool g_bSelectionLocked = false;
53 53
54 cfg (bool, lv_colorize, true); 54 cfg (bool, lv_colorize, true);
55 cfg (int, gui_toolbar_iconsize, 24);
56 cfg (str, gui_colortoolbar, "16:24:|:1:2:4:14:0:15:|:33:34:36:46"); 55 cfg (str, gui_colortoolbar, "16:24:|:1:2:4:14:0:15:|:33:34:36:46");
57 extern_cfg (str, io_recentfiles); 56 extern_cfg (str, io_recentfiles);
58 extern_cfg (bool, gl_axes); 57 extern_cfg (bool, gl_axes);
59 extern_cfg (str, gl_maincolor); 58 extern_cfg (str, gl_maincolor);
60 extern_cfg (float, gl_maincolor_alpha); 59 extern_cfg (float, gl_maincolor_alpha);
89 88
90 // Init message log manager 89 // Init message log manager
91 m_msglog = new MessageManager; 90 m_msglog = new MessageManager;
92 m_msglog->setRenderer (R()); 91 m_msglog->setRenderer (R());
93 m_renderer->setMessageLog (m_msglog); 92 m_renderer->setMessageLog (m_msglog);
94 m_colorMeta = parseQuickColorMeta(); 93 m_quickColors = quickColorsFromConfig();
95 slot_selectionChanged(); 94 slot_selectionChanged();
96 setStatusBar (new QStatusBar); 95 setStatusBar (new QStatusBar);
97 96
98 // Init primitive loader task stuff 97 // Init primitive loader task stuff
99 m_primLoaderBar = new QProgressBar; 98 m_primLoaderBar = new QProgressBar;
163 } 162 }
164 163
165 // ============================================================================= 164 // =============================================================================
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
167 // ============================================================================= 166 // =============================================================================
168 vector<quickColor> parseQuickColorMeta() { 167 vector<LDQuickColor> quickColorsFromConfig() {
169 vector<quickColor> meta; 168 vector<LDQuickColor> colors;
170 169
171 for (str colorname : gui_colortoolbar.value.split (":")) { 170 for (str colorname : gui_colortoolbar.value.split (":")) {
172 if (colorname == "|") { 171 if (colorname == "|") {
173 meta << quickColor ({null, null, true}); 172 colors << LDQuickColor ({null, null, true});
174 } else { 173 } else {
175 LDColor* col = getColor (colorname.toLong()); 174 LDColor* col = getColor (colorname.toLong());
176 assert (col != null); 175 assert (col != null);
177 meta << quickColor ({col, null, false}); 176 colors << LDQuickColor ({col, null, false});
178 } 177 }
179 } 178 }
180 179
181 return meta; 180 return colors;
182 } 181 }
183 182
184 // ============================================================================= 183 // =============================================================================
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
186 // ============================================================================= 185 // =============================================================================
192 m_colorButtons.clear(); 191 m_colorButtons.clear();
193 192
194 // Clear the toolbar - we deleted the buttons but there's still separators 193 // Clear the toolbar - we deleted the buttons but there's still separators
195 ui->colorToolbar->clear(); 194 ui->colorToolbar->clear();
196 195
197 for (quickColor& entry : m_colorMeta) { 196 for (LDQuickColor& entry : m_quickColors) {
198 if (entry.isSeparator) 197 if (entry.isSeparator)
199 ui->colorToolbar->addSeparator(); 198 ui->colorToolbar->addSeparator();
200 else { 199 else {
201 QToolButton* colorButton = new QToolButton; 200 QToolButton* colorButton = new QToolButton;
202 colorButton->setIcon (makeColorIcon (entry.col, gui_toolbar_iconsize)); 201 colorButton->setIcon (makeColorIcon (entry.col, 22));
203 colorButton->setIconSize (QSize (22, 22)); 202 colorButton->setIconSize (QSize (22, 22));
204 colorButton->setToolTip (entry.col->name); 203 colorButton->setToolTip (entry.col->name);
205 204
206 connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor())); 205 connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor()));
207 ui->colorToolbar->addWidget (colorButton); 206 ui->colorToolbar->addWidget (colorButton);
453 void ForgeWindow::slot_quickColor() { 452 void ForgeWindow::slot_quickColor() {
454 beginAction (null); 453 beginAction (null);
455 QToolButton* button = static_cast<QToolButton*> (sender()); 454 QToolButton* button = static_cast<QToolButton*> (sender());
456 LDColor* col = null; 455 LDColor* col = null;
457 456
458 for (quickColor entry : m_colorMeta) { 457 for (LDQuickColor entry : m_quickColors) {
459 if (entry.btn == button) { 458 if (entry.btn == button) {
460 col = entry.col; 459 col = entry.col;
461 break; 460 break;
462 } 461 }
463 } 462 }
812 811
813 ++row; 812 ++row;
814 } 813 }
815 } 814 }
816 815
817 CheckBoxGroup* makeAxesBox() {
818 CheckBoxGroup* cbg_axes = new CheckBoxGroup ("Axes", Qt::Horizontal);
819 cbg_axes->addCheckBox ("X", X);
820 cbg_axes->addCheckBox ("Y", Y);
821 cbg_axes->addCheckBox ("Z", Z);
822 return cbg_axes;
823 }
824
825 void ForgeWindow::setStatusBarText (str text) { 816 void ForgeWindow::setStatusBarText (str text) {
826 statusBar()->showMessage (text); 817 statusBar()->showMessage (text);
827 } 818 }
828 819
829 void ForgeWindow::clearSelection() { 820 void ForgeWindow::clearSelection() {

mercurial