New action export recipe.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2019-07-11 14:15:54 +03:00
parent 965cf34c15
commit 65e831da05
2 changed files with 40 additions and 5 deletions

View File

@ -64,6 +64,7 @@
#include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecepath.h"
#include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmuparsererror.h"
#include "../vtools/dialogs/support/dialogeditlabel.h" #include "../vtools/dialogs/support/dialogeditlabel.h"
#include "../vformat/vpatternrecipe.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
#include "../vmisc/backport/qscopeguard.h" #include "../vmisc/backport/qscopeguard.h"
@ -3058,6 +3059,7 @@ void MainWindow::Clear()
ui->actionZoomFitBestCurrent->setEnabled(false); ui->actionZoomFitBestCurrent->setEnabled(false);
ui->actionZoomOriginal->setEnabled(false); ui->actionZoomOriginal->setEnabled(false);
ui->actionHistory->setEnabled(false); ui->actionHistory->setEnabled(false);
ui->actionExportRecipe->setEnabled(false);
ui->actionTable->setEnabled(false); ui->actionTable->setEnabled(false);
ui->actionExportIncrementsToCSV->setEnabled(false); ui->actionExportIncrementsToCSV->setEnabled(false);
ui->actionExportFinalMeasurementsToCSV->setEnabled(false); ui->actionExportFinalMeasurementsToCSV->setEnabled(false);
@ -3426,6 +3428,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionZoomOut->setEnabled(enable); ui->actionZoomOut->setEnabled(enable);
ui->actionArrowTool->setEnabled(enable && designStage); ui->actionArrowTool->setEnabled(enable && designStage);
ui->actionHistory->setEnabled(enable && drawStage); ui->actionHistory->setEnabled(enable && drawStage);
ui->actionExportRecipe->setEnabled(enable && drawStage);
ui->actionNewDraw->setEnabled(enable && drawStage); ui->actionNewDraw->setEnabled(enable && drawStage);
ui->actionDraw->setEnabled(enable); ui->actionDraw->setEnabled(enable);
ui->actionDetails->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]() connect(ui->actionNewDraw, &QAction::triggered, this, [this]()
{ {
qCDebug(vMainWindow, "New PP."); qCDebug(vMainWindow, "New PP.");

View File

@ -372,7 +372,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>126</width> <width>140</width>
<height>108</height> <height>108</height>
</rect> </rect>
</property> </property>
@ -481,7 +481,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>126</width> <width>140</width>
<height>243</height> <height>243</height>
</rect> </rect>
</property> </property>
@ -743,7 +743,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>126</width> <width>140</width>
<height>282</height> <height>282</height>
</rect> </rect>
</property> </property>
@ -1034,7 +1034,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>126</width> <width>140</width>
<height>102</height> <height>102</height>
</rect> </rect>
</property> </property>
@ -1321,7 +1321,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>126</width> <width>140</width>
<height>237</height> <height>237</height>
</rect> </rect>
</property> </property>
@ -1781,6 +1781,7 @@
<string>History</string> <string>History</string>
</property> </property>
<addaction name="actionHistory"/> <addaction name="actionHistory"/>
<addaction name="actionExportRecipe"/>
</widget> </widget>
<widget class="QMenu" name="menuMode"> <widget class="QMenu" name="menuMode">
<property name="title"> <property name="title">
@ -2821,6 +2822,17 @@
<string>Hide labels</string> <string>Hide labels</string>
</property> </property>
</action> </action>
<action name="actionExportRecipe">
<property name="checkable">
<bool>false</bool>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Export recipe</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>