From 4e1248472502944d6a5b3aad97cb66c562f6dddc Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 6 Jan 2016 07:34:30 +0200 Subject: [PATCH] Retranslate configdialog. --HG-- branch : feature --- src/app/valentina/dialogs/configdialog.cpp | 36 +++++++++++++++++++--- src/app/valentina/dialogs/configdialog.h | 6 ++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/app/valentina/dialogs/configdialog.cpp b/src/app/valentina/dialogs/configdialog.cpp index 684a94c5b..30825ea22 100644 --- a/src/app/valentina/dialogs/configdialog.cpp +++ b/src/app/valentina/dialogs/configdialog.cpp @@ -38,7 +38,8 @@ //--------------------------------------------------------------------------------------------------------------------- ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr), - communityPage(nullptr), pathPage(nullptr), isInitialized(false) + communityPage(nullptr), pathPage(nullptr), applyButton(nullptr), cancelButton(nullptr), okButton(nullptr), + isInitialized(false) { contentsWidget = new QListWidget; contentsWidget->setViewMode(QListView::IconMode); @@ -62,9 +63,9 @@ ConfigDialog::ConfigDialog(QWidget *parent) : pathPage = new PathPage(); pagesWidget->addWidget(pathPage); - QPushButton *applyButton = new QPushButton(tr("Apply")); - QPushButton *cancelButton = new QPushButton(tr("&Cancel")); - QPushButton *okButton = new QPushButton(tr("&Ok")); + applyButton = new QPushButton(tr("Apply")); + cancelButton = new QPushButton(tr("&Cancel")); + okButton = new QPushButton(tr("&Ok")); createIcons(); contentsWidget->setCurrentRow(0); @@ -115,6 +116,19 @@ void ConfigDialog::closeEvent(QCloseEvent *event) event->accept(); } +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + RetranslateUi(); + } + + // remember to call base class implementation + QDialog::changeEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- void ConfigDialog::showEvent(QShowEvent *event) { @@ -188,3 +202,17 @@ void ConfigDialog::Ok() Apply(); done(QDialog::Accepted); } + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigDialog::RetranslateUi() +{ + applyButton->setText(tr("Apply")); + cancelButton->setText(tr("&Cancel")); + okButton->setText(tr("&Ok")); + setWindowTitle(tr("Config Dialog")); + contentsWidget->item(0)->setText(tr("Configuration")); + contentsWidget->item(1)->setText(tr("Pattern")); + contentsWidget->item(2)->setText(tr("Community")); + contentsWidget->item(3)->setText(tr("Paths")); +} + diff --git a/src/app/valentina/dialogs/configdialog.h b/src/app/valentina/dialogs/configdialog.h index 9f8d9556e..bb1932032 100644 --- a/src/app/valentina/dialogs/configdialog.h +++ b/src/app/valentina/dialogs/configdialog.h @@ -47,6 +47,7 @@ signals: void UpdateProperties(); protected: virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(ConfigDialog) @@ -56,11 +57,16 @@ private: PatternPage *patternPage; CommunityPage *communityPage; PathPage *pathPage; + QPushButton *applyButton; + QPushButton *cancelButton; + QPushButton *okButton; bool isInitialized; void createIcons(); void createIcon(const QString &icon, const QString &text); void Apply(); void Ok(); + + void RetranslateUi(); }; #endif // CONFIGDIALOG_H