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