diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 47155b812..22a4961de 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -202,6 +202,7 @@ void MainWindow::OptionDraw() } //--------------------------------------------------------------------------------------------------------------------- +// TODO Issue 79 : remove function template void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, Func closeDialogSlot) @@ -230,6 +231,36 @@ void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString & } } +//--------------------------------------------------------------------------------------------------------------------- +// TODO Issue 79 : rename to SetToolButton +template +void MainWindow::SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot, Func2 applyDialogSlot) +{ + if (checked) + { + CancelTool(); + tool = t; + QPixmap pixmap(cursor); + QCursor cur(pixmap, 2, 3); + view->setCursor(cur); + helpLabel->setText(toolTip); + dialogTool = new Dialog(pattern, this); + connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChoosedObject); + connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); + connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot); + connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); + connect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); + } + else + { + if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) + { + Q_CHECK_PTR(tButton); + tButton->setChecked(true); + } + } +} //--------------------------------------------------------------------------------------------------------------------- template void MainWindow::ClosedDialog(int result) @@ -242,11 +273,32 @@ void MainWindow::ClosedDialog(int result) ArrowTool(); } +//--------------------------------------------------------------------------------------------------------------------- +template +void MainWindow::ApplyDialog() +{// TODO ISSUE 79 : copy + Q_CHECK_PTR(dialogTool); + + // TODO ISSUE 79 : Only create on first apply for now, + // for updating : VDataTool * stored in DialogTool ? + DrawTool::Create(dialogTool, currentScene, doc, pattern); + + ArrowTool(); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolEndLine(bool checked) { - SetToolButton(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), - &MainWindow::ClosedDialogEndLine); +// SetToolButton(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), +// &MainWindow::ClosedDialogEndLine); + SetToolButton2(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), + &MainWindow::ClosedDialogEndLine,&MainWindow::ApplyDialogEndLine); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ApplyDialogEndLine() +{ // TODO ISSUE 79 : copy + ApplyDialog(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 9a8f8407f..c0c70d47a 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -254,6 +254,10 @@ public slots: * @param result result of dialog working. */ void ClosedDialogEndLine(int result); + /** // TODO ISSUE 79 : copy + * @brief ApplyDialogEndLine actions after apply in DialogEndLine. + */ + void ApplyDialogEndLine(); /** * @brief ClosedDialogLine actions after closing DialogLine. * @param result result of dialog working. @@ -503,7 +507,7 @@ private: */ void RestoreCurrentScene(); template - /** + /** // TODO ISSUE 79 : delete * @brief SetToolButton set tool and show dialog. * @param checked true if tool button checked. * @param t tool type. @@ -513,6 +517,18 @@ private: */ void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, Func closeDialogSlot); + /** // TODO ISSUE 79 : copy + * @brief SetToolButton set tool and show dialog. + * @param checked true if tool button checked. + * @param t tool type. + * @param cursor path tool cursor icon. + * @param toolTip first tooltipe. + * @param closeDialogSlot function to handle close of dialog. + * @param applyDialogSlot function to handle apply in dialog. + */ + template + void SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot, Func2 applyDialogSlot); /** * @brief MinimumScrollBar set scroll bar to minimum. */ @@ -523,6 +539,11 @@ private: * @param result result working dialog. */ void ClosedDialog(int result); + /** // TODO ISSUE 79 : copy + * @brief ApplyDialog handle apply in dialog + */ + template + void ApplyDialog(); /** * @brief SavePattern save pattern file. * @param fileName pattern file name.