Ask about changes before close file.

--HG--
branch : develop
This commit is contained in:
dismine 2014-11-13 14:38:55 +02:00
parent 1f0521ea30
commit 0d28b98602
2 changed files with 38 additions and 15 deletions

View File

@ -786,19 +786,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (MaybeSave()) if (MaybeSave())
{ {
WriteSettings(); FileClosedCorrect();
//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();
}
event->accept(); event->accept();
qApp->closeAllWindows(); qApp->closeAllWindows();
@ -1421,9 +1409,42 @@ void MainWindow::Clear()
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
qt_ntfs_permission_lookup--; // turn it off again qt_ntfs_permission_lookup--; // turn it off again
#endif /*Q_OS_WIN32*/ #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() void MainWindow::FullParseFile()
{ {
toolOptions->ClearPropertyBrowser(); toolOptions->ClearPropertyBrowser();
@ -2133,7 +2154,7 @@ void MainWindow::CreateActions()
connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties); connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties);
ui->actionPattern_properties->setEnabled(false); ui->actionPattern_properties->setEnabled(false);
connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode); 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); ui->actionEdit_pattern_code->setEnabled(false);
//Actions for recent files loaded by a main window application. //Actions for recent files loaded by a main window application.

View File

@ -81,6 +81,7 @@ public slots:
void ShowToolTip(const QString &toolTip); void ShowToolTip(const QString &toolTip);
void OpenRecentFile(); void OpenRecentFile();
void Clear(); void Clear();
void ResetWindow();
void currentPPChanged(int index); void currentPPChanged(int index);
void OptionDraw(); void OptionDraw();
@ -256,6 +257,7 @@ private:
void AddDocks(); void AddDocks();
void PropertyBrowser(); void PropertyBrowser();
void OpenNewValentina(const QString &fileName = QString())const; void OpenNewValentina(const QString &fileName = QString())const;
void FileClosedCorrect();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H