Skip to content

Commit

Permalink
Fix for ticket #64.
Browse files Browse the repository at this point in the history
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 committed May 13, 2006
1 parent 07fe394 commit 868f1cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
25 changes: 19 additions & 6 deletions src/gui/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2746,7 +2749,7 @@ void QgisApp::fileSave()
Qt::NoButton );

}

return true;
} // QgisApp::fileSave


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

Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 & );
Expand Down

0 comments on commit 868f1cf

Please sign in to comment.