From a4e1db90e805f0bc931b618aad85f5330aa645f0 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Sat, 9 Jan 2016 14:38:26 +0200 Subject: [PATCH] Change pattern making system in Valentina settings --HG-- branch : feature --- .../dialogs/configpages/configurationpage.cpp | 89 +++++++++++++++++-- .../dialogs/configpages/configurationpage.h | 12 +++ 2 files changed, 96 insertions(+), 5 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/configurationpage.cpp b/src/app/valentina/dialogs/configpages/configurationpage.cpp index d2caf82d3..cc4e4d44d 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/configurationpage.cpp @@ -54,6 +54,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), + systemChanged(), unitChanged(false), labelLangChanged(false), sendReportCheck(nullptr), @@ -66,20 +67,29 @@ ConfigurationPage::ConfigurationPage(QWidget *parent) separatorLabel(nullptr), unitLabel(nullptr), languageLabel(nullptr), + pmSystemGroup(nullptr), + systemLabel(nullptr), + systemCombo(nullptr), + systemAuthorLabel(nullptr), + systemBookLabel(nullptr), + systemAuthorValueLabel(nullptr), + systemBookValueLabel(nullptr), sendGroup(nullptr), description(nullptr), drawGroup(nullptr), toolBarGroup(nullptr) { - QGroupBox *saveGroup = SaveGroup(); - QGroupBox *langGroup = LangGroup(); - QGroupBox *sendGroup = SendGroup(); - QGroupBox *drawGroup = DrawGroup(); - QGroupBox *toolBarGroup = ToolBarGroup(); + QGroupBox *saveGroup = SaveGroup(); + QGroupBox *langGroup = LangGroup(); + QGroupBox *pmSystemGroup = PMSystemGroup(); + QGroupBox *sendGroup = SendGroup(); + QGroupBox *drawGroup = DrawGroup(); + QGroupBox *toolBarGroup = ToolBarGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(saveGroup); mainLayout->addWidget(langGroup); + mainLayout->addWidget(pmSystemGroup); mainLayout->addWidget(sendGroup); mainLayout->addWidget(drawGroup); mainLayout->addWidget(toolBarGroup); @@ -111,6 +121,12 @@ void ConfigurationPage::Apply() langChanged = false; qApp->LoadTranslation(locale); } + if (systemChanged) + { + const QString code = qvariant_cast(systemCombo->itemData(systemCombo->currentIndex())); + settings->SetPMSystemCode(code); + systemChanged = false; + } if (this->unitChanged) { const QString unit = qvariant_cast(this->unitCombo->itemData(this->unitCombo->currentIndex())); @@ -267,6 +283,49 @@ QGroupBox *ConfigurationPage::LangGroup() return langGroup; } +//--------------------------------------------------------------------------------------------------------------------- +QGroupBox *ConfigurationPage::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, + &ConfigurationPage::SystemChanged); + + // set default pattern making system + const VSettings *settings = qApp->ValentinaSettings(); + const int index = systemCombo->findData(settings->GetPMSystemCode()); + if (index != -1) + { + systemCombo->setCurrentIndex(index); + } + + pmSystemGroup->setLayout(pmSystemLayout); + return pmSystemGroup; +} + //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::SendGroup() { @@ -322,6 +381,26 @@ QGroupBox *ConfigurationPage::ToolBarGroup() return toolBarGroup; } +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::SystemChanged() +{ + systemChanged = true; +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->itemData(systemCombo->currentIndex()).toString()); +#else + QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString()); +#endif + systemAuthorValueLabel->setText(text); + systemAuthorValueLabel->setToolTip(text); + +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + text = qApp->TrVars()->PMSystemBook(systemCombo->itemData(systemCombo->currentIndex()).toString()); +#else + text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString()); +#endif + systemBookValueLabel->setPlainText(text); +} + //--------------------------------------------------------------------------------------------------------------------- void ConfigurationPage::SetLabelComboBox(const QStringList &list) { diff --git a/src/app/valentina/dialogs/configpages/configurationpage.h b/src/app/valentina/dialogs/configpages/configurationpage.h index f63394981..69cdc308f 100644 --- a/src/app/valentina/dialogs/configpages/configurationpage.h +++ b/src/app/valentina/dialogs/configpages/configurationpage.h @@ -30,6 +30,7 @@ #define CONFIGURATIONPAGE_H #include +#include #include class QCheckBox; @@ -46,6 +47,7 @@ public: void Apply(); public slots: void LangChanged(); + void SystemChanged(); void UnitChanged(); void LabelLangChanged(); protected: @@ -59,6 +61,7 @@ private: QComboBox *unitCombo; QCheckBox *osOptionCheck; bool langChanged; + bool systemChanged; bool unitChanged; bool labelLangChanged; QCheckBox *sendReportCheck; @@ -73,6 +76,14 @@ private: QLabel *unitLabel; QLabel *languageLabel; + QGroupBox *pmSystemGroup; + QLabel *systemLabel; + QComboBox *systemCombo; + QLabel *systemAuthorLabel; + QLabel *systemBookLabel; + QLabel *systemAuthorValueLabel; + QPlainTextEdit *systemBookValueLabel; + QGroupBox *sendGroup; QLabel *description; @@ -81,6 +92,7 @@ private: QGroupBox *SaveGroup(); QGroupBox *LangGroup(); + QGroupBox *PMSystemGroup(); QGroupBox *SendGroup(); QGroupBox *DrawGroup(); QGroupBox *ToolBarGroup();