From 51b75d520f780be8e2fda5bebf6d86265868af85 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 18 Apr 2025 22:19:27 +0200 Subject: [PATCH] WindowsVistaStyle: misc cleanup of QWindowsVistaStyle::standardIcon() Clean up QWindowsVistaStyle::standardIcon a little bit by using separate icons for SP_TitleBarMaxButton and SP_TitleBarNormalButton Change-Id: I876d41f0373268a0a8888f00392a8e32d0f413a1 Reviewed-by: Volker Hilsheimer (cherry picked from commit aed4307a1f3e0bea9aac6013e3ba6ef32a47a989) Reviewed-by: Qt Cherry-pick Bot --- .../modernwindows/qwindowsvistastyle.cpp | 36 +++++++++---------- .../modernwindows/qwindowsvistastyle_p_p.h | 6 +++- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp index 2737b1f8a94..6a003c2e7b2 100644 --- a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp +++ b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp @@ -4901,7 +4901,7 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon, switch (standardIcon) { case SP_TitleBarMaxButton: if (qstyleoption_cast(option)) { - if (d->dockFloat.isNull()) { + if (d->m_titleBarMaxIcon.isNull()) { QWindowsThemeData themeSize(nullptr, nullptr, QWindowsVistaStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); QWindowsThemeData theme(nullptr, nullptr, QWindowsVistaStylePrivate::WindowTheme, @@ -4914,29 +4914,29 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon, theme.painter = &p; theme.rect = QRect(QPoint(0, 0), size); d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal + d->m_titleBarMaxIcon.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal pm.fill(Qt::transparent); theme.stateId = MAXBS_PUSHED; d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed + d->m_titleBarMaxIcon.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed pm.fill(Qt::transparent); theme.stateId = MAXBS_HOT; d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover + d->m_titleBarMaxIcon.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover pm.fill(Qt::transparent); theme.stateId = MAXBS_INACTIVE; d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled + d->m_titleBarMaxIcon.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled } } if (widget && widget->isWindow()) - return d->dockFloat; + return d->m_titleBarMaxIcon; } break; case SP_TitleBarCloseButton: if (qstyleoption_cast(option)) { - if (d->dockClose.isNull()) { + if (d->m_titleBarCloseIcon.isNull()) { QWindowsThemeData theme(nullptr, nullptr, QWindowsVistaStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); if (theme.isValid()) { @@ -4948,29 +4948,29 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon, theme.partId = WP_CLOSEBUTTON; // #### theme.rect = QRect(QPoint(0, 0), size); d->drawBackground(theme); - d->dockClose.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal + d->m_titleBarCloseIcon.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal pm.fill(Qt::transparent); theme.stateId = CBS_PUSHED; d->drawBackground(theme); - d->dockClose.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed + d->m_titleBarCloseIcon.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed pm.fill(Qt::transparent); theme.stateId = CBS_HOT; d->drawBackground(theme); - d->dockClose.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover + d->m_titleBarCloseIcon.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover pm.fill(Qt::transparent); theme.stateId = CBS_INACTIVE; d->drawBackground(theme); - d->dockClose.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled + d->m_titleBarCloseIcon.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled } } if (widget && widget->isWindow()) - return d->dockClose; + return d->m_titleBarCloseIcon; } break; case SP_TitleBarNormalButton: if (qstyleoption_cast(option)) { - if (d->dockFloat.isNull()) { + if (d->m_titleBarNormalIcon.isNull()) { QWindowsThemeData themeSize(nullptr, nullptr, QWindowsVistaStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL); QWindowsThemeData theme(nullptr, nullptr, QWindowsVistaStylePrivate::WindowTheme, @@ -4983,23 +4983,23 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon, theme.painter = &p; theme.rect = QRect(QPoint(0, 0), size); d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal + d->m_titleBarNormalIcon.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal pm.fill(Qt::transparent); theme.stateId = RBS_PUSHED; d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed + d->m_titleBarNormalIcon.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed pm.fill(Qt::transparent); theme.stateId = RBS_HOT; d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover + d->m_titleBarNormalIcon.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover pm.fill(Qt::transparent); theme.stateId = RBS_INACTIVE; d->drawBackground(theme); - d->dockFloat.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled + d->m_titleBarNormalIcon.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled } } if (widget && widget->isWindow()) - return d->dockFloat; + return d->m_titleBarNormalIcon; } break; diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle_p_p.h b/src/plugins/styles/modernwindows/qwindowsvistastyle_p_p.h index 506a097b2b2..e2bd915a2b2 100644 --- a/src/plugins/styles/modernwindows/qwindowsvistastyle_p_p.h +++ b/src/plugins/styles/modernwindows/qwindowsvistastyle_p_p.h @@ -148,11 +148,15 @@ public: QRgb groupBoxTextColorDisabled = 0; QRgb sliderTickColor = 0; bool hasInitColors = false; - QIcon dockFloat, dockClose; QTime animationTime() const; bool transitionsEnabled() const; +protected: + QIcon m_titleBarMaxIcon; + QIcon m_titleBarCloseIcon; + QIcon m_titleBarNormalIcon; + private: static bool initVistaTreeViewTheming(const QScreen *screen); static void cleanupVistaTreeViewTheming();