| 137 } |
135 } |
| 138 |
136 |
| 139 // ============================================================================= |
137 // ============================================================================= |
| 140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 141 // ============================================================================= |
139 // ============================================================================= |
| 142 void ConfigDialog::initQuickColorTab() |
140 void ConfigDialog::initQuickColorTab() { |
| 143 { |
141 quickColors = quickColorsFromConfig(); |
| 144 quickColorMeta = parseQuickColorMeta(); |
|
| 145 updateQuickColorList(); |
142 updateQuickColorList(); |
| 146 |
143 |
| 147 connect( ui->quickColor_add, SIGNAL( clicked() ), this, SLOT( slot_setColor() )); |
144 connect (ui->quickColor_add, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
| 148 connect( ui->quickColor_remove, SIGNAL( clicked() ), this, SLOT( slot_delColor() )); |
145 connect (ui->quickColor_remove, SIGNAL (clicked()), this, SLOT (slot_delColor())); |
| 149 connect( ui->quickColor_edit, SIGNAL( clicked() ), this, SLOT( slot_setColor() )); |
146 connect (ui->quickColor_edit, SIGNAL (clicked()), this, SLOT (slot_setColor())); |
| 150 connect( ui->quickColor_addSep, SIGNAL( clicked() ), this, SLOT( slot_addColorSeparator() )); |
147 connect (ui->quickColor_addSep, SIGNAL (clicked()), this, SLOT (slot_addColorSeparator())); |
| 151 connect( ui->quickColor_moveUp, SIGNAL( clicked() ), this, SLOT( slot_moveColor() )); |
148 connect (ui->quickColor_moveUp, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
| 152 connect( ui->quickColor_moveDown, SIGNAL( clicked() ), this, SLOT( slot_moveColor() )); |
149 connect (ui->quickColor_moveDown, SIGNAL (clicked()), this, SLOT (slot_moveColor())); |
| 153 connect( ui->quickColor_clear, SIGNAL( clicked() ), this, SLOT( slot_clearColors() )); |
150 connect (ui->quickColor_clear, SIGNAL (clicked()), this, SLOT (slot_clearColors())); |
| 154 } |
151 } |
| 155 |
152 |
| 156 // ============================================================================= |
153 // ============================================================================= |
| 157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 158 // ============================================================================= |
155 // ============================================================================= |
| 159 void ConfigDialog::initGridTab() |
156 void ConfigDialog::initGridTab() { |
| 160 { |
|
| 161 QGridLayout* gridlayout = new QGridLayout; |
157 QGridLayout* gridlayout = new QGridLayout; |
| 162 |
158 QLabel* xlabel = new QLabel ("X"), |
| 163 QLabel* xlabel = new QLabel( "X" ), |
159 *ylabel = new QLabel ("Y"), |
| 164 *ylabel = new QLabel( "Y" ), |
160 *zlabel = new QLabel ("Z"), |
| 165 *zlabel = new QLabel( "Z" ), |
161 *anglabel = new QLabel ("Angle"); |
| 166 *anglabel = new QLabel( "Angle" ); |
|
| 167 |
|
| 168 short i = 1; |
162 short i = 1; |
| 169 |
163 |
| 170 for( QLabel* label : initlist<QLabel*> ({ xlabel, ylabel, zlabel, anglabel })) |
164 for (QLabel * label : initlist<QLabel*> ( { xlabel, ylabel, zlabel, anglabel })) { |
| 171 { |
165 label->setAlignment (Qt::AlignCenter); |
| 172 label->setAlignment( Qt::AlignCenter ); |
166 gridlayout->addWidget (label, 0, i++); |
| 173 gridlayout->addWidget( label, 0, i++ ); |
167 } |
| 174 } |
168 |
| 175 |
169 for (int i = 0; i < g_NumGrids; ++i) { |
| 176 for( int i = 0; i < g_NumGrids; ++i ) |
|
| 177 { |
|
| 178 // Icon |
170 // Icon |
| 179 lb_gridIcons[i] = new QLabel; |
171 lb_gridIcons[i] = new QLabel; |
| 180 lb_gridIcons[i]->setPixmap( getIcon( fmt( "grid-%1", str( g_GridInfo[i].name ).toLower() ))); |
172 lb_gridIcons[i]->setPixmap (getIcon (fmt ("grid-%1", str (g_GridInfo[i].name).toLower()))); |
| 181 |
173 |
| 182 // Text label |
174 // Text label |
| 183 lb_gridLabels[i] = new QLabel( fmt( "%1:", g_GridInfo[i].name )); |
175 lb_gridLabels[i] = new QLabel (fmt ("%1:", g_GridInfo[i].name)); |
| 184 |
176 |
| 185 QHBoxLayout* labellayout = new QHBoxLayout; |
177 QHBoxLayout* labellayout = new QHBoxLayout; |
| 186 labellayout->addWidget( lb_gridIcons[i] ); |
178 labellayout->addWidget (lb_gridIcons[i]); |
| 187 labellayout->addWidget( lb_gridLabels[i] ); |
179 labellayout->addWidget (lb_gridLabels[i]); |
| 188 gridlayout->addLayout( labellayout, i + 1, 0 ); |
180 gridlayout->addLayout (labellayout, i + 1, 0); |
| 189 |
181 |
| 190 // Add the widgets |
182 // Add the widgets |
| 191 for( int j = 0; j < 4; ++j ) |
183 for (int j = 0; j < 4; ++j) { |
| 192 { |
|
| 193 dsb_gridData[i][j] = new QDoubleSpinBox; |
184 dsb_gridData[i][j] = new QDoubleSpinBox; |
| 194 dsb_gridData[i][j]->setValue( g_GridInfo[i].confs[j]->value ); |
185 dsb_gridData[i][j]->setValue (g_GridInfo[i].confs[j]->value); |
| 195 gridlayout->addWidget( dsb_gridData[i][j], i + 1, j + 1 ); |
186 gridlayout->addWidget (dsb_gridData[i][j], i + 1, j + 1); |
| 196 } |
187 } |
| 197 } |
188 } |
| 198 |
189 |
| 199 ui->grids->setLayout( gridlayout ); |
190 ui->grids->setLayout (gridlayout); |
| 200 } |
191 } |
| 201 |
192 |
| 202 // ============================================================================= |
193 // ============================================================================= |
| 203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 204 // ============================================================================= |
195 // ============================================================================= |
| 205 extern_cfg( str, prog_ytruder ); |
196 extern_cfg (str, prog_ytruder); |
| 206 extern_cfg( str, prog_rectifier ); |
197 extern_cfg (str, prog_rectifier); |
| 207 extern_cfg( str, prog_intersector ); |
198 extern_cfg (str, prog_intersector); |
| 208 extern_cfg( str, prog_coverer ); |
199 extern_cfg (str, prog_coverer); |
| 209 extern_cfg( str, prog_isecalc ); |
200 extern_cfg (str, prog_isecalc); |
| 210 extern_cfg( str, prog_edger2 ); |
201 extern_cfg (str, prog_edger2); |
| 211 extern_cfg( bool, prog_ytruder_wine ); |
202 extern_cfg (bool, prog_ytruder_wine); |
| 212 extern_cfg( bool, prog_rectifier_wine ); |
203 extern_cfg (bool, prog_rectifier_wine); |
| 213 extern_cfg( bool, prog_intersector_wine ); |
204 extern_cfg (bool, prog_intersector_wine); |
| 214 extern_cfg( bool, prog_coverer_wine ); |
205 extern_cfg (bool, prog_coverer_wine); |
| 215 extern_cfg( bool, prog_isecalc_wine ); |
206 extern_cfg (bool, prog_isecalc_wine); |
| 216 extern_cfg( bool, prog_edger2_wine ); |
207 extern_cfg (bool, prog_edger2_wine); |
| 217 |
208 |
| 218 static const struct extProgInfo |
209 static const struct extProgInfo { |
| 219 { |
|
| 220 const str name, iconname; |
210 const str name, iconname; |
| 221 strconfig* const path; |
211 strconfig* const path; |
| 222 mutable QLineEdit* input; |
212 mutable QLineEdit* input; |
| 223 mutable QPushButton* setPathButton; |
213 mutable QPushButton* setPathButton; |
| 224 #ifndef _WIN32 |
214 #ifndef _WIN32 |
| 225 boolconfig* const wine; |
215 boolconfig* const wine; |
| 226 mutable QCheckBox* wineBox; |
216 mutable QCheckBox* wineBox; |
| 227 #endif // _WIN32 |
217 #endif // _WIN32 |
| 228 } g_extProgInfo[] = { |
218 } g_extProgInfo[] = { |
| 229 #ifndef _WIN32 |
219 #ifndef _WIN32 |
| 230 # define EXTPROG( NAME, LOWNAME ) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null }, |
220 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null }, |
| 231 #else |
221 #else |
| 232 # define EXTPROG( NAME, LOWNAME ) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null }, |
222 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null }, |
| 233 #endif |
223 #endif |
| 234 EXTPROG( Ytruder, ytruder ) |
224 EXTPROG (Ytruder, ytruder) |
| 235 EXTPROG( Rectifier, rectifier ) |
225 EXTPROG (Rectifier, rectifier) |
| 236 EXTPROG( Intersector, intersector ) |
226 EXTPROG (Intersector, intersector) |
| 237 EXTPROG( Isecalc, isecalc ) |
227 EXTPROG (Isecalc, isecalc) |
| 238 EXTPROG( Coverer, coverer ) |
228 EXTPROG (Coverer, coverer) |
| 239 EXTPROG( Edger2, edger2 ) |
229 EXTPROG (Edger2, edger2) |
| 240 #undef EXTPROG |
230 #undef EXTPROG |
| 241 }; |
231 }; |
| 242 |
232 |
| 243 void ConfigDialog::initExtProgTab() |
233 void ConfigDialog::initExtProgTab() { |
| 244 { |
|
| 245 QGridLayout* pathsLayout = new QGridLayout; |
234 QGridLayout* pathsLayout = new QGridLayout; |
| 246 ulong row = 0; |
235 ulong row = 0; |
| 247 |
236 |
| 248 for( const extProgInfo & info : g_extProgInfo ) |
237 for (const extProgInfo & info : g_extProgInfo) { |
| 249 { |
|
| 250 QLabel* icon = new QLabel, |
238 QLabel* icon = new QLabel, |
| 251 *progLabel = new QLabel( info.name ); |
239 *progLabel = new QLabel (info.name); |
| 252 QLineEdit* input = new QLineEdit; |
240 QLineEdit* input = new QLineEdit; |
| 253 QPushButton* setPathButton = new QPushButton; |
241 QPushButton* setPathButton = new QPushButton; |
| 254 |
242 |
| 255 icon->setPixmap( getIcon( info.iconname )); |
243 icon->setPixmap (getIcon (info.iconname)); |
| 256 input->setText( info.path->value ); |
244 input->setText (info.path->value); |
| 257 setPathButton->setIcon( getIcon( "folder" )); |
245 setPathButton->setIcon (getIcon ("folder")); |
| 258 info.input = input; |
246 info.input = input; |
| 259 info.setPathButton = setPathButton; |
247 info.setPathButton = setPathButton; |
| 260 |
248 |
| 261 connect( setPathButton, SIGNAL( clicked() ), this, SLOT( slot_setExtProgPath() )); |
249 connect (setPathButton, SIGNAL (clicked()), this, SLOT (slot_setExtProgPath())); |
| 262 |
250 |
| 263 pathsLayout->addWidget( icon, row, 0 ); |
251 pathsLayout->addWidget (icon, row, 0); |
| 264 pathsLayout->addWidget( progLabel, row, 1 ); |
252 pathsLayout->addWidget (progLabel, row, 1); |
| 265 pathsLayout->addWidget( input, row, 2 ); |
253 pathsLayout->addWidget (input, row, 2); |
| 266 pathsLayout->addWidget( setPathButton, row, 3 ); |
254 pathsLayout->addWidget (setPathButton, row, 3); |
| 267 |
255 |
| 268 #ifndef _WIN32 |
256 #ifndef _WIN32 |
| 269 QCheckBox* wineBox = new QCheckBox( "Wine" ); |
257 QCheckBox* wineBox = new QCheckBox ("Wine"); |
| 270 wineBox->setChecked( *info.wine ); |
258 wineBox->setChecked (*info.wine); |
| 271 info.wineBox = wineBox; |
259 info.wineBox = wineBox; |
| 272 pathsLayout->addWidget( wineBox, row, 4 ); |
260 pathsLayout->addWidget (wineBox, row, 4); |
| 273 #endif |
261 #endif |
| 274 |
262 |
| 275 ++row; |
263 ++row; |
| 276 } |
264 } |
| 277 |
265 |
| 278 ui->extProgs->setLayout( pathsLayout ); |
266 ui->extProgs->setLayout (pathsLayout); |
| 279 } |
267 } |
| 280 |
268 |
| 281 // ============================================================================= |
269 // ============================================================================= |
| 282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 283 // ============================================================================= |
271 // ============================================================================= |
| 284 void ConfigDialog::updateQuickColorList( quickColor* sel ) |
272 void ConfigDialog::updateQuickColorList( LDQuickColor* sel ) { |
| 285 { |
273 for (QListWidgetItem* item : quickColorItems) |
| 286 for( QListWidgetItem* item : quickColorItems ) |
|
| 287 delete item; |
274 delete item; |
| 288 |
275 |
| 289 quickColorItems.clear(); |
276 quickColorItems.clear(); |
| 290 |
277 |
| 291 // Init table items |
278 // Init table items |
| 292 for( quickColor& entry : quickColorMeta ) |
279 for (LDQuickColor& entry : quickColors) { |
| 293 { |
|
| 294 QListWidgetItem* item = new QListWidgetItem; |
280 QListWidgetItem* item = new QListWidgetItem; |
| 295 |
281 |
| 296 if( entry.isSeparator ) |
282 if (entry.isSeparator) { |
| 297 { |
283 item->setText ("--------"); |
| 298 item->setText( "--------" ); |
284 item->setIcon (getIcon ("empty")); |
| 299 item->setIcon( getIcon( "empty" )); |
285 } else { |
| 300 } |
|
| 301 else |
|
| 302 { |
|
| 303 LDColor* col = entry.col; |
286 LDColor* col = entry.col; |
| 304 |
287 |
| 305 if( col == null ) |
288 if (col == null) { |
| 306 { |
289 item->setText ("[[unknown color]]"); |
| 307 item->setText( "[[unknown color]]" ); |
290 item->setIcon (getIcon ("error")); |
| 308 item->setIcon( getIcon( "error" )); |
291 } else { |
| 309 } |
292 item->setText (col->name); |
| 310 else |
293 item->setIcon (makeColorIcon (col, 16)); |
| 311 { |
|
| 312 item->setText( col->name ); |
|
| 313 item->setIcon( makeColorIcon( col, 16 )); |
|
| 314 } |
294 } |
| 315 } |
295 } |
| 316 |
296 |
| 317 ui->quickColorList->addItem( item ); |
297 ui->quickColorList->addItem (item); |
| 318 quickColorItems << item; |
298 quickColorItems << item; |
| 319 |
299 |
| 320 if( sel && &entry == sel ) |
300 if (sel && &entry == sel) { |
| 321 { |
301 ui->quickColorList->setCurrentItem (item); |
| 322 ui->quickColorList->setCurrentItem( item ); |
302 ui->quickColorList->scrollToItem (item); |
| 323 ui->quickColorList->scrollToItem( item ); |
|
| 324 } |
303 } |
| 325 } |
304 } |
| 326 } |
305 } |
| 327 |
306 |
| 328 // ============================================================================= |
307 // ============================================================================= |
| 329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 330 // ============================================================================= |
309 // ============================================================================= |
| 331 void ConfigDialog::slot_setColor() |
310 void ConfigDialog::slot_setColor() { |
| 332 { |
311 LDQuickColor* entry = null; |
| 333 quickColor* entry = null; |
|
| 334 QListWidgetItem* item = null; |
312 QListWidgetItem* item = null; |
| 335 const bool isNew = static_cast<QPushButton*>( sender() ) == ui->quickColor_add; |
313 const bool isNew = static_cast<QPushButton*> (sender()) == ui->quickColor_add; |
| 336 |
314 |
| 337 if( isNew == false ) |
315 if (isNew == false) { |
| 338 { |
|
| 339 item = getSelectedQuickColor(); |
316 item = getSelectedQuickColor(); |
| 340 |
317 |
| 341 if( !item ) |
318 if (!item) |
| 342 return; |
319 return; |
| 343 |
320 |
| 344 ulong i = getItemRow( item, quickColorItems ); |
321 ulong i = getItemRow (item, quickColorItems); |
| 345 entry = &quickColorMeta[i]; |
322 entry = &quickColors[i]; |
| 346 |
323 |
| 347 if( entry->isSeparator == true ) |
324 if (entry->isSeparator == true) |
| 348 return; // don't color separators |
325 return; // don't color separators |
| 349 } |
326 } |
| 350 |
327 |
| 351 short defval = entry ? entry->col->index : -1; |
328 short defval = entry ? entry->col->index : -1; |
| 352 short val; |
329 short val; |
| 353 |
330 |
| 354 if( ColorSelector::getColor( val, defval, this ) == false ) |
331 if (ColorSelector::getColor (val, defval, this) == false) |
| 355 return; |
332 return; |
| 356 |
333 |
| 357 if( entry ) |
334 if (entry) |
| 358 entry->col = getColor( val ); |
335 entry->col = getColor (val); |
| 359 else |
336 else { |
| 360 { |
337 LDQuickColor entry = {getColor (val), null, false}; |
| 361 quickColor entry = {getColor( val ), null, false}; |
|
| 362 |
338 |
| 363 item = getSelectedQuickColor(); |
339 item = getSelectedQuickColor(); |
| 364 ulong idx; |
340 ulong idx; |
| 365 |
341 |
| 366 if( item ) |
342 if (item) |
| 367 idx = getItemRow( item, quickColorItems ) + 1; |
343 idx = getItemRow (item, quickColorItems) + 1; |
| 368 else |
344 else |
| 369 idx = quickColorItems.size(); |
345 idx = quickColorItems.size(); |
| 370 |
346 |
| 371 quickColorMeta.insert( idx, entry ); |
347 quickColors.insert (idx, entry); |
| 372 entry = quickColorMeta[idx]; |
348 entry = quickColors[idx]; |
| 373 } |
349 } |
| 374 |
350 |
| 375 updateQuickColorList( entry ); |
351 updateQuickColorList (entry); |
| 376 } |
352 } |
| 377 |
353 |
| 378 // ============================================================================= |
354 // ============================================================================= |
| 379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 380 // ============================================================================= |
356 // ============================================================================= |
| 381 void ConfigDialog::slot_delColor() |
357 void ConfigDialog::slot_delColor() { |
| 382 { |
358 if (ui->quickColorList->selectedItems().size() == 0) |
| 383 if( ui->quickColorList->selectedItems().size() == 0 ) |
|
| 384 return; |
359 return; |
| 385 |
360 |
| 386 QListWidgetItem* item = ui->quickColorList->selectedItems()[0]; |
361 QListWidgetItem* item = ui->quickColorList->selectedItems() [0]; |
| 387 quickColorMeta.erase( getItemRow( item, quickColorItems )); |
362 quickColors.erase (getItemRow (item, quickColorItems)); |
| 388 updateQuickColorList(); |
363 updateQuickColorList(); |
| 389 } |
364 } |
| 390 |
365 |
| 391 // ============================================================================= |
366 // ============================================================================= |
| 392 void ConfigDialog::slot_moveColor() |
367 void ConfigDialog::slot_moveColor() { |
| 393 { |
368 const bool up = (static_cast<QPushButton*> (sender()) == ui->quickColor_moveUp); |
| 394 const bool up = ( static_cast<QPushButton*>( sender() ) == ui->quickColor_moveUp ); |
369 |
| 395 |
370 if (ui->quickColorList->selectedItems().size() == 0) |
| 396 if( ui->quickColorList->selectedItems().size() == 0 ) |
|
| 397 return; |
371 return; |
| 398 |
372 |
| 399 QListWidgetItem* item = ui->quickColorList->selectedItems()[0]; |
373 QListWidgetItem* item = ui->quickColorList->selectedItems() [0]; |
| 400 int idx = getItemRow( item, quickColorItems ); |
374 int idx = getItemRow (item, quickColorItems); |
| 401 int dest = up ? ( idx - 1 ) : ( idx + 1 ); |
375 int dest = up ? (idx - 1) : (idx + 1); |
| 402 |
376 |
| 403 if( dest < 0 || ( ulong ) dest >= quickColorItems.size() ) |
377 if (dest < 0 || (ulong) dest >= quickColorItems.size()) |
| 404 return; // destination out of bounds |
378 return; // destination out of bounds |
| 405 |
379 |
| 406 quickColor tmp = quickColorMeta[dest]; |
380 LDQuickColor tmp = quickColors[dest]; |
| 407 quickColorMeta[dest] = quickColorMeta[idx]; |
381 quickColors[dest] = quickColors[idx]; |
| 408 quickColorMeta[idx] = tmp; |
382 quickColors[idx] = tmp; |
| 409 |
383 |
| 410 updateQuickColorList( &quickColorMeta[dest] ); |
384 updateQuickColorList (&quickColors[dest]); |
| 411 } |
385 } |
| 412 |
386 |
| 413 // ============================================================================= |
387 // ============================================================================= |
| 414 void ConfigDialog::slot_addColorSeparator() |
388 void ConfigDialog::slot_addColorSeparator() { |
| 415 { |
389 quickColors << LDQuickColor ({null, null, true}); |
| 416 quickColorMeta << quickColor({ null, null, true }); |
390 updateQuickColorList (&quickColors[quickColors.size() - 1]); |
| 417 updateQuickColorList( &quickColorMeta[quickColorMeta.size() - 1] ); |
391 } |
| 418 } |
392 |
| 419 |
393 // ============================================================================= |
| 420 // ============================================================================= |
394 void ConfigDialog::slot_clearColors() { |
| 421 void ConfigDialog::slot_clearColors() |
395 quickColors.clear(); |
| 422 { |
|
| 423 quickColorMeta.clear(); |
|
| 424 updateQuickColorList(); |
396 updateQuickColorList(); |
| 425 } |
397 } |
| 426 |
398 |
| 427 // ============================================================================= |
399 // ============================================================================= |
| 428 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
400 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 429 // ============================================================================= |
401 // ============================================================================= |
| 430 void ConfigDialog::pickColor( strconfig& conf, QPushButton* button ) |
402 void ConfigDialog::pickColor (strconfig& conf, QPushButton* button) { |
| 431 { |
403 QColor col = QColorDialog::getColor (QColor (conf)); |
| 432 QColor col = QColorDialog::getColor( QColor( conf )); |
404 |
| 433 |
405 if (col.isValid()) { |
| 434 if( col.isValid() ) |
|
| 435 { |
|
| 436 uchar r = col.red(), |
406 uchar r = col.red(), |
| 437 g = col.green(), |
407 g = col.green(), |
| 438 b = col.blue(); |
408 b = col.blue(); |
| 439 conf.value.sprintf( "#%.2X%.2X%.2X", r, g, b ); |
409 conf.value.sprintf ("#%.2X%.2X%.2X", r, g, b); |
| 440 setButtonBackground( button, conf.value ); |
410 setButtonBackground (button, conf.value); |
| 441 } |
411 } |
| 442 } |
412 } |
| 443 |
413 |
| 444 void ConfigDialog::slot_setGLBackground() |
414 void ConfigDialog::slot_setGLBackground() { |
| 445 { |
415 pickColor (gl_bgcolor, ui->backgroundColorButton); |
| 446 pickColor( gl_bgcolor, ui->backgroundColorButton ); |
416 } |
| 447 } |
417 |
| 448 |
418 void ConfigDialog::slot_setGLForeground() { |
| 449 void ConfigDialog::slot_setGLForeground() |
419 pickColor (gl_maincolor, ui->mainColorButton); |
| 450 { |
420 } |
| 451 pickColor( gl_maincolor, ui->mainColorButton ); |
421 |
| 452 } |
422 // ============================================================================= |
| 453 |
423 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 454 // ============================================================================= |
424 // ============================================================================= |
| 455 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
425 void ConfigDialog::setButtonBackground (QPushButton* button, str value) { |
| 456 // ============================================================================= |
426 button->setIcon (getIcon ("colorselect")); |
| 457 void ConfigDialog::setButtonBackground( QPushButton* button, str value ) |
427 button->setAutoFillBackground (true); |
| 458 { |
428 button->setStyleSheet (fmt ("background-color: %1", value)); |
| 459 button->setIcon( getIcon( "colorselect" )); |
429 } |
| 460 button->setAutoFillBackground( true ); |
430 |
| 461 button->setStyleSheet( fmt( "background-color: %1", value )); |
431 // ============================================================================= |
| 462 } |
432 int ConfigDialog::getItemRow (QListWidgetItem* item, vector<QListWidgetItem*>& haystack) { |
| 463 |
|
| 464 // ============================================================================= |
|
| 465 int ConfigDialog::getItemRow( QListWidgetItem* item, vector<QListWidgetItem*>& haystack ) |
|
| 466 { |
|
| 467 int i = 0; |
433 int i = 0; |
| 468 |
434 |
| 469 for( QListWidgetItem * it : haystack ) |
435 for (QListWidgetItem* it : haystack) { |
| 470 { |
436 if (it == item) |
| 471 if( it == item ) |
|
| 472 return i; |
437 return i; |
| 473 |
438 |
| 474 ++i; |
439 ++i; |
| 475 } |
440 } |
| 476 |
|
| 477 return -1; |
441 return -1; |
| 478 } |
442 } |
| 479 |
443 |
| 480 // ============================================================================= |
444 // ============================================================================= |
| 481 QListWidgetItem* ConfigDialog::getSelectedQuickColor() |
445 QListWidgetItem* ConfigDialog::getSelectedQuickColor() { |
| 482 { |
446 if (ui->quickColorList->selectedItems().size() == 0) |
| 483 if( ui->quickColorList->selectedItems().size() == 0 ) |
|
| 484 return null; |
447 return null; |
| 485 |
448 |
| 486 return ui->quickColorList->selectedItems()[0]; |
449 return ui->quickColorList->selectedItems() [0]; |
| 487 } |
450 } |
| 488 |
451 |
| 489 // ============================================================================= |
452 // ============================================================================= |
| 490 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() |
453 QList<ShortcutListItem*> ConfigDialog::getShortcutSelection() |
| 491 { |
454 { |
| 548 str filter; |
511 str filter; |
| 549 #ifdef _WIN32 |
512 #ifdef _WIN32 |
| 550 filter = "Applications (*.exe)(*.exe);;All files (*.*)(*.*)"; |
513 filter = "Applications (*.exe)(*.exe);;All files (*.*)(*.*)"; |
| 551 #endif // WIN32 |
514 #endif // WIN32 |
| 552 |
515 |
| 553 str fpath = QFileDialog::getOpenFileName( this, fmt( "Path to %1", info->name ), *info->path, filter ); |
516 str fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), *info->path, filter); |
| 554 |
517 |
| 555 if( fpath.length() == 0 ) |
518 if (fpath.length() == 0) |
| 556 return; |
519 return; |
| 557 |
520 |
| 558 info->input->setText( fpath ); |
521 info->input->setText (fpath); |
| 559 } |
522 } |
| 560 |
523 |
| 561 // ============================================================================= |
524 // ============================================================================= |
| 562 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
525 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 563 // ============================================================================= |
526 // ============================================================================= |
| 564 void ConfigDialog::setShortcutText( ShortcutListItem* item ) { |
527 void ConfigDialog::setShortcutText (ShortcutListItem* item) { |
| 565 QAction* act = item->action(); |
528 QAction* act = item->action(); |
| 566 str label = act->iconText(); |
529 str label = act->iconText(); |
| 567 str keybind = item->keyConfig()->value.toString(); |
530 str keybind = item->keyConfig()->value.toString(); |
| 568 |
|
| 569 item->setText (fmt ("%1 (%2)", label, keybind)); |
531 item->setText (fmt ("%1 (%2)", label, keybind)); |
| 570 } |
532 } |
| 571 |
533 |
| 572 // ============================================================================= |
534 // ============================================================================= |
| 573 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
535 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 574 // ============================================================================= |
536 // ============================================================================= |
| 575 str ConfigDialog::makeColorToolBarString() |
537 str ConfigDialog::quickColorString() { |
| 576 { |
|
| 577 str val; |
538 str val; |
| 578 |
539 |
| 579 for( quickColor entry : quickColorMeta ) |
540 for (LDQuickColor entry : quickColors) { |
| 580 { |
541 if (val.length() > 0) |
| 581 if( val.length() > 0 ) |
|
| 582 val += ':'; |
542 val += ':'; |
| 583 |
543 |
| 584 if( entry.isSeparator ) |
544 if (entry.isSeparator) |
| 585 val += '|'; |
545 val += '|'; |
| 586 else |
546 else |
| 587 val += fmt( "%1", entry.col->index ); |
547 val += fmt ("%1", entry.col->index); |
| 588 } |
548 } |
| 589 |
549 |
| 590 return val; |
550 return val; |
| 591 } |
551 } |
| 592 |
552 |
| 593 const Ui_ConfigUI* ConfigDialog::getUI() const |
553 const Ui_ConfigUI* ConfigDialog::getUI() const { |
| 594 { |
|
| 595 return ui; |
554 return ui; |
| 596 } |
555 } |
| 597 |
556 |
| 598 float ConfigDialog::getGridValue( int i, int j ) const |
557 float ConfigDialog::getGridValue (int i, int j) const { |
| 599 { |
|
| 600 return dsb_gridData[i][j]->value(); |
558 return dsb_gridData[i][j]->value(); |
| 601 } |
559 } |
| 602 |
560 |
| 603 // ============================================================================= |
561 // ============================================================================= |
| 604 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
562 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 605 // ============================================================================= |
563 // ============================================================================= |
| 606 void ConfigDialog::staticDialog() |
564 void ConfigDialog::staticDialog() { |
| 607 { |
565 ConfigDialog dlg (g_win); |
| 608 ConfigDialog dlg( g_win ); |
566 |
| 609 |
567 if (dlg.exec()) { |
| 610 if( dlg.exec() ) |
|
| 611 { |
|
| 612 // Apply configuration |
568 // Apply configuration |
| 613 lv_colorize = dlg.getUI()->colorizeObjects->isChecked(); |
569 lv_colorize = dlg.getUI()->colorizeObjects->isChecked(); |
| 614 gl_colorbfc = dlg.getUI()->colorBFC->isChecked(); |
570 gl_colorbfc = dlg.getUI()->colorBFC->isChecked(); |
| 615 edit_schemanticinline = dlg.getUI()->scemanticInlining->isChecked(); |
571 edit_schemanticinline = dlg.getUI()->scemanticInlining->isChecked(); |
| 616 gl_blackedges = dlg.getUI()->blackEdges->isChecked(); |
572 gl_blackedges = dlg.getUI()->blackEdges->isChecked(); |
| 617 gl_maincolor_alpha = ( ( double )dlg.getUI()->mainColorAlpha->value() ) / 10.0f; |
573 gl_maincolor_alpha = ((double) dlg.getUI()->mainColorAlpha->value()) / 10.0f; |
| 618 gl_linethickness = dlg.getUI()->lineThickness->value(); |
574 gl_linethickness = dlg.getUI()->lineThickness->value(); |
| 619 gui_toolbar_iconsize = ( dlg.getUI()->iconSize->value() * 4 ) + 12; |
575 |
| 620 |
576 // Rebuild the quick color toolbar |
| 621 // Manage the quick color toolbar |
577 g_win->setQuickColors (dlg.quickColors); |
| 622 g_win->setQuickColorMeta( dlg.quickColorMeta ); |
578 gui_colortoolbar = dlg.quickColorString(); |
| 623 gui_colortoolbar = dlg.makeColorToolBarString(); |
|
| 624 |
579 |
| 625 // Set the grid settings |
580 // Set the grid settings |
| 626 for( int i = 0; i < g_NumGrids; ++i ) |
581 for (int i = 0; i < g_NumGrids; ++i) |
| 627 for( int j = 0; j < 4; ++j ) |
582 for (int j = 0; j < 4; ++j) |
| 628 g_GridInfo[i].confs[j]->value = dlg.getGridValue( i, j ); |
583 g_GridInfo[i].confs[j]->value = dlg.getGridValue (i, j); |
| 629 |
584 |
| 630 // Apply key shortcuts |
585 // Apply key shortcuts |
| 631 #define act(N) ACTION(N)->setShortcut (key_##N); |
586 #define act(N) ACTION(N)->setShortcut (key_##N); |
| 632 #include "actions.h" |
587 #include "actions.h" |
| 633 |
588 |
| 634 // Ext program settings |
589 // Ext program settings |
| 635 for( const extProgInfo & info : g_extProgInfo ) |
590 for (const extProgInfo & info : g_extProgInfo) { |
| 636 { |
|
| 637 *info.path = info.input->text(); |
591 *info.path = info.input->text(); |
| 638 |
592 |
| 639 #ifndef _WIN32 |
593 #ifndef _WIN32 |
| 640 *info.wine = info.wineBox->isChecked(); |
594 *info.wine = info.wineBox->isChecked(); |
| 641 #endif // _WIN32 |
595 #endif // _WIN32 |
| 642 } |
596 } |
| 643 |
597 |
| 644 // Save the config |
|
| 645 config::save(); |
598 config::save(); |
| 646 |
|
| 647 // Reload all subfiles as the ldraw path potentially changed. |
|
| 648 reloadAllSubfiles(); |
599 reloadAllSubfiles(); |
| 649 |
|
| 650 g_win->R()->setBackground(); |
600 g_win->R()->setBackground(); |
| 651 g_win->fullRefresh(); |
601 g_win->fullRefresh(); |
| 652 g_win->updateToolBars(); |
602 g_win->updateToolBars(); |
| 653 } |
603 } |
| 654 } |
604 } |