[vlmc-devel] Settings: Project and Library

Yikai Lu git at videolan.org
Sat Apr 9 22:18:05 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sat Apr  9 11:44:04 2016 +0900| [593cb0a6f545bde605671b2f6a31d7e16039ce33] | committer: Hugo Beauzée-Luyssen

Settings: Project and Library

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> https://code.videolan.org/videolan/vlmc/commit/593cb0a6f545bde605671b2f6a31d7e16039ce33
---

 src/Library/Library.cpp | 10 +++++++++-
 src/Library/Library.h   |  6 ++++--
 src/Main/Core.cpp       |  4 ++--
 src/Project/Project.cpp | 20 ++++----------------
 4 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 66eb450..89c0353 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -40,9 +40,17 @@
 #include <QHash>
 #include <QUuid>
 
-Library::Library()
+Library::Library( Settings *projectSettings )
     : m_cleanState( true )
+    , m_settings( new Settings )
 {
+    m_settings->createVar( SettingValue::List, QString( "medias" ), QVariantList(), "", "", SettingValue::Nothing );
+    projectSettings->addSettings( "Library", *m_settings );
+}
+
+Library::~Library()
+{
+    delete m_settings;
 }
 
 void
diff --git a/src/Library/Library.h b/src/Library/Library.h
index a074511..3a0fd79 100644
--- a/src/Library/Library.h
+++ b/src/Library/Library.h
@@ -41,6 +41,7 @@ class Clip;
 class Media;
 class ProjectManager;
 class Workspace;
+class Settings;
 
 /**
  *  \class Library
@@ -52,8 +53,8 @@ class Library : public MediaContainer
     Q_DISABLE_COPY( Library );
 
 public:
-    Library();
-    virtual ~Library(){}
+    Library( Settings* projectSettings );
+    virtual ~Library();
     virtual void    addMedia( Media* media );
     virtual Media   *addMedia( const QFileInfo &fileInfo );
     virtual bool    addClip( Clip *clip );
@@ -67,6 +68,7 @@ private:
     bool        m_cleanState;
     Workspace*  m_workspace;
 
+    Settings*   m_settings;
 
 private slots:
     void    mediaLoaded( const Media* m );
diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
index 42b6681..9827d39 100644
--- a/src/Main/Core.cpp
+++ b/src/Main/Core.cpp
@@ -47,13 +47,13 @@ Core::Core()
     m_logger = new VlmcLogger;
 
     createSettings();
+    m_currentProject = new Project( m_settings );
+    m_library = new Library( m_currentProject->settings() );
     m_recentProjects = new RecentProjects( m_settings );
     m_workspace = new Workspace( m_settings );
     m_workflow = new MainWorkflow;
     m_workflowRenderer = new WorkflowRenderer( Backend::getBackend(), m_workflow );
     m_undoStack = new QUndoStack;
-    m_library = new Library;
-    m_currentProject = new Project( m_settings );
 
     connect( m_undoStack, &QUndoStack::cleanChanged, m_currentProject, &Project::cleanChanged );
     connect( m_currentProject, &Project::projectSaved, m_undoStack, &QUndoStack::setClean );
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index 69dac55..bbf71db 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -137,6 +137,8 @@ Project::load( const QString& path )
         doc.setContent( m_projectFile );
     }
 
+    m_settings->setSettingsFile( path );
+    m_settings->load();
     auto projectName = m_settings->value( "vlmc/ProjectName" )->get().toString();
     emit projectLoading( projectName );
     m_isClean = autoBackupFound == false;
@@ -228,22 +230,8 @@ Project::initSettings()
 void
 Project::saveProject( const QString& fileName )
 {
-    QByteArray          projectString;
-
-    QXmlStreamWriter    project( &projectString );
-
-    project.setAutoFormatting( true );
-    project.writeStartDocument();
-    project.writeStartElement( "vlmc" );
-
-    project.writeEndElement();
-    project.writeEndDocument();
-
-    // We are not necessarily saving the project to the "main" project file here
-    // so we don't use m_projectFile
-    QFile   projectFile( fileName );
-    projectFile.open( QFile::WriteOnly );
-    projectFile.write( projectString );
+    m_settings->setSettingsFile( fileName );
+    m_settings->save();
     emit projectSaved();
 }
 



More information about the Vlmc-devel mailing list