diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-06-11 17:52:45 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-17 15:46:03 +0200 |
commit | 20d667983b5d0ec434b03a68b42f610338877fe8 (patch) | |
tree | c5d16797e1bafa61ca43b612e131e953eb675200 /src/widgets | |
parent | 1ebef55cf796c86cdcb693fc01ae39ed688872f8 (diff) |
QMacStyle: enable scroll style changes for non-QScrollBars
Task-number: QTBUG-31537
Change-Id: Iee2148609df5cb2c121da4088bcd79f26c2eedc4
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 18 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac_p_p.h | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index a8fba4fb68..3daa696155 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -119,9 +119,12 @@ QMacStylePrivate *mPrivate; { Q_UNUSED(notification); QEvent event(QEvent::StyleChange); - foreach (QWidget *widget, QApplication::allWidgets()) { - if (QScrollBar *scrollBar = qobject_cast<QScrollBar *>(widget)) - QCoreApplication::sendEvent(scrollBar, &event); + QMutableSetIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars); + while (it.hasNext()) { + if (!it.next()) + it.remove(); + else + QCoreApplication::sendEvent(it.value(), &event); } } @end @@ -142,6 +145,13 @@ const int QMacStylePrivate::PushButtonContentPadding = 6; const qreal QMacStylePrivate::ScrollBarFadeOutDuration = 200.0; const qreal QMacStylePrivate::ScrollBarFadeOutDelay = 450.0; +QSet<QPointer<QObject> > QMacStylePrivate::scrollBars; + +static uint qHash(const QPointer<QObject> &ptr) +{ + return qHash(ptr.data()); +} + // These colors specify the titlebar gradient colors on // Leopard. Ideally we should get them from the system. static const QColor titlebarGradientActiveBegin(220, 220, 220); @@ -4934,6 +4944,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // no longer possible to move it, second the up/down buttons are removed when // there is not enough space for them. if (cc == CC_ScrollBar) { + if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject)) + QMacStylePrivate::scrollBars.insert(QPointer<QObject>(opt->styleObject)); const int scrollBarLength = (slider->orientation == Qt::Horizontal) ? slider->rect.width() : slider->rect.height(); const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget, opt); diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index c424ff0c3c..bf42087fcb 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -93,6 +93,7 @@ #include <qlibrary.h> #include <qdatetimeedit.h> #include <qmath.h> +#include <qset.h> #include <QtWidgets/qgraphicsproxywidget.h> #include <QtWidgets/qgraphicsview.h> @@ -197,6 +198,7 @@ public: mutable QPointer<QObject> pressedButton; mutable QPointer<QObject> defaultButton; mutable QPointer<QObject> autoDefaultButton; + static QSet<QPointer<QObject> > scrollBars; struct ButtonState { int frame; |