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>
bb10
Gabriel de Dietrich 2018-05-29 18:47:30 -07:00
parent 0866fe2079
commit 23ae05cf68
1 changed files with 8 additions and 4 deletions

View File

@ -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)) {