From 2c8539a30da58d5fabc53c520c55f67cb4977846 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 14 Mar 2019 11:53:08 +0200 Subject: [PATCH] Fixed issue #956. Setting pattern unit doesn't change combobox value in Tape app. (grafted from 591df5032a71d33d0f17242bebc2d128f9e27d99) --HG-- branch : develop --- ChangeLog.txt | 1 + src/app/tape/tmainwindow.cpp | 35 +++++++++++++++++++++-------------- src/app/tape/tmainwindow.h | 4 ++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9152645c7..81bfc810e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -30,6 +30,7 @@ - [#942] Save Layout mode ignores paper format for tiled PDF. - [#954] Valentina produces empty rotation operation. - [#955] Valentina corrupts file. +- [#956] Setting pattern unit doesn't change combobox value in Tape app. # Version 0.6.1 October 23, 2018 - [#885] Regression. Broken support for multi size measurements. diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index b2a92a03a..f7237f00c 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -202,6 +202,7 @@ void TMainWindow::SetBaseMSize(int size) void TMainWindow::SetPUnit(Unit unit) { pUnit = unit; + SetCurrentPatternUnit(); UpdatePatternUnit(); } @@ -1895,14 +1896,6 @@ void TMainWindow::SaveMFullName() } } -//--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::PatternUnitChanged(int index) -{ - pUnit = static_cast(comboBoxUnits->itemData(index).toInt()); - - UpdatePatternUnit(); -} - //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetupMenu() { @@ -3301,6 +3294,21 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv) RefreshDataAfterImport(); } +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::SetCurrentPatternUnit() +{ + if (comboBoxUnits) + { + comboBoxUnits->blockSignals(true); + const qint32 indexUnit = comboBoxUnits->findData(static_cast(pUnit)); + if (indexUnit != -1) + { + comboBoxUnits->setCurrentIndex(indexUnit); + } + comboBoxUnits->blockSignals(false); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetDecimals() { @@ -3349,15 +3357,14 @@ void TMainWindow::InitUnits() comboBoxUnits = new QComboBox(this); InitComboBoxUnits(); + SetCurrentPatternUnit(); - // set default unit - const qint32 indexUnit = comboBoxUnits->findData(static_cast(pUnit)); - if (indexUnit != -1) + connect(comboBoxUnits, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index) { - comboBoxUnits->setCurrentIndex(indexUnit); - } + pUnit = static_cast(comboBoxUnits->itemData(index).toInt()); - connect(comboBoxUnits, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::PatternUnitChanged); + UpdatePatternUnit(); + }); ui->toolBarGradation->addWidget(comboBoxUnits); } diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 5503eafa7..05bad7bab 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -126,8 +126,6 @@ private slots: void SaveMDescription(); void SaveMFullName(); - void PatternUnitChanged(int index); - private: Q_DISABLE_COPY(TMainWindow) Ui::TMainWindow *ui; @@ -219,6 +217,8 @@ private: void ImportIndividualMeasurements(const QxtCsvModel &csv); void ImportMultisizeMeasurements(const QxtCsvModel &csv); + + void SetCurrentPatternUnit(); }; #endif // TMAINWINDOW_H