diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 7f1f6af46..a42c603c6 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -786,19 +786,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { if (MaybeSave()) { - WriteSettings(); - - //File was closed correct. - QStringList restoreFiles = qApp->getSettings()->value("restoreFileList").toStringList(); - restoreFiles.removeAll(curFile); - qApp->getSettings()->setValue("restoreFileList", restoreFiles); - - // Remove autosave file - QFile autofile(curFile +".autosave"); - if (autofile.exists()) - { - autofile.remove(); - } + FileClosedCorrect(); event->accept(); qApp->closeAllWindows(); @@ -1421,9 +1409,42 @@ void MainWindow::Clear() #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ - + qApp->getUndoStack()->clear(); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::FileClosedCorrect() +{ + WriteSettings(); + + //File was closed correct. + QStringList restoreFiles = qApp->getSettings()->value("restoreFileList").toStringList(); + restoreFiles.removeAll(curFile); + qApp->getSettings()->setValue("restoreFileList", restoreFiles); + + // Remove autosave file + QFile autofile(curFile +".autosave"); + if (autofile.exists()) + { + autofile.remove(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ResetWindow() +{ + if (MaybeSave()) + { + FileClosedCorrect(); + } + else + { + return; + } + Clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- void MainWindow::FullParseFile() { toolOptions->ClearPropertyBrowser(); @@ -2133,7 +2154,7 @@ void MainWindow::CreateActions() connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties); ui->actionPattern_properties->setEnabled(false); connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode); - connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::Clear); + connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow); ui->actionEdit_pattern_code->setEnabled(false); //Actions for recent files loaded by a main window application. diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 0169846c4..57e12f321 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -81,6 +81,7 @@ public slots: void ShowToolTip(const QString &toolTip); void OpenRecentFile(); void Clear(); + void ResetWindow(); void currentPPChanged(int index); void OptionDraw(); @@ -256,6 +257,7 @@ private: void AddDocks(); void PropertyBrowser(); void OpenNewValentina(const QString &fileName = QString())const; + void FileClosedCorrect(); }; #endif // MAINWINDOW_H