Seam allowence width can't be <= 0.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-03-14 12:39:09 +02:00
parent 3dbeb4aff4
commit d287e63790
2 changed files with 49 additions and 1 deletions

View file

@ -44,7 +44,7 @@
* @param parent parent widget
*/
DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true)
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true)
{
ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;
@ -71,6 +71,8 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
this, &DialogDetail::BiasXChanged);
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
connect(ui.doubleSpinBoxSeams, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::AlowenceChanged);
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
connect(ui.checkBoxReverse, &QCheckBox::clicked, this, &DialogDetail::ClickedReverse);
@ -137,6 +139,18 @@ void DialogDetail::SaveData()
detail = CreateDetail();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagFormula && flagName && flagError && flagWidth);
// In case dialog hasn't apply button
if ( bApply != nullptr)
{
bApply->setEnabled(bOk->isEnabled());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NewItem add new object (point, arc, spline or spline path) to list
@ -300,6 +314,25 @@ void DialogDetail::BiasYChanged(qreal d)
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::AlowenceChanged(qreal d)
{
if (ui.doubleSpinBoxSeams->isEnabled())
{
if (d <= 0)
{
flagWidth = false;
ChangeColor(ui.labelEditWidth, errorColor);
}
else
{
flagWidth = true;
ChangeColor(ui.labelEditWidth, okColor);
}
CheckState();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ClickedSeams save supplement of seams for detail
@ -310,6 +343,18 @@ void DialogDetail::ClickedSeams(bool checked)
supplement = checked;
ui.checkBoxClosed->setEnabled(checked);
ui.doubleSpinBoxSeams->setEnabled(checked);
if (checked && ui.doubleSpinBoxSeams->value() <= 0)
{
flagWidth = false;
ChangeColor(ui.labelEditWidth, errorColor);
}
else
{
flagWidth = true;
ChangeColor(ui.labelEditWidth, okColor);
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -48,6 +48,7 @@ public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type);
void BiasXChanged(qreal d);
void BiasYChanged(qreal d);
void AlowenceChanged(qreal d);
void ClickedSeams(bool checked);
void ClickedClosed(bool checked);
void ClickedReverse(bool checked);
@ -59,6 +60,7 @@ protected:
* @brief SaveData Put dialog data in local variables
*/
virtual void SaveData();
virtual void CheckState();
private:
/** @brief ui keeps information about user interface */
@ -72,6 +74,7 @@ private:
/** @brief closed keep option about equdistant (closed or not) */
bool closed;
bool flagWidth;
void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode,
qreal mx = 0, qreal my = 0, bool reverse = false);