QDockWidget: fix dock buttons size
The size of the dock buttons did not account the SH_DockWidget_ButtonsHaveFrame style hint and therefore was too large when a full 16x16 icon was used (which was the case after the latest style cleanups) and therefore appeared too large. This also allows the remove of the hack for the windows style. The windows vista/11 style is not even affected by this hack because there the size comes from windows itself and can not be modified via PM_SmallIconSize. Fixes: QTBUG-118643 Task-number: QTBUG-118122 Change-Id: Ie09a6a4e89df66b5393c5a57735002da47415c0e Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>bb10
parent
91fe6fb2e1
commit
04f4b27774
|
|
@ -128,33 +128,12 @@ bool QDockWidgetTitleButton::event(QEvent *event)
|
|||
return QAbstractButton::event(event);
|
||||
}
|
||||
|
||||
static inline bool isWindowsStyle(const QStyle *style)
|
||||
{
|
||||
// Note: QStyleSheetStyle inherits QWindowsStyle
|
||||
const QStyle *effectiveStyle = style;
|
||||
|
||||
#if QT_CONFIG(style_stylesheet)
|
||||
if (style->inherits("QStyleSheetStyle"))
|
||||
effectiveStyle = static_cast<const QStyleSheetStyle *>(style)->baseStyle();
|
||||
#endif
|
||||
#if !defined(QT_NO_STYLE_PROXY)
|
||||
if (style->inherits("QProxyStyle"))
|
||||
effectiveStyle = static_cast<const QProxyStyle *>(style)->baseStyle();
|
||||
#endif
|
||||
|
||||
return effectiveStyle->inherits("QWindowsStyle");
|
||||
}
|
||||
|
||||
QSize QDockWidgetTitleButton::dockButtonIconSize() const
|
||||
{
|
||||
if (m_iconSize < 0) {
|
||||
m_iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
|
||||
// Dock Widget title buttons on Windows where historically limited to size 10
|
||||
// (from small icon size 16) since only a 10x10 XPM was provided.
|
||||
// Adding larger pixmaps to the icons thus caused the icons to grow; limit
|
||||
// this to qpiScaled(10) here.
|
||||
if (isWindowsStyle(style()))
|
||||
m_iconSize = qMin((10 * logicalDpiX()) / 96, m_iconSize);
|
||||
if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, nullptr, this))
|
||||
m_iconSize = (m_iconSize * 3) / 4;
|
||||
}
|
||||
return QSize(m_iconSize, m_iconSize);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue