From ac899a4cf1bff0b20a6ea6d3c5c5b5378c1e859a Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 6 Jan 2016 07:55:05 +0200 Subject: [PATCH] Retranslate configurationpage. --HG-- branch : feature --- .../dialogs/configpages/configurationpage.cpp | 111 +++++++++++++++--- .../dialogs/configpages/configurationpage.h | 19 +++ 2 files changed, 112 insertions(+), 18 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/configurationpage.cpp b/src/app/valentina/dialogs/configpages/configurationpage.cpp index 99e67432b..bde6b3838 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/configurationpage.cpp @@ -46,9 +46,30 @@ //--------------------------------------------------------------------------------------------------------------------- ConfigurationPage::ConfigurationPage(QWidget *parent) - : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), labelCombo(nullptr), - unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false), - sendReportCheck(nullptr), askPointDeletionCheck(nullptr), toolBarStyleCheck(nullptr) + : QWidget(parent), + autoSaveCheck(nullptr), + autoTime(nullptr), + langCombo(nullptr), + labelCombo(nullptr), + unitCombo(nullptr), + osOptionCheck(nullptr), + langChanged(false), + unitChanged(false), + labelLangChanged(false), + sendReportCheck(nullptr), + askPointDeletionCheck(nullptr), + toolBarStyleCheck(nullptr), + saveGroup(nullptr), + intervalLabel(nullptr), + langGroup(nullptr), + guiLabel(nullptr), + separatorLabel(nullptr), + unitLabel(nullptr), + languageLabel(nullptr), + sendGroup(nullptr), + description(nullptr), + drawGroup(nullptr), + toolBarGroup(nullptr) { QGroupBox *saveGroup = SaveGroup(); QGroupBox *langGroup = LangGroup(); @@ -88,9 +109,7 @@ void ConfigurationPage::Apply() const QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); settings->SetLocale(locale); langChanged = false; - const QString text = tr("Setup user interface language updated and will be used the next time start") + " " + - QApplication::applicationName(); - QMessageBox::information(this, QApplication::applicationName(), text); + qApp->LoadTranslation(locale); } if (this->unitChanged) { @@ -129,7 +148,7 @@ void ConfigurationPage::LabelLangChanged() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::SaveGroup() { - QGroupBox *saveGroup = new QGroupBox(tr("Save")); + saveGroup = new QGroupBox(tr("Save")); autoSaveCheck = new QCheckBox(tr("Auto-save modified pattern")); autoSaveCheck->setChecked(qApp->ValentinaSettings()->GetAutosaveState()); @@ -141,7 +160,8 @@ QGroupBox *ConfigurationPage::SaveGroup() QHBoxLayout *autosaveLayout = new QHBoxLayout; autosaveLayout->addWidget(autoSaveCheck); - autosaveLayout->addWidget(new QLabel(tr("Interval:"))); + intervalLabel = new QLabel(tr("Interval:")); + autosaveLayout->addWidget(intervalLabel); autosaveLayout->addWidget(autoTime); QVBoxLayout *saveLayout = new QVBoxLayout; @@ -153,7 +173,8 @@ QGroupBox *ConfigurationPage::SaveGroup() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::LangGroup() { - QGroupBox *langGroup = new QGroupBox(tr("Language")); + langGroup = new QGroupBox(tr("Language")); + guiLabel = new QLabel(tr("GUI language:")); langCombo = new QComboBox; QStringList fileNames; @@ -200,12 +221,13 @@ QGroupBox *ConfigurationPage::LangGroup() QFormLayout *langLayout = new QFormLayout; langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - langLayout->addRow(tr("GUI language:"), langCombo); + langLayout->addRow(guiLabel, langCombo); //-------------------- Decimal separator setup - osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); + separatorLabel = new QLabel(tr("Decimal separator parts:")); + osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); osOptionCheck->setChecked(settings->GetOsSeparator()); - langLayout->addRow(tr("Decimal separator parts:"), osOptionCheck); + langLayout->addRow(separatorLabel, osOptionCheck); //----------------------- Unit setup this->unitCombo = new QComboBox; @@ -222,7 +244,8 @@ QGroupBox *ConfigurationPage::LangGroup() connect(this->unitCombo, static_cast(&QComboBox::currentIndexChanged), this, &ConfigurationPage::UnitChanged); - langLayout->addRow(tr("Default unit:"), this->unitCombo); + unitLabel = new QLabel(tr("Default unit:")); + langLayout->addRow(unitLabel, this->unitCombo); //----------------------- Label language labelCombo = new QComboBox; @@ -237,7 +260,8 @@ QGroupBox *ConfigurationPage::LangGroup() connect(labelCombo, static_cast(&QComboBox::currentIndexChanged), this, &ConfigurationPage::LabelLangChanged); - langLayout->addRow(tr("Label language:"), labelCombo); + languageLabel = new QLabel(tr("Label language:")); + langLayout->addRow(languageLabel, labelCombo); langGroup->setLayout(langLayout); return langGroup; @@ -246,12 +270,12 @@ QGroupBox *ConfigurationPage::LangGroup() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::SendGroup() { - QGroupBox *sendGroup = new QGroupBox(tr("Send crash reports")); + sendGroup = new QGroupBox(tr("Send crash reports")); sendReportCheck = new QCheckBox(tr("Send crash reports (recommended)")); sendReportCheck->setChecked(qApp->ValentinaSettings()->GetSendReportState()); - QLabel *description = new QLabel(tr("After each crash Valentina collect information that may help us fix a " + description = new QLabel(tr("After each crash Valentina collect information that may help us fix a " "problem. We do not collect any personal information. Find more about what " "kind of information we collect.")); @@ -271,7 +295,7 @@ QGroupBox *ConfigurationPage::SendGroup() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::DrawGroup() { - QGroupBox *drawGroup = new QGroupBox(tr("Pattern Editing")); + drawGroup = new QGroupBox(tr("Pattern Editing")); askPointDeletionCheck = new QCheckBox(tr("Confirm item deletion")); askPointDeletionCheck->setChecked(qApp->ValentinaSettings()->GetConfirmItemDelete()); @@ -286,7 +310,7 @@ QGroupBox *ConfigurationPage::DrawGroup() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::ToolBarGroup() { - QGroupBox *toolBarGroup = new QGroupBox(tr("Toolbar")); + toolBarGroup = new QGroupBox(tr("Toolbar")); toolBarStyleCheck = new QCheckBox(tr("The text appears under the icon. (recommended for beginners.)")); toolBarStyleCheck->setChecked(qApp->ValentinaSettings()->GetToolBarStyle()); @@ -307,3 +331,54 @@ void ConfigurationPage::SetLabelComboBox(const QStringList &list) labelCombo->addItem(loc.nativeLanguageName(), list.at(i)); } } + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + RetranslateUi(); + } + + // remember to call base class implementation + QWidget::changeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::RetranslateUi() +{ + toolBarStyleCheck->setText(tr("The text appears under the icon. (recommended for beginners.)")); + askPointDeletionCheck->setText(tr("Confirm item deletion")); + + saveGroup->setTitle(tr("Save")); + autoSaveCheck->setText(tr("Auto-save modified pattern")); + autoTime->setSuffix(tr("min")); + intervalLabel->setText(tr("Interval:")); + + langGroup->setTitle(tr("Language")); + guiLabel->setText(tr("GUI language:")); + + separatorLabel->setText(tr("Decimal separator parts:")); + osOptionCheck->setText(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); + + unitLabel->setText(tr("Default unit:")); + this->unitCombo->setItemText(0, tr("Centimeters")); + this->unitCombo->setItemText(1, tr("Millimiters")); + this->unitCombo->setItemText(2, tr("Inches")); + + languageLabel->setText(tr("Label language:")); + + sendGroup->setTitle(tr("Send crash reports")); + sendReportCheck->setText(tr("Send crash reports (recommended)")); + description->setText(tr("After each crash Valentina collect information that may help us fix a " + "problem. We do not collect any personal information. Find more about what " + "kind of information we collect.")); + + drawGroup->setTitle(tr("Pattern Editing")); + askPointDeletionCheck->setText(tr("Confirm item deletion")); + toolBarGroup->setTitle(tr("Toolbar")); + toolBarStyleCheck->setText(tr("The text appears under the icon. (recommended for beginners.)")); + +} diff --git a/src/app/valentina/dialogs/configpages/configurationpage.h b/src/app/valentina/dialogs/configpages/configurationpage.h index 3b79b97c2..f63394981 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.h +++ b/src/app/valentina/dialogs/configpages/configurationpage.h @@ -36,6 +36,7 @@ class QCheckBox; class QSpinBox; class QComboBox; class QGroupBox; +class QLabel; class ConfigurationPage : public QWidget { @@ -47,6 +48,8 @@ public slots: void LangChanged(); void UnitChanged(); void LabelLangChanged(); +protected: + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(ConfigurationPage) QCheckBox *autoSaveCheck; @@ -62,12 +65,28 @@ private: QCheckBox *askPointDeletionCheck; QCheckBox *toolBarStyleCheck; + QGroupBox *saveGroup; + QLabel *intervalLabel; + QGroupBox *langGroup; + QLabel *guiLabel; + QLabel *separatorLabel; + QLabel *unitLabel; + QLabel *languageLabel; + + QGroupBox *sendGroup; + QLabel *description; + + QGroupBox *drawGroup; + QGroupBox *toolBarGroup; + QGroupBox *SaveGroup(); QGroupBox *LangGroup(); QGroupBox *SendGroup(); QGroupBox *DrawGroup(); QGroupBox *ToolBarGroup(); void SetLabelComboBox(const QStringList &list); + + void RetranslateUi(); }; #endif // CONFIGURATIONPAGE_H