[vlmc-devel] commit: Workspace: Avoid having a workspace and a project dir. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Jun 27 23:06:25 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Jun 23 00:12:15 2010 +0200| [0cd238f3763d293e917b30b8a41802730abf3c2f] | committer: Hugo Beauzée-Luyssen 

Workspace: Avoid having a workspace and a project dir.

Everything will be stored in a project dir.
This is probably not functionnal as it is, and require much work.

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

 src/Gui/project/GuiProjectManager.cpp |    6 +++---
 src/Gui/wizard/GeneralPage.cpp        |    6 +++---
 src/Gui/wizard/WelcomePage.cpp        |    4 ++--
 src/Library/Library.cpp               |    4 ++--
 src/Library/MediaContainer.cpp        |    2 +-
 src/Project/ProjectManager.cpp        |   15 +++++++--------
 src/Project/ProjectManager.h          |    4 ++--
 7 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index 469f856..b69b040 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -97,7 +97,7 @@ GUIProjectManager::createNewProjectFile( bool saveAs )
     {
         QString outputFileName =
             QFileDialog::getSaveFileName( NULL, "Enter the output file name",
-                                          VLMC_PROJECT_GET_STRING( "general/ProjectDir" ),
+                                          VLMC_PROJECT_GET_STRING( "general/Workspace" ),
                                           "VLMC project file(*.vlmc)" );
         if ( outputFileName.length() == 0 )
             return false;
@@ -257,10 +257,10 @@ GUIProjectManager::loadProject( const QString &fileName )
 void
 GUIProjectManager::loadProject()
 {
+    //FIXME: Have a default path to store projects
     QString fileName =
             QFileDialog::getOpenFileName( NULL, "Enter the output file name",
-                                          VLMC_GET_STRING( "general/VLMCWorkspace" ),
-                                          "VLMC project file(*.vlmc)" );
+                                            QString(), "VLMC project file(*.vlmc)" );
     if ( fileName.length() <= 0 ) //If the user canceled.
         return ;
     loadProject( fileName );
diff --git a/src/Gui/wizard/GeneralPage.cpp b/src/Gui/wizard/GeneralPage.cpp
index 094dea0..241a82d 100644
--- a/src/Gui/wizard/GeneralPage.cpp
+++ b/src/Gui/wizard/GeneralPage.cpp
@@ -76,7 +76,8 @@ void GeneralPage::initializePage()
     ui.lineEditName->setText( projectName );
 
     //fetching the global workspace path
-    QString workspacePath = VLMC_GET_STRING( "general/VLMCWorkspace" );
+    //FIXME: have a default path to store projects.
+    QString workspacePath = QDir::homePath();
     ui.lineEditWorkspace->setText( workspacePath );
 
     updateProjectLocation();
@@ -109,7 +110,6 @@ bool GeneralPage::validatePage()
 
     QVariant projectName( ui.lineEditName->text() );
     sManager->setValue( "general/ProjectName", projectName, SettingsManager::Project );
-    sManager->setValue( "general/VLMCWorkspace", ui.lineEditWorkspace->text(), SettingsManager::Vlmc );
 
     //Create the project directory in the workspace dir.
     QString     projectPath = ui.lineEditName->text().replace( ' ', '_' );
@@ -117,7 +117,7 @@ bool GeneralPage::validatePage()
 
     if ( workspaceDir.exists( projectPath ) == false )
         workspaceDir.mkdir( projectPath );
-    sManager->setValue( "general/ProjectDir", ui.lineEditProjectLocation->text(), SettingsManager::Project );
+    sManager->setValue( "general/Workspace", ui.lineEditProjectLocation->text(), SettingsManager::Project );
     return true;
 }
 
diff --git a/src/Gui/wizard/WelcomePage.cpp b/src/Gui/wizard/WelcomePage.cpp
index 582a106..564bb50 100644
--- a/src/Gui/wizard/WelcomePage.cpp
+++ b/src/Gui/wizard/WelcomePage.cpp
@@ -132,10 +132,10 @@ void WelcomePage::loadRecentsProjects()
 
 void WelcomePage::loadProject()
 {
+    //FIXME: have a default path to store vlmc projects
     QString projectPath =
             QFileDialog::getOpenFileName( NULL, "Enter the output file name",
-                                          VLMC_GET_STRING( "general/VLMCWorkspace" ),
-                                          "VLMC project file(*.vlmc)" );
+                                          QDir::homePath(), "VLMC project file(*.vlmc)" );
 
     if ( projectPath.isEmpty() ) return;
 
diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 15a360f..ea9aed9 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -60,7 +60,8 @@ Library::loadProject( const QDomElement& doc )
             //If in workspace: compute the path in workspace
             if ( mrl.startsWith( Workspace::workspacePrefix ) == true )
             {
-                QString     projectPath = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
+                //Transforming the workspace://[path] into [project-path]/[path]
+                QString     projectPath = VLMC_PROJECT_GET_STRING( "general/Workspace" );
                 mrl = projectPath + mrl.mid( Workspace::workspacePrefix.length() );
             }
             Media*  m = addMedia( mrl );
