Skip to content
Permalink
Browse files

Fix for ticket #64.

When quitting with a modified state the user is
prompted as to whether they want to save the project.
Qgis now also captures the window close event and treats it like a
File:Quit menu item.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5445 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m
g_j_m committed May 13, 2006
1 parent 07fe394 commit 868f1cf22e5ecc5ad8488d27f44aaf6789dbed18
Showing with 23 additions and 10 deletions.
  1. +19 −6 src/gui/qgisapp.cpp
  2. +4 −4 src/gui/qgisapp.h
@@ -2271,8 +2271,11 @@ findLayers_( QString const & fileFilters, list<QDomNode> const & layerNodes )

void QgisApp::fileExit()
{
removeAllLayers();
qApp->exit(0);
if (saveDirty() != QMessageBox::Cancel)
{
removeAllLayers();
qApp->exit(0);
}
}


@@ -2662,7 +2665,7 @@ bool QgisApp::addProject(QString projectFile)



void QgisApp::fileSave()
bool QgisApp::fileSave()
{
// if we don't have a filename, then obviously we need to get one; note
// that the project file name is reset to null in fileNew()
@@ -2697,7 +2700,7 @@ void QgisApp::fileSave()
{
// if they didn't select anything, just return
// delete saveFileDialog; auto_ptr auto destroys
return;
return false;
}

// make sure we have the .qgs extension in the file name
@@ -2746,7 +2749,7 @@ void QgisApp::fileSave()
Qt::NoButton );

}

return true;
} // QgisApp::fileSave


@@ -4319,7 +4322,8 @@ int QgisApp::saveDirty()
QMessageBox::Cancel | QMessageBox::Escape);
if (QMessageBox::Yes == answer )
{
fileSave();
if (!fileSave())
answer = QMessageBox::Cancel;
}
}

@@ -4330,6 +4334,15 @@ int QgisApp::saveDirty()
} // QgisApp::saveDirty()


void QgisApp::closeEvent(QCloseEvent* event)
{
// We'll close in our own good time, thank you very much
event->ignore();
// Do the usual checks and ask if they want to save, etc
fileExit();
}


void QgisApp::whatsThis()
{
QWhatsThis::enterWhatsThisMode();
@@ -212,8 +212,8 @@ public slots:
void saveWindowState();
//! Restore the window and toolbar state
void restoreWindowState();
//! Save project
void fileSave();
//! Save project. Returns true if the user selected a file to save to, false if not.
bool fileSave();
//! Save project as
void fileSaveAs();
//! Open the project file corresponding to the
@@ -396,8 +396,8 @@ public slots:
void pasteTransformations();
//! check to see if file is dirty and if so, prompt the user th save it
int saveDirty();
//! Set the pointer to the splash screen so status messages can be

//! Have some control over closing of the application
virtual void closeEvent(QCloseEvent* event);

/// QgisApp aren't copyable
QgisApp( QgisApp const & );

0 comments on commit 868f1cf

Please sign in to comment.
You can’t perform that action at this time.