diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 7d680bd38..e8e14fa8f 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -74,6 +74,8 @@ enum class PieceNodeAngle : unsigned char BySecondEdgeRightAngle }; +enum class PiecePathType : unsigned char {CutomSeamAllowance, InternalPath}; + typedef unsigned char ToolVisHolderType; enum class Tool : ToolVisHolderType { diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index a33edaeee..792c5d4a6 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -42,12 +42,16 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget ui->setupUi(this); InitOkCancel(ui); + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged); + + InitPathTypes(); + connect(ui->comboBoxType, static_cast(&QComboBox::currentIndexChanged), + [this](){ValidObjects(PathIsValid());}); + flagName = true;//We have default name of piece. flagError = PathIsValid(); CheckState(); - connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged); - if (not m_showMode) { vis = new VisToolPiecePath(data); @@ -155,7 +159,7 @@ void DialogPiecePath::SaveData() void DialogPiecePath::CheckState() { SCASSERT(bOk != nullptr); - bOk->setEnabled(flagName && flagError && ui->comboBoxPiece->count() > 0); + bOk->setEnabled(flagName && flagError); } //--------------------------------------------------------------------------------------------------------------------- @@ -228,6 +232,13 @@ void DialogPiecePath::NameChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::InitPathTypes() +{ + ui->comboBoxType->addItem(tr("Custom seam allowance"), static_cast(PiecePathType::CutomSeamAllowance)); + //ui->comboBoxType->addItem(tr("Internal path"), static_cast(PiecePathType::InternalPath)); +} + //--------------------------------------------------------------------------------------------------------------------- VPiecePath DialogPiecePath::GetPiecePath() const { @@ -248,6 +259,29 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path) ListChanged(); } +//--------------------------------------------------------------------------------------------------------------------- +PiecePathType DialogPiecePath::GetType() const +{ +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + const PiecePathType type = + static_cast(ui->comboBoxType->itemData(ui->comboBoxType->currentIndex()).toInt()); +#else + const PiecePathType type = static_cast(ui->comboBoxType->currentData().toInt()); +#endif + + return type; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::SetType(PiecePathType type) +{ + const qint32 index = ui->comboBoxType->findData(static_cast(type)); + if (index != -1) + { + ui->comboBoxType->setCurrentIndex(index); + } +} + //--------------------------------------------------------------------------------------------------------------------- VPiecePath DialogPiecePath::CreatePath() const { @@ -274,7 +308,7 @@ bool DialogPiecePath::PathIsValid() const } else { - if (FirstPointEqualLast(ui->listWidget)) + if (GetType() == PiecePathType::CutomSeamAllowance && FirstPointEqualLast(ui->listWidget)) { url += tr("First point cannot be equal to the last point!"); ui->helpLabel->setText(url); @@ -287,6 +321,14 @@ bool DialogPiecePath::PathIsValid() const return false; } } + + if (m_showMode && ui->comboBoxPiece->count() <= 0) + { + url += tr("List of pieces is empty!"); + ui->helpLabel->setText(url); + return false; + } + ui->helpLabel->setText(tr("Ready!")); return true; } diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/dialogpiecepath.h index 78a1056de..fcd347b5a 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.h @@ -48,6 +48,9 @@ public: VPiecePath GetPiecePath() const; void SetPiecePath(const VPiecePath &path); + PiecePathType GetType() const; + void SetType(PiecePathType type); + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; @@ -67,6 +70,8 @@ private: Ui::DialogPiecePath *ui; bool m_showMode; + void InitPathTypes(); + VPiecePath CreatePath() const; bool PathIsValid() const;