diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index 9377303f8..f44fd5075 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -42,6 +42,7 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare m_defGradationChanged(false) { ui->setupUi(this); + RetranslateUi(); InitLanguages(ui->langCombo); connect(ui->langCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() @@ -50,11 +51,9 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare }); //-------------------- Decimal separator setup - ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint())); ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator()); //---------------------- Pattern making system - InitPMSystems(ui->systemCombo); ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing()); connect(ui->systemCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { @@ -77,15 +76,14 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare //----------------------------- Measurements Editing connect(ui->resetWarningsButton, &QPushButton::released, this, []() { - VTapeSettings *settings = qApp->TapeSettings(); - - settings->SetConfirmFormatRewriting(true); + qApp->TapeSettings()->SetConfirmFormatRewriting(true); }); //----------------------- Toolbar ui->toolBarStyleCheck->setChecked(qApp->TapeSettings()->GetToolBarStyle()); //---------------------------Default height and size + // If change units don't forget about the label ui->defHeightCombo->addItems(VMeasurement::WholeListHeights(Unit::Cm)); index = ui->defHeightCombo->findText(QString().setNum(qApp->TapeSettings()->GetDefHeight())); if (index != -1) @@ -100,13 +98,14 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare connect(ui->defHeightCombo, QOverload::of(&QComboBox::currentIndexChanged), this, DefGradationChanged); + // If change units don't forget about the label ui->defSizeCombo->addItems(VMeasurement::WholeListSizes(Unit::Cm)); index = ui->defSizeCombo->findText(QString().setNum(qApp->TapeSettings()->GetDefSize())); if (index != -1) { ui->defSizeCombo->setCurrentIndex(index); } - connect(ui->defHeightCombo, QOverload::of(&QComboBox::currentIndexChanged), this, DefGradationChanged); + connect(ui->defSizeCombo, QOverload::of(&QComboBox::currentIndexChanged), this, DefGradationChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -156,6 +155,7 @@ void TapePreferencesConfigurationPage::changeEvent(QEvent *event) { // retranslate designer form (single inheritance approach) RetranslateUi(); + ui->retranslateUi(this); } // remember to call base class implementation QWidget::changeEvent(event); @@ -164,5 +164,18 @@ void TapePreferencesConfigurationPage::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void TapePreferencesConfigurationPage::RetranslateUi() { - ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint())); + ui->osOptionCheck->setText(tr("With OS options") + QStringLiteral(" (%1)").arg(QLocale().decimalPoint())); + + { + const QString code = qvariant_cast(ui->systemCombo->currentData()); + ui->systemCombo->blockSignals(true); + ui->systemCombo->clear(); + InitPMSystems(ui->systemCombo); + ui->systemCombo->setCurrentIndex(-1); + ui->systemCombo->blockSignals(false); + ui->systemCombo->setCurrentIndex(ui->systemCombo->findData(code)); + } + + ui->labelHeightUnit->setText(UnitsToStr(Unit::Cm, true)); + ui->labelSizeUnit->setText(UnitsToStr(Unit::Cm, true)); } diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui index cd16d2a14..a54bc9df4 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.ui @@ -7,7 +7,7 @@ 0 0 501 - 526 + 550 @@ -155,10 +155,24 @@ Default height and size - - - QFormLayout::ExpandingFieldsGrow - + + + + + Height unit + + + + + + + + 0 + 0 + + + + @@ -167,7 +181,21 @@ - + + + + 0 + 0 + + + + + + + + Size unit + + @@ -176,8 +204,31 @@ - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index 9ac1010c9..1a31ca31e 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -43,6 +43,15 @@ TapePreferencesPathPage::TapePreferencesPathPage(QWidget *parent) InitTable(); + connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() + { + ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->defaultButton->setDefault(false); + + ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->editButton->setDefault(true); + }); + connect(ui->defaultButton, &QPushButton::clicked, this, &TapePreferencesPathPage::DefaultPath); connect(ui->editButton, &QPushButton::clicked, this, &TapePreferencesPathPage::EditPath); } @@ -62,6 +71,19 @@ void TapePreferencesPathPage::Apply() settings->SetPathTemplate(ui->pathTable->item(2, 1)->text()); } +//--------------------------------------------------------------------------------------------------------------------- +void TapePreferencesPathPage::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + ui->retranslateUi(this); + InitTable(); + } + // remember to call base class implementation + QWidget::changeEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- void TapePreferencesPathPage::DefaultPath() { @@ -141,6 +163,7 @@ void TapePreferencesPathPage::EditPath() //--------------------------------------------------------------------------------------------------------------------- void TapePreferencesPathPage::InitTable() { + ui->pathTable->clearContents(); ui->pathTable->setRowCount(3); ui->pathTable->setColumnCount(2); @@ -171,13 +194,4 @@ void TapePreferencesPathPage::InitTable() ui->pathTable->resizeColumnsToContents(); ui->pathTable->resizeRowsToContents(); ui->pathTable->horizontalHeader()->setStretchLastSection(true); - - connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() - { - ui->defaultButton->setEnabled(true); - ui->defaultButton->setDefault(false); - - ui->editButton->setEnabled(true); - ui->editButton->setDefault(true); - }); } diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h index ad72bb3cc..d17b54199 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h @@ -45,6 +45,8 @@ public: virtual ~TapePreferencesPathPage(); void Apply(); +protected: + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private slots: void DefaultPath(); void EditPath(); diff --git a/src/app/tape/dialogs/dialogtapepreferences.cpp b/src/app/tape/dialogs/dialogtapepreferences.cpp index 8f4eff643..b3292fde3 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.cpp +++ b/src/app/tape/dialogs/dialogtapepreferences.cpp @@ -111,6 +111,18 @@ void DialogTapePreferences::resizeEvent(QResizeEvent *event) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogTapePreferences::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + ui->retranslateUi(this); + } + // remember to call base class implementation + QDialog::changeEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogTapePreferences::Apply() { diff --git a/src/app/tape/dialogs/dialogtapepreferences.h b/src/app/tape/dialogs/dialogtapepreferences.h index da1dd7848..ce86829df 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.h +++ b/src/app/tape/dialogs/dialogtapepreferences.h @@ -52,6 +52,7 @@ signals: protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private slots: void Apply(); void Ok(); diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index f9faade5b..7e16cf44c 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -45,6 +45,7 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) m_labelLangChanged(false) { ui->setupUi(this); + RetranslateUi(); ui->tabWidget->setCurrentIndex(0); @@ -58,11 +59,16 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) }); //-------------------- Decimal separator setup - ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint())); ui->osOptionCheck->setChecked(qApp->ValentinaSettings()->GetOsSeparator()); //----------------------- Unit setup - InitUnits(); + // set default unit + const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit()); + if (indexUnit != -1) + { + ui->unitCombo->setCurrentIndex(indexUnit); + } + connect(ui->unitCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { m_unitChanged = true; @@ -82,7 +88,6 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) }); //---------------------- Pattern making system - InitPMSystems(ui->systemCombo); ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing()); connect(ui->systemCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { @@ -209,6 +214,7 @@ void PreferencesConfigurationPage::changeEvent(QEvent *event) { // retranslate designer form (single inheritance approach) RetranslateUi(); + ui->retranslateUi(this); } // remember to call base class implementation QWidget::changeEvent(event); @@ -229,17 +235,29 @@ void PreferencesConfigurationPage::InitUnits() ui->unitCombo->addItem(tr("Centimeters"), unitCM); ui->unitCombo->addItem(tr("Millimiters"), unitMM); ui->unitCombo->addItem(tr("Inches"), unitINCH); - - // set default unit - const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit()); - if (indexUnit != -1) - { - ui->unitCombo->setCurrentIndex(indexUnit); - } } //--------------------------------------------------------------------------------------------------------------------- void PreferencesConfigurationPage::RetranslateUi() { - ui->osOptionCheck->setText(tr("With OS options") + QString(" (%1)").arg(QLocale().decimalPoint())); + ui->osOptionCheck->setText(tr("With OS options") + QStringLiteral(" (%1)").arg(QLocale().decimalPoint())); + + { + ui->unitCombo->blockSignals(true); + const QString unit = qvariant_cast(ui->unitCombo->currentData()); + ui->unitCombo->clear(); + InitUnits(); + ui->unitCombo->setCurrentIndex(ui->unitCombo->findData(unit)); + ui->unitCombo->blockSignals(false); + } + + { + const QString code = qvariant_cast(ui->systemCombo->currentData()); + ui->systemCombo->blockSignals(true); + ui->systemCombo->clear(); + InitPMSystems(ui->systemCombo); + ui->systemCombo->setCurrentIndex(-1); + ui->systemCombo->blockSignals(false); + ui->systemCombo->setCurrentIndex(ui->systemCombo->findData(code)); + } } diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index 0bbc77e9b..89dd5a9bb 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -44,6 +44,15 @@ PreferencesPathPage::PreferencesPathPage(QWidget *parent) InitTable(); + connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() + { + ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->defaultButton->setDefault(false); + + ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty()); + ui->editButton->setDefault(true); + }); + connect(ui->defaultButton, &QPushButton::clicked, this, &PreferencesPathPage::DefaultPath); connect(ui->editButton, &QPushButton::clicked, this, &PreferencesPathPage::EditPath); } @@ -68,6 +77,19 @@ QStringList PreferencesPathPage::Apply() return QStringList(); // No changes those require restart. } +//--------------------------------------------------------------------------------------------------------------------- +void PreferencesPathPage::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + ui->retranslateUi(this); + InitTable(); + } + // remember to call base class implementation + QWidget::changeEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- void PreferencesPathPage::DefaultPath() { @@ -176,6 +198,7 @@ void PreferencesPathPage::EditPath() //--------------------------------------------------------------------------------------------------------------------- void PreferencesPathPage::InitTable() { + ui->pathTable->clearContents(); ui->pathTable->setRowCount(6); ui->pathTable->setColumnCount(2); @@ -226,13 +249,4 @@ void PreferencesPathPage::InitTable() ui->pathTable->verticalHeader()->setDefaultSectionSize(20); ui->pathTable->resizeColumnsToContents(); ui->pathTable->resizeRowsToContents(); - - connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]() - { - ui->defaultButton->setEnabled(true); - ui->defaultButton->setDefault(false); - - ui->editButton->setEnabled(true); - ui->editButton->setDefault(true); - }); } diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.h b/src/app/valentina/dialogs/configpages/preferencespathpage.h index 92f79dbb6..499d001e6 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.h @@ -46,6 +46,9 @@ public: QStringList Apply(); +protected: + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + private slots: void DefaultPath(); void EditPath(); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index fbfeca4ca..c2b017d64 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -61,6 +61,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) m_oldLineUnit(Unit::Mm) { ui->setupUi(this); + RetranslateUi(); VSettings *settings = qApp->ValentinaSettings(); @@ -72,7 +73,14 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) ui->undoCount->setValue(settings->GetUndoCount()); //----------------------- Unit setup - InitUnits(); + // set default unit + const Unit defUnit = QLocale().measurementSystem() == QLocale::MetricSystem ? Unit::Mm : Unit::Inch; + const qint32 indexUnit = ui->comboBoxLineWidthUnit->findData(static_cast(defUnit)); + if (indexUnit != -1) + { + ui->comboBoxLineWidthUnit->setCurrentIndex(indexUnit); + } + connect(ui->comboBoxLineWidthUnit, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { const Unit lineUnit = static_cast(ui->comboBoxLineWidthUnit->currentData().toInt()); @@ -176,6 +184,19 @@ void PreferencesPatternPage::InitDefaultSeamAllowance() ui->defaultSeamAllowance->setSuffix(UnitsToStr(StrToUnits(qApp->ValentinaSettings()->GetUnit()), true)); } +//--------------------------------------------------------------------------------------------------------------------- +void PreferencesPatternPage::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + RetranslateUi(); + ui->retranslateUi(this); + } + // remember to call base class implementation + QWidget::changeEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::EditDateTimeFormats() { @@ -244,14 +265,17 @@ void PreferencesPatternPage::InitUnits() { ui->comboBoxLineWidthUnit->addItem(tr("Millimiters"), static_cast(Unit::Mm)); ui->comboBoxLineWidthUnit->addItem(tr("Inches"), static_cast(Unit::Inch)); +} - // set default unit - const Unit defUnit = QLocale().measurementSystem() == QLocale::MetricSystem ? Unit::Mm : Unit::Inch; - const qint32 indexUnit = ui->comboBoxLineWidthUnit->findData(static_cast(defUnit)); - if (indexUnit != -1) - { - ui->comboBoxLineWidthUnit->setCurrentIndex(indexUnit); - } +//--------------------------------------------------------------------------------------------------------------------- +void PreferencesPatternPage::RetranslateUi() +{ + ui->comboBoxLineWidthUnit->blockSignals(true); + const int unit = ui->comboBoxLineWidthUnit->currentData().toInt(); + ui->comboBoxLineWidthUnit->clear(); + InitUnits(); + ui->comboBoxLineWidthUnit->setCurrentIndex(ui->comboBoxLineWidthUnit->findData(unit)); + ui->comboBoxLineWidthUnit->blockSignals(false); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.h b/src/app/valentina/dialogs/configpages/preferencespatternpage.h index 360012c4d..82de2d184 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.h @@ -50,6 +50,9 @@ public: QStringList Apply(); void InitDefaultSeamAllowance(); +protected: + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + private slots: void EditDateTimeFormats(); void ManageKnownMaterials(); @@ -63,6 +66,7 @@ private: void InitLabelDateTimeFormats(); void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat); void InitUnits(); + void RetranslateUi(); template void CallDateTimeFormatEditor(const T &type, const QStringList &predefinedFormats, diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui index 2baaaf6b9..0b2011584 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui @@ -116,7 +116,14 @@ This option will take an affect after restart. - + + + + 0 + 0 + + + @@ -125,7 +132,7 @@ This option will take an affect after restart. - 40 + 500 20 diff --git a/src/app/valentina/dialogs/dialogpreferences.cpp b/src/app/valentina/dialogs/dialogpreferences.cpp index c0f6aae14..9b8754f06 100644 --- a/src/app/valentina/dialogs/dialogpreferences.cpp +++ b/src/app/valentina/dialogs/dialogpreferences.cpp @@ -114,6 +114,18 @@ void DialogPreferences::resizeEvent(QResizeEvent *event) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPreferences::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + ui->retranslateUi(this); + } + // remember to call base class implementation + QDialog::changeEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPreferences::PageChanged(QListWidgetItem *current, QListWidgetItem *previous) { diff --git a/src/app/valentina/dialogs/dialogpreferences.h b/src/app/valentina/dialogs/dialogpreferences.h index ce1fe3992..6db49fca6 100644 --- a/src/app/valentina/dialogs/dialogpreferences.h +++ b/src/app/valentina/dialogs/dialogpreferences.h @@ -54,6 +54,7 @@ signals: protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private slots: void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); private: