247 } |
247 } |
248 } |
248 } |
249 |
249 |
250 // --------------------------------------------------------------------------------------------------------------------- |
250 // --------------------------------------------------------------------------------------------------------------------- |
251 // |
251 // |
252 QList<LDQuickColor> LoadQuickColorList() |
252 QList<ColorToolbarItem> LoadQuickColorList() |
253 { |
253 { |
254 QList<LDQuickColor> colors; |
254 QList<ColorToolbarItem> colors; |
255 |
255 |
256 for (QString colorname : g_win->configBag()->quickColorToolbar().split (":")) |
256 for (QString colorname : g_win->configBag()->quickColorToolbar().split (":")) |
257 { |
257 { |
258 if (colorname == "|") |
258 if (colorname == "|") |
259 colors << LDQuickColor::getSeparator(); |
259 colors << ColorToolbarItem::makeSeparator(); |
260 else |
260 else |
261 { |
261 { |
262 LDColor color = colorname.toInt(); |
262 LDColor color = colorname.toInt(); |
263 |
263 |
264 if (color.isValid()) |
264 if (color.isValid()) |
265 colors << LDQuickColor (color, nullptr); |
265 colors << ColorToolbarItem (color, nullptr); |
266 } |
266 } |
267 } |
267 } |
268 |
268 |
269 return colors; |
269 return colors; |
270 } |
270 } |
276 m_colorButtons.clear(); |
276 m_colorButtons.clear(); |
277 ui.toolBarColors->clear(); |
277 ui.toolBarColors->clear(); |
278 ui.toolBarColors->addAction (ui.actionUncolor); |
278 ui.toolBarColors->addAction (ui.actionUncolor); |
279 ui.toolBarColors->addSeparator(); |
279 ui.toolBarColors->addSeparator(); |
280 |
280 |
281 for (LDQuickColor& entry : m_quickColors) |
281 for (ColorToolbarItem& entry : m_quickColors) |
282 { |
282 { |
283 if (entry.isSeparator()) |
283 if (entry.isSeparator()) |
284 { |
284 { |
285 ui.toolBarColors->addSeparator(); |
285 ui.toolBarColors->addSeparator(); |
286 } |
286 } |
566 void MainWindow::quickColorClicked() |
566 void MainWindow::quickColorClicked() |
567 { |
567 { |
568 QToolButton* button = static_cast<QToolButton*> (sender()); |
568 QToolButton* button = static_cast<QToolButton*> (sender()); |
569 LDColor color = LDColor::nullColor(); |
569 LDColor color = LDColor::nullColor(); |
570 |
570 |
571 for (const LDQuickColor& entry : m_quickColors) |
571 for (const ColorToolbarItem& entry : m_quickColors) |
572 { |
572 { |
573 if (entry.toolButton() == button) |
573 if (entry.toolButton() == button) |
574 { |
574 { |
575 color = entry.color(); |
575 color = entry.color(); |
576 break; |
576 break; |
1058 return m_renderer; |
1058 return m_renderer; |
1059 } |
1059 } |
1060 |
1060 |
1061 // --------------------------------------------------------------------------------------------------------------------- |
1061 // --------------------------------------------------------------------------------------------------------------------- |
1062 // |
1062 // |
1063 void MainWindow::setQuickColors (const QList<LDQuickColor>& colors) |
1063 void MainWindow::setQuickColors (const QList<ColorToolbarItem>& colors) |
1064 { |
1064 { |
1065 m_quickColors = colors; |
1065 m_quickColors = colors; |
1066 updateColorToolbar(); |
1066 updateColorToolbar(); |
1067 } |
1067 } |
1068 |
1068 |
1069 // --------------------------------------------------------------------------------------------------------------------- |
1069 // --------------------------------------------------------------------------------------------------------------------- |
1070 // |
1070 // |
1071 void MainWindow::updatePrimitives() |
1071 void MainWindow::updatePrimitives() |
1072 { |
1072 { |
1073 PopulatePrimitives (ui.primitives); |
1073 populatePrimitivesTree (ui.primitives); |
1074 } |
1074 } |
1075 |
1075 |
1076 // --------------------------------------------------------------------------------------------------------------------- |
1076 // --------------------------------------------------------------------------------------------------------------------- |
1077 // |
1077 // |
1078 void MainWindow::closeTab (int tabindex) |
1078 void MainWindow::closeTab (int tabindex) |
1323 return m_guiUtilities; |
1323 return m_guiUtilities; |
1324 } |
1324 } |
1325 |
1325 |
1326 // --------------------------------------------------------------------------------------------------------------------- |
1326 // --------------------------------------------------------------------------------------------------------------------- |
1327 // |
1327 // |
1328 LDQuickColor::LDQuickColor (LDColor color, QToolButton* toolButton) : |
1328 ColorToolbarItem::ColorToolbarItem (LDColor color, QToolButton* toolButton) : |
1329 m_color (color), |
1329 m_color (color), |
1330 m_toolButton (toolButton) {} |
1330 m_toolButton (toolButton) {} |
1331 |
1331 |
1332 // --------------------------------------------------------------------------------------------------------------------- |
1332 ColorToolbarItem ColorToolbarItem::makeSeparator() |
1333 // |
1333 { |
1334 LDQuickColor LDQuickColor::getSeparator() |
1334 return ColorToolbarItem (LDColor::nullColor(), nullptr); |
1335 { |
1335 } |
1336 return LDQuickColor (LDColor::nullColor(), nullptr); |
1336 |
1337 } |
1337 bool ColorToolbarItem::isSeparator() const |
1338 |
|
1339 // --------------------------------------------------------------------------------------------------------------------- |
|
1340 // |
|
1341 bool LDQuickColor::isSeparator() const |
|
1342 { |
1338 { |
1343 return color() == LDColor::nullColor(); |
1339 return color() == LDColor::nullColor(); |
1344 } |
1340 } |
1345 |
1341 |
1346 // --------------------------------------------------------------------------------------------------------------------- |
1342 LDColor ColorToolbarItem::color() const |
1347 // |
1343 { |
1348 void PopulatePrimitives (QTreeWidget* tw, QString const& selectByDefault) |
1344 return m_color; |
|
1345 } |
|
1346 |
|
1347 void ColorToolbarItem::setColor (LDColor color) |
|
1348 { |
|
1349 m_color = color; |
|
1350 } |
|
1351 |
|
1352 QToolButton* ColorToolbarItem::toolButton() const |
|
1353 { |
|
1354 return m_toolButton; |
|
1355 } |
|
1356 |
|
1357 void ColorToolbarItem::setToolButton (QToolButton* value) |
|
1358 { |
|
1359 m_toolButton = value; |
|
1360 } |
|
1361 |
|
1362 // --------------------------------------------------------------------------------------------------------------------- |
|
1363 // |
|
1364 void populatePrimitivesTree (QTreeWidget* tw, QString const& selectByDefault) |
1349 { |
1365 { |
1350 tw->clear(); |
1366 tw->clear(); |
1351 |
1367 |
1352 for (PrimitiveCategory* cat : g_PrimitiveCategories) |
1368 for (PrimitiveCategory* cat : g_PrimitiveCategories) |
1353 { |
1369 { |
1354 SubfileListItem* parentItem = new SubfileListItem (tw, nullptr); |
1370 PrimitiveTreeItem* parentItem = new PrimitiveTreeItem (tw, nullptr); |
1355 parentItem->setText (0, cat->name()); |
1371 parentItem->setText (0, cat->name()); |
1356 QList<QTreeWidgetItem*> subfileItems; |
1372 QList<QTreeWidgetItem*> subfileItems; |
1357 |
1373 |
1358 for (Primitive& prim : cat->prims) |
1374 for (Primitive& prim : cat->prims) |
1359 { |
1375 { |
1360 SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
1376 PrimitiveTreeItem* item = new PrimitiveTreeItem (parentItem, &prim); |
1361 item->setText (0, format ("%1 - %2", prim.name, prim.title)); |
1377 item->setText (0, format ("%1 - %2", prim.name, prim.title)); |
1362 subfileItems << item; |
1378 subfileItems << item; |
1363 |
1379 |
1364 // If this primitive is the one the current object points to, |
1380 // If this primitive is the one the current object points to, |
1365 // select it by default |
1381 // select it by default |