"Maybe save" message.
--HG-- branch : feature
This commit is contained in:
parent
820d3dc9bd
commit
ac187de0c9
|
@ -120,6 +120,19 @@ void TMainWindow::FileOpen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
if (MaybeSave())
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::FileSave()
|
void TMainWindow::FileSave()
|
||||||
{
|
{
|
||||||
|
@ -495,3 +508,24 @@ bool TMainWindow::SaveMeasurements(const QString &fileName, QString &error)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool TMainWindow::MaybeSave()
|
||||||
|
{
|
||||||
|
if (this->isWindowModified())
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton ret;
|
||||||
|
ret = QMessageBox::warning(this, tr("Unsaved changes"), tr("Measurements have been modified.\n"
|
||||||
|
"Do you want to save your changes?"),
|
||||||
|
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||||
|
if (ret == QMessageBox::Save)
|
||||||
|
{
|
||||||
|
FileSave();
|
||||||
|
}
|
||||||
|
else if (ret == QMessageBox::Cancel)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -52,6 +52,9 @@ public slots:
|
||||||
void FileNew();
|
void FileNew();
|
||||||
void FileOpen();
|
void FileOpen();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void FileSave();
|
void FileSave();
|
||||||
void FileSaveAs();
|
void FileSaveAs();
|
||||||
|
@ -82,6 +85,8 @@ private:
|
||||||
void MeasurementsWasSaved(bool saved);
|
void MeasurementsWasSaved(bool saved);
|
||||||
void SetCurrentFile(const QString &fileName);
|
void SetCurrentFile(const QString &fileName);
|
||||||
bool SaveMeasurements(const QString &fileName, QString &error);
|
bool SaveMeasurements(const QString &fileName, QString &error);
|
||||||
|
|
||||||
|
bool MaybeSave();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TMAINWINDOW_H
|
#endif // TMAINWINDOW_H
|
||||||
|
|
|
@ -2437,7 +2437,7 @@ bool MainWindow::MaybeSave()
|
||||||
if (this->isWindowModified() && guiEnabled)
|
if (this->isWindowModified() && guiEnabled)
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton ret;
|
QMessageBox::StandardButton ret;
|
||||||
ret = QMessageBox::warning(this, tr("Unsaved change"), tr("The pattern has been modified.\n"
|
ret = QMessageBox::warning(this, tr("Unsaved changes"), tr("The pattern has been modified.\n"
|
||||||
"Do you want to save your changes?"),
|
"Do you want to save your changes?"),
|
||||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||||
if (ret == QMessageBox::Save)
|
if (ret == QMessageBox::Save)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user