Alias field for tool Cubic Bezier Path.

This commit is contained in:
Roman Telezhynskyi 2020-11-04 14:50:58 +02:00
parent 38e60d5905
commit 7fe316c876
5 changed files with 50 additions and 1 deletions

View File

@ -2134,6 +2134,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezierPath(VPE::VProperty *
case 61: // AttrNotes case 61: // AttrNotes
SetNotes<VToolCubicBezierPath>(property); SetNotes<VToolCubicBezierPath>(property);
break; break;
case 62: // AttrAlias
SetAlias<VToolCubicBezierPath>(property);
break;
default: default:
qWarning()<<"Unknown property type. id = "<<id; qWarning()<<"Unknown property type. id = "<<id;
break; break;
@ -2856,6 +2859,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCubicBezierPath(QGraphicsItem *
formView->setTitle(tr("Tool cubic bezier curve")); formView->setTitle(tr("Tool cubic bezier curve"));
AddPropertyObjectName(i, tr("Name:"), true); AddPropertyObjectName(i, tr("Name:"), true);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics()); AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor); AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->getSplinePath().GetApproximationScale()); AddPropertyApproximationScale(tr("Approximation scale:"), i->getSplinePath().GetApproximationScale());
@ -3705,6 +3709,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezierPath()
idToProperty[AttrAScale]->setValue(valueApproximationScale); idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes()); idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -2830,6 +2830,7 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
const QString penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine); const QString penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0')); const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0'));
const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0')); const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
const QString alias = GetParametrEmptyString(domElement, AttrAlias);
QVector<VPointF> points; QVector<VPointF> points;
@ -2861,6 +2862,7 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
initData.path->SetColor(color); initData.path->SetColor(color);
initData.path->SetPenStyle(penStyle); initData.path->SetPenStyle(penStyle);
initData.path->SetApproximationScale(approximationScale); initData.path->SetApproximationScale(approximationScale);
initData.path->SetAliasSuffix(alias);
VToolCubicBezierPath::Create(initData); VToolCubicBezierPath::Create(initData);
} }

View File

@ -80,6 +80,8 @@ DialogCubicBezierPath::DialogCubicBezierPath(const VContainer *data, quint32 too
connect(ui->comboBoxPoint, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxPoint, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogCubicBezierPath::currentPointChanged); this, &DialogCubicBezierPath::currentPointChanged);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogCubicBezierPath::ValidateAlias);
vis = new VisToolCubicBezierPath(data); vis = new VisToolCubicBezierPath(data);
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
@ -112,6 +114,9 @@ void DialogCubicBezierPath::SetPath(const VCubicBezierPath &value)
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name())); ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
ui->doubleSpinBoxApproximationScale->setValue(path.GetApproximationScale()); ui->doubleSpinBoxApproximationScale->setValue(path.GetApproximationScale());
ui->lineEditAlias->setText(path.GetAliasSuffix());
ValidateAlias();
ChangeCurrentData(ui->comboBoxPenStyle, path.GetPenStyle()); ChangeCurrentData(ui->comboBoxPenStyle, path.GetPenStyle());
ChangeCurrentData(ui->comboBoxColor, path.GetColor()); ChangeCurrentData(ui->comboBoxColor, path.GetColor());
@ -200,6 +205,7 @@ void DialogCubicBezierPath::SaveData()
path.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine)); path.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine));
path.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack)); path.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack));
path.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); path.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value());
path.SetAliasSuffix(ui->lineEditAlias->text());
auto visPath = qobject_cast<VisToolCubicBezierPath *>(vis); auto visPath = qobject_cast<VisToolCubicBezierPath *>(vis);
SCASSERT(visPath != nullptr) SCASSERT(visPath != nullptr)
@ -245,6 +251,25 @@ void DialogCubicBezierPath::currentPointChanged(int index)
CheckState(); CheckState();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezierPath::ValidateAlias()
{
VCubicBezierPath tempPath = path;
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
if (not ui->lineEditAlias->text().isEmpty() && not data->IsUnique(tempPath.GetAlias()))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezierPath::NewItem(const VPointF &point) void DialogCubicBezierPath::NewItem(const VPointF &point)
{ {

View File

@ -69,6 +69,7 @@ protected:
private slots: private slots:
void PointChanged(int row); void PointChanged(int row);
void currentPointChanged(int index); void currentPointChanged(int index);
void ValidateAlias();
private: private:
Q_DISABLE_COPY(DialogCubicBezierPath) Q_DISABLE_COPY(DialogCubicBezierPath)
@ -80,6 +81,7 @@ private:
qint32 newDuplicate; qint32 newDuplicate;
bool flagError; bool flagError;
bool flagAlias{true};
void NewItem(const VPointF &point); void NewItem(const VPointF &point);
void DataPoint(const VPointF &p); void DataPoint(const VPointF &p);
@ -93,7 +95,7 @@ private:
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline bool DialogCubicBezierPath::IsValid() const inline bool DialogCubicBezierPath::IsValid() const
{ {
return flagError; return flagError && flagAlias;
} }
#endif // DIALOGCUBICBEZIERPATH_H #endif // DIALOGCUBICBEZIERPATH_H

View File

@ -138,6 +138,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>