diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-05-18 15:05:32 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-05-19 09:43:14 +0000 |
commit | adcc0f1bd79d66ab2c5f9417c3ad26a258425e02 (patch) | |
tree | b3de20ac656e33104ba73e12c8a442935ea1e138 | |
parent | 7027b2040be5c9675e542244dc457f208d903612 (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.
Change-Id: I6c9699a798680695ea1d0013266d3a034b74ae7b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 1f4f547a070356dda459a45b9f1c17fd4995d793)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quicktemplates2/qquickdialogbuttonbox.cpp | 27 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdialogbuttonbox_p.h | 1 | ||||
-rw-r--r-- | tests/auto/translation/tst_translation.cpp | 1 |
3 files changed, 8 insertions, 21 deletions
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index f3dd2da1..e6db14eb 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::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p.h index 51ae473f..75c05afb 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) diff --git a/tests/auto/translation/tst_translation.cpp b/tests/auto/translation/tst_translation.cpp index ffb39f96..81eb0b77 100644 --- a/tests/auto/translation/tst_translation.cpp +++ b/tests/auto/translation/tst_translation.cpp @@ -88,6 +88,7 @@ void tst_translation::dialogButtonBox() QTranslator translator; QVERIFY(translator.load("qtbase_fr.qm", ":/")); QVERIFY(qApp->installTranslator(&translator)); + qApp->sendPostedEvents(); view.engine()->retranslate(); QString translatedSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); |