diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 5 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 17 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper_p.h | 2 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index b0a43c563c..83895b64b0 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5434,7 +5434,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex case CC_ToolButton: if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { - if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { + + if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)) { if (tb->subControls & SC_ToolButtonMenu) { QStyleOption arrowOpt(0); arrowOpt.rect = proxy()->subControlRect(cc, tb, SC_ToolButtonMenu, widget); @@ -6030,7 +6031,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op break; case CC_ToolButton: ret = QCommonStyle::subControlRect(cc, opt, sc, widget); - if (sc == SC_ToolButtonMenu && widget && !qobject_cast<QToolBar*>(widget->parentWidget())) { + if (sc == SC_ToolButtonMenu && !QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)) { ret.adjust(-1, 0, 0, 0); } break; diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index e23db2b637..8d67683eae 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -86,6 +86,23 @@ qreal dpiScaled(qreal value) #endif } +// Searches for an ancestor of a particular accessible role +bool hasAncestor(QObject *obj, QAccessible::Role role) +{ + bool found = false; +#ifndef QT_NO_ACCESSIBILITY + QObject *parent = obj ? obj->parent() : 0; + while (parent && !found) { + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parent); + if (iface && iface->role() == role) + found = true; + delete iface; + parent = parent->parent(); + } +#endif // QT_NO_ACCESSIBILITY + return found; +} + #ifndef QT_NO_DIAL diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index e47722bd9f..ab6a97e59a 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -44,6 +44,7 @@ #include <QtCore/qstring.h> #include <QtGui/qpolygon.h> #include <QtCore/qstringbuilder.h> +#include <QtGui/qaccessible.h> #ifndef QSTYLEHELPER_P_H #define QSTYLEHELPER_P_H @@ -81,6 +82,7 @@ namespace QStyleHelper void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left = 0, int top = 0, int right = 0, int bottom = 0); + bool hasAncestor(QObject *obj, QAccessible::Role role); } |