diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-21 13:15:25 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-24 12:57:21 +0200 |
commit | b278a4f9b04e80772573a686eac6552436d15915 (patch) | |
tree | 30b393fd5d39dc2b4452b766cde33edce694bf9a /src/widgets | |
parent | 8b882f42e80f4b98e8fefcbae30a85382e67ef4a (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.
Pick-to: 6.2
Task-number: QTBUG-38776
Change-Id: Ic04070196b97a4fb66d7a2669e9894fd7960230e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qdockwidget.cpp | 6 |
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(); |