Some updates for dialog.
--HG-- branch : feature
This commit is contained in:
parent
bb39410296
commit
6793bb69f1
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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<void (QComboBox::*)(int)>(&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<int>(PiecePathType::CutomSeamAllowance));
|
||||
//ui->comboBoxType->addItem(tr("Internal path"), static_cast<int>(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<PiecePathType>(ui->comboBoxType->itemData(ui->comboBoxType->currentIndex()).toInt());
|
||||
#else
|
||||
const PiecePathType type = static_cast<PiecePathType>(ui->comboBoxType->currentData().toInt());
|
||||
#endif
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::SetType(PiecePathType type)
|
||||
{
|
||||
const qint32 index = ui->comboBoxType->findData(static_cast<int>(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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user