diff --git a/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp index 3b9b700bd..bc206d1a6 100644 --- a/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp @@ -29,6 +29,7 @@ #include "tapeconfigurationpage.h" #include "../../mapplication.h" #include "../vmisc/vtapesettings.h" +#include "../vpatterndb/variables/vmeasurement.h" #include #include #include @@ -52,6 +53,7 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent) osOptionCheck(nullptr), langChanged(false), systemChanged(false), + defGradationChanged(false), unitChanged(false), labelLangChanged(false), sendReportCheck(nullptr), @@ -61,15 +63,25 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent) systemBookValueLabel(nullptr), langGroup(nullptr), guiLabel(nullptr), + separatorLabel(nullptr), + pmSystemGroup(nullptr), systemLabel(nullptr), systemAuthorLabel(nullptr), systemBookLabel(nullptr), - separatorLabel(nullptr) + gradationGroup(nullptr), + defHeightLabel(nullptr), + defSizeLabel(nullptr), + defHeightCombo(nullptr), + defSizeCombo(nullptr) { QGroupBox *langGroup = LangGroup(); + QGroupBox *pmSystemGroup = PMSystemGroup(); + QGroupBox *gradationBox = GradationGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(langGroup); + mainLayout->addWidget(pmSystemGroup); + mainLayout->addWidget(gradationBox); mainLayout->addStretch(1); setLayout(mainLayout); } @@ -96,6 +108,13 @@ void TapeConfigurationPage::Apply() qApp->RetranslateTables(); qApp->RetranslateGroups(); } + + if (defGradationChanged) + { + settings->SetDefHeight(defHeightCombo->currentText().toInt()); + settings->SetDefSize(defSizeCombo->currentText().toInt()); + defGradationChanged = false; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -123,6 +142,12 @@ void TapeConfigurationPage::SystemChanged() systemBookValueLabel->setPlainText(text); } +//--------------------------------------------------------------------------------------------------------------------- +void TapeConfigurationPage::DefGradationChanged() +{ + defGradationChanged = true; +} + //--------------------------------------------------------------------------------------------------------------------- void TapeConfigurationPage::UnitChanged() { @@ -200,38 +225,6 @@ QGroupBox *TapeConfigurationPage::LangGroup() langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); langLayout->addRow(guiLabel, langCombo); - //-------------------- Pattern making system - systemLabel = new QLabel(tr("Pattern making system:")); - systemCombo = new QComboBox; - - InitPMSystems(systemCombo); - - langLayout->addRow(systemLabel, systemCombo); - - //---- - systemAuthorLabel = new QLabel(tr("Author:")); - systemAuthorValueLabel = new QLabel(""); - - langLayout->addRow(systemAuthorLabel, systemAuthorValueLabel); - - //---- - systemBookLabel = new QLabel(tr("Book:")); - systemBookValueLabel = new QPlainTextEdit(""); - systemBookValueLabel->setReadOnly(true); - systemBookValueLabel->setFixedHeight(4 * QFontMetrics(systemBookValueLabel->font()).lineSpacing()); - - langLayout->addRow(systemBookLabel, systemBookValueLabel); - - connect(systemCombo, static_cast(&QComboBox::currentIndexChanged), this, - &TapeConfigurationPage::SystemChanged); - - // set default pattern making system - index = systemCombo->findData(settings->GetPMSystemCode()); - if (index != -1) - { - systemCombo->setCurrentIndex(index); - } - //-------------------- Decimal separator setup separatorLabel = new QLabel(tr("Decimal separator parts:")); @@ -245,6 +238,88 @@ QGroupBox *TapeConfigurationPage::LangGroup() return langGroup; } +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *TapeConfigurationPage::PMSystemGroup() +{ + pmSystemGroup = new QGroupBox(tr("Pattern making system")); + + systemLabel = new QLabel(tr("Pattern making system:")); + systemCombo = new QComboBox; + + InitPMSystems(systemCombo); + + QFormLayout *pmSystemLayout = new QFormLayout; + pmSystemLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + pmSystemLayout->addRow(systemLabel, systemCombo); + + //---- + systemAuthorLabel = new QLabel(tr("Author:")); + systemAuthorValueLabel = new QLabel(""); + + pmSystemLayout->addRow(systemAuthorLabel, systemAuthorValueLabel); + + //---- + systemBookLabel = new QLabel(tr("Book:")); + systemBookValueLabel = new QPlainTextEdit(""); + systemBookValueLabel->setReadOnly(true); + systemBookValueLabel->setFixedHeight(4 * QFontMetrics(systemBookValueLabel->font()).lineSpacing()); + + pmSystemLayout->addRow(systemBookLabel, systemBookValueLabel); + + connect(systemCombo, static_cast(&QComboBox::currentIndexChanged), this, + &TapeConfigurationPage::SystemChanged); + + // set default pattern making system + const VTapeSettings *settings = qApp->TapeSettings(); + const int index = systemCombo->findData(settings->GetPMSystemCode()); + if (index != -1) + { + systemCombo->setCurrentIndex(index); + } + + pmSystemGroup->setLayout(pmSystemLayout); + return pmSystemGroup; +} + +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *TapeConfigurationPage::GradationGroup() +{ + gradationGroup = new QGroupBox(tr("Default height and size")); + + QFormLayout *gradationLayout = new QFormLayout; + gradationLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + + const VTapeSettings *settings = qApp->TapeSettings(); + + defHeightLabel = new QLabel(tr("Default height:")); + defHeightCombo = new QComboBox; + defHeightCombo->addItems(VMeasurement::WholeListHeights(Unit::Cm)); + int index = defHeightCombo->findText(QString().setNum(settings->GetDefHeight())); + if (index != -1) + { + defHeightCombo->setCurrentIndex(index); + } + connect(defHeightCombo, static_cast(&QComboBox::currentIndexChanged), this, + &TapeConfigurationPage::DefGradationChanged); + gradationLayout->addRow(defHeightLabel, defHeightCombo); + + + defSizeLabel = new QLabel(tr("Default size:")); + defSizeCombo = new QComboBox; + defSizeCombo->addItems(VMeasurement::WholeListSizes(Unit::Cm)); + index = defSizeCombo->findText(QString().setNum(settings->GetDefSize())); + if (index != -1) + { + defSizeCombo->setCurrentIndex(index); + } + connect(defHeightCombo, static_cast(&QComboBox::currentIndexChanged), this, + &TapeConfigurationPage::DefGradationChanged); + gradationLayout->addRow(defSizeLabel, defSizeCombo); + + gradationGroup->setLayout(gradationLayout); + return gradationGroup; +} + //--------------------------------------------------------------------------------------------------------------------- void TapeConfigurationPage::SetLabelComboBox(const QStringList &list) { @@ -259,8 +334,12 @@ void TapeConfigurationPage::SetLabelComboBox(const QStringList &list) void TapeConfigurationPage::RetranslateUi() { langGroup->setTitle(tr("Language")); - guiLabel->setText(tr("GUI language")); - systemLabel->setText(tr("Pattern making system")); + guiLabel->setText(tr("GUI language:")); + separatorLabel->setText(tr("Decimal separator parts:")); + osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); + + pmSystemGroup->setTitle(tr("Pattern making system")); + systemLabel->setText(tr("Pattern making system:")); const int index = systemCombo->currentIndex(); systemCombo->blockSignals(true); @@ -286,6 +365,7 @@ void TapeConfigurationPage::RetranslateUi() #endif systemBookValueLabel->setPlainText(text); - separatorLabel->setText(tr("Decimal separator parts")); - osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); + gradationGroup->setTitle(tr("Default height and size")); + defHeightLabel->setText(tr("Default height:")); + defSizeLabel->setText(tr("Default size:")); } diff --git a/src/app/tape/dialogs/configpages/tapeconfigurationpage.h b/src/app/tape/dialogs/configpages/tapeconfigurationpage.h index 984b9c1fb..45e792433 100644 --- a/src/app/tape/dialogs/configpages/tapeconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapeconfigurationpage.h @@ -48,6 +48,7 @@ public: public slots: void LangChanged(); void SystemChanged(); + void DefGradationChanged(); void UnitChanged(); void LabelLangChanged(); protected: @@ -61,6 +62,7 @@ private: QCheckBox *osOptionCheck; bool langChanged; bool systemChanged; + bool defGradationChanged; bool unitChanged; bool labelLangChanged; QCheckBox *sendReportCheck; @@ -71,12 +73,22 @@ private: QGroupBox *langGroup; QLabel *guiLabel; + QLabel *separatorLabel; + + QGroupBox *pmSystemGroup; QLabel *systemLabel; QLabel *systemAuthorLabel; QLabel *systemBookLabel; - QLabel *separatorLabel; + + QGroupBox *gradationGroup; + QLabel *defHeightLabel; + QLabel *defSizeLabel; + QComboBox *defHeightCombo; + QComboBox *defSizeCombo; QGroupBox *LangGroup(); + QGroupBox *PMSystemGroup(); + QGroupBox *GradationGroup(); void SetLabelComboBox(const QStringList &list); void RetranslateUi(); }; diff --git a/src/app/tape/dialogs/dialognewmeasurements.cpp b/src/app/tape/dialogs/dialognewmeasurements.cpp index 782bbfe4f..897af7bb7 100644 --- a/src/app/tape/dialogs/dialognewmeasurements.cpp +++ b/src/app/tape/dialogs/dialognewmeasurements.cpp @@ -30,6 +30,8 @@ #include "ui_dialognewmeasurements.h" #include "../vpatterndb/variables/vmeasurement.h" +#include "../vmisc/vtapesettings.h" +#include "../mapplication.h" #include @@ -46,6 +48,22 @@ DialogNewMeasurements::DialogNewMeasurements(QWidget *parent) InitHeightsList(); InitSizesList(); + const VTapeSettings *settings = qApp->TapeSettings(); + + const int height = static_cast(UnitConvertor(settings->GetDefHeight(), Unit::Cm, MUnit())); + int index = ui->comboBoxBaseHeight->findText(QString().setNum(height)); + if (index != -1) + { + ui->comboBoxBaseHeight->setCurrentIndex(index); + } + + const int size = static_cast(UnitConvertor(settings->GetDefSize(), Unit::Cm, MUnit())); + index = ui->comboBoxBaseSize->findText(QString().setNum(size)); + if (index != -1) + { + ui->comboBoxBaseSize->setCurrentIndex(index); + } + connect(ui->comboBoxMType, static_cast(&QComboBox::currentIndexChanged), this, &DialogNewMeasurements::CurrentTypeChanged); @@ -155,8 +173,17 @@ void DialogNewMeasurements::CurrentTypeChanged(int index) void DialogNewMeasurements::CurrentUnitChanged(int index) { Q_UNUSED(index); - InitHeightsList(); - InitSizesList(); + + if (MUnit() != Unit::Inch) + { + int i = ui->comboBoxBaseHeight->currentIndex(); + InitHeightsList(); + ui->comboBoxBaseHeight->setCurrentIndex(i); + + i = ui->comboBoxBaseSize->currentIndex(); + InitSizesList(); + ui->comboBoxBaseSize->setCurrentIndex(i); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -222,6 +249,7 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type) { ui->comboBoxUnit->addItem(tr("Inches"), static_cast(Unit::Inch)); } + ui->comboBoxUnit->setCurrentIndex(-1); ui->comboBoxUnit->blockSignals(false); int index = ui->comboBoxUnit->findData(val); @@ -229,4 +257,9 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type) { ui->comboBoxUnit->setCurrentIndex(index); } + else + { + index = ui->comboBoxUnit->findData(static_cast(Unit::Cm)); + ui->comboBoxUnit->setCurrentIndex(index); + } } diff --git a/src/app/tape/dialogs/dialognewmeasurements.ui b/src/app/tape/dialogs/dialognewmeasurements.ui index 444b80ec1..de6b15994 100644 --- a/src/app/tape/dialogs/dialognewmeasurements.ui +++ b/src/app/tape/dialogs/dialognewmeasurements.ui @@ -34,7 +34,14 @@ - + + + + 0 + 0 + + + @@ -44,7 +51,14 @@ - + + + + 0 + 0 + + + @@ -58,6 +72,21 @@ false + + + 0 + 0 + + + + + 0 + 0 + + + + 3 + @@ -72,6 +101,21 @@ false + + + 0 + 0 + + + + + 0 + 0 + + + + 4 + diff --git a/src/libs/vmisc/vtapesettings.cpp b/src/libs/vmisc/vtapesettings.cpp index 11f1023ee..f28a893cb 100644 --- a/src/libs/vmisc/vtapesettings.cpp +++ b/src/libs/vmisc/vtapesettings.cpp @@ -33,6 +33,9 @@ const QString VTapeSettings::SettingDataBaseGeometry = QStringLiteral("database/geometry"); +const QString VTapeSettings::SettingDefHeight = QStringLiteral("gradation/defHeight"); +const QString VTapeSettings::SettingDefSize = QStringLiteral("gradation/defHeight"); + //--------------------------------------------------------------------------------------------------------------------- VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application, QObject *parent) @@ -51,3 +54,27 @@ void VTapeSettings::SetDataBaseGeometry(const QByteArray &value) { setValue(SettingDataBaseGeometry, value); } + +//--------------------------------------------------------------------------------------------------------------------- +void VTapeSettings::SetDefHeight(int value) +{ + setValue(SettingDefHeight, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VTapeSettings::GetDefHeight() const +{ + return value(SettingDefHeight, 176).toInt(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VTapeSettings::SetDefSize(int value) +{ + setValue(SettingDefSize, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VTapeSettings::GetDefSize() const +{ + return value(SettingDefSize, 50).toInt(); +} diff --git a/src/libs/vmisc/vtapesettings.h b/src/libs/vmisc/vtapesettings.h index 275e09b73..ba5424921 100644 --- a/src/libs/vmisc/vtapesettings.h +++ b/src/libs/vmisc/vtapesettings.h @@ -41,10 +41,18 @@ public: QByteArray GetDataBaseGeometry() const; void SetDataBaseGeometry(const QByteArray &value); + void SetDefHeight(int value); + int GetDefHeight() const; + + void SetDefSize(int value); + int GetDefSize() const; + private: Q_DISABLE_COPY(VTapeSettings) static const QString SettingDataBaseGeometry; + static const QString SettingDefHeight; + static const QString SettingDefSize; }; #endif // VTAPESETTINGS_H