Mon, 06 Mar 2017 00:35:47 +0200
GuiUtilities is now a namespace.
--- a/src/dialogs/colorselector.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/dialogs/colorselector.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -181,7 +181,7 @@ ui.colorLabel->setText(format("%1 - %2", newColor.indexString(), newColor.isDirect() ? newColor.faceColor().name() : newColor.name())); - ui.iconLabel->setPixmap(guiUtilities()->makeColorIcon(newColor, 16).pixmap(16, 16)); + ui.iconLabel->setPixmap(GuiUtilities::makeColorIcon(newColor, 16).pixmap(16, 16)); ui.transparentDirectColor->setEnabled(newColor.isDirect()); ui.transparentDirectColor->setChecked(newColor.isDirect() and newColor.faceColor().alphaF() < 1.0); }
--- a/src/dialogs/configdialog.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/dialogs/configdialog.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -127,7 +127,7 @@ ui.shortcutsList->setSortingEnabled (true); ui.shortcutsList->sortItems(); - quickColors = guiUtilities()->loadQuickColorList(); + quickColors = GuiUtilities::loadQuickColorList(); updateQuickColorList(); initExtProgs(); selectPage (defaulttab); @@ -354,7 +354,7 @@ if (color.isValid()) { item->setText (color.name()); - item->setIcon (guiUtilities()->makeColorIcon (color, 16)); + item->setIcon (GuiUtilities::makeColorIcon (color, 16)); } else {
--- a/src/glcompiler.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/glcompiler.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -156,7 +156,7 @@ if (polygonOwner->color() == MainColor) { // If that also is the main color, then we whatever the user has configured the main color to look like. - color = guiUtilities()->mainColorRepresentation(); + color = GuiUtilities::mainColorRepresentation(); } else { @@ -199,7 +199,7 @@ { // The color was unknown. Use main color to make the polygon at least not appear pitch-black. if (polygon.num != 2 and polygon.num != 5) - color = guiUtilities()->mainColorRepresentation(); + color = GuiUtilities::mainColorRepresentation(); else color = Qt::black;
--- a/src/guiutilities.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/guiutilities.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -23,10 +23,6 @@ #include "lddocument.h" #include "mainwindow.h" -GuiUtilities::GuiUtilities (QObject* parent) : - QObject (parent), - HierarchyElement (parent) {} - /* * makeColorIcon * @@ -63,11 +59,11 @@ * * Fills the provided combo box with the colors used in the current document. */ -void GuiUtilities::fillUsedColorsToComboBox (QComboBox* box) +void GuiUtilities::fillUsedColorsToComboBox(Model* model, QComboBox* box) { QMap<LDColor, int> frequencies; - for (LDObject* object : currentDocument()->objects()) + for (LDObject* object : model->objects()) { if (object->isColored() and object->color().isValid()) {
--- a/src/guiutilities.h Sun Mar 05 20:26:56 2017 +0200 +++ b/src/guiutilities.h Mon Mar 06 00:35:47 2017 +0200 @@ -26,14 +26,10 @@ * * Contains generic state-aware GUI functions. */ -class GuiUtilities : public QObject, public HierarchyElement +namespace GuiUtilities { - Q_OBJECT -public: - explicit GuiUtilities (QObject* parent); - - QIcon makeColorIcon (LDColor ldcolor, int size); - void fillUsedColorsToComboBox (class QComboBox* box); + QIcon makeColorIcon(LDColor ldcolor, int size); + void fillUsedColorsToComboBox(Model* model, class QComboBox* box); QColor mainColorRepresentation(); QVector<ColorToolbarItem> loadQuickColorList(); -}; +}
--- a/src/hierarchyelement.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/hierarchyelement.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -45,12 +45,6 @@ } -GuiUtilities* HierarchyElement::guiUtilities() const -{ - return m_window->guiUtilities(); -} - - LDDocument* HierarchyElement::currentDocument() { return m_window->currentDocument();
--- a/src/hierarchyelement.h Sun Mar 05 20:26:56 2017 +0200 +++ b/src/hierarchyelement.h Mon Mar 06 00:35:47 2017 +0200 @@ -23,7 +23,6 @@ #include "messageLog.h" #include "mainwindow.h" -class GuiUtilities; class LDDocument; class DocumentManager; class PrimitiveManager; @@ -42,7 +41,6 @@ const QSet<LDObject*>& selectedObjects(); LDDocument* currentDocument(); - GuiUtilities* guiUtilities() const; PrimitiveManager* primitives(); Grid* grid() const; MathFunctions* math() const;
--- a/src/mainwindow.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/mainwindow.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -50,8 +50,7 @@ // --------------------------------------------------------------------------------------------------------------------- // MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) : - QMainWindow (parent, flags), - m_guiUtilities (new GuiUtilities (this)), + QMainWindow (parent, flags), m_primitives(new PrimitiveManager(this)), m_grid(new Grid), m_mathFunctions(new MathFunctions(this)), @@ -83,7 +82,7 @@ else updatePrimitives(); - m_quickColors = m_guiUtilities->loadQuickColorList(); + m_quickColors = GuiUtilities::loadQuickColorList(); updateActions(); // Connect all actions and save default sequences @@ -168,7 +167,6 @@ MainWindow::~MainWindow() { - delete m_guiUtilities; delete m_primitives; delete m_grid; delete m_mathFunctions; @@ -246,11 +244,11 @@ else { QToolButton* colorButton = new QToolButton; - colorButton->setIcon (m_guiUtilities->makeColorIcon (entry.color(), 16)); - colorButton->setIconSize (QSize (16, 16)); - colorButton->setToolTip (entry.color().name()); + colorButton->setIcon(GuiUtilities::makeColorIcon(entry.color(), 16)); + colorButton->setIconSize({16, 16}); + colorButton->setToolTip(entry.color().name()); - connect (colorButton, SIGNAL (clicked()), this, SLOT (quickColorClicked())); + connect(colorButton, SIGNAL (clicked()), this, SLOT (quickColorClicked())); ui.toolBarColors->addWidget (colorButton); m_colorButtons << colorButton; @@ -1221,11 +1219,6 @@ return m_externalPrograms; } -GuiUtilities* MainWindow::guiUtilities() -{ - return m_guiUtilities; -} - Grid* MainWindow::grid() { return m_grid;
--- a/src/mainwindow.h Sun Mar 05 20:26:56 2017 +0200 +++ b/src/mainwindow.h Mon Mar 06 00:35:47 2017 +0200 @@ -87,7 +87,6 @@ LDColor getUniformSelectedColor(); Canvas* getRendererForDocument(LDDocument* document); Grid* grid(); - class GuiUtilities* guiUtilities(); void loadShortcuts(); MathFunctions* mathFunctions() const; MessageManager* messageLog() const; @@ -146,7 +145,6 @@ private: struct ToolInfo; - class GuiUtilities* m_guiUtilities; MessageManager* m_messageLog = nullptr; QMap<LDDocument*, Canvas*> m_renderers; PrimitiveManager* m_primitives;
--- a/src/toolsets/extprogramtoolset.cpp Sun Mar 05 20:26:56 2017 +0200 +++ b/src/toolsets/extprogramtoolset.cpp Mon Mar 06 00:35:47 2017 +0200 @@ -442,8 +442,8 @@ QDialog* dlg = new QDialog; Ui::IntersectorUI ui; ui.setupUi (dlg); - guiUtilities()->fillUsedColorsToComboBox (ui.cmb_incol); - guiUtilities()->fillUsedColorsToComboBox (ui.cmb_cutcol); + GuiUtilities::fillUsedColorsToComboBox(currentDocument(), ui.cmb_incol); + GuiUtilities::fillUsedColorsToComboBox(currentDocument(), ui.cmb_cutcol); ui.cb_repeat->setWhatsThis ("If this is set, " APPNAME " runs Intersector a second time with inverse files to cut " " the cutter group with the input group. Both groups are cut by the intersection."); ui.cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection."); @@ -530,8 +530,8 @@ QDialog* dlg = new QDialog; Ui::CovererUI ui; ui.setupUi (dlg); - guiUtilities()->fillUsedColorsToComboBox (ui.cmb_col1); - guiUtilities()->fillUsedColorsToComboBox (ui.cmb_col2); + GuiUtilities::fillUsedColorsToComboBox(currentDocument(), ui.cmb_col1); + GuiUtilities::fillUsedColorsToComboBox(currentDocument(), ui.cmb_col2); if (not dlg->exec()) return; @@ -581,8 +581,8 @@ QDialog* dlg = new QDialog; ui.setupUi (dlg); - guiUtilities()->fillUsedColorsToComboBox (ui.cmb_col1); - guiUtilities()->fillUsedColorsToComboBox (ui.cmb_col2); + GuiUtilities::fillUsedColorsToComboBox(currentDocument(), ui.cmb_col1); + GuiUtilities::fillUsedColorsToComboBox(currentDocument(), ui.cmb_col2); LDColor in1Col, in2Col;