diff --git a/src/app/dialogs/app/dialogpatternproperties.cpp b/src/app/dialogs/app/dialogpatternproperties.cpp index 07783621f..6f05c604f 100644 --- a/src/app/dialogs/app/dialogpatternproperties.cpp +++ b/src/app/dialogs/app/dialogpatternproperties.cpp @@ -33,9 +33,12 @@ #include "../../xml/vpattern.h" #include "../../widgets/vapplication.h" +#define MAX_HEIGHTS 18 +#define MAX_SIZES 18 + //--------------------------------------------------------------------------------------------------------------------- DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) : - QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc) + QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), heightsChecked(MAX_HEIGHTS), sizesChecked(MAX_SIZES) { ui->setupUi(this); @@ -64,10 +67,50 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) connect(this, &DialogPatternProperties::haveChange, this->doc, &VPattern::haveLiteChange); ui->tabWidget->setCurrentIndex(0); - if (qApp->patternUnit() == Unit::Inch) + if (qApp->patternType() == MeasurementsType::Individual) { ui->tabWidget->setTabEnabled(1, false); } + connect(ui->checkBoxAllHeights, &QCheckBox::stateChanged, this, &DialogPatternProperties::SelectAll); + connect(ui->checkBoxAllSizes, &QCheckBox::stateChanged, this, &DialogPatternProperties::SelectAll); + + connect(ui->checkBoxH92, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH98, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH104, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH110, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH116, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH122, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH128, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH134, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH140, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH146, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH152, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH158, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH164, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH170, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH176, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH182, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH188, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + connect(ui->checkBoxH194, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckHeight); + + connect(ui->checkBoxS22, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS24, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS26, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS28, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS30, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS32, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS34, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS36, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS38, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS40, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS42, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS44, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS46, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS48, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS50, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS52, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS54, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); + connect(ui->checkBoxS56, &QCheckBox::stateChanged, this, &DialogPatternProperties::UncheckSize); } //--------------------------------------------------------------------------------------------------------------------- @@ -86,6 +129,140 @@ void DialogPatternProperties::Apply() close(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SelectAll(int state) +{ + QCheckBox* box = qobject_cast(sender()); + if (box) + { + if (box == ui->checkBoxAllHeights) + { + if (state == Qt::Checked) + { + ui->checkBoxH92->setChecked(true); + ui->checkBoxH98->setChecked(true); + ui->checkBoxH104->setChecked(true); + ui->checkBoxH110->setChecked(true); + ui->checkBoxH116->setChecked(true); + ui->checkBoxH122->setChecked(true); + ui->checkBoxH128->setChecked(true); + ui->checkBoxH134->setChecked(true); + ui->checkBoxH140->setChecked(true); + ui->checkBoxH146->setChecked(true); + ui->checkBoxH152->setChecked(true); + ui->checkBoxH158->setChecked(true); + ui->checkBoxH164->setChecked(true); + ui->checkBoxH170->setChecked(true); + ui->checkBoxH176->setChecked(true); + ui->checkBoxH182->setChecked(true); + ui->checkBoxH188->setChecked(true); + ui->checkBoxH194->setChecked(true); + + SetHeightsEnabled(false); + } + else if (state == Qt::Unchecked) + { + SetHeightsEnabled(true); + } + } + + if (box == ui->checkBoxAllSizes) + { + if (state == Qt::Checked) + { + ui->checkBoxS22->setChecked(true); + ui->checkBoxS24->setChecked(true); + ui->checkBoxS26->setChecked(true); + ui->checkBoxS28->setChecked(true); + ui->checkBoxS30->setChecked(true); + ui->checkBoxS32->setChecked(true); + ui->checkBoxS34->setChecked(true); + ui->checkBoxS36->setChecked(true); + ui->checkBoxS38->setChecked(true); + ui->checkBoxS40->setChecked(true); + ui->checkBoxS42->setChecked(true); + ui->checkBoxS44->setChecked(true); + ui->checkBoxS46->setChecked(true); + ui->checkBoxS48->setChecked(true); + ui->checkBoxS50->setChecked(true); + ui->checkBoxS52->setChecked(true); + ui->checkBoxS54->setChecked(true); + ui->checkBoxS56->setChecked(true); + + SetSizesEnabled(false); + } + else if (state == Qt::Unchecked) + { + SetSizesEnabled(true); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::UncheckHeight(int state) +{ + QCheckBox* box = qobject_cast(sender()); + if (box) + { + if (box == ui->checkBoxH92 || box == ui->checkBoxH98 || box == ui->checkBoxH104 || box == ui->checkBoxH110 || + box == ui->checkBoxH116 || box == ui->checkBoxH122 || box == ui->checkBoxH128 || box == ui->checkBoxH134 || + box == ui->checkBoxH140 || box == ui->checkBoxH146 || box == ui->checkBoxH152 || box == ui->checkBoxH158 || + box == ui->checkBoxH164 || box == ui->checkBoxH170 || box == ui->checkBoxH176 || box == ui->checkBoxH182 || + box == ui->checkBoxH188 || box == ui->checkBoxH194) + { + if (state == Qt::Checked) + { + ++heightsChecked; + } + else if (state == Qt::Unchecked) + { + if (heightsChecked == 1) + { + box->setCheckState(Qt::Checked);//Will call this method again with Qt::Checked state + --heightsChecked;// That's why we will increase. + } + else + { + --heightsChecked; + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::UncheckSize(int state) +{ + QCheckBox* box = qobject_cast(sender()); + if (box) + { + if (box == ui->checkBoxS22 || box == ui->checkBoxS24 || box == ui->checkBoxS26 || box == ui->checkBoxS28 || + box == ui->checkBoxS30 || box == ui->checkBoxS32 || box == ui->checkBoxS34 || box == ui->checkBoxS36 || + box == ui->checkBoxS38 || box == ui->checkBoxS40 || box == ui->checkBoxS42 || box == ui->checkBoxS44 || + box == ui->checkBoxS46 || box == ui->checkBoxS48 || box == ui->checkBoxS50 || box == ui->checkBoxS52 || + box == ui->checkBoxS54 || box == ui->checkBoxS56) + { + if (state == Qt::Checked) + { + ++sizesChecked; + } + else if (state == Qt::Unchecked) + { + if (sizesChecked == 1) + { + box->setCheckState(Qt::Checked);//Will call this method again with Qt::Checked state + --sizesChecked; // That's why we will increase. + } + else + { + --sizesChecked; + } + } + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::Write(const QString &tagName, const QString &text) const { @@ -97,7 +274,7 @@ void DialogPatternProperties::Write(const QString &tagName, const QString &text) QDomElement tag = doc->createElement(tagName); QDomText domText = doc->createTextNode(text); tag.appendChild(domText); - //Old pattern file doesn't have comment. But here we try insert tag after first child (comment). + //The Old pattern file doesn't have comment. But here we try insert the tag after first child (comment). // // // -->place for new tag<-- @@ -125,3 +302,49 @@ void DialogPatternProperties::Write(const QString &tagName, const QString &text) } } } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SetHeightsEnabled(bool enabled) +{ + ui->checkBoxH92->setEnabled(enabled); + ui->checkBoxH98->setEnabled(enabled); + ui->checkBoxH104->setEnabled(enabled); + ui->checkBoxH110->setEnabled(enabled); + ui->checkBoxH116->setEnabled(enabled); + ui->checkBoxH122->setEnabled(enabled); + ui->checkBoxH128->setEnabled(enabled); + ui->checkBoxH134->setEnabled(enabled); + ui->checkBoxH140->setEnabled(enabled); + ui->checkBoxH146->setEnabled(enabled); + ui->checkBoxH152->setEnabled(enabled); + ui->checkBoxH158->setEnabled(enabled); + ui->checkBoxH164->setEnabled(enabled); + ui->checkBoxH170->setEnabled(enabled); + ui->checkBoxH176->setEnabled(enabled); + ui->checkBoxH182->setEnabled(enabled); + ui->checkBoxH188->setEnabled(enabled); + ui->checkBoxH194->setEnabled(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SetSizesEnabled(bool enabled) +{ + ui->checkBoxS22->setEnabled(enabled); + ui->checkBoxS24->setEnabled(enabled); + ui->checkBoxS26->setEnabled(enabled); + ui->checkBoxS28->setEnabled(enabled); + ui->checkBoxS30->setEnabled(enabled); + ui->checkBoxS32->setEnabled(enabled); + ui->checkBoxS34->setEnabled(enabled); + ui->checkBoxS36->setEnabled(enabled); + ui->checkBoxS38->setEnabled(enabled); + ui->checkBoxS40->setEnabled(enabled); + ui->checkBoxS42->setEnabled(enabled); + ui->checkBoxS44->setEnabled(enabled); + ui->checkBoxS46->setEnabled(enabled); + ui->checkBoxS48->setEnabled(enabled); + ui->checkBoxS50->setEnabled(enabled); + ui->checkBoxS52->setEnabled(enabled); + ui->checkBoxS54->setEnabled(enabled); + ui->checkBoxS56->setEnabled(enabled); +} diff --git a/src/app/dialogs/app/dialogpatternproperties.h b/src/app/dialogs/app/dialogpatternproperties.h index c099058a5..2d89a7b5e 100644 --- a/src/app/dialogs/app/dialogpatternproperties.h +++ b/src/app/dialogs/app/dialogpatternproperties.h @@ -48,11 +48,18 @@ signals: void haveChange(); public slots: void Apply(); + void SelectAll(int state); + void UncheckHeight(int state); + void UncheckSize(int state); private: Q_DISABLE_COPY(DialogPatternProperties) Ui::DialogPatternProperties *ui; VPattern *doc; + char heightsChecked; + char sizesChecked; void Write(const QString &tagName, const QString &text) const; + void SetHeightsEnabled(bool enabled); + void SetSizesEnabled(bool enabled); }; #endif // DIALOGPATTERNPROPERTIES_H diff --git a/src/app/dialogs/app/dialogpatternproperties.ui b/src/app/dialogs/app/dialogpatternproperties.ui index 82cf6a777..16dd0bdd3 100644 --- a/src/app/dialogs/app/dialogpatternproperties.ui +++ b/src/app/dialogs/app/dialogpatternproperties.ui @@ -86,7 +86,7 @@ - + All heights (cm) @@ -108,7 +108,10 @@ QLayout::SetMaximumSize - + + + false + 0 @@ -124,7 +127,10 @@ - + + + false + 0 @@ -140,7 +146,10 @@ - + + + false + 0 @@ -156,7 +165,10 @@ - + + + false + 0 @@ -172,7 +184,10 @@ - + + + false + 0 @@ -194,7 +209,10 @@ - + + + false + 0 @@ -210,7 +228,10 @@ - + + + false + 0 @@ -226,7 +247,10 @@ - + + + false + 0 @@ -242,7 +266,10 @@ - + + + false + 0 @@ -258,7 +285,10 @@ - + + + false + 0 @@ -274,7 +304,10 @@ - + + + false + 0 @@ -290,7 +323,10 @@ - + + + false + 0 @@ -306,7 +342,10 @@ - + + + false + 0 @@ -322,7 +361,10 @@ - + + + false + 0 @@ -338,7 +380,10 @@ - + + + false + 0 @@ -354,7 +399,10 @@ - + + + false + 0 @@ -370,7 +418,10 @@ - + + + false + 0 @@ -386,7 +437,10 @@ - + + + false + 0 @@ -409,7 +463,7 @@ - + All sizes (cm) @@ -428,7 +482,10 @@ - + + + false + 0 @@ -444,7 +501,10 @@ - + + + false + 0 @@ -460,7 +520,10 @@ - + + + false + 0 @@ -476,7 +539,10 @@ - + + + false + 0 @@ -492,7 +558,10 @@ - + + + false + 0 @@ -508,7 +577,10 @@ - + + + false + 0 @@ -524,7 +596,10 @@ - + + + false + 0 @@ -540,7 +615,10 @@ - + + + false + 0 @@ -556,7 +634,10 @@ - + + + false + 0 @@ -572,7 +653,10 @@ - + + + false + 0 @@ -588,7 +672,10 @@ - + + + false + 0 @@ -604,7 +691,10 @@ - + + + false + 0 @@ -620,7 +710,10 @@ - + + + false + 0 @@ -636,7 +729,10 @@ - + + + false + 0 @@ -652,7 +748,10 @@ - + + + false + 0 @@ -668,7 +767,10 @@ - + + + false + 0 @@ -684,7 +786,10 @@ - + + + false + 0 @@ -700,7 +805,10 @@ - + + + false + 0 diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 64ec90702..c12ff3294 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1813,7 +1813,7 @@ void MainWindow::UpdateRecentFileActions() for (int i = 0; i < numRecentFiles; ++i) { - QString text = QString("&%1 %2").arg(i + 1).arg(strippedName(files.at(i))); + QString text = QString("&%1. %2").arg(i + 1).arg(strippedName(files.at(i))); recentFileActs[i]->setText(text); recentFileActs[i]->setData(files.at(i)); recentFileActs[i]->setVisible(true);