diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index c865db382..936e61574 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -480,7 +480,7 @@ void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString & { VEnumProperty* itemProperty = new VEnumProperty(propertyName); itemProperty->setLiterals(QStringList()<< tr("First point") << tr("Second point")); - itemProperty->setValue(static_cast(i->GetCrossCirclesPoint())); + itemProperty->setValue(static_cast(i->GetCrossCirclesPoint())-1); AddProperty(itemProperty, AttrCrossPoint); } @@ -490,7 +490,7 @@ void VToolOptionsPropertyBrowser::AddPropertyVCrossPoint(Tool *i, const QString { auto itemProperty = new VEnumProperty(propertyName); itemProperty->setLiterals(QStringList()<< tr("Highest point") << tr("Lowest point")); - itemProperty->setValue(static_cast(i->GetVCrossPoint())); + itemProperty->setValue(static_cast(i->GetVCrossPoint())-1); AddProperty(itemProperty, AttrVCrossPoint); } @@ -500,7 +500,7 @@ void VToolOptionsPropertyBrowser::AddPropertyHCrossPoint(Tool *i, const QString { auto itemProperty = new VEnumProperty(propertyName); itemProperty->setLiterals(QStringList()<< tr("Leftmost point") << tr("Rightmost point")); - itemProperty->setValue(static_cast(i->GetHCrossPoint())); + itemProperty->setValue(static_cast(i->GetHCrossPoint())-1); AddProperty(itemProperty, AttrHCrossPoint); } @@ -629,9 +629,9 @@ Type VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) { switch(val) { + case 0: case 1: - case 2: - cross = static_cast(val); + cross = static_cast(val+1); break; default: break; @@ -2037,7 +2037,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs() VToolPointOfIntersectionArcs *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); } //--------------------------------------------------------------------------------------------------------------------- @@ -2046,7 +2046,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles() VToolPointOfIntersectionCircles *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); QVariant c1Radius; c1Radius.setValue(i->GetFirstCircleRadius()); @@ -2063,8 +2063,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCurves() auto i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint())); - idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint())); + idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint())-1); + idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint())-1); } //--------------------------------------------------------------------------------------------------------------------- @@ -2073,7 +2073,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent() VToolPointFromCircleAndTangent *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); QVariant cRadius; cRadius.setValue(i->GetCircleRadius()); @@ -2086,7 +2086,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent() VToolPointFromArcAndTangent *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp index 9598a0bac..63fca7842 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -46,6 +46,7 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine labelEditNamePoint = ui->labelEditNamePoint; InitOkCancelApply(ui); + CheckState(); FillComboBoxCurves(ui->comboBoxCurve1); FillComboBoxCurves(ui->comboBoxCurve2); @@ -53,6 +54,10 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCurves::NamePointChanged); + connect(ui->comboBoxCurve1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfIntersectionCurves::CurveChanged); + connect(ui->comboBoxCurve2, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfIntersectionCurves::CurveChanged); vis = new VisToolPointOfIntersectionCurves(data); } @@ -80,7 +85,7 @@ quint32 DialogPointOfIntersectionCurves::GetFirstCurveId() const //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value) { - setCurrentPointId(ui->comboBoxCurve1, value); + setCurrentCurveId(ui->comboBoxCurve1, value); auto point = qobject_cast(vis); SCASSERT(point != nullptr); @@ -96,7 +101,7 @@ quint32 DialogPointOfIntersectionCurves::GetSecondCurveId() const //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value) { - setCurrentPointId(ui->comboBoxCurve2, value); + setCurrentCurveId(ui->comboBoxCurve2, value); auto point = qobject_cast(vis); SCASSERT(point != nullptr); @@ -202,3 +207,34 @@ void DialogPointOfIntersectionCurves::SaveData() point->setHCrossPoint(GetHCrossPoint()); point->RefreshGeometry(); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagName && flagError); + // In case dialog hasn't apply button + if ( bApply != nullptr) + { + bApply->setEnabled(bOk->isEnabled()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::CurveChanged() +{ + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxCurve1) == getCurrentObjectId(ui->comboBoxCurve2)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelCurve1, color); + ChangeColor(ui->labelCurve2, color); + CheckState(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h index d70b1bc34..7b6aea822 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h @@ -67,6 +67,10 @@ protected: * @brief SaveData Put dialog data in local variables */ virtual void SaveData() Q_DECL_OVERRIDE; + virtual void CheckState() Q_DECL_OVERRIDE; + +private slots: + void CurveChanged(); private: Q_DISABLE_COPY(DialogPointOfIntersectionCurves) diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui index 2ce932e5d..4fb60acd9 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui @@ -24,7 +24,7 @@ QFormLayout::ExpandingFieldsGrow - + 0 @@ -44,7 +44,7 @@ - + 0