diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp
index bde1c62ea..99d8b8975 100644
--- a/src/app/valentina/mainwindow.cpp
+++ b/src/app/valentina/mainwindow.cpp
@@ -1140,6 +1140,7 @@ void MainWindow::LoadIndividual()
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
}
+ ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath);
PatternWasModified(false);
@@ -1166,6 +1167,7 @@ void MainWindow::LoadStandard()
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
}
+ ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath);
PatternWasModified(false);
@@ -1176,6 +1178,31 @@ void MainWindow::LoadStandard()
}
}
+//---------------------------------------------------------------------------------------------------------------------
+void MainWindow::UnloadMeasurements()
+{
+ if (doc->MPath().isEmpty())
+ {
+ ui->actionUnloadMeasurements->setDisabled(true);
+ return;
+ }
+
+ if (doc->ListMeasurements().isEmpty())
+ {
+ watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
+ doc->SetPath(QString());
+ PatternWasModified(false);
+ ui->actionShowM->setEnabled(false);
+ ui->actionUnloadMeasurements->setDisabled(true);
+ helpLabel->setText(tr("Measurements unloaded"));
+ }
+ else
+ {
+ qCWarning(vMainWindow, "%s",
+ qUtf8Printable(tr("Couldn't unload measurements. Some of them are used in the pattern.")));
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::CreateMeasurements()
{
@@ -2132,6 +2159,7 @@ void MainWindow::Clear()
ui->actionShowCurveDetails->setEnabled(false);
ui->actionLoadIndividual->setEnabled(false);
ui->actionLoadStandard->setEnabled(false);
+ ui->actionUnloadMeasurements->setEnabled(false);
ui->actionShowM->setEnabled(false);
SetEnableTool(false);
qApp->setPatternUnit(Unit::Cm);
@@ -2375,6 +2403,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionShowCurveDetails->setEnabled(enable);
ui->actionLoadIndividual->setEnabled(enable);
ui->actionLoadStandard->setEnabled(enable);
+ ui->actionUnloadMeasurements->setEnabled(enable);
//Now we don't want allow user call context menu
sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP());
@@ -3178,6 +3207,7 @@ void MainWindow::CreateActions()
}
connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements);
+ connect(ui->actionUnloadMeasurements, &QAction::triggered, this, &MainWindow::UnloadMeasurements);
}
//---------------------------------------------------------------------------------------------------------------------
@@ -3336,6 +3366,7 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
}
else
{
+ ui->actionUnloadMeasurements->setEnabled(true);
watcher->addPath(path);
ui->actionShowM->setEnabled(true);
}
diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h
index d633f9986..87e5aa907 100644
--- a/src/app/valentina/mainwindow.h
+++ b/src/app/valentina/mainwindow.h
@@ -163,6 +163,7 @@ protected:
private slots:
void LoadIndividual();
void LoadStandard();
+ void UnloadMeasurements();
void CreateMeasurements();
void ShowMeasurements();
void MeasurementsChanged(const QString &path);
diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui
index d86d69f39..92cb7c1e5 100644
--- a/src/app/valentina/mainwindow.ui
+++ b/src/app/valentina/mainwindow.ui
@@ -1090,6 +1090,7 @@
+
@@ -1991,6 +1992,20 @@
+
+
+ false
+
+
+ Unload measurements
+
+
+ Unload measurements if they was not used in a pattern file.
+
+
+
+
+
@@ -2004,8 +2019,8 @@
toolButtonSplinePath
-
+
diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp
index acb1113f2..990b0578c 100644
--- a/src/libs/ifc/xml/vabstractpattern.cpp
+++ b/src/libs/ifc/xml/vabstractpattern.cpp
@@ -457,12 +457,6 @@ QString VAbstractPattern::MPath() const
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPath(const QString &path)
{
- if (path.isEmpty())
- {
- qDebug()<<"Path to measurements is empty"<