From f8ee078ef7950a897763fb991d9d1ca263831ad0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 4 Nov 2016 19:36:36 +0200 Subject: [PATCH] When user creates new piece button Apply should be disabled. --HG-- branch : feature --- .../vtools/dialogs/tools/dialogseamallowance.cpp | 14 ++++++++++++-- .../vtools/dialogs/tools/dialogseamallowance.h | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp index fa1ef109f..b2c93467c 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp @@ -37,11 +37,13 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent) : DialogTool(data, toolId, parent), ui(new Ui::DialogSeamAllowance), - m_piece() + m_piece(), + applyAllowed(false)// By default disabled { ui->setupUi(this); InitOkCancelApply(ui); + EnableApply(applyAllowed); flagName = true;//We have default name of piece. flagError = MainPathIsValid(); @@ -57,6 +59,14 @@ DialogSeamAllowance::~DialogSeamAllowance() delete ui; } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::EnableApply(bool enable) +{ + SCASSERT(bApply != nullptr); + bApply->setEnabled(enable); + applyAllowed = enable; +} + //--------------------------------------------------------------------------------------------------------------------- VPiece DialogSeamAllowance::GetPiece() const { @@ -128,7 +138,7 @@ void DialogSeamAllowance::CheckState() SCASSERT(bOk != nullptr); bOk->setEnabled(flagName && flagError); // In case dialog hasn't apply button - if ( bApply != nullptr) + if ( bApply != nullptr && applyAllowed) { bApply->setEnabled(bOk->isEnabled()); } diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/dialogseamallowance.h index ff1095a72..beb4c2477 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.h @@ -45,6 +45,8 @@ public: DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); virtual ~DialogSeamAllowance(); + void EnableApply(bool enable); + VPiece GetPiece() const; void SetPiece(const VPiece &m_piece); @@ -64,6 +66,7 @@ private: Ui::DialogSeamAllowance *ui; VPiece m_piece; + bool applyAllowed; VPiece CreatePiece() const;