[vlmc-devel] Fetch project settings from the project class

Hugo Beauzée-Luyssen git at videolan.org
Sun Mar 27 17:03:53 CEST 2016


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sun Mar 27 13:51:30 2016 +0200| [42f262518786507ef122072eb7a7b26a704f1d3b] | committer: Hugo Beauzée-Luyssen

Fetch project settings from the project class

Remembering the setting names is annoying and error prone

> https://code.videolan.org/videolan/vlmc/commit/42f262518786507ef122072eb7a7b26a704f1d3b
---

 src/Gui/MainWindow.cpp              |  2 +-
 src/Gui/export/RendererSettings.cpp |  9 ++++----
 src/Gui/export/ShareOnInternet.cpp  |  2 +-
 src/Gui/timeline/TracksRuler.cpp    |  2 +-
 src/Project/Project.cpp             | 42 +++++++++++++++++++++++++++++++++++++
 src/Project/Project.h               |  9 ++++++++
 src/Renderer/WorkflowRenderer.cpp   |  8 +++----
 src/Settings/Settings.h             |  7 -------
 src/Workflow/ImageClipWorkflow.cpp  |  2 +-
 src/Workflow/VideoClipWorkflow.cpp  |  2 +-
 10 files changed, 65 insertions(+), 20 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 597c3a2..8c84449 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -682,7 +682,7 @@ MainWindow::on_actionShare_On_Internet_triggered()
 
         checkFolders();
         QString fileName = VLMC_GET_STRING( "vlmc/TempFolderLocation" ) + "/" +
-                           VLMC_PROJECT_GET_STRING( "vlmc/ProjectName" ) +
+                           Core::getInstance()->project()->name() +
                            "-vlmc.mp4";
 
         loadGlobalProxySettings();
diff --git a/src/Gui/export/RendererSettings.cpp b/src/Gui/export/RendererSettings.cpp
index 59e882f..1e3978c 100644
--- a/src/Gui/export/RendererSettings.cpp
+++ b/src/Gui/export/RendererSettings.cpp
@@ -35,6 +35,7 @@
 RendererSettings::RendererSettings( bool shareOnInternet )
 {
     m_ui.setupUi( this );
+    auto project = Core::getInstance()->project();
 
     if( shareOnInternet )
     {
@@ -43,13 +44,13 @@ RendererSettings::RendererSettings( bool shareOnInternet )
         m_ui.outputFileNameButton->setVisible( false );
         m_ui.outputFileName->setText(
             VLMC_GET_STRING( "vlmc/TempFolderLocation" ) + "/" +
-            VLMC_PROJECT_GET_STRING( "vlmc/ProjectName" ) + "-vlmc.mp4" );
+            project->name() + "-vlmc.mp4" );
         setWindowTitle( tr("Export Settings: Publish on Internet") );
     }
 
-    m_ui.width->setValue( VLMC_PROJECT_GET_INT( "video/VideoProjectWidth" ) );
-    m_ui.height->setValue( VLMC_PROJECT_GET_INT( "video/VideoProjectHeight" ) );
-    m_ui.fps->setValue( VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) );
+    m_ui.width->setValue( project->width() );
+    m_ui.height->setValue( project->height() );
+    m_ui.fps->setValue( project->fps() );
 
     QCompleter* completer = new QCompleter( this );
     completer->setModel( new QDirModel( completer ) );
diff --git a/src/Gui/export/ShareOnInternet.cpp b/src/Gui/export/ShareOnInternet.cpp
index d2c926e..84cbf84 100644
--- a/src/Gui/export/ShareOnInternet.cpp
+++ b/src/Gui/export/ShareOnInternet.cpp
@@ -46,7 +46,7 @@ ShareOnInternet::ShareOnInternet( QWidget* parent )
         case YOUTUBE:
             m_ui.username->setText( VLMC_GET_STRING( "youtube/Username" ) );
             m_ui.password->setText( VLMC_GET_STRING( "youtube/Password" ) );
-            m_ui.title->setText( VLMC_PROJECT_GET_STRING( "vlmc/ProjectName" ) );
+            m_ui.title->setText( Core::getInstance()->project()->name() );
             break;
     }
 }
diff --git a/src/Gui/timeline/TracksRuler.cpp b/src/Gui/timeline/TracksRuler.cpp
index bccdc52..b42d7ce 100644
--- a/src/Gui/timeline/TracksRuler.cpp
+++ b/src/Gui/timeline/TracksRuler.cpp
@@ -37,7 +37,7 @@ TracksRuler::TracksRuler( TracksView* tracksView, QWidget* parent )
 
     //TODO We should really get that from the
     // workflow and not directly from the settings.
-    m_fps = qRound( VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) );
+    m_fps = qRound( Core::getInstance()->project()->fps() );
 
     m_factor = 1;
     m_scale = 3;
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index 7bf2413..9150610 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -287,6 +287,48 @@ Project::removeBackupFile()
         autoBackup.remove();
 }
 
