summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2018-05-29 18:47:30 -0700
committerGabriel de Dietrich <gabriel.dedietrich@qt.io>2018-06-04 16:44:25 +0000
commit23ae05cf6801426daa01b2f3f278fce17b3b86ff (patch)
treed7a1ea8b54164ddcef48c28cb29759e1ac8bc537
parent0866fe20799cf1ad8295f7c156f8d55a3166e40b (diff)
QMacStyle: Fix clipped arrow in QToolButton
A quick and reasonable fix is to make sure the arrow fits in SC_ToolButtonMenu returns. In the future, we should keep the arrow's actual size and offset the icon accordingly. Change-Id: I218fa7726efbe4576a72889c41685de87ac14ac1 Task-number: QTBUG-68517 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 21013dc76c..5999163c91 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -2826,7 +2826,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
#if QT_CONFIG(toolbutton)
if (const QToolButton *tb = qobject_cast<const QToolButton *>(w)) {
// When stroking the arrow, make sure it fits in the tool button
- if (tb->arrowType() != Qt::NoArrow)
+ if (tb->arrowType() != Qt::NoArrow
+ || tb->popupMode() == QToolButton::MenuButtonPopup)
halfSize -= penWidth;
}
#endif
@@ -5865,11 +5866,11 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
#endif
case CC_ToolButton:
ret = QCommonStyle::subControlRect(cc, opt, sc, widget);
- if (sc == SC_ToolButtonMenu
+ if (sc == SC_ToolButtonMenu) {
#ifndef QT_NO_ACCESSIBILITY
- && !QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)
+ if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar))
+ ret.adjust(-toolButtonArrowMargin, 0, 0, 0);
#endif
- ) {
ret.adjust(-1, 0, 0, 0);
}
break;
@@ -6107,6 +6108,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_ToolButton:
sz.rwidth() += 10;
sz.rheight() += 10;
+ if (const auto *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt))
+ if (tb->features & QStyleOptionToolButton::Menu)
+ sz.rwidth() += toolButtonArrowMargin;
return sz;
case CT_ComboBox:
if (const auto *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {