Commit d753473b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Change made to the project are now detected.

You're asked if you want to save your change, discard, or cancel.
parent c34d8b9c
......@@ -386,3 +386,31 @@ void MainWindow::on_actionProject_Wizard_triggered()
m_pWizard->show();
}
void MainWindow::closeEvent( QCloseEvent* e )
{
if ( ProjectManager::getInstance()->needSave() == true )
{
QMessageBox msgBox;
msgBox.setText( tr( "The project has been modified." ) );
msgBox.setInformativeText( tr( "Do you want to save it ?" ) );
msgBox.setStandardButtons( QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
switch ( ret )
{
case QMessageBox::Save:
ProjectManager::getInstance()->saveProject();
break ;
case QMessageBox::Discard:
break ;
case QMessageBox::Cancel:
default:
e->ignore();
return ;
e->accept();
}
}
else
e->accept();
}
......@@ -57,7 +57,8 @@ public slots:
void zoomOut();
protected:
virtual void changeEvent( QEvent *e );
virtual void changeEvent( QEvent *e );
virtual void closeEvent( QCloseEvent* e );
private:
void initializeDockWidgets( void );
......
......@@ -21,6 +21,7 @@
*****************************************************************************/
#include "UndoStack.h"
#include "ProjectManager.h"
UndoStack::UndoStack( QWidget* parent ) : QUndoView( parent )
{
......@@ -28,7 +29,8 @@ UndoStack::UndoStack( QWidget* parent ) : QUndoView( parent )
m_undoStack = new QUndoStack( this );
setStack( m_undoStack );
connect( m_undoStack, SIGNAL( cleanChanged(bool) ), this, SIGNAL( cleanChanged() ) );
connect( m_undoStack, SIGNAL( cleanChanged( bool ) ),
ProjectManager::getInstance(), SLOT( cleanChanged( bool ) ) );
m_undoShortcut = new QShortcut( QKeySequence( tr( "Ctrl+z", "Undo" ) ), this );
m_redoShortcut = new QShortcut( QKeySequence( tr( "Ctrl+Shift+z", "Redo" ) ), this );
......
......@@ -45,7 +45,7 @@ class UndoStack : public QUndoView, public QSingleton<UndoStack>
QShortcut* m_redoShortcut;
signals:
void cleanChanged();
void cleanChanged( bool val );
friend class QSingleton<UndoStack>;
};
......
......@@ -21,13 +21,14 @@
*****************************************************************************/
#include <QFileDialog>
#include <QtDebug>
#include "ProjectManager.h"
#include "Library.h"
#include "MainWorkflow.h"
#include "SettingsManager.h"
ProjectManager::ProjectManager() : m_projectFile( NULL )
ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
{
}
......@@ -37,6 +38,16 @@ ProjectManager::~ProjectManager()
delete m_projectFile;
}
bool ProjectManager::needSave() const
{
return m_needSave;
}
void ProjectManager::cleanChanged( bool val )
{
m_needSave = !val;
}
void ProjectManager::loadTimeline()
{
QDomElement root = m_domDocument->documentElement();
......
......@@ -36,6 +36,7 @@ class ProjectManager : public QObject, public Singleton<ProjectManager>
public:
void loadProject();
void saveProject();
bool needSave() const;
private:
ProjectManager();
......@@ -47,11 +48,13 @@ private:
private:
QFile* m_projectFile;
QDomDocument* m_domDocument;
bool m_needSave;
friend class Singleton<ProjectManager>;
private slots:
void loadTimeline();
void loadTimeline();
void cleanChanged( bool val );
};
#endif // PROJECTMANAGER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment