Thu, 01 Mar 2018 11:59:54 +0200
refactor
src/dialogs/colorselector.cpp | file | annotate | diff | comparison | revisions | |
src/dialogs/configdialog.cpp | file | annotate | diff | comparison | revisions | |
src/guiutilities.cpp | file | annotate | diff | comparison | revisions | |
src/guiutilities.h | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions | |
src/main.h | file | annotate | diff | comparison | revisions | |
src/mainwindow.cpp | file | annotate | diff | comparison | revisions |
--- a/src/dialogs/colorselector.cpp Thu Feb 22 11:41:58 2018 +0200 +++ b/src/dialogs/colorselector.cpp Thu Mar 01 11:59:54 2018 +0200 @@ -61,8 +61,11 @@ QString edgeColor = luma(faceColor) < 80 ? "white" : "black"; button->setAutoFillBackground(true); - button->setStyleSheet(format("background-color: rgba(%1, %2, %3, %4); color: %5", - faceColor.red(), faceColor.green(), faceColor.blue(), faceColor.alpha(), edgeColor)); + button->setStyleSheet(format( + "background-color: #%1; color: %2;", + faceColor.name(QColor::HexArgb), + edgeColor + )); button->setCheckable(true); button->setText(QString::number(color.index())); button->setToolTip(format("%1: %2", color.index(), color.name())); @@ -181,7 +184,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(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 Thu Feb 22 11:41:58 2018 +0200 +++ b/src/dialogs/configdialog.cpp Thu Mar 01 11:59:54 2018 +0200 @@ -354,7 +354,7 @@ if (color.isValid()) { item->setText (color.name()); - item->setIcon (guiUtilities()->makeColorIcon (color, 16)); + item->setIcon (makeColorIcon (color, 16)); } else {
--- a/src/guiutilities.cpp Thu Feb 22 11:41:58 2018 +0200 +++ b/src/guiutilities.cpp Thu Mar 01 11:59:54 2018 +0200 @@ -32,30 +32,36 @@ * * Creates an icon to represent an LDraw color. */ -QIcon GuiUtilities::makeColorIcon (LDColor ldColor, int size) +QIcon makeColorIcon(LDColor color, int size) { QImage image {size, size, QImage::Format_ARGB32}; QPainter painter {&image}; - QColor color; + QColor truecolor; - if (ldColor == MainColor) + if (color == MainColor) { // Use the user preferences for the main color. - color = m_config->mainColor(); - color.setAlphaF(m_config->mainColorAlpha()); + truecolor = config->mainColor(); + truecolor.setAlphaF(config->mainColorAlpha()); } else - color = ldColor.faceColor(); + { + truecolor = color.faceColor(); + } // Paint the icon border - painter.fillRect(QRect {0, 0, size, size}, ldColor.edgeColor()); + painter.fillRect(QRect {0, 0, size, size}, color.edgeColor()); // Paint the checkerboard background, visible with translucent icons - painter.drawPixmap(QRect {1, 1, size - 2, size - 2}, MainWindow::getIcon("checkerboard"), QRect {0, 0, 8, 8}); + painter.drawPixmap( + QRect {1, 1, size - 2, size - 2}, + MainWindow::getIcon("checkerboard"), + QRect {0, 0, 8, 8} + ); // Paint the color above the checkerboard - painter.fillRect (QRect {1, 1, size - 2, size - 2}, color); - return QIcon {QPixmap::fromImage(image)}; + painter.fillRect(QRect {1, 1, size - 2, size - 2}, truecolor); + return {QPixmap::fromImage(image)}; } /*
--- a/src/guiutilities.h Thu Feb 22 11:41:58 2018 +0200 +++ b/src/guiutilities.h Thu Mar 01 11:59:54 2018 +0200 @@ -32,8 +32,9 @@ public: explicit GuiUtilities (QObject* parent); - QIcon makeColorIcon (LDColor ldcolor, int size); void fillUsedColorsToComboBox (class QComboBox* box); QColor mainColorRepresentation(); QVector<ColorToolbarItem> loadQuickColorList(); }; + +QIcon makeColorIcon(LDColor color, int size);
--- a/src/main.cpp Thu Feb 22 11:41:58 2018 +0200 +++ b/src/main.cpp Thu Mar 01 11:59:54 2018 +0200 @@ -23,6 +23,8 @@ #include "mainwindow.h" #include "generics/reverse.h" +Configuration* config = nullptr; + int main (int argc, char* argv[]) { QApplication app (argc, argv); @@ -30,6 +32,7 @@ app.setApplicationName (APPNAME); static Configuration configObject; + config = &configObject; LDPaths* paths = new LDPaths(&configObject); paths->checkPaths(); paths->deleteLater();
--- a/src/main.h Thu Feb 22 11:41:58 2018 +0200 +++ b/src/main.h Thu Mar 01 11:59:54 2018 +0200 @@ -32,3 +32,5 @@ #include "version.h" #include "format.h" #include "configuration.h" + +extern Configuration* config;
--- a/src/mainwindow.cpp Thu Feb 22 11:41:58 2018 +0200 +++ b/src/mainwindow.cpp Thu Mar 01 11:59:54 2018 +0200 @@ -249,7 +249,7 @@ else { QToolButton* colorButton = new QToolButton; - colorButton->setIcon (m_guiUtilities->makeColorIcon (entry.color(), 16)); + colorButton->setIcon (makeColorIcon (entry.color(), 16)); colorButton->setIconSize (QSize (16, 16)); colorButton->setToolTip (entry.color().name());