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>bb10
parent
8b882f42e8
commit
b278a4f9b0
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue