diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 1288aad7d..ff88eba71 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -64,6 +64,7 @@ #include "../vpatterndb/vpiecepath.h" #include "../qmuparser/qmuparsererror.h" #include "../vtools/dialogs/support/dialogeditlabel.h" +#include "../vformat/vpatternrecipe.h" #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" @@ -3058,6 +3059,7 @@ void MainWindow::Clear() ui->actionZoomFitBestCurrent->setEnabled(false); ui->actionZoomOriginal->setEnabled(false); ui->actionHistory->setEnabled(false); + ui->actionExportRecipe->setEnabled(false); ui->actionTable->setEnabled(false); ui->actionExportIncrementsToCSV->setEnabled(false); ui->actionExportFinalMeasurementsToCSV->setEnabled(false); @@ -3426,6 +3428,7 @@ void MainWindow::SetEnableWidgets(bool enable) ui->actionZoomOut->setEnabled(enable); ui->actionArrowTool->setEnabled(enable && designStage); ui->actionHistory->setEnabled(enable && drawStage); + ui->actionExportRecipe->setEnabled(enable && drawStage); ui->actionNewDraw->setEnabled(enable && drawStage); ui->actionDraw->setEnabled(enable); ui->actionDetails->setEnabled(enable); @@ -4350,6 +4353,26 @@ void MainWindow::CreateActions() } }); + connect(ui->actionExportRecipe, &QAction::triggered, this, [this]() + { + QString filters(tr("Recipe files") + QStringLiteral("(*.vpr)")); + QString fileName = + QFileDialog::getSaveFileName(this, tr("Export recipe"), + QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), + filters, nullptr); + if (fileName.isEmpty()) + { + return; + } + + VPatternRecipe recipe(pattern, doc); + QString error; + if (not recipe.SaveDocument(fileName, error)) + { + qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Could not save recipe. %1").arg(error))); + } + }); + connect(ui->actionNewDraw, &QAction::triggered, this, [this]() { qCDebug(vMainWindow, "New PP."); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 250072cca..1d8fcf1e6 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -372,7 +372,7 @@ 0 0 - 126 + 140 108 @@ -481,7 +481,7 @@ 0 0 - 126 + 140 243 @@ -743,7 +743,7 @@ 0 0 - 126 + 140 282 @@ -1034,7 +1034,7 @@ 0 0 - 126 + 140 102 @@ -1321,7 +1321,7 @@ 0 0 - 126 + 140 237 @@ -1781,6 +1781,7 @@ History + @@ -2821,6 +2822,17 @@ Hide labels + + + false + + + false + + + Export recipe + +