+QString
+Project::name() const
+{
+    return m_settings->value( "vlmc/ProjectName" )->get().toString();
+}
+
+double
+Project::fps() const
+{
+    return m_settings->value( "video/VLMCOutputFPS" )->get().toDouble();
+}
+
+unsigned int
+Project::width() const
+{
+    return m_settings->value( "video/VideoProjectWidth" )->get().toUInt();
+}
+
+unsigned int
+Project::height() const
+{
+    return m_settings->value( "video/VideoProjectHeight" )->get().toUInt();
+}
+
+QString
+Project::aspectRatio() const
+{
+    return m_settings->value( "video/AspectRatio" )->get().toString();
+}
+
+unsigned int
+Project::sampleRate() const
+{
+    return m_settings->value( "audio/AudioSampleRate" )->get().toUInt();
+}
+
+unsigned int
+Project::nbChannels() const
+{
+    return m_settings->value( "audio/NbChannels" )->get().toUInt();
+}
+
 QFile* Project::emergencyBackupFile()
 {
     const QString lastProject = Core::getInstance()->settings()->value( "private/EmergencyBackup" )->get().toString();
diff --git a/src/Project/Project.h b/src/Project/Project.h
index 6b7b35a..38595a2 100644
--- a/src/Project/Project.h
+++ b/src/Project/Project.h
@@ -73,6 +73,15 @@ class Project : public QObject
          */
         void            removeBackupFile();
 
+        // Settings getters
+        QString         name() const;
+        double          fps() const;
+        unsigned int    width() const;
+        unsigned int    height() const;
+        QString         aspectRatio() const;
+        unsigned int    sampleRate() const;
+        unsigned int    nbChannels() const;
+
     public:
         static QFile* emergencyBackupFile();
 
diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index e21c704..8f5bc2f 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -335,25 +335,25 @@ Backend::ISourceRenderer::MemoryInputUnlockCallback WorkflowRenderer::getUnlockC
 quint32
 WorkflowRenderer::width() const
 {
-    return VLMC_PROJECT_GET_UINT( "video/VideoProjectWidth" );
+    return Core::getInstance()->project()->width();
 }
 
 quint32
 WorkflowRenderer::height() const
 {
-    return VLMC_PROJECT_GET_UINT( "video/VideoProjectHeight" );
+    return Core::getInstance()->project()->height();
 }
 
 float
 WorkflowRenderer::outputFps() const
 {
-    return VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" );
+    return Core::getInstance()->project()->fps();
 }
 
 const QString
 WorkflowRenderer::aspectRatio() const
 {
-    return VLMC_PROJECT_GET_STRING("video/AspectRatio");
+    return Core::getInstance()->project()->aspectRatio();
 }
 
 bool
diff --git a/src/Settings/Settings.h b/src/Settings/Settings.h
index b53533b..b95b3a6 100644
--- a/src/Settings/Settings.h
+++ b/src/Settings/Settings.h
@@ -50,13 +50,6 @@ class QDomElement;
 #define VLMC_GET_STRINGLIST( key )  Core::getInstance()->settings()->value( key )->get().toStringList()
 #define VLMC_GET_BYTEARRAY( key )   Core::getInstance()->settings()->value( key )->get().toByteArray()
 
-#define VLMC_PROJECT_GET_STRING( key )  Core::getInstance()->project()->settings()->value( key )->get().toString()
-#define VLMC_PROJECT_GET_INT( key )     Core::getInstance()->project()->settings()->value( key )->get().toInt()
-#define VLMC_PROJECT_GET_UINT( key )    Core::getInstance()->project()->settings()->value( key )->get().toUInt()
-#define VLMC_PROJECT_GET_DOUBLE( key )  Core::getInstance()->project()->settings()->value( key )->get().toDouble()
-#define VLMC_PROJECT_GET_BOOL( key )    Core::getInstance()->project()->settings()->value( key )->get().toBool()
-
-
 #define VLMC_CREATE_PROJECT_VAR( type, key, defaultValue, name, desc, flags )  \
         Core::getInstance()->currentProject()->settings()->createVar( type, key, defaultValue, name, \
                                                        desc, flags );
diff --git a/src/Workflow/ImageClipWorkflow.cpp b/src/Workflow/ImageClipWorkflow.cpp
index db8619d..83cc8c3 100644
--- a/src/Workflow/ImageClipWorkflow.cpp
+++ b/src/Workflow/ImageClipWorkflow.cpp
@@ -58,7 +58,7 @@ void ImageClipWorkflow::initializeInternals()
     m_renderer->enableVideoOutputToMemory( this, &lock, &unlock, m_fullSpeedRender );
     m_renderer->setOutputWidth( m_width );
     m_renderer->setOutputHeight( m_height );
-    m_renderer->setOutputFps( (float)VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) );
+    m_renderer->setOutputFps( Core::getInstance()->project()->fps() );
     m_renderer->setOutputVideoCodec( "RV32" );
 
     m_effectFrame->resize( Core::getInstance()->workflow()->getWidth(),
diff --git a/src/Workflow/VideoClipWorkflow.cpp b/src/Workflow/VideoClipWorkflow.cpp
index 7b93eea..5e9faf6 100644
--- a/src/Workflow/VideoClipWorkflow.cpp
+++ b/src/Workflow/VideoClipWorkflow.cpp
@@ -78,7 +78,7 @@ VideoClipWorkflow::initializeInternals()
     m_renderer->enableVideoOutputToMemory( this, &lock, &unlock, m_fullSpeedRender );
     m_renderer->setOutputWidth( m_width );
     m_renderer->setOutputHeight( m_height );
-    m_renderer->setOutputFps( (float)VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) );
+    m_renderer->setOutputFps( Core::getInstance()->project()->fps() );
     m_renderer->setOutputVideoCodec( "RV32" );
 }
 



More information about the Vlmc-devel mailing list