Commit 5cecf1d2 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

ProjectManager: Move UI project file selection to MainWindow

parent 88fd63a8
......@@ -342,7 +342,12 @@ MainWindow::on_actionSave_As_triggered()
void
MainWindow::on_actionLoad_Project_triggered()
{
Project::getInstance()->projectManager()->loadProject();
// FIXME: We probably could use a default folder.
QString fileName = QFileDialog::getOpenFileName( NULL, tr( "Please choose a project file" ),
"", tr( "VLMC project file(*.vlmc)" ) );
if ( fileName.isEmpty() == true )
return ;
Project::getInstance()->projectManager()->loadProject( fileName );
}
void
......
......@@ -45,13 +45,8 @@ GUIProjectManager::shouldDeleteOutdatedBackupFile()
}
QString
GUIProjectManager::getProjectFile(const QString &defaultPath, bool isOpen)
GUIProjectManager::getProjectFileDestination( const QString &defaultPath )
{
if ( isOpen )
{
return QFileDialog::getOpenFileName( NULL, QObject::tr( "Please choose a project file" ),
defaultPath, QObject::tr( "VLMC project file(*.vlmc)" ) );
}
return QFileDialog::getSaveFileName( NULL, QObject::tr( "Enter the output file name" ),
defaultPath, QObject::tr( "VLMC project file(*.vlmc)" ) );
}
......
......@@ -30,7 +30,7 @@ class GUIProjectManager : public IProjectManagerUiCb
public:
virtual bool shouldLoadBackupFile();
virtual bool shouldDeleteOutdatedBackupFile();
virtual QString getProjectFile( const QString &defaultPath, bool isOpen );
virtual QString getProjectFileDestination( const QString &defaultPath );
virtual SaveMode shouldSaveBeforeClose();
};
......
......@@ -148,8 +148,8 @@ ProjectManager::saveAs()
{
if ( m_projectManagerUi == NULL )
return ;
const QString& fileName = m_projectManagerUi->getProjectFile(
m_projectSettings->value( "vlmc/Workspace" )->get().toString(), false );
const QString& fileName = m_projectManagerUi->getProjectFileDestination(
m_projectSettings->value( "vlmc/Workspace" )->get().toString() );
if ( fileName.isEmpty() )
return ;
saveProject( fileName );
......@@ -272,16 +272,6 @@ ProjectManager::newProject( const QString &projectName, const QString &workspace
emit projectLoaded( projectName, m_projectFile->fileName() );
}
void
ProjectManager::loadProject()
{
if ( m_projectManagerUi == NULL )
return ;
const QString workspace = m_projectSettings->value( "vlmc/Workspace" )->get().toString();
const QString& fileName = m_projectManagerUi->getProjectFile( workspace, true );
loadProject( fileName );
}
void
ProjectManager::loadProject( const QString &fileName )
{
......
......@@ -57,11 +57,9 @@ public:
/**
* @brief getProjectFile Ask the user where to save a new project
* @param defaultPath A default project location, if any.
* @param isOpen True if the project will be opened, false if it's about to
* be saved.
* @return The selected project file
*/
virtual QString getProjectFile( const QString& defaultPath, bool isOpen ) = 0;
virtual QString getProjectFileDestination( const QString& defaultPath ) = 0;
/**
* @brief shouldLoadBackupFile
......@@ -99,7 +97,6 @@ public:
bool hasProjectLoaded() const;
void newProject( const QString& projectName, const QString &workspacePath );
void loadProject();
/**
* @brief Check for a project backup file, and load the appropriate file,
* according to the user input.
......
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