diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index 90412de76..92b98a43f 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -69,9 +69,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- void DialogAlongLine::FormulaTextChanged() { - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); + this->FormulaChangedPlainText(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 873e9808e..3fe156386 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -48,7 +48,7 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) timerF2 = new QTimer(this); connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF2); - InitOkCancelApply(ui); + InitOkCancel(ui); FillComboBoxPoints(ui->comboBoxBasePoint); diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 774bba5ea..f7cfbbcf5 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -70,9 +70,7 @@ DialogBisector::DialogBisector(const VContainer *data, QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::FormulaTextChanged() { - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); + this->FormulaChangedPlainText(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 1bdd471c2..bf7e0f873 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -41,7 +41,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) : ui->setupUi(this); InitVariables(ui); labelResultCalculation = ui->labelResultCalculation; - lineEditFormula = ui->lineEditFormula; + plainTextEditFormula = ui->plainTextEditFormula; labelEditFormula = ui->labelEditFormula; labelEditNamePoint = ui->labelEditNamePoint; @@ -49,6 +49,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) : flagFormula = false; flagName = false; CheckState(); + this->formulaBaseHeight=ui->plainTextEditFormula->height(); FillComboBoxArcs(ui->comboBoxArc); @@ -57,7 +58,36 @@ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) : connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutArc::EvalFormula); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutArc::FormulaChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit); + + ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", + QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::FormulaTextChanged() +{ + this->FormulaChangedPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::DeployFormulaTextEdit() +{ + if (ui->plainTextEditFormula->height() < DIALOGCUTARC_MAX_FORMULA_HEIGHT) + { + ui->plainTextEditFormula->setFixedHeight(DIALOGCUTARC_MAX_FORMULA_HEIGHT); + //Set icon from theme (internal for Windows system) + ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", + QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); + } + else + { + ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); + //Set icon from theme (internal for Windows system) + ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", + QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -89,12 +119,25 @@ void DialogCutArc::ChoosedObject(quint32 id, const Valentina::Scenes &type) */ void DialogCutArc::DialogAccepted() { - pointName = ui->lineEditNamePoint->text(); - formula = ui->lineEditFormula->text(); - arcId = getCurrentObjectId(ui->comboBoxArc); + this->SaveData(); emit DialogClosed(QDialog::Accepted); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::DialogApply() +{ + this->SaveData(); + emit DialogApplied(); +} +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n"," "); + arcId = getCurrentObjectId(ui->comboBoxArc); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief setArcId set id of arc @@ -114,7 +157,12 @@ void DialogCutArc::setArcId(const quint32 &value, const quint32 &id) void DialogCutArc::setFormula(const QString &value) { formula = qApp->FormulaToUser(value); - ui->lineEditFormula->setText(formula); + // increase height if needed. + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h index 3c2fa5dbe..e527c4aa1 100644 --- a/src/app/dialogs/tools/dialogcutarc.h +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -31,6 +31,7 @@ #include "dialogtool.h" +#define DIALOGCUTARC_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogCutArc; @@ -55,12 +56,24 @@ public: public slots: virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); virtual void DialogAccepted(); - /** TODO ISSUE 79 : create real function + /** * @brief DialogApply apply data and emit signal about applied dialog. */ - virtual void DialogApply(){} + virtual void DialogApply(); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); + /** + * @brief FormulaTextChanged when formula text changes for validation and calc + */ + void FormulaTextChanged(); private: Q_DISABLE_COPY(DialogCutArc) + /** + * @brief SaveData Put dialog data in local variables + */ + void SaveData(); /** * @brief ui keeps information about user interface */ @@ -77,6 +90,10 @@ private: * @brief arcId keep id of arc */ quint32 arcId; + /** + * @brief formulaBaseHeight base height defined by dialogui + */ + int formulaBaseHeight; }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutarc.ui b/src/app/dialogs/tools/dialogcutarc.ui index bfbff85fa..c79294e69 100644 --- a/src/app/dialogs/tools/dialogcutarc.ui +++ b/src/app/dialogs/tools/dialogcutarc.ui @@ -67,17 +67,17 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Formula for the calculation of the spline + + + 40 + 20 + - + @@ -140,6 +140,56 @@ + + + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + @@ -353,7 +403,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index aa5b6ce56..d21bf80d1 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -39,7 +39,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent) lineEditFormula = ui->lineEditFormula; labelEditFormula = ui->labelEditFormula; labelEditNamePoint = ui->labelEditNamePoint; - InitOkCancelApply(ui); + InitOkCancel(ui); flagFormula = false; flagName = false; diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index bea8089c0..cf1d3d5ed 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -41,7 +41,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent labelEditFormula = ui->labelEditFormula; labelEditNamePoint = ui->labelEditNamePoint; - InitOkCancelApply(ui); + InitOkCancel(ui); flagFormula = false; flagName = false; CheckState(); diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index 3f341ab32..d016fd1e5 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -70,9 +70,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- void DialogEndLine::FormulaTextChanged() { - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); + this->FormulaChangedPlainText(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index f9b03c0a2..a07e09a11 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -38,7 +38,7 @@ DialogHeight::DialogHeight(const VContainer *data, QWidget *parent) { ui->setupUi(this); labelEditNamePoint = ui->labelEditNamePoint; - InitOkCancelApply(ui); + InitOkCancel(ui); flagName = false; CheckState(); diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 9c24a6e35..179e80eaf 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -38,7 +38,7 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent { ui->setupUi(this); number = 0; - InitOkCancelApply(ui); + InitOkCancel(ui); labelEditNamePoint = ui->labelEditNamePoint; flagName = false; diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 056bfaf26..1fd36750d 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -70,9 +70,7 @@ DialogNormal::DialogNormal(const VContainer *data, QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- void DialogNormal::FormulaTextChanged() { - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); + this->FormulaChangedPlainText(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index fd3de2f51..b9696aa0b 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -50,8 +50,10 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare labelEditFormula = ui->labelEditFormula; labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight=ui->plainTextEditFormula->height(); InitOkCancelApply(ui); -/* bOk = ui.buttonBox->button(QDialogButtonBox::Ok); + + /* bOk = ui.buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr); connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted); QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); @@ -99,9 +101,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfContact::FormulaTextChanged() { - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); + this->FormulaChangedPlainText(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 34a736aa1..a5e09ef40 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -38,7 +38,7 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, QWi { ui->setupUi(this); labelEditNamePoint = ui->labelEditNamePoint; - InitOkCancelApply(ui); + InitOkCancel(ui); flagName = false; CheckState(); diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index fe9af1bc7..9a4081a25 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -70,9 +70,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent //--------------------------------------------------------------------------------------------------------------------- void DialogShoulderPoint::FormulaTextChanged() { - // TODO issue #79 : back to FormulaChanged when full update - // Also remove this function if only one function called here - this->FormulaChanged2(); + this->FormulaChangedPlainText(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogsinglepoint.cpp b/src/app/dialogs/tools/dialogsinglepoint.cpp index f65840db2..6e929ee23 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.cpp +++ b/src/app/dialogs/tools/dialogsinglepoint.cpp @@ -40,7 +40,7 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize)); ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize)); labelEditNamePoint = ui->labelEditName; - InitOkCancelApply(ui); + InitOkCancel(ui); flagName = false; CheckState(); diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index 193a5db87..b76e06f3b 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -37,7 +37,7 @@ DialogSpline::DialogSpline(const VContainer *data, QWidget *parent) kAsm1(1), kAsm2(1), kCurve(1) { ui->setupUi(this); - InitOkCancelApply(ui); + InitOkCancel(ui); FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP4); diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index de42f970b..592443515 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -37,7 +37,7 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()) { ui->setupUi(this); - InitOkCancelApply(ui); + InitOkCancel(ui); bOk->setEnabled(false); FillComboBoxPoints(ui->comboBoxPoint); diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 469ed6473..e075e63ed 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -290,7 +290,7 @@ void DialogTool::ChangeCurrentData(QComboBox *box, const quint32 &value) const } void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget) -{ // TODO issue #79 : erase this function after all tools updated to plainTextEdit +{ SCASSERT(lineEdit != nullptr); SCASSERT(listWidget != nullptr); QListWidgetItem *item = listWidget->currentItem(); @@ -324,7 +324,7 @@ void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidg //--------------------------------------------------------------------------------------------------------------------- void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer) -{// TODO issue #79 : erase this function after all tools updated to plainTextEdit +{ SCASSERT(edit != nullptr); SCASSERT(timer != nullptr); SCASSERT(labelEditFormula != nullptr); @@ -358,7 +358,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim } void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) -{ // TODO issue #79 : erase this function after all tools updated to plainTextEdit +{ SCASSERT(edit != nullptr); SCASSERT(timer != nullptr); SCASSERT(label != nullptr); @@ -565,9 +565,11 @@ void DialogTool::CheckState() { SCASSERT(bOk != nullptr); bOk->setEnabled(flagFormula && flagName); - SCASSERT(bApply != nullptr); - bApply->setEnabled(flagFormula && flagName); - + // In case dialog hasn't apply button + if ( bApply != nullptr) + { + bApply->setEnabled(flagFormula && flagName); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -617,7 +619,7 @@ void DialogTool::DialogRejected() //--------------------------------------------------------------------------------------------------------------------- void DialogTool::FormulaChanged() -{ // TODO issue #79 : erase after full update of tools. +{ QLineEdit* edit = qobject_cast(sender()); if (edit) { @@ -625,7 +627,7 @@ void DialogTool::FormulaChanged() } } //--------------------------------------------------------------------------------------------------------------------- -void DialogTool::FormulaChanged2() +void DialogTool::FormulaChangedPlainText() { QPlainTextEdit* edit = qobject_cast(sender()); if (edit) diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 3c1f83f33..ccd8d99d4 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -117,10 +117,13 @@ public slots: */ virtual void DialogRejected(); /** - * @brief formula check formula + * @brief FormulaChanged check formula (one line input only) */ void FormulaChanged(); - void FormulaChanged2(); + /** + * @brief FormulaChangedPlainText check formula (plain text editor editor) + */ + void FormulaChangedPlainText(); /** * @brief ArrowUp set angle value 90 degree */ @@ -475,16 +478,22 @@ protected: connect(radioButtonLengthCurve, &QRadioButton::clicked, this, &DialogTool::LengthCurves); } template + /** + * @brief InitOkCancelApply initialise OK / Cancel and Apply buttons + * @param ui Dialog container + */ void InitOkCancelApply(T *ui) { InitOkCancel(ui); - // TODO issue #79 bApply = ui->buttonBox->button(QDialogButtonBox::Apply); SCASSERT(bApply != nullptr); connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply); } - //Left this method for dialog what do not need apply button template + /** + * @brief InitOkCancel initialise OK and Cancel buttons + * @param ui Dialog container + */ void InitOkCancel(T *ui) { bOk = ui->buttonBox->button(QDialogButtonBox::Ok); diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index ea011f33e..63da15c19 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -38,7 +38,7 @@ DialogTriangle::DialogTriangle(const VContainer *data, QWidget *parent) { ui->setupUi(this); labelEditNamePoint = ui->labelEditNamePoint; - InitOkCancelApply(ui); + InitOkCancel(ui); flagName = false; CheckState(); diff --git a/src/app/dialogs/tools/dialoguniondetails.cpp b/src/app/dialogs/tools/dialoguniondetails.cpp index b9e0a2566..7c430437f 100644 --- a/src/app/dialogs/tools/dialoguniondetails.cpp +++ b/src/app/dialogs/tools/dialoguniondetails.cpp @@ -35,7 +35,7 @@ DialogUnionDetails::DialogUnionDetails(const VContainer *data, QWidget *parent) numberP(0), p1(0), p2(0) { ui->setupUi(this); - InitOkCancelApply(ui); + InitOkCancel(ui); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index b5705a1d5..175e16c0a 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -223,7 +223,6 @@ void MainWindow::OptionDraw() * @param toolTip first tooltipe. * @param closeDialogSlot function what handle after close dialog. */ -// TODO Issue 79 : remove function template void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, Func closeDialogSlot) @@ -253,10 +252,9 @@ void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString & } //--------------------------------------------------------------------------------------------------------------------- -// TODO Issue 79 : rename to SetToolButton template /** - * @brief SetToolButton set tool and show dialog. + * @brief SetToolButtonWithApply set tool and show dialog. * @param checked true if tool button checked. * @param t tool type. * @param cursor path tool cursor icon. @@ -298,7 +296,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Valentina::Tools t, const */ template void MainWindow::ClosedDialog(int result) -{// TODO ISSUE 79 : delete +{ SCASSERT(dialogTool != nullptr); if (result == QDialog::Accepted) { @@ -309,10 +307,9 @@ void MainWindow::ClosedDialog(int result) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief ClosedDialog handle close dialog + * @brief ClosedDialogWithApply handle close dialog that has apply button * @param result result working dialog. */ -// TODO ISSUE 79 : rename template void MainWindow::ClosedDialogWithApply(int result) { @@ -345,7 +342,7 @@ void MainWindow::ClosedDialogWithApply(int result) */ template void MainWindow::ApplyDialog() -{// TODO ISSUE 79 : copy +{ SCASSERT(dialogTool != nullptr); // Only create tool if not already created with apply @@ -367,19 +364,17 @@ void MainWindow::ApplyDialog() * @param checked true - button checked. */ void MainWindow::ToolEndLine(bool checked) -{// TODO ISSUE 79 : copy -// SetToolButton(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), -// &MainWindow::ClosedDialogEndLine); +{ SetToolButtonWithApply(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), &MainWindow::ClosedDialogEndLine,&MainWindow::ApplyDialogEndLine); } //--------------------------------------------------------------------------------------------------------------------- -/** // TODO ISSUE 79 : copy +/** * @brief ApplyDialogEndLine actions after apply in DialogEndLine. */ void MainWindow::ApplyDialogEndLine() -{ // TODO ISSUE 79 : copy +{ ApplyDialog(); } @@ -458,7 +453,7 @@ void MainWindow::ToolShoulderPoint(bool checked) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief ApplyDialogShoulderPoint actions after apply in DialogEndLine. + * @brief ApplyDialogShoulderPoint actions after apply in DialogShoulderPoint. */ void MainWindow::ApplyDialogShoulderPoint() { @@ -489,7 +484,7 @@ void MainWindow::ToolNormal(bool checked) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief ApplyDialogNormal actions after apply in ApplyDialogNormal. + * @brief ApplyDialogNormal actions after apply in DialogNormal. */ void MainWindow::ApplyDialogNormal() { @@ -816,8 +811,17 @@ void MainWindow::ClosedDialogUnionDetails(int result) */ void MainWindow::ToolCutArc(bool checked) { - SetToolButton(checked, Valentina::CutArcTool, ":/cursor/arc_cut_cursor.png", tr("Select arc"), - &MainWindow::ClosedDialogCutArc); + SetToolButtonWithApply(checked, Valentina::CutArcTool, ":/cursor/arc_cut_cursor.png", + tr("Select arc"), &MainWindow::ClosedDialogCutArc, &MainWindow::ApplyDialogCutArc); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ApplyDialogCutArc actions after apply in DialogCutArc. + */ +void MainWindow::ApplyDialogCutArc() +{ + ApplyDialog(); } //--------------------------------------------------------------------------------------------------------------------- @@ -827,7 +831,7 @@ void MainWindow::ToolCutArc(bool checked) */ void MainWindow::ClosedDialogCutArc(int result) { - ClosedDialog(result); + ClosedDialogWithApply(result); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 285b78956..268103c30 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -127,6 +127,7 @@ public slots: void ClosedDialogUnionDetails(int result); void ClosedDialogCutSpline(int result); void ClosedDialogCutArc(int result); + void ApplyDialogCutArc(); void About(); void AboutQt(); diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index f9e94a570..b46a7c7ab 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -77,7 +77,7 @@ void VToolCutArc::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, +VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -86,11 +86,17 @@ void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); const quint32 arcId = dialogTool->getArcId(); - Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); + VToolCutArc* point = nullptr; + point=Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, +VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) { @@ -149,7 +155,9 @@ void VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &f doc->AddTool(arc1id, point); doc->AddTool(arc2id, point); doc->IncrementReferens(arcId); + return point; } + return nullptr; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index 53dbcd740..f53e64523 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -65,7 +65,7 @@ public: * @param doc dom document container. * @param data container with variables. */ - static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); /** * @brief Create help create tool. * @param _id tool id, 0 if tool doesn't exist yet. @@ -80,7 +80,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, + static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); static const QString ToolType;