zz_configDialog.cpp

changeset 135
c243df39913e
parent 124
7962744759ad
child 141
184d117e1b12
equal deleted inserted replaced
134:7fd0784471df 135:c243df39913e
51 // ============================================================================= 51 // =============================================================================
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
53 // ============================================================================= 53 // =============================================================================
54 ConfigDialog::ConfigDialog (ForgeWindow* parent) : QDialog (parent) { 54 ConfigDialog::ConfigDialog (ForgeWindow* parent) : QDialog (parent) {
55 g_ConfigDialog = this; 55 g_ConfigDialog = this;
56 qTabs = new QTabWidget; 56 tabs = new QTabWidget;
57 57
58 initMainTab (); 58 initMainTab ();
59 initShortcutsTab (); 59 initShortcutsTab ();
60 initQuickColorTab (); 60 initQuickColorTab ();
61 initGridTab (); 61 initGridTab ();
62 62
63 IMPLEMENT_DIALOG_BUTTONS 63 IMPLEMENT_DIALOG_BUTTONS
64 64
65 QVBoxLayout* layout = new QVBoxLayout; 65 QVBoxLayout* layout = new QVBoxLayout;
66 layout->addWidget (qTabs); 66 layout->addWidget (tabs);
67 layout->addWidget (qButtons); 67 layout->addWidget (bbx_buttons);
68 setLayout (layout); 68 setLayout (layout);
69 69
70 setWindowTitle (APPNAME_DISPLAY " - Settings"); 70 setWindowTitle (APPNAME_DISPLAY " - Settings");
71 setWindowIcon (QIcon ("icons/settings.png")); 71 setWindowIcon (QIcon ("icons/settings.png"));
72 } 72 }
73 73
74 // ============================================================================= 74 // =============================================================================
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
76 // ============================================================================= 76 // =============================================================================
77 void ConfigDialog::initMainTab () { 77 void ConfigDialog::initMainTab () {
78 qMainTab = new QWidget; 78 mainTab = new QWidget;
79 79
80 // ========================================================================= 80 // =========================================================================
81 // LDraw path 81 // LDraw path
82 qLDrawPathLabel = new QLabel ("LDraw path:"); 82 lb_LDrawPath = new QLabel ("LDraw path:");
83 83
84 qLDrawPath = new QLineEdit; 84 le_LDrawPath = new QLineEdit;
85 qLDrawPath->setText (io_ldpath.value.chars()); 85 le_LDrawPath->setText (io_ldpath.value.chars());
86 86
87 qLDrawPathFindButton = new QPushButton; 87 pb_findLDrawPath = new QPushButton;
88 qLDrawPathFindButton->setIcon (QIcon ("icons/folder.png")); 88 pb_findLDrawPath->setIcon (QIcon ("icons/folder.png"));
89 connect (qLDrawPathFindButton, SIGNAL (clicked ()), 89 connect (pb_findLDrawPath, SIGNAL (clicked ()),
90 this, SLOT (slot_findLDrawPath ())); 90 this, SLOT (slot_findLDrawPath ()));
91 91
92 QHBoxLayout* qLDrawPathLayout = new QHBoxLayout; 92 QHBoxLayout* qLDrawPathLayout = new QHBoxLayout;
93 qLDrawPathLayout->addWidget (qLDrawPath); 93 qLDrawPathLayout->addWidget (le_LDrawPath);
94 qLDrawPathLayout->addWidget (qLDrawPathFindButton); 94 qLDrawPathLayout->addWidget (pb_findLDrawPath);
95 95
96 // ========================================================================= 96 // =========================================================================
97 // Background and foreground colors 97 // Background and foreground colors
98 qGLBackgroundLabel = new QLabel ("Background color:"); 98 lb_viewBg = new QLabel ("Background color:");
99 qGLBackgroundButton = new QPushButton; 99 pb_viewBg = new QPushButton;
100 setButtonBackground (qGLBackgroundButton, gl_bgcolor.value); 100 setButtonBackground (pb_viewBg, gl_bgcolor.value);
101 connect (qGLBackgroundButton, SIGNAL (clicked ()), 101 connect (pb_viewBg, SIGNAL (clicked ()),
102 this, SLOT (slot_setGLBackground ())); 102 this, SLOT (slot_setGLBackground ()));
103 103
104 qGLForegroundLabel = new QLabel ("Foreground color:"); 104 lb_viewFg = new QLabel ("Foreground color:");
105 qGLForegroundButton = new QPushButton; 105 pb_viewFg = new QPushButton;
106 setButtonBackground (qGLForegroundButton, gl_maincolor.value); 106 setButtonBackground (pb_viewFg, gl_maincolor.value);
107 connect (qGLForegroundButton, SIGNAL (clicked ()), 107 connect (pb_viewFg, SIGNAL (clicked ()),
108 this, SLOT (slot_setGLForeground ())); 108 this, SLOT (slot_setGLForeground ()));
109 109
110 // ========================================================================= 110 // =========================================================================
111 // Alpha and line thickness sliders 111 // Alpha and line thickness sliders
112 qGLForegroundAlphaLabel = new QLabel ("Alpha:"); 112 lb_viewFgAlpha = new QLabel ("Alpha:");
113 makeSlider (qGLForegroundAlpha, 1, 10, (gl_maincolor_alpha * 10.0f)); 113 makeSlider (sl_viewFgAlpha, 1, 10, (gl_maincolor_alpha * 10.0f));
114 114
115 qGLLineThicknessLabel = new QLabel ("Line thickness:"); 115 lb_lineThickness = new QLabel ("Line thickness:");
116 makeSlider (qGLLineThickness, 1, 8, gl_linethickness); 116 makeSlider (sl_lineThickness, 1, 8, gl_linethickness);
117 117
118 // ========================================================================= 118 // =========================================================================
119 // Tool bar icon size slider 119 // Tool bar icon size slider
120 qToolBarIconSizeLabel = new QLabel ("Toolbar icon size:"); 120 lb_iconSize = new QLabel ("Toolbar icon size:");
121 makeSlider (qToolBarIconSize, 1, 5, (gui_toolbar_iconsize - 12) / 4); 121 makeSlider (sl_iconSize, 1, 5, (gui_toolbar_iconsize - 12) / 4);
122 122
123 // ========================================================================= 123 // =========================================================================
124 // List view colorizer and BFC red/green view checkboxes 124 // List view colorizer and BFC red/green view checkboxes
125 qLVColorize = new QCheckBox ("Colorize polygons in list view"); 125 cb_colorize = new QCheckBox ("Colorize polygons in list view");
126 INIT_CHECKBOX (qLVColorize, lv_colorize) 126 INIT_CHECKBOX (cb_colorize, lv_colorize)
127 127
128 qGLColorBFC = new QCheckBox ("Red/green BFC view"); 128 cb_colorBFC = new QCheckBox ("Red/green BFC view");
129 INIT_CHECKBOX (qGLColorBFC, gl_colorbfc) 129 INIT_CHECKBOX (cb_colorBFC, gl_colorbfc)
130 130
131 qGLSelFlash = new QCheckBox ("Selection flash"); 131 cb_selFlash = new QCheckBox ("Selection flash");
132 INIT_CHECKBOX (qGLSelFlash, gl_selflash) 132 INIT_CHECKBOX (cb_selFlash, gl_selflash)
133 133
134 QGridLayout* layout = new QGridLayout; 134 QGridLayout* layout = new QGridLayout;
135 layout->addWidget (qLDrawPathLabel, 0, 0); 135 layout->addWidget (lb_LDrawPath, 0, 0);
136 layout->addLayout (qLDrawPathLayout, 0, 1, 1, 3); 136 layout->addLayout (qLDrawPathLayout, 0, 1, 1, 3);
137 137
138 layout->addWidget (qGLBackgroundLabel, 1, 0); 138 layout->addWidget (lb_viewBg, 1, 0);
139 layout->addWidget (qGLBackgroundButton, 1, 1); 139 layout->addWidget (pb_viewBg, 1, 1);
140 layout->addWidget (qGLForegroundLabel, 1, 2); 140 layout->addWidget (lb_viewFg, 1, 2);
141 layout->addWidget (qGLForegroundButton, 1, 3); 141 layout->addWidget (pb_viewFg, 1, 3);
142 142
143 layout->addWidget (qGLLineThicknessLabel, 2, 0); 143 layout->addWidget (lb_lineThickness, 2, 0);
144 layout->addWidget (qGLLineThickness, 2, 1); 144 layout->addWidget (sl_lineThickness, 2, 1);
145 layout->addWidget (qGLForegroundAlphaLabel, 2, 2); 145 layout->addWidget (lb_viewFgAlpha, 2, 2);
146 layout->addWidget (qGLForegroundAlpha, 2, 3); 146 layout->addWidget (sl_viewFgAlpha, 2, 3);
147 147
148 layout->addWidget (qToolBarIconSizeLabel, 3, 0); 148 layout->addWidget (lb_iconSize, 3, 0);
149 layout->addWidget (qToolBarIconSize, 3, 1); 149 layout->addWidget (sl_iconSize, 3, 1);
150 150
151 layout->addWidget (qLVColorize, 4, 0, 1, 4); 151 layout->addWidget (cb_colorize, 4, 0, 1, 4);
152 layout->addWidget (qGLColorBFC, 5, 0, 1, 4); 152 layout->addWidget (cb_colorBFC, 5, 0, 1, 4);
153 layout->addWidget (qGLSelFlash, 6, 0, 1, 4); 153 layout->addWidget (cb_selFlash, 6, 0, 1, 4);
154 qMainTab->setLayout (layout); 154 mainTab->setLayout (layout);
155 155
156 // Add the tab to the manager 156 // Add the tab to the manager
157 qTabs->addTab (qMainTab, "Main settings"); 157 tabs->addTab (mainTab, "Main settings");
158 } 158 }
159 159
160 // ============================================================================= 160 // =============================================================================
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
162 // ============================================================================= 162 // =============================================================================
163 void ConfigDialog::initShortcutsTab () { 163 void ConfigDialog::initShortcutsTab () {
164 QGridLayout* qLayout; 164 QGridLayout* qLayout;
165 165
166 qShortcutsTab = new QWidget; 166 shortcutsTab = new QWidget;
167 qShortcutList = new QListWidget; 167 lw_shortcutList = new QListWidget;
168 qLayout = new QGridLayout; 168 qLayout = new QGridLayout;
169 169
170 // Init table items 170 // Init table items
171 ulong i = 0; 171 ulong i = 0;
172 for (actionmeta meta : g_ActionMeta) { 172 for (actionmeta meta : g_ActionMeta) {
174 174
175 QListWidgetItem* qItem = new QListWidgetItem; 175 QListWidgetItem* qItem = new QListWidgetItem;
176 setShortcutText (qItem, meta); 176 setShortcutText (qItem, meta);
177 qItem->setIcon (qAct->icon ()); 177 qItem->setIcon (qAct->icon ());
178 178
179 qaShortcutItems.push_back (qItem); 179 shortcutItems.push_back (qItem);
180 qShortcutList->insertItem (i, qItem); 180 lw_shortcutList->insertItem (i, qItem);
181 ++i; 181 ++i;
182 } 182 }
183 183
184 qSetShortcut = new QPushButton ("Set"); 184 pb_setShortcut = new QPushButton ("Set");
185 qResetShortcut = new QPushButton ("Reset"); 185 pb_resetShortcut = new QPushButton ("Reset");
186 qClearShortcut = new QPushButton ("Clear"); 186 pb_clearShortcut = new QPushButton ("Clear");
187 187
188 connect (qSetShortcut, SIGNAL (clicked ()), this, SLOT (slot_setShortcut ())); 188 connect (pb_setShortcut, SIGNAL (clicked ()), this, SLOT (slot_setShortcut ()));
189 connect (qResetShortcut, SIGNAL (clicked ()), this, SLOT (slot_resetShortcut ())); 189 connect (pb_resetShortcut, SIGNAL (clicked ()), this, SLOT (slot_resetShortcut ()));
190 connect (qClearShortcut, SIGNAL (clicked ()), this, SLOT (slot_clearShortcut ())); 190 connect (pb_clearShortcut, SIGNAL (clicked ()), this, SLOT (slot_clearShortcut ()));
191 191
192 QVBoxLayout* qButtonLayout = new QVBoxLayout; 192 QVBoxLayout* qButtonLayout = new QVBoxLayout;
193 qButtonLayout->addWidget (qSetShortcut); 193 qButtonLayout->addWidget (pb_setShortcut);
194 qButtonLayout->addWidget (qResetShortcut); 194 qButtonLayout->addWidget (pb_resetShortcut);
195 qButtonLayout->addWidget (qClearShortcut); 195 qButtonLayout->addWidget (pb_clearShortcut);
196 qButtonLayout->addStretch (10); 196 qButtonLayout->addStretch (10);
197 197
198 qLayout->addWidget (qShortcutList, 0, 0); 198 qLayout->addWidget (lw_shortcutList, 0, 0);
199 qLayout->addLayout (qButtonLayout, 0, 1); 199 qLayout->addLayout (qButtonLayout, 0, 1);
200 qShortcutsTab->setLayout (qLayout); 200 shortcutsTab->setLayout (qLayout);
201 qTabs->addTab (qShortcutsTab, "Shortcuts"); 201 tabs->addTab (shortcutsTab, "Shortcuts");
202 } 202 }
203 203
204 // ============================================================================= 204 // =============================================================================
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
206 // ============================================================================= 206 // =============================================================================
207 void ConfigDialog::initQuickColorTab () { 207 void ConfigDialog::initQuickColorTab () {
208 qQuickColorTab = new QWidget; 208 quickColorTab = new QWidget;
209 209
210 qAddColor = new QPushButton (getIcon ("palette"), "Add"); 210 pb_addColor = new QPushButton (getIcon ("palette"), "Add");
211 qDelColor = new QPushButton (getIcon ("delete"), "Remove"); 211 pb_delColor = new QPushButton (getIcon ("delete"), "Remove");
212 qChangeColor = new QPushButton (getIcon ("palette"), "Set"); 212 pb_changeColor = new QPushButton (getIcon ("palette"), "Set");
213 qAddColorSeparator = new QPushButton ("Add Separator"); 213 pb_addColorSeparator = new QPushButton ("Add Separator");
214 qMoveColorUp = new QPushButton (getIcon ("arrow-up"), "Move Up"); 214 pb_moveColorUp = new QPushButton (getIcon ("arrow-up"), "Move Up");
215 qMoveColorDown = new QPushButton (getIcon ("arrow-down"), "Move Down"); 215 pb_moveColorDown = new QPushButton (getIcon ("arrow-down"), "Move Down");
216 qClearColors = new QPushButton (getIcon ("delete-all"), "Clear"); 216 pb_clearColors = new QPushButton (getIcon ("delete-all"), "Clear");
217 217
218 qQuickColorList = new QListWidget; 218 lw_quickColors = new QListWidget;
219 219
220 quickColorMeta = parseQuickColorMeta (); 220 quickColorMeta = parseQuickColorMeta ();
221 updateQuickColorList (); 221 updateQuickColorList ();
222 222
223 QVBoxLayout* qButtonLayout = new QVBoxLayout; 223 QVBoxLayout* qButtonLayout = new QVBoxLayout;
224 qButtonLayout->addWidget (qAddColor); 224 qButtonLayout->addWidget (pb_addColor);
225 qButtonLayout->addWidget (qDelColor); 225 qButtonLayout->addWidget (pb_delColor);
226 qButtonLayout->addWidget (qChangeColor); 226 qButtonLayout->addWidget (pb_changeColor);
227 qButtonLayout->addWidget (qAddColorSeparator); 227 qButtonLayout->addWidget (pb_addColorSeparator);
228 qButtonLayout->addWidget (qMoveColorUp); 228 qButtonLayout->addWidget (pb_moveColorUp);
229 qButtonLayout->addWidget (qMoveColorDown); 229 qButtonLayout->addWidget (pb_moveColorDown);
230 qButtonLayout->addWidget (qClearColors); 230 qButtonLayout->addWidget (pb_clearColors);
231 qButtonLayout->addStretch (1); 231 qButtonLayout->addStretch (1);
232 232
233 connect (qAddColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ())); 233 connect (pb_addColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ()));
234 connect (qDelColor, SIGNAL (clicked ()), this, SLOT (slot_delColor ())); 234 connect (pb_delColor, SIGNAL (clicked ()), this, SLOT (slot_delColor ()));
235 connect (qChangeColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ())); 235 connect (pb_changeColor, SIGNAL (clicked ()), this, SLOT (slot_setColor ()));
236 connect (qAddColorSeparator, SIGNAL (clicked ()), this, SLOT (slot_addColorSeparator ())); 236 connect (pb_addColorSeparator, SIGNAL (clicked ()), this, SLOT (slot_addColorSeparator ()));
237 connect (qMoveColorUp, SIGNAL (clicked ()), this, SLOT (slot_moveColor ())); 237 connect (pb_moveColorUp, SIGNAL (clicked ()), this, SLOT (slot_moveColor ()));
238 connect (qMoveColorDown, SIGNAL (clicked ()), this, SLOT (slot_moveColor ())); 238 connect (pb_moveColorDown, SIGNAL (clicked ()), this, SLOT (slot_moveColor ()));
239 connect (qClearColors, SIGNAL (clicked ()), this, SLOT (slot_clearColors ())); 239 connect (pb_clearColors, SIGNAL (clicked ()), this, SLOT (slot_clearColors ()));
240 240
241 QGridLayout* qLayout = new QGridLayout; 241 QGridLayout* qLayout = new QGridLayout;
242 qLayout->addWidget (qQuickColorList, 0, 0); 242 qLayout->addWidget (lw_quickColors, 0, 0);
243 qLayout->addLayout (qButtonLayout, 0, 1); 243 qLayout->addLayout (qButtonLayout, 0, 1);
244 244
245 qQuickColorTab->setLayout (qLayout); 245 quickColorTab->setLayout (qLayout);
246 qTabs->addTab (qQuickColorTab, "Quick Colors"); 246 tabs->addTab (quickColorTab, "Quick Colors");
247 } 247 }
248 248
249 // ============================================================================= 249 // =============================================================================
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
251 // ============================================================================= 251 // =============================================================================
265 layout->addWidget (label, 0, i++); 265 layout->addWidget (label, 0, i++);
266 } 266 }
267 267
268 for (int i = 0; i < g_NumGrids; ++i) { 268 for (int i = 0; i < g_NumGrids; ++i) {
269 // Icon 269 // Icon
270 gridIcons[i] = new QLabel; 270 lb_gridIcons[i] = new QLabel;
271 gridIcons[i]->setPixmap (QPixmap (format ("icons/grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); 271 lb_gridIcons[i]->setPixmap (QPixmap (format ("icons/grid-%s", str (g_GridInfo[i].name).tolower ().chars ())));
272 272
273 // Text label 273 // Text label
274 gridLabels[i] = new QLabel (format ("%s:", g_GridInfo[i].name)); 274 lb_gridLabels[i] = new QLabel (format ("%s:", g_GridInfo[i].name));
275 275
276 QHBoxLayout* labellayout = new QHBoxLayout; 276 QHBoxLayout* labellayout = new QHBoxLayout;
277 labellayout->addWidget (gridIcons[i]); 277 labellayout->addWidget (lb_gridIcons[i]);
278 labellayout->addWidget (gridLabels[i]); 278 labellayout->addWidget (lb_gridLabels[i]);
279 layout->addLayout (labellayout, i + 1, 0); 279 layout->addLayout (labellayout, i + 1, 0);
280 280
281 // Add the widgets 281 // Add the widgets
282 for (int j = 0; j < 4; ++j) { 282 for (int j = 0; j < 4; ++j) {
283 gridData[i][j] = new QDoubleSpinBox; 283 dsb_gridData[i][j] = new QDoubleSpinBox;
284 gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value); 284 dsb_gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value);
285 layout->addWidget (gridData[i][j], i + 1, j + 1); 285 layout->addWidget (dsb_gridData[i][j], i + 1, j + 1);
286 } 286 }
287 } 287 }
288 288
289 l2->addLayout (layout); 289 l2->addLayout (layout);
290 l2->addStretch (1); 290 l2->addStretch (1);
291 291
292 tab->setLayout (l2); 292 tab->setLayout (l2);
293 qTabs->addTab (tab, "Grids"); 293 tabs->addTab (tab, "Grids");
294 } 294 }
295 295
296 // ============================================================================= 296 // =============================================================================
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
298 // ============================================================================= 298 // =============================================================================
299 void ConfigDialog::updateQuickColorList (quickColorMetaEntry* pSel) { 299 void ConfigDialog::updateQuickColorList (quickColorMetaEntry* pSel) {
300 for (QListWidgetItem* qItem : qaQuickColorItems) 300 for (QListWidgetItem* qItem : quickColorItems)
301 delete qItem; 301 delete qItem;
302 302
303 qaQuickColorItems.clear (); 303 quickColorItems.clear ();
304 304
305 // Init table items 305 // Init table items
306 for (quickColorMetaEntry& entry : quickColorMeta) { 306 for (quickColorMetaEntry& entry : quickColorMeta) {
307 QListWidgetItem* qItem = new QListWidgetItem; 307 QListWidgetItem* qItem = new QListWidgetItem;
308 308
319 qItem->setText (col->zName); 319 qItem->setText (col->zName);
320 qItem->setIcon (getIcon ("palette")); 320 qItem->setIcon (getIcon ("palette"));
321 } 321 }
322 } 322 }
323 323
324 qQuickColorList->addItem (qItem); 324 lw_quickColors->addItem (qItem);
325 qaQuickColorItems.push_back (qItem); 325 quickColorItems.push_back (qItem);
326 326
327 if (pSel && &entry == pSel) { 327 if (pSel && &entry == pSel) {
328 qQuickColorList->setCurrentItem (qItem); 328 lw_quickColors->setCurrentItem (qItem);
329 qQuickColorList->scrollToItem (qItem); 329 lw_quickColors->scrollToItem (qItem);
330 } 330 }
331 } 331 }
332 } 332 }
333 333
334 // ============================================================================= 334 // =============================================================================
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
336 // ============================================================================= 336 // =============================================================================
337 void ConfigDialog::slot_setColor () { 337 void ConfigDialog::slot_setColor () {
338 quickColorMetaEntry* pEntry = null; 338 quickColorMetaEntry* pEntry = null;
339 QListWidgetItem* qItem = null; 339 QListWidgetItem* qItem = null;
340 const bool bNew = static_cast<QPushButton*> (sender ()) == qAddColor; 340 const bool bNew = static_cast<QPushButton*> (sender ()) == pb_addColor;
341 341
342 if (bNew == false) { 342 if (bNew == false) {
343 qItem = getSelectedQuickColor (); 343 qItem = getSelectedQuickColor ();
344 if (!qItem) 344 if (!qItem)
345 return; 345 return;
346 346
347 ulong ulIdx = getItemRow (qItem, qaQuickColorItems); 347 ulong ulIdx = getItemRow (qItem, quickColorItems);
348 pEntry = &quickColorMeta[ulIdx]; 348 pEntry = &quickColorMeta[ulIdx];
349 349
350 if (pEntry->bSeparator == true) 350 if (pEntry->bSeparator == true)
351 return; // don't color separators 351 return; // don't color separators
352 } 352 }
364 364
365 qItem = getSelectedQuickColor (); 365 qItem = getSelectedQuickColor ();
366 ulong idx; 366 ulong idx;
367 367
368 if (qItem) 368 if (qItem)
369 idx = getItemRow (qItem, qaQuickColorItems) + 1; 369 idx = getItemRow (qItem, quickColorItems) + 1;
370 else 370 else
371 idx = qaQuickColorItems.size(); 371 idx = quickColorItems.size();
372 372
373 quickColorMeta.insert (quickColorMeta.begin() + idx, entry); 373 quickColorMeta.insert (quickColorMeta.begin() + idx, entry);
374 pEntry = &quickColorMeta[idx]; 374 pEntry = &quickColorMeta[idx];
375 } 375 }
376 376
379 379
380 // ============================================================================= 380 // =============================================================================
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
382 // ============================================================================= 382 // =============================================================================
383 void ConfigDialog::slot_delColor () { 383 void ConfigDialog::slot_delColor () {
384 if (qQuickColorList->selectedItems().size() == 0) 384 if (lw_quickColors->selectedItems().size() == 0)
385 return; 385 return;
386 386
387 QListWidgetItem* qItem = qQuickColorList->selectedItems ()[0]; 387 QListWidgetItem* qItem = lw_quickColors->selectedItems ()[0];
388 ulong ulIdx = getItemRow (qItem, qaQuickColorItems); 388 ulong ulIdx = getItemRow (qItem, quickColorItems);
389 quickColorMeta.erase (quickColorMeta.begin () + ulIdx); 389 quickColorMeta.erase (quickColorMeta.begin () + ulIdx);
390 updateQuickColorList (); 390 updateQuickColorList ();
391 } 391 }
392 392
393 // ============================================================================= 393 // =============================================================================
394 void ConfigDialog::slot_moveColor () { 394 void ConfigDialog::slot_moveColor () {
395 const bool bUp = (static_cast<QPushButton*> (sender()) == qMoveColorUp); 395 const bool bUp = (static_cast<QPushButton*> (sender()) == pb_moveColorUp);
396 396
397 if (qQuickColorList->selectedItems().size() == 0) 397 if (lw_quickColors->selectedItems().size() == 0)
398 return; 398 return;
399 399
400 QListWidgetItem* qItem = qQuickColorList->selectedItems ()[0]; 400 QListWidgetItem* qItem = lw_quickColors->selectedItems ()[0];
401 ulong ulIdx = getItemRow (qItem, qaQuickColorItems); 401 ulong ulIdx = getItemRow (qItem, quickColorItems);
402 402
403 long lDest = bUp ? (ulIdx - 1) : (ulIdx + 1); 403 long lDest = bUp ? (ulIdx - 1) : (ulIdx + 1);
404 404
405 if (lDest < 0 || (ulong)lDest >= qaQuickColorItems.size ()) 405 if (lDest < 0 || (ulong)lDest >= quickColorItems.size ())
406 return; // destination out of bounds 406 return; // destination out of bounds
407 407
408 quickColorMetaEntry tmp = quickColorMeta[lDest]; 408 quickColorMetaEntry tmp = quickColorMeta[lDest];
409 quickColorMeta[lDest] = quickColorMeta[ulIdx]; 409 quickColorMeta[lDest] = quickColorMeta[ulIdx];
410 quickColorMeta[ulIdx] = tmp; 410 quickColorMeta[ulIdx] = tmp;
447 // ============================================================================= 447 // =============================================================================
448 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 448 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
449 // ============================================================================= 449 // =============================================================================
450 void ConfigDialog::slot_findLDrawPath () { 450 void ConfigDialog::slot_findLDrawPath () {
451 str zDir = QFileDialog::getExistingDirectory (this, "Choose LDraw directory", 451 str zDir = QFileDialog::getExistingDirectory (this, "Choose LDraw directory",
452 qLDrawPath->text()); 452 le_LDrawPath->text());
453 453
454 if (~zDir) 454 if (~zDir)
455 qLDrawPath->setText (zDir.chars()); 455 le_LDrawPath->setText (zDir.chars());
456 } 456 }
457 457
458 // ============================================================================= 458 // =============================================================================
459 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 459 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
460 // ============================================================================= 460 // =============================================================================
470 setButtonBackground (qButton, cfg.value); 470 setButtonBackground (qButton, cfg.value);
471 } 471 }
472 } 472 }
473 473
474 void ConfigDialog::slot_setGLBackground () { 474 void ConfigDialog::slot_setGLBackground () {
475 pickColor (gl_bgcolor, qGLBackgroundButton); 475 pickColor (gl_bgcolor, pb_viewBg);
476 } 476 }
477 477
478 void ConfigDialog::slot_setGLForeground () { 478 void ConfigDialog::slot_setGLForeground () {
479 pickColor (gl_maincolor, qGLForegroundButton); 479 pickColor (gl_maincolor, pb_viewFg);
480 } 480 }
481 481
482 // ============================================================================= 482 // =============================================================================
483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
484 // ============================================================================= 484 // =============================================================================
503 return -1; 503 return -1;
504 } 504 }
505 505
506 // ============================================================================= 506 // =============================================================================
507 QListWidgetItem* ConfigDialog::getSelectedQuickColor () { 507 QListWidgetItem* ConfigDialog::getSelectedQuickColor () {
508 if (qQuickColorList->selectedItems().size() == 0) 508 if (lw_quickColors->selectedItems().size() == 0)
509 return null; 509 return null;
510 510
511 return qQuickColorList->selectedItems ()[0]; 511 return lw_quickColors->selectedItems ()[0];
512 } 512 }
513 513
514 // ============================================================================= 514 // =============================================================================
515 void ConfigDialog::slot_setShortcut () { 515 void ConfigDialog::slot_setShortcut () {
516 QList<QListWidgetItem*> qaSel = qShortcutList->selectedItems (); 516 QList<QListWidgetItem*> qaSel = lw_shortcutList->selectedItems ();
517 517
518 if (qaSel.size() < 1) 518 if (qaSel.size() < 1)
519 return; 519 return;
520 520
521 QListWidgetItem* qItem = qaSel[0]; 521 QListWidgetItem* qItem = qaSel[0];
522 522
523 // Find the row this object is on. 523 // Find the row this object is on.
524 long idx = getItemRow (qItem, qaShortcutItems); 524 long idx = getItemRow (qItem, shortcutItems);
525 525
526 if (KeySequenceDialog::staticDialog (g_ActionMeta[idx], this)) 526 if (KeySequenceDialog::staticDialog (g_ActionMeta[idx], this))
527 setShortcutText (qItem, g_ActionMeta[idx]); 527 setShortcutText (qItem, g_ActionMeta[idx]);
528 } 528 }
529 529
530 // ============================================================================= 530 // =============================================================================
531 void ConfigDialog::slot_resetShortcut () { 531 void ConfigDialog::slot_resetShortcut () {
532 QList<QListWidgetItem*> qaSel = qShortcutList->selectedItems (); 532 QList<QListWidgetItem*> qaSel = lw_shortcutList->selectedItems ();
533 533
534 for (QListWidgetItem* qItem : qaSel) { 534 for (QListWidgetItem* qItem : qaSel) {
535 long idx = getItemRow (qItem, qaShortcutItems); 535 long idx = getItemRow (qItem, shortcutItems);
536 536
537 actionmeta meta = g_ActionMeta[idx]; 537 actionmeta meta = g_ActionMeta[idx];
538 keyseqconfig* conf = g_ActionMeta[idx].conf; 538 keyseqconfig* conf = g_ActionMeta[idx].conf;
539 539
540 conf->reset (); 540 conf->reset ();
544 } 544 }
545 } 545 }
546 546
547 // ============================================================================= 547 // =============================================================================
548 void ConfigDialog::slot_clearShortcut () { 548 void ConfigDialog::slot_clearShortcut () {
549 QList<QListWidgetItem*> qaSel = qShortcutList->selectedItems (); 549 QList<QListWidgetItem*> qaSel = lw_shortcutList->selectedItems ();
550 QKeySequence qDummySeq; 550 QKeySequence qDummySeq;
551 551
552 for (QListWidgetItem* qItem : qaSel) { 552 for (QListWidgetItem* qItem : qaSel) {
553 long idx = getItemRow (qItem, qaShortcutItems); 553 long idx = getItemRow (qItem, shortcutItems);
554 554
555 actionmeta meta = g_ActionMeta[idx]; 555 actionmeta meta = g_ActionMeta[idx];
556 keyseqconfig* conf = g_ActionMeta[idx].conf; 556 keyseqconfig* conf = g_ActionMeta[idx].conf;
557 conf->value = qDummySeq; 557 conf->value = qDummySeq;
558 558
596 // ============================================================================= 596 // =============================================================================
597 void ConfigDialog::staticDialog () { 597 void ConfigDialog::staticDialog () {
598 ConfigDialog dlg (g_ForgeWindow); 598 ConfigDialog dlg (g_ForgeWindow);
599 599
600 if (dlg.exec ()) { 600 if (dlg.exec ()) {
601 io_ldpath = dlg.qLDrawPath->text(); 601 io_ldpath = dlg.le_LDrawPath->text();
602 602
603 APPLY_CHECKBOX (dlg.qLVColorize, lv_colorize) 603 APPLY_CHECKBOX (dlg.cb_colorize, lv_colorize)
604 APPLY_CHECKBOX (dlg.qGLColorBFC, gl_colorbfc) 604 APPLY_CHECKBOX (dlg.cb_colorBFC, gl_colorbfc)
605 APPLY_CHECKBOX (dlg.qGLSelFlash, gl_selflash) 605 APPLY_CHECKBOX (dlg.cb_selFlash, gl_selflash)
606 606
607 gl_maincolor_alpha = ((double)dlg.qGLForegroundAlpha->value ()) / 10.0f; 607 gl_maincolor_alpha = ((double)dlg.sl_viewFgAlpha->value ()) / 10.0f;
608 gl_linethickness = dlg.qGLLineThickness->value (); 608 gl_linethickness = dlg.sl_lineThickness->value ();
609 gui_toolbar_iconsize = (dlg.qToolBarIconSize->value () * 4) + 12; 609 gui_toolbar_iconsize = (dlg.sl_iconSize->value () * 4) + 12;
610 610
611 // Manage the quick color toolbar 611 // Manage the quick color toolbar
612 g_ForgeWindow->quickColorMeta = dlg.quickColorMeta; 612 g_ForgeWindow->quickColorMeta = dlg.quickColorMeta;
613 gui_colortoolbar = dlg.makeColorToolBarString (); 613 gui_colortoolbar = dlg.makeColorToolBarString ();
614 614
615 // Set the grid settings 615 // Set the grid settings
616 for (int i = 0; i < g_NumGrids; ++i) 616 for (int i = 0; i < g_NumGrids; ++i)
617 for (int j = 0; j < 4; ++j) 617 for (int j = 0; j < 4; ++j)
618 g_GridInfo[i].confs[j]->value = dlg.gridData[i][j]->value (); 618 g_GridInfo[i].confs[j]->value = dlg.dsb_gridData[i][j]->value ();
619 619
620 // Save the config 620 // Save the config
621 config::save (); 621 config::save ();
622 622
623 // Reload all subfiles 623 // Reload all subfiles
637 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 637 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
638 // ========================================================================================================================= 638 // =========================================================================================================================
639 KeySequenceDialog::KeySequenceDialog (QKeySequence seq, QWidget* parent, 639 KeySequenceDialog::KeySequenceDialog (QKeySequence seq, QWidget* parent,
640 Qt::WindowFlags f) : QDialog (parent, f), seq (seq) 640 Qt::WindowFlags f) : QDialog (parent, f), seq (seq)
641 { 641 {
642 qOutput = new QLabel; 642 lb_output = new QLabel;
643 IMPLEMENT_DIALOG_BUTTONS 643 IMPLEMENT_DIALOG_BUTTONS
644 644
645 setWhatsThis ("Into this dialog you can input a key sequence for use as a " 645 setWhatsThis ("Into this dialog you can input a key sequence for use as a "
646 "shortcut in LDForge. Use OK to confirm the new shortcut and Cancel to " 646 "shortcut in LDForge. Use OK to confirm the new shortcut and Cancel to "
647 "dismiss."); 647 "dismiss.");
648 648
649 QVBoxLayout* layout = new QVBoxLayout; 649 QVBoxLayout* layout = new QVBoxLayout;
650 layout->addWidget (qOutput); 650 layout->addWidget (lb_output);
651 layout->addWidget (qButtons); 651 layout->addWidget (bbx_buttons);
652 setLayout (layout); 652 setLayout (layout);
653 653
654 updateOutput (); 654 updateOutput ();
655 } 655 }
656 656
674 void KeySequenceDialog::updateOutput () { 674 void KeySequenceDialog::updateOutput () {
675 str zShortcut = seq.toString (); 675 str zShortcut = seq.toString ();
676 676
677 str zText = format ("<center><b>%s</b></center>", zShortcut.chars ()); 677 str zText = format ("<center><b>%s</b></center>", zShortcut.chars ());
678 678
679 qOutput->setText (zText); 679 lb_output->setText (zText);
680 } 680 }
681 681
682 // ============================================================================= 682 // =============================================================================
683 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 683 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
684 // ============================================================================= 684 // =============================================================================

mercurial