[vlmc-devel] ProjectManager: Move UI project file selection to MainWindow

Hugo Beauzée-Luyssen git at videolan.org
Mon Mar 31 17:59:21 CEST 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Mar 31 01:00:20 2014 +0300| [5cecf1d26a3dafb226a721a1e264810772940d6e] | committer: Hugo Beauzée-Luyssen

ProjectManager: Move UI project file selection to MainWindow

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=5cecf1d26a3dafb226a721a1e264810772940d6e
---

 src/Gui/MainWindow.cpp                |    7 ++++++-
 src/Gui/project/GuiProjectManager.cpp |    7 +------
 src/Gui/project/GuiProjectManager.h   |    2 +-
 src/Project/ProjectManager.cpp        |   14 ++------------
 src/Project/ProjectManager.h          |    5 +----
 5 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 9e595c8..802432a 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -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
diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index cb64761..6a86ee3 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -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)" ) );
 }
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index e15fe46..840bad2 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -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();
 };
 
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index cc3a3cc..2d7c7d6 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -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 );
@@ -273,16 +273,6 @@ ProjectManager::newProject( const QString &projectName, const QString &workspace
 }
 
 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 )
 {
     if ( fileName.isEmpty() == true )
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index ef58c15..3ddd8ec 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -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.



More information about the Vlmc-devel mailing list