diff --git a/src/qt/platformstyle.cpp b/src/qt/platformstyle.cpp index 1d0605c9030..2257c2ad4f6 100644 --- a/src/qt/platformstyle.cpp +++ b/src/qt/platformstyle.cpp @@ -71,25 +71,28 @@ PlatformStyle::PlatformStyle(const QString &_name, bool _imagesOnButtons, bool _ name(_name), imagesOnButtons(_imagesOnButtons), colorizeIcons(_colorizeIcons), - useExtraSpacing(_useExtraSpacing), - singleColor(0,0,0), - textColor(0,0,0) + useExtraSpacing(_useExtraSpacing) +{ +} + +QColor PlatformStyle::TextColor() const +{ + return QApplication::palette().color(QPalette::WindowText); +} + +QColor PlatformStyle::SingleColor() const { - // Determine icon highlighting color if (colorizeIcons) { const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight)); const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText)); const QColor colorText(QApplication::palette().color(QPalette::WindowText)); const int colorTextLightness = colorText.lightness(); - QColor colorbase; - if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) - colorbase = colorHighlightBg; - else - colorbase = colorHighlightFg; - singleColor = colorbase; + if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) { + return colorHighlightBg; + } + return colorHighlightFg; } - // Determine text color - textColor = QColor(QApplication::palette().color(QPalette::WindowText)); + return {0, 0, 0}; } QImage PlatformStyle::SingleColorImage(const QString& filename) const diff --git a/src/qt/platformstyle.h b/src/qt/platformstyle.h index 53632e56e2e..9df0a1f9854 100644 --- a/src/qt/platformstyle.h +++ b/src/qt/platformstyle.h @@ -21,8 +21,8 @@ public: bool getImagesOnButtons() const { return imagesOnButtons; } bool getUseExtraSpacing() const { return useExtraSpacing; } - QColor TextColor() const { return textColor; } - QColor SingleColor() const { return singleColor; } + QColor TextColor() const; + QColor SingleColor() const; /** Colorize an image (given filename) with the icon color */ QImage SingleColorImage(const QString& filename) const; @@ -43,9 +43,6 @@ private: bool imagesOnButtons; bool colorizeIcons; bool useExtraSpacing; - QColor singleColor; - QColor textColor; - /* ... more to come later */ }; #endif // BITCOIN_QT_PLATFORMSTYLE_H