When user creates new piece button Apply should be disabled.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-04 19:36:36 +02:00
parent f40bf977c8
commit f8ee078ef7
2 changed files with 15 additions and 2 deletions

View File

@ -37,11 +37,13 @@
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogSeamAllowance), ui(new Ui::DialogSeamAllowance),
m_piece() m_piece(),
applyAllowed(false)// By default disabled
{ {
ui->setupUi(this); ui->setupUi(this);
InitOkCancelApply(ui); InitOkCancelApply(ui);
EnableApply(applyAllowed);
flagName = true;//We have default name of piece. flagName = true;//We have default name of piece.
flagError = MainPathIsValid(); flagError = MainPathIsValid();
@ -57,6 +59,14 @@ DialogSeamAllowance::~DialogSeamAllowance()
delete ui; delete ui;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnableApply(bool enable)
{
SCASSERT(bApply != nullptr);
bApply->setEnabled(enable);
applyAllowed = enable;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::GetPiece() const VPiece DialogSeamAllowance::GetPiece() const
{ {
@ -128,7 +138,7 @@ void DialogSeamAllowance::CheckState()
SCASSERT(bOk != nullptr); SCASSERT(bOk != nullptr);
bOk->setEnabled(flagName && flagError); bOk->setEnabled(flagName && flagError);
// In case dialog hasn't apply button // In case dialog hasn't apply button
if ( bApply != nullptr) if ( bApply != nullptr && applyAllowed)
{ {
bApply->setEnabled(bOk->isEnabled()); bApply->setEnabled(bOk->isEnabled());
} }

View File

@ -45,6 +45,8 @@ public:
DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogSeamAllowance(); virtual ~DialogSeamAllowance();
void EnableApply(bool enable);
VPiece GetPiece() const; VPiece GetPiece() const;
void SetPiece(const VPiece &m_piece); void SetPiece(const VPiece &m_piece);
@ -64,6 +66,7 @@ private:
Ui::DialogSeamAllowance *ui; Ui::DialogSeamAllowance *ui;
VPiece m_piece; VPiece m_piece;
bool applyAllowed;
VPiece CreatePiece() const; VPiece CreatePiece() const;