From af7bff14cf471e3ec9dd1e1f5df29599cc3be5ab Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 10 Sep 2014 19:59:38 +0200 Subject: [PATCH] Offer to save changes when closing a dialog. --- .../georges_editor/georges_dock_widget.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp b/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp index 9602a7678..e031fbc8f 100644 --- a/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp +++ b/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp @@ -17,6 +17,7 @@ // along with this program. If not, see . #include "georges_dock_widget.h" +#include GeorgesDockWidget::GeorgesDockWidget( QWidget *parent ) : QDockWidget( parent ) @@ -31,6 +32,26 @@ GeorgesDockWidget::~GeorgesDockWidget() void GeorgesDockWidget::closeEvent( QCloseEvent *e ) { + if( isModified() ) + { + QString title = windowTitle(); + title.remove( '*' ); + + int reply = QMessageBox::question( this, + tr( "Closing dialog" ), + title + tr( " has been modified.\nWould you like to save the changes?" ), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); + + if( reply == QMessageBox::Cancel ) + { + e->ignore(); + return; + } + + if( reply == QMessageBox::Yes ) + write(); + } + Q_EMIT closing( this ); }