[vlmc-devel] commit: ProjectManager: Check for a backup file even when the project is loaded from the CLI. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Tue Jun 1 02:20:01 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Jun  1 02:22:12 2010 +0200| [07e5caa0d0509b5ee3d4bd441e42c463c91e1490] | committer: Hugo Beauzée-Luyssen 

ProjectManager: Check for a backup file even when the project is loaded from the CLI.

This is not performed in non GUI mode.

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

 src/Gui/project/GuiProjectManager.cpp |   25 ++++++++++++++++---------
 src/Gui/project/GuiProjectManager.h   |   11 +++++++++--
 src/Main/guimain.cpp                  |    2 +-
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index 1b4bddc..6ad7473 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -215,19 +215,14 @@ GUIProjectManager::loadTimeline( const QDomElement &root )
 }
 
 void
-GUIProjectManager::loadProject()
+GUIProjectManager::loadProject( const QString &fileName )
 {
-    QString fileName =
-            QFileDialog::getOpenFileName( NULL, "Enter the output file name",
-                                          VLMC_PROJECT_GET_STRING( "general/VLMCWorkspace" ),
-                                          "VLMC project file(*.vlmc)" );
-    if ( fileName.length() <= 0 ) //If the user canceled.
-        return ;
     QFile   projectFile( fileName );
     //If for some reason this happens... better safe than sorry
     if ( projectFile.exists() == false )
         return ;
 
+    QString fileToLoad = fileName;
     QString backupFilename = createAutoSaveOutputFileName( fileName );
     QFile   autoBackup( backupFilename );
     if ( autoBackup.exists() == true )
@@ -242,7 +237,7 @@ GUIProjectManager::loadProject()
                                         "Do you want to load it ?" ),
                                         QMessageBox::Ok | QMessageBox::No ) == QMessageBox::Ok )
             {
-                fileName = backupFilename;
+                fileToLoad = backupFilename;
             }
         }
         else
@@ -256,5 +251,17 @@ GUIProjectManager::loadProject()
             }
         }
     }
-    ProjectManager::loadProject( fileName );
+    ProjectManager::loadProject( fileToLoad );
+}
+
+void
+GUIProjectManager::loadProject()
+{
+    QString fileName =
+            QFileDialog::getOpenFileName( NULL, "Enter the output file name",
+                                          VLMC_PROJECT_GET_STRING( "general/VLMCWorkspace" ),
+                                          "VLMC project file(*.vlmc)" );
+    if ( fileName.length() <= 0 ) //If the user canceled.
+        return ;
+    loadProject( fileName );
 }
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index a202f07..44930e3 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -52,10 +52,17 @@ public:
     /**
      *  \brief      Display the open file name dialog, and call the actual project loading
      *              method.
-     *
-     *  \warning    This is not an overload for the ProjectManager::loadProject() method.
      */
     void            loadProject();
+    /**
+     *  \brief      Check for a project backup file, and load the appropriate file,
+     *              according to the user input.
+     *
+     *  if an outdated project backup is found, the used is asked if she wants to delete
+     *  it.
+     *  This is handled here as there's no use for this in non-GUI mode.
+     */
+    void            loadProject( const QString& fileName );
 
 protected:
     virtual void    failedToLoad( const QString &reason ) const;
diff --git a/src/Main/guimain.cpp b/src/Main/guimain.cpp
index f6520c6..2bb72ce 100644
--- a/src/Main/guimain.cpp
+++ b/src/Main/guimain.cpp
@@ -102,7 +102,7 @@ VLMCmain( int argc, char **argv )
 
     MainWindow w;
     if ( argc > 1 )
-        GUIProjectManager::getInstance()->ProjectManager::loadProject( argv[argc - 1] );
+        GUIProjectManager::getInstance()->loadProject( argv[argc - 1] );
     w.show();
     return app.exec();
 }



More information about the Vlmc-devel mailing list