Added message box about did not saved changes.

This commit is contained in:
dismine 2013-09-26 16:47:46 +03:00
parent d28265b3dc
commit 0f5d2c0720
2 changed files with 37 additions and 0 deletions

View File

@ -155,6 +155,7 @@ void MainWindow::ActionNewDraw(){
VDrawTool::AddRecord(id, Tools::SinglePointTool, doc);
SetEnableTool(true);
SetEnableWidgets(true);
changeInFile = true;
}
void MainWindow::OptionDraw(){
@ -457,6 +458,41 @@ void MainWindow::showEvent( QShowEvent *event ){
isInitialized = true;//first show windows are held
}
void MainWindow::closeEvent(QCloseEvent *event){
if(changeInFile == true){
QMessageBox msgBox;
msgBox.setText("The pattern has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
msgBox.setIcon(QMessageBox::Question);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Save:
// Save was clicked
if(fileName.isEmpty()){
ActionSaveAs();
} else {
ActionSave();
}
event->accept();
break;
case QMessageBox::Discard:
// Don't Save was clicked
event->accept();
break;
case QMessageBox::Cancel:
// Cancel was clicked
event->ignore();
break;
default:
// should never be reached
event->accept();
break;
}
}
}
void MainWindow::ToolBarOption(){
QLabel * labelGrowth = new QLabel;
labelGrowth->setText(tr("Growth: "));

View File

@ -108,6 +108,7 @@ signals:
protected:
virtual void keyPressEvent ( QKeyEvent * event );
virtual void showEvent( QShowEvent *event );
virtual void closeEvent( QCloseEvent * event );
void Clear();
private:
Ui::MainWindow *ui;