diff --git a/include/MainWindow.h b/include/MainWindow.h index c621059ad..5403238d7 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -58,9 +58,20 @@ public: void addSpacingToToolBar( int _size ); - // every function that replaces current file (e.g. creates new file, - // opens another file...) has to call this before and may only process - // if this function returns true + /// + /// \brief Asks whether changes made to the project are to be saved. + /// + /// Opens a dialog giving the user the choice to (a) confirm his choice + /// (such as opening a new file), (b) save the current project before + /// proceeding or (c) cancel the process. + /// + /// Every function that replaces the current file (e.g. creates new file, + /// opens another file...) must call this before and may only proceed if + /// this function returns true. + /// + /// \return true if the user allows the software to proceed, false if they + /// cancel the action. + /// bool mayChangeProject(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 9529c45e4..4f27d8ded 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -754,11 +754,14 @@ void MainWindow::updateRecentlyOpenedProjectsMenu() void MainWindow::openRecentlyOpenedProject( QAction * _action ) { - const QString & f = _action->text(); - setCursor( Qt::WaitCursor ); - engine::getSong()->loadProject( f ); - configManager::inst()->addRecentlyOpenedProject( f ); - setCursor( Qt::ArrowCursor ); + if ( mayChangeProject() ) + { + const QString & f = _action->text(); + setCursor( Qt::WaitCursor ); + engine::getSong()->loadProject( f ); + configManager::inst()->addRecentlyOpenedProject( f ); + setCursor( Qt::ArrowCursor ); + } }