diff --git a/src/app/core/vtranslation.h b/src/app/core/vtranslation.h index edcd3b3a8..96e997c47 100644 --- a/src/app/core/vtranslation.h +++ b/src/app/core/vtranslation.h @@ -38,7 +38,7 @@ * I took idea from this article http://ololoepepe.blogspot.com/2013/08/qt.html. * As you know, if wrap string to a function translate, it will be marked for translation. No matter what namespace * contains this function. In class Translation used this circumstance. - * It is mean never change name of method translate!!!!!. + * This mean never change name of method translate!!!!!. * Instead of using QT_TRANSLATE_NOOP3 macros we can store strings in QMap. * Example: * create map and fill up its diff --git a/src/app/dialogs/app/configpages/configurationpage.cpp b/src/app/dialogs/app/configpages/configurationpage.cpp index 8e1d13bca..4cc4e01de 100644 --- a/src/app/dialogs/app/configpages/configurationpage.cpp +++ b/src/app/dialogs/app/configpages/configurationpage.cpp @@ -86,8 +86,8 @@ void ConfigurationPage::Apply() QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); qApp->getSettings()->setValue("configuration/locale", locale); langChanged = false; - QString text = QString(tr("Setup user interface language updated and will be used the next time start") + " " + - QApplication::applicationName()); + QString text = tr("Setup user interface language updated and will be used the next time start") + " " + + QApplication::applicationName(); QMessageBox::information(this, QApplication::applicationName(), text); } if (this->unitChanged) @@ -95,7 +95,7 @@ void ConfigurationPage::Apply() QString unit = qvariant_cast(this->unitCombo->itemData(this->unitCombo->currentIndex())); qApp->getSettings()->setValue("configuration/unit", unit); this->unitChanged = false; - QString text = QString(tr("Default unit updated and will be used the next pattern creation")); + QString text = tr("Default unit updated and will be used the next pattern creation"); QMessageBox::information(this, QApplication::applicationName(), text); } if (labelLangChanged) diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 81ff33926..78b7c6d96 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -201,7 +201,7 @@ QString DialogHistory::Record(const VToolRecord &tool) if (domElem.isElement() == false) { qDebug()<<"Can't find element by id"<element->GettreeNodeName(); Changes += "/"; Changes += (currentChange->element->GettreeNodeValueSet()) ? - currentChange->element->GettreeNodeValue(): QString(tr("")); + currentChange->element->GettreeNodeValue(): tr(""); Changes += "\n"; } else @@ -466,9 +466,9 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked() if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify) { Changes += QString("Modified type %1 : ").arg(nodetype); - Changes += (currentChange->changedText) ? *currentChange->newText : QString(tr("Unchanged")); + Changes += (currentChange->changedText) ? *currentChange->newText : tr("Unchanged"); Changes += "/"; - Changes += (currentChange->changedValue) ? *currentChange->newValue: QString(tr("Unchanged")); + Changes += (currentChange->changedValue) ? *currentChange->newValue: tr("Unchanged"); Changes += "\n"; } else @@ -479,7 +479,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked() Changes += currentChange->element->GettreeNodeName(); Changes += "/"; Changes += (currentChange->element->GettreeNodeValueSet()) ? - currentChange->element->GettreeNodeValue(): QString(tr("")); + currentChange->element->GettreeNodeValue(): tr(""); Changes += "\n"; } } diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 31671ed08..9d0293416 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -47,7 +47,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par :DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()), f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), - angleF1(0), angleF2(0) + angleF1(INT_MIN), angleF2(INT_MIN) { ui->setupUi(this); @@ -352,7 +352,17 @@ void DialogArc::EvalRadius() { labelEditFormula = ui->labelEditRadius; const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); - Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix); + const qreal radius = Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix); + + if (radius < 0) + { + flagRadius = false; + ChangeColor(labelEditFormula, Qt::red); + ui->labelResultRadius->setText(tr("Error")); + ui->labelResultRadius->setToolTip(tr("Radius can't be negative")); + + DialogArc::CheckState(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -394,14 +404,21 @@ void DialogArc::ShowLineAngles() //--------------------------------------------------------------------------------------------------------------------- void DialogArc::CheckAngles() { + if (angleF1 == INT_MIN || angleF2 == INT_MIN) + { + return; + } + if (qFuzzyCompare(angleF1 + 1, angleF2 + 1)) { flagF1 = false; ChangeColor(ui->labelEditF1, Qt::red); + ui->labelResultF1->setText(tr("Error")); ui->labelResultF1->setToolTip(tr("Angles equal")); flagF2 = false; ChangeColor(ui->labelEditF2, Qt::red); + ui->labelResultF2->setText(tr("Error")); ui->labelResultF2->setToolTip(tr("Angles equal")); } diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index e5942bc19..4d5264391 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -441,6 +441,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer) CheckState(); ChangeColor(labelEditFormula, Qt::red); labelResultCalculation->setText(tr("Error")); + labelResultCalculation->setToolTip(tr("Empty field")); return; } timer->start(1000); @@ -458,6 +459,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim CheckState(); ChangeColor(labelEditFormula, Qt::red); labelResultCalculation->setText(tr("Error")); + labelResultCalculation->setToolTip(tr("Empty field")); return; } timer->setSingleShot(true); @@ -478,7 +480,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt SCASSERT(label != nullptr); SCASSERT(labelEditFormula != nullptr); - qreal result = 0; + qreal result = INT_MIN;//Value can be 0, so use max imposible value if (text.isEmpty()) { @@ -908,7 +910,7 @@ void DialogTool::EvalFormula() SCASSERT(plainTextEditFormula != nullptr); SCASSERT(labelResultCalculation != nullptr); const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit()); - Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix); + Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 9ef6e70a1..5e245d2e3 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -214,10 +214,13 @@ void VToolArc::setFormulaRadius(const VFormula &value) { if (value.error() == false) { - QSharedPointer obj = VAbstractTool::data.GetGObject(id); - QSharedPointer arc = qSharedPointerDynamicCast(obj); - arc->SetFormulaRadius(value); - SaveOption(obj); + if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative + { + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer arc = qSharedPointerDynamicCast(obj); + arc->SetFormulaRadius(value); + SaveOption(obj); + } } } @@ -241,8 +244,12 @@ void VToolArc::setFormulaF1(const VFormula &value) { QSharedPointer obj = VAbstractTool::data.GetGObject(id); QSharedPointer arc = qSharedPointerDynamicCast(obj); - arc->SetFormulaF1(value); - SaveOption(obj); + + if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF2() + 1)==false)// Angles can't be equal + { + arc->SetFormulaF1(value); + SaveOption(obj); + } } } @@ -266,8 +273,11 @@ void VToolArc::setFormulaF2(const VFormula &value) { QSharedPointer obj = VAbstractTool::data.GetGObject(id); QSharedPointer arc = qSharedPointerDynamicCast(obj); - arc->SetFormulaF2(value); - SaveOption(obj); + if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF1() + 1)==false)// Angles can't be equal + { + arc->SetFormulaF2(value); + SaveOption(obj); + } } } diff --git a/src/app/visualization/vistoolsplinepath.cpp b/src/app/visualization/vistoolsplinepath.cpp index e5e12a212..0fe4ff474 100644 --- a/src/app/visualization/vistoolsplinepath.cpp +++ b/src/app/visualization/vistoolsplinepath.cpp @@ -84,12 +84,12 @@ void VisToolSplinePath::RefreshGeometry() } if (path.CountPoint() < 3) { - Visualization::toolTip = QString(tr("Curve path: select three or more points")); + Visualization::toolTip = tr("Curve path: select three or more points"); } else { - Visualization::toolTip = QString(tr("Curve path: select three or more points, " - "Enter - finish creation")); + Visualization::toolTip = tr("Curve path: select three or more points, " + "Enter - finish creation"); } } }