diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-05-18 15:05:32 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-05-19 11:08:46 +0200 |
commit | 1f4f547a070356dda459a45b9f1c17fd4995d793 (patch) | |
tree | 3de995fe507d4f2b474c55794b97e14b09900465 /src | |
parent | 4e1e01c4e484337586a7419e28c3625055f88038 (diff) |
Listen for the LanguageChange event in event() instead of using filters
Now that the LanguageChange event is sent to all top level windows to
pass on down to items then we can drop the event filter and just listen
for it in the event() function.
Pick-to: 5.15
Change-Id: I6c9699a798680695ea1d0013266d3a034b74ae7b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickdialogbuttonbox.cpp | 27 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdialogbuttonbox_p.h | 1 |
2 files changed, 7 insertions, 21 deletions
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index df253add..b9e9674b 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -706,34 +706,19 @@ void QQuickDialogButtonBox::updatePolish() d->updateLayout(); } -class LanguageEventFilter : public QObject +bool QQuickDialogButtonBox::event(QEvent *e) { -public: - LanguageEventFilter(QQuickDialogButtonBoxPrivate *box) - : QObject(box->q_ptr) - , boxPrivate(box) - { - } - -protected: - bool eventFilter(QObject *, QEvent *event) - { - if (event->type() == QEvent::LanguageChange) - boxPrivate->updateLanguage(); - return false; - } - -private: - QQuickDialogButtonBoxPrivate *boxPrivate; -}; + Q_D(QQuickDialogButtonBox); + if (e->type() == QEvent::LanguageChange) + d->updateLanguage(); + return QQuickContainer::event(e); +} void QQuickDialogButtonBox::componentComplete() { Q_D(QQuickDialogButtonBox); QQuickContainer::componentComplete(); d->updateLayout(); - // TODO: use the solution in QTBUG-78141 instead, when it's implemented. - qApp->installEventFilter(new LanguageEventFilter(d)); } void QQuickDialogButtonBox::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p.h index f54ecdca..996f4ef7 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox_p.h +++ b/src/quicktemplates2/qquickdialogbuttonbox_p.h @@ -131,6 +131,7 @@ protected: #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; #endif + bool event(QEvent *e) override; private: Q_DISABLE_COPY(QQuickDialogButtonBox) |