@@ -108,4 +109,3 @@ Library::mediaLoaded( const Media* media )
     if ( m_nbMediaToLoad == 0 )
         emit projectLoaded();
 }
-
diff --git a/src/Library/MediaContainer.cpp b/src/Library/MediaContainer.cpp
index 08f10bc..fcd003f 100644
--- a/src/Library/MediaContainer.cpp
+++ b/src/Library/MediaContainer.cpp
@@ -208,7 +208,7 @@ MediaContainer::load( const QDomElement &clips, MediaContainer *parentMC )
 
             //Handle workspace stuff.
             if ( media.startsWith( Workspace::workspacePrefix ) == true )
-                media = media.replace( Workspace::workspacePrefix, VLMC_PROJECT_GET_STRING( "general/ProjectDir" ) );
+                media = media.replace( Workspace::workspacePrefix, VLMC_PROJECT_GET_STRING( "general/Workspace" ) );
             if ( m_medias.contains( media ) == true )
             {
                 Media*  m = m_medias[media];
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index dc3809f..f580434 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -58,15 +58,16 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
     VLMC_CREATE_PROJECT_INT( "audio/AudioSampleRate", 0,
                              QT_TRANSLATE_NOOP( "PreferenceWidget", "Audio samplerate" ),
                              QT_TRANSLATE_NOOP( "PreferenceWidget", "Output project audio samplerate" ) );
-    VLMC_CREATE_PREFERENCE_STRING( "general/VLMCWorkspace", QDir::homePath(),
-                                QT_TRANSLATE_NOOP( "PreferenceWidget", "Workspace location" ),
-                                QT_TRANSLATE_NOOP( "PreferenceWidget", "The place where all project's medias will be stored" ) );
+    //FIXME: Change this to have a default path for vlmc projects
+//    VLMC_CREATE_PREFERENCE_STRING( "general/VLMCWorkspace", QDir::homePath(),
+//                                QT_TRANSLATE_NOOP( "PreferenceWidget", "Workspace location" ),
+//                                QT_TRANSLATE_NOOP( "PreferenceWidget", "The place where all project's medias will be stored" ) );
 
     VLMC_CREATE_PROJECT_STRING( "general/ProjectName", unNamedProject,
                                 QT_TRANSLATE_NOOP( "PreferenceWidget", "Project name" ),
                                 QT_TRANSLATE_NOOP( "PreferenceWidget", "The project name" ) );
 
-    VLMC_CREATE_PRIVATE_PROJECT_STRING( "general/ProjectDir", "" );
+    VLMC_CREATE_PRIVATE_PROJECT_STRING( "general/Workspace", "" );
 
     //We have to wait for the library to be loaded before loading the workflow
     connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadWorkflow() ) );
@@ -119,6 +120,7 @@ void    ProjectManager::loadProject( const QString& fileName )
     if ( closeProject() == false )
         return ;
     m_projectFile = new QFile( fileName );
+    QFileInfo       fInfo( fileName );
     if ( m_projectFile->open( QFile::ReadOnly ) == false )
     {
         failedToLoad( tr( "Can't open project file. (%1)" ).arg( m_projectFile->errorString() ) );
@@ -143,10 +145,7 @@ void    ProjectManager::loadProject( const QString& fileName )
 
     //Load settings first, as it contains some informations about the workspace.
     SettingsManager::getInstance()->load( root );
-    QString     workspacePath = VLMC_GET_STRING("general/VLMCWorkspace");
-    QString     projectName = VLMC_PROJECT_GET_STRING("general/ProjectName");
-    QString     projectPath = workspacePath + '/' + projectName.replace( " ", "_" );
-    SettingsManager::getInstance()->setValue( "general/ProjectDir", projectPath, SettingsManager::Project );
+    SettingsManager::getInstance()->setValue( "general/Workspace", fInfo.absolutePath(), SettingsManager::Project );
     Library::getInstance()->loadProject( root );
 }
 
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index a579c0a..66622ad 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -65,7 +65,7 @@ protected:
      *
      *  In non GUI mode, this does nothing.
      */
-    virtual void    saveTimeline( QXmlStreamWriter& ){};
+    virtual void    saveTimeline( QXmlStreamWriter& ){}
     static bool     isBackupFile( const QString& projectFile );
     void            appendToRecentProject( const QString& projectName );
     /**
@@ -80,7 +80,7 @@ protected:
     virtual QString outputFileName() const;
 
     virtual void    failedToLoad( const QString& reason ) const;
-    virtual void    loadTimeline( const QDomElement& ){};
+    virtual void    loadTimeline( const QDomElement& ){}
     QString         createAutoSaveOutputFileName( const QString& baseName ) const;
 
     ProjectManager();



More information about the Vlmc-devel mailing list