Commit 505d69ce authored by Ludovic Fauvet's avatar Ludovic Fauvet

Split the open file dialog from the ProjectManager

parent cd6e6ba4
...@@ -163,7 +163,8 @@ void MainWindow::on_actionSave_As_triggered() ...@@ -163,7 +163,8 @@ void MainWindow::on_actionSave_As_triggered()
void MainWindow::on_actionLoad_Project_triggered() void MainWindow::on_actionLoad_Project_triggered()
{ {
ProjectManager::getInstance()->loadProject(); ProjectManager* pm = ProjectManager::getInstance();
pm->loadProject( pm->loadProjectFile() );
} }
void MainWindow::createStatusBar() void MainWindow::createStatusBar()
......
...@@ -109,7 +109,8 @@ void ProjectWizard::reject() ...@@ -109,7 +109,8 @@ void ProjectWizard::reject()
void ProjectWizard::loadProject() void ProjectWizard::loadProject()
{ {
ProjectManager::getInstance()->loadProject(); ProjectManager* pm = ProjectManager::getInstance();
pm->loadProject( pm->loadProjectFile() );
restart(); restart();
QDialog::accept(); QDialog::accept();
} }
...@@ -65,10 +65,15 @@ void ProjectManager::loadTimeline() ...@@ -65,10 +65,15 @@ void ProjectManager::loadTimeline()
emit projectChanged( fInfo.fileName(), true ); emit projectChanged( fInfo.fileName(), true );
} }
void ProjectManager::loadProject() void ProjectManager::loadProject( const QString& fileName )
{ {
if ( loadProjectFile() == false ) if ( fileName.length() == 0 )
return ; return;
if ( !m_projectFile )
delete m_projectFile;
m_projectFile = new QFile( fileName );
m_domDocument = new QDomDocument; m_domDocument = new QDomDocument;
m_projectFile->open( QFile::ReadOnly ); m_projectFile->open( QFile::ReadOnly );
m_domDocument->setContent( m_projectFile ); m_domDocument->setContent( m_projectFile );
...@@ -81,17 +86,12 @@ void ProjectManager::loadProject() ...@@ -81,17 +86,12 @@ void ProjectManager::loadProject()
SettingsManager::getInstance()->loadSettings( "project", root.firstChildElement( "project" ) ); SettingsManager::getInstance()->loadSettings( "project", root.firstChildElement( "project" ) );
} }
bool ProjectManager::loadProjectFile() QString ProjectManager::loadProjectFile()
{ {
QString fileName = QString fileName =
QFileDialog::getOpenFileName( NULL, "Enter the output file name", QFileDialog::getOpenFileName( NULL, "Enter the output file name",
QString(), "VLMC project file(*.vlmc)" ); QString(), "VLMC project file(*.vlmc)" );
if ( fileName.length() == 0 ) return fileName;
return false;
if ( m_projectFile != NULL )
delete m_projectFile;
m_projectFile = new QFile( fileName );
return true;
} }
bool ProjectManager::checkProjectOpen( bool saveAs ) bool ProjectManager::checkProjectOpen( bool saveAs )
......
...@@ -34,16 +34,16 @@ class ProjectManager : public QObject, public Singleton<ProjectManager> ...@@ -34,16 +34,16 @@ class ProjectManager : public QObject, public Singleton<ProjectManager>
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY( ProjectManager ); Q_DISABLE_COPY( ProjectManager );
public: public:
void loadProject(); void loadProject( const QString& fileName );
void saveProject( bool saveAs = true ); QString loadProjectFile();
bool needSave() const; void saveProject( bool saveAs = true );
bool needSave() const;
private: private:
ProjectManager(); ProjectManager();
~ProjectManager(); ~ProjectManager();
bool checkProjectOpen( bool saveAs ); bool checkProjectOpen( bool saveAs );
bool loadProjectFile();
private: private:
QFile* m_projectFile; QFile* m_projectFile;
......
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