| 66 |
66 |
| 67 vector<actionmeta> g_ActionMeta; |
67 vector<actionmeta> g_ActionMeta; |
| 68 |
68 |
| 69 cfg (bool, lv_colorize, true); |
69 cfg (bool, lv_colorize, true); |
| 70 cfg (int, gui_toolbar_iconsize, 24); |
70 cfg (int, gui_toolbar_iconsize, 24); |
| |
71 cfg (str, gui_colortoolbar, "16:24:|:0:1:2:3:4:5:6:7"); |
| 71 extern_cfg (str, io_recentfiles); |
72 extern_cfg (str, io_recentfiles); |
| 72 |
73 |
| 73 // ============================================================================= |
74 // ============================================================================= |
| 74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 75 // ============================================================================= |
76 // ============================================================================= |
| 94 layout->addWidget (R, 0, 0); |
95 layout->addWidget (R, 0, 0); |
| 95 layout->addWidget (qObjList, 0, 1); |
96 layout->addWidget (qObjList, 0, 1); |
| 96 layout->addWidget (qMessageLog, 1, 0, 1, 2); |
97 layout->addWidget (qMessageLog, 1, 0, 1, 2); |
| 97 w->setLayout (layout); |
98 w->setLayout (layout); |
| 98 setCentralWidget (w); |
99 setCentralWidget (w); |
| |
100 |
| |
101 quickColorMeta = parseQuickColorMeta (); |
| 99 |
102 |
| 100 createMenuActions (); |
103 createMenuActions (); |
| 101 createMenus (); |
104 createMenus (); |
| 102 createToolbars (); |
105 createToolbars (); |
| 103 |
106 |
| 267 initSingleToolBar ("Move"); |
270 initSingleToolBar ("Move"); |
| 268 ADD_TOOLBAR_ITEM (moveUp) |
271 ADD_TOOLBAR_ITEM (moveUp) |
| 269 ADD_TOOLBAR_ITEM (moveDown) |
272 ADD_TOOLBAR_ITEM (moveDown) |
| 270 |
273 |
| 271 // ========================================== |
274 // ========================================== |
| |
275 // Color toolbar |
| |
276 qColorToolBar = new QToolBar; |
| |
277 addToolBar (Qt::RightToolBarArea, qColorToolBar); |
| |
278 |
| |
279 // ========================================== |
| 272 // Left area toolbars |
280 // Left area toolbars |
| 273 g_ToolBarArea = Qt::LeftToolBarArea; |
281 g_ToolBarArea = Qt::LeftToolBarArea; |
| 274 initSingleToolBar ("Objects"); |
282 initSingleToolBar ("Objects"); |
| 275 ADD_TOOLBAR_ITEM (setColor) |
283 ADD_TOOLBAR_ITEM (setColor) |
| 276 ADD_TOOLBAR_ITEM (inlineContents) |
284 ADD_TOOLBAR_ITEM (inlineContents) |
| 280 ADD_TOOLBAR_ITEM (makeBorders) |
288 ADD_TOOLBAR_ITEM (makeBorders) |
| 281 |
289 |
| 282 updateToolBars (); |
290 updateToolBars (); |
| 283 } |
291 } |
| 284 |
292 |
| |
293 // ============================================================================= |
| |
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| |
295 // ============================================================================= |
| |
296 std::vector<quickColorMetaEntry> parseQuickColorMeta () { |
| |
297 std::vector<quickColorMetaEntry> meta; |
| |
298 |
| |
299 for (str zColor : gui_colortoolbar.value / ":") { |
| |
300 if (zColor == "|") { |
| |
301 meta.push_back ({nullptr, nullptr, true}); |
| |
302 } else { |
| |
303 color* col = getColor (atoi (zColor)); |
| |
304 meta.push_back ({col, nullptr, false}); |
| |
305 } |
| |
306 } |
| |
307 |
| |
308 return meta; |
| |
309 } |
| |
310 |
| |
311 // ============================================================================= |
| |
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| |
313 // ============================================================================= |
| 285 void ForgeWindow::updateToolBars () { |
314 void ForgeWindow::updateToolBars () { |
| 286 for (QToolBar* qBar : qaToolBars) { |
315 for (QToolBar* qBar : qaToolBars) |
| 287 qBar->setIconSize (QSize (gui_toolbar_iconsize, gui_toolbar_iconsize)); |
316 qBar->setIconSize (QSize (gui_toolbar_iconsize, gui_toolbar_iconsize)); |
| |
317 |
| |
318 // Update the quick color toolbar. |
| |
319 for (QPushButton* qButton : qaColorButtons) |
| |
320 delete qButton; |
| |
321 |
| |
322 qaColorButtons.clear (); |
| |
323 |
| |
324 // Clear the toolbar to remove separators |
| |
325 qColorToolBar->clear (); |
| |
326 |
| |
327 for (quickColorMetaEntry& entry : quickColorMeta) { |
| |
328 if (entry.bSeparator) |
| |
329 qColorToolBar->addSeparator (); |
| |
330 else { |
| |
331 QPushButton* qColorButton = new QPushButton; |
| |
332 qColorButton->setAutoFillBackground (true); |
| |
333 qColorButton->setStyleSheet (str::mkfmt ("background-color: %s", entry.col->zColorString.chars())); |
| |
334 qColorButton->setToolTip (entry.col->zName); |
| |
335 |
| |
336 connect (qColorButton, SIGNAL (clicked ()), this, SLOT (slot_quickColor ())); |
| |
337 qColorToolBar->addWidget (qColorButton); |
| |
338 qaColorButtons.push_back (qColorButton); |
| |
339 |
| |
340 entry.btn = qColorButton; |
| |
341 } |
| 288 } |
342 } |
| 289 } |
343 } |
| 290 |
344 |
| 291 // ============================================================================= |
345 // ============================================================================= |
| 292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
346 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 510 } |
564 } |
| 511 |
565 |
| 512 // ============================================================================= |
566 // ============================================================================= |
| 513 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
567 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 514 // ============================================================================= |
568 // ============================================================================= |
| |
569 void ForgeWindow::slot_quickColor () { |
| |
570 QPushButton* qBtn = static_cast<QPushButton*> (sender ()); |
| |
571 color* col = nullptr; |
| |
572 |
| |
573 for (quickColorMetaEntry entry : quickColorMeta) { |
| |
574 if (entry.btn == qBtn) { |
| |
575 col = entry.col; |
| |
576 break; |
| |
577 } |
| |
578 } |
| |
579 |
| |
580 if (col == nullptr) |
| |
581 return; |
| |
582 |
| |
583 std::vector<ulong> ulaIndices; |
| |
584 std::vector<short> daColors; |
| |
585 short dNewColor = col->index (); |
| |
586 |
| |
587 for (LDObject* obj : getSelectedObjects ()) { |
| |
588 if (obj->dColor == -1) |
| |
589 continue; // uncolored object |
| |
590 |
| |
591 ulaIndices.push_back (obj->getIndex (g_CurrentFile)); |
| |
592 daColors.push_back (obj->dColor); |
| |
593 |
| |
594 obj->dColor = dNewColor; |
| |
595 } |
| |
596 |
| |
597 History::addEntry (new SetColorHistory (ulaIndices, daColors, dNewColor)); |
| |
598 refresh (); |
| |
599 } |
| |
600 |
| |
601 // ============================================================================= |
| |
602 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| |
603 // ============================================================================= |
| 515 ulong ForgeWindow::getInsertionPoint () { |
604 ulong ForgeWindow::getInsertionPoint () { |
| 516 ulong ulIndex; |
605 ulong ulIndex; |
| 517 |
606 |
| 518 if (qObjList->selectedItems().size() == 1) { |
607 if (qObjList->selectedItems().size() == 1) { |
| 519 // If we have a selection, put the item after it. |
608 // If we have a selection, put the item after it. |
| 559 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
648 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 560 // ============================================================================= |
649 // ============================================================================= |
| 561 QIcon getIcon (const char* sIconName) { |
650 QIcon getIcon (const char* sIconName) { |
| 562 return (QIcon (str::mkfmt ("./icons/%s.png", sIconName))); |
651 return (QIcon (str::mkfmt ("./icons/%s.png", sIconName))); |
| 563 } |
652 } |
| |
653 |
| |
654 // ============================================================================= |
| |
655 bool confirm (str zMessage) { |
| |
656 return QMessageBox::question (g_ForgeWindow, "Confirm", zMessage, |
| |
657 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
| |
658 } |