Offer to save changes when closing a dialog.
This commit is contained in:
parent
8394ce3796
commit
d5d14619b0
1 changed files with 21 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "georges_dock_widget.h"
|
#include "georges_dock_widget.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
GeorgesDockWidget::GeorgesDockWidget( QWidget *parent ) :
|
GeorgesDockWidget::GeorgesDockWidget( QWidget *parent ) :
|
||||||
QDockWidget( parent )
|
QDockWidget( parent )
|
||||||
|
@ -31,6 +32,26 @@ GeorgesDockWidget::~GeorgesDockWidget()
|
||||||
|
|
||||||
void GeorgesDockWidget::closeEvent( QCloseEvent *e )
|
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 );
|
Q_EMIT closing( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue