aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickdialogbuttonbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2/qquickdialogbuttonbox.cpp')
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index 2c09cd11..e6db14eb 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -455,8 +455,11 @@ void QQuickDialogButtonBoxPrivate::updateLanguage()
qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, true));
const auto boxAttachedPrivate = QQuickDialogButtonBoxAttachedPrivate::get(attached);
const QPlatformDialogHelper::StandardButton standardButton = boxAttachedPrivate->standardButton;
- const QString buttonText = QGuiApplicationPrivate::platformTheme()->standardButtonText(standardButton);
- button->setText(QPlatformTheme::removeMnemonics(buttonText));
+ // The button might be a custom one with explicitly specified text, so we shouldn't change it in that case.
+ if (standardButton != QPlatformDialogHelper::NoButton) {
+ const QString buttonText = QGuiApplicationPrivate::platformTheme()->standardButtonText(standardButton);
+ button->setText(QPlatformTheme::removeMnemonics(buttonText));
+ }
}
--i;
}
@@ -703,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)