summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-21 13:15:25 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-24 17:19:40 +0000
commitc339100f0ad7e5ccec4cdc30ff35a98104a6826f (patch)
treef2649dea7f2ef09fa2699521690711bcc7235c92
parent30e941a75cd108cbba5124486387d3b2034d0cac (diff)
Use On icon for pressed dock widget title buttons without frame
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. Task-number: QTBUG-38776 Change-Id: Ic04070196b97a4fb66d7a2669e9894fd7960230e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit b278a4f9b04e80772573a686eac6552436d15915) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/widgets/widgets/qdockwidget.cpp6
1 files changed, 4 insertions, 2 deletions
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();