Fix validation of Curved path tool. Closes smart-pattern/valentina#41.
This commit is contained in:
parent
590e0089da
commit
42ed025afa
|
@ -121,6 +121,8 @@ void DialogCubicBezierPath::SetPath(const VCubicBezierPath &value)
|
|||
{
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
|
||||
ValidatePath();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -219,7 +221,6 @@ void DialogCubicBezierPath::PointChanged(int row)
|
|||
void DialogCubicBezierPath::currentPointChanged(int index)
|
||||
{
|
||||
const quint32 id = qvariant_cast<quint32>(ui->comboBoxPoint->itemData(index));
|
||||
QColor color;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -228,50 +229,16 @@ void DialogCubicBezierPath::currentPointChanged(int index)
|
|||
DataPoint(*point);
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(*point));
|
||||
|
||||
if (not IsPathValid())
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
|
||||
ui->lineEditSplPathName->setText(tr("Invalid spline path"));
|
||||
}
|
||||
else
|
||||
{
|
||||
flagError = true;
|
||||
color = OkColor(this);
|
||||
|
||||
auto first = qvariant_cast<VPointF>(ui->listWidget->item(0)->data(Qt::UserRole));
|
||||
auto last = qvariant_cast<VPointF>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
|
||||
|
||||
if (first.id() == path.at(0).id() && last.id() == path.at(path.CountPoints()-1).id())
|
||||
{
|
||||
newDuplicate = -1;
|
||||
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VCubicBezierPath newPath = ExtractPath();
|
||||
|
||||
if (not data->IsUnique(newPath.name()))
|
||||
{
|
||||
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
|
||||
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
|
||||
}
|
||||
|
||||
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
|
||||
}
|
||||
}
|
||||
ValidatePath();
|
||||
}
|
||||
catch (const VExceptionBadId &)
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
ChangeColor(ui->labelName, errorColor);
|
||||
ChangeColor(ui->labelPoint, errorColor);
|
||||
|
||||
ui->lineEditSplPathName->setText(tr("Cannot find point with id %1").arg(id));
|
||||
}
|
||||
|
||||
ChangeColor(ui->labelName, color);
|
||||
ChangeColor(ui->labelPoint, color);
|
||||
CheckState();
|
||||
}
|
||||
|
||||
|
@ -350,3 +317,46 @@ VCubicBezierPath DialogCubicBezierPath::ExtractPath() const
|
|||
}
|
||||
return VCubicBezierPath(points);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCubicBezierPath::ValidatePath()
|
||||
{
|
||||
QColor color;
|
||||
|
||||
if (not IsPathValid())
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
|
||||
ui->lineEditSplPathName->setText(tr("Invalid spline path"));
|
||||
}
|
||||
else
|
||||
{
|
||||
flagError = true;
|
||||
color = OkColor(this);
|
||||
|
||||
auto first = qvariant_cast<VPointF>(ui->listWidget->item(0)->data(Qt::UserRole));
|
||||
auto last = qvariant_cast<VPointF>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
|
||||
|
||||
if (first.id() == path.at(0).id() && last.id() == path.at(path.CountPoints()-1).id())
|
||||
{
|
||||
newDuplicate = -1;
|
||||
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VCubicBezierPath newPath = ExtractPath();
|
||||
|
||||
if (not data->IsUnique(newPath.name()))
|
||||
{
|
||||
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
|
||||
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
|
||||
}
|
||||
|
||||
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
|
||||
}
|
||||
}
|
||||
|
||||
ChangeColor(ui->labelName, color);
|
||||
ChangeColor(ui->labelPoint, color);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ private:
|
|||
QSet<quint32> AllPathBackboneIds() const;
|
||||
bool IsPathValid() const;
|
||||
VCubicBezierPath ExtractPath() const;
|
||||
void ValidatePath();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user