From b2b78545981796f3f7a90e81d42781de3448a2ce Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 29 Aug 2014 16:57:12 +0300 Subject: [PATCH] Check if internal cursor stack is empty. --HG-- branch : feature --- .../dialogs/tools/dialogeditwrongformula.cpp | 9 +++-- src/app/widgets/vformulapropertyeditor.cpp | 3 +- .../widgets/vtooloptionspropertybrowser.cpp | 40 +++++++++++++++---- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp index 3c2797d95..6c81c10bb 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.cpp +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -52,10 +52,13 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui //Disable Qt::WaitCursor #ifndef QT_NO_CURSOR - if (QApplication::overrideCursor()->shape() == Qt::WaitCursor) + if (QApplication::overrideCursor() != nullptr) { - restoreCursor = true; - QApplication::restoreOverrideCursor(); + if (QApplication::overrideCursor()->shape() == Qt::WaitCursor) + { + restoreCursor = true; + QApplication::restoreOverrideCursor(); + } } #endif } diff --git a/src/app/widgets/vformulapropertyeditor.cpp b/src/app/widgets/vformulapropertyeditor.cpp index 3118979aa..f286d6154 100644 --- a/src/app/widgets/vformulapropertyeditor.cpp +++ b/src/app/widgets/vformulapropertyeditor.cpp @@ -85,7 +85,8 @@ void VFormulaPropertyEditor::setFormula(const VFormula& formula) //--------------------------------------------------------------------------------------------------------------------- void VFormulaPropertyEditor::onToolButtonClicked() { - DialogEditWrongFormula* tmpWidget = new DialogEditWrongFormula(formula.getData(), formula.getToolId()); + DialogEditWrongFormula* tmpWidget = new DialogEditWrongFormula(formula.getData(), formula.getToolId(), + qApp->getMainWindow()); tmpWidget->setCheckZero(formula.getCheckZero()); tmpWidget->setPostfix(formula.getPostfix()); tmpWidget->setFormula(formula.getFormula(FormulaType::FromUser)); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index a085a493f..42e803b42 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -151,6 +151,14 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) i->setFormulaLength(variant.value().getFormula(FormulaType::FromUser)); } } + else if (id == QLatin1String("formulaAngle")) + { + VFormula formula = variant.value(); + if (formula.error() == false) + { + i->setFormulaAngle(variant.value().getFormula(FormulaType::FromUser)); + } + } break; } default: @@ -216,9 +224,17 @@ void VToolOptionsPropertyBrowser::UpdateOptions() formula.setCheckZero(true); formula.setToolId(i->getId()); formula.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); - QVariant value; - value.setValue(formula); - idToProperty[QLatin1String("formulaLength")]->setValue(value); + QVariant valueFormula; + valueFormula.setValue(formula); + idToProperty[QLatin1String("formulaLength")]->setValue(valueFormula); + + VFormula formulaAngle(i->getFormulaAngle(), i->getData()); + formulaAngle.setCheckZero(false); + formulaAngle.setToolId(i->getId()); + formulaAngle.setPostfix(QStringLiteral("°")); + QVariant valueAngle; + valueAngle.setValue(formulaAngle); + idToProperty[QLatin1String("formulaAngle")]->setValue(valueAngle); break; } @@ -286,12 +302,20 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) AddProperty(lineTypeProperty, QLatin1String("lineType")); VFormulaProperty* itemLength = new VFormulaProperty(tr("Length")); - VFormula formula(i->getFormulaLength(), i->getData()); - formula.setCheckZero(true); - formula.setToolId(i->getId()); - formula.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); - itemLength->setFormula(formula); + VFormula formulaLength(i->getFormulaLength(), i->getData()); + formulaLength.setCheckZero(true); + formulaLength.setToolId(i->getId()); + formulaLength.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); + itemLength->setFormula(formulaLength); AddProperty(itemLength, QLatin1String("formulaLength")); + + VFormulaProperty* itemAngle = new VFormulaProperty(tr("Angle")); + VFormula formulaAngle(i->getFormulaAngle(), i->getData()); + formulaAngle.setCheckZero(false); + formulaAngle.setToolId(i->getId()); + formulaAngle.setPostfix(QStringLiteral("°")); + itemAngle->setFormula(formulaAngle); + AddProperty(itemAngle, QLatin1String("formulaAngle")); break; } case VGraphicsSimpleTextItem::Type: