From 8bb3377a60ca15df53bbb1dec66f12f1f1ef1778 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 29 Nov 2016 16:29:09 +0200 Subject: [PATCH] Fix several bugs in dialogs. --HG-- branch : feature --- .../vtools/dialogs/tools/dialogpiecepath.cpp | 25 ++++++++----------- .../vtools/dialogs/tools/dialogpiecepath.h | 1 - .../dialogs/tools/dialogseamallowance.cpp | 19 ++++++++++---- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index 7049a309d..478f08eb9 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -37,8 +37,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget *parent) : DialogTool(data, toolId, parent), ui(new Ui::DialogPiecePath), - m_showMode(false), - m_saWidth(0) + m_showMode(false) { ui->setupUi(this); InitOkCancel(ui); @@ -88,15 +87,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget connect(ui->comboBoxAngle, static_cast(&QComboBox::currentIndexChanged), this, &DialogPiecePath::NodeAngleChanged); - if (not m_showMode) - { - vis = new VisToolPiecePath(data); - } - else - { - ui->comboBoxType->setDisabled(true); - ui->comboBoxPiece->setDisabled(true); - } + vis = new VisToolPiecePath(data); ui->tabWidget->removeTab(1); } @@ -111,6 +102,8 @@ DialogPiecePath::~DialogPiecePath() void DialogPiecePath::EnbleShowMode(bool disable) { m_showMode = disable; + ui->comboBoxType->setDisabled(m_showMode); + ui->comboBoxPiece->setDisabled(m_showMode); } //--------------------------------------------------------------------------------------------------------------------- @@ -308,7 +301,7 @@ void DialogPiecePath::NodeChanged(int index) qreal w1 = node.GetSABefore(); if (w1 < 0) { - w1 = m_saWidth; + w1 = ui->doubleSpinBoxSeams->value(); } else { @@ -319,7 +312,7 @@ void DialogPiecePath::NodeChanged(int index) qreal w2 = node.GetSAAfter(); if (w2 < 0) { - w2 = m_saWidth; + w2 = ui->doubleSpinBoxSeams->value(); } else { @@ -588,6 +581,8 @@ void DialogPiecePath::SetPieceId(quint32 id) ui->comboBoxType->setCurrentIndex(index); } } + + ValidObjects(PathIsValid()); } //--------------------------------------------------------------------------------------------------------------------- @@ -595,8 +590,8 @@ void DialogPiecePath::SetSAWidth(qreal width) { if (width >=0) { - m_saWidth = width; - ui->tabWidget->addTab(ui->tabSeamAllowance, QString()); + ui->tabWidget->addTab(ui->tabSeamAllowance, tr("Seam allowance")); + ui->doubleSpinBoxSeams->setValue(width); } else { diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/dialogpiecepath.h index 6149853f9..767694adc 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.h @@ -78,7 +78,6 @@ private: Q_DISABLE_COPY(DialogPiecePath) Ui::DialogPiecePath *ui; bool m_showMode; - qreal m_saWidth; void InitPathTypes(); void InitListPieces(); diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp index 849ff8d3a..576fa9a3c 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp @@ -641,12 +641,21 @@ void DialogSeamAllowance::PathDialogClosed(int result) SCASSERT(not m_dialog.isNull()); DialogPiecePath *dialogTool = qobject_cast(m_dialog.data()); SCASSERT(dialogTool != nullptr); - const VPiecePath newPath = dialogTool->GetPiecePath(); - const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetPieceId()); + try + { + const VPiecePath newPath = dialogTool->GetPiecePath(); + const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetToolId()); - SavePiecePathOptions *saveCommand = new SavePiecePathOptions(newPath, oldPath, qApp->getCurrentDocument(), - const_cast(data), toolId); - qApp->getUndoStack()->push(saveCommand); + SavePiecePathOptions *saveCommand = new SavePiecePathOptions(oldPath, newPath, qApp->getCurrentDocument(), + const_cast(data), + dialogTool->GetToolId()); + qApp->getUndoStack()->push(saveCommand); + } + catch (const VExceptionBadId &e) + { + qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Error. Can't save piece path.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + } } delete m_dialog; }