From b278a4f9b04e80772573a686eac6552436d15915 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 21 Jun 2021 13:15:25 +0200 Subject: Use On icon for pressed dock widget title buttons without frame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QCommonStyle provides explicit pixmaps for the SP_TitleBarCloseButton and SP_TitleBarNormalButton, but never showed the "down" pixmap on macOS because the button has no frame, so the On state flag was never set. Set the style states so that the "down" pixmap is used on a button that is either pressed or checked if it doesn't have a frame. Since QIcon only has two states, use the "On" state for both pressed and checked. Pick-to: 6.2 Task-number: QTBUG-38776 Change-Id: Ic04070196b97a4fb66d7a2669e9894fd7960230e Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qdockwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 6675d7a6bd..4939078870 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -225,8 +225,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *) opt.initFrom(this); opt.state |= QStyle::State_AutoRaise; - if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, nullptr, this)) - { + if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, nullptr, this)) { if (isEnabled() && underMouse() && !isChecked() && !isDown()) opt.state |= QStyle::State_Raised; if (isChecked()) @@ -234,6 +233,9 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *) if (isDown()) opt.state |= QStyle::State_Sunken; style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); + } else if (isDown() || isChecked()) { + // no frame, but the icon might have explicit pixmaps for QIcon::On + opt.state |= QStyle::State_On | QStyle::State_Sunken; } opt.icon = icon(); -- cgit v1.2.3