[vlmc-devel] Move showEffectStack from Timeline to MainWorkflow

Yikai Lu git at videolan.org
Fri Aug 12 16:52:36 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Fri Aug 12 09:35:56 2016 -0500| [a726e8255c8783736002a38676dd9c2942e6a1f9] | committer: Yikai Lu

Move showEffectStack from Timeline to MainWorkflow

> https://code.videolan.org/videolan/vlmc/commit/a726e8255c8783736002a38676dd9c2942e6a1f9
---

 src/Gui/timeline/Clip.qml            |  2 +-
 src/Gui/timeline/ClipContextMenu.qml |  2 +-
 src/Gui/timeline/Timeline.cpp        | 15 ---------------
 src/Gui/timeline/Timeline.h          |  4 ----
 src/Gui/timeline/Track.qml           |  2 +-
 src/Workflow/MainWorkflow.cpp        | 35 ++++++++++++++++++++---------------
 src/Workflow/MainWorkflow.h          | 14 ++++++++++----
 7 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index a773bf9..5364198 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -369,7 +369,7 @@ Rectangle {
             anchors.fill: parent
             hoverEnabled: true
             onClicked: {
-                timeline.showEffectStack( uuid );
+                workflow.showEffectStack( uuid );
             }
         }
 
diff --git a/src/Gui/timeline/ClipContextMenu.qml b/src/Gui/timeline/ClipContextMenu.qml
index 2473773..64dd89a 100644
--- a/src/Gui/timeline/ClipContextMenu.qml
+++ b/src/Gui/timeline/ClipContextMenu.qml
@@ -68,7 +68,7 @@ Menu {
         text: "Effects"
 
         onTriggered: {
-            timeline.showEffectStack( clip.uuid );
+            workflow.showEffectStack( clip.uuid );
         }
     }
 }
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index f800478..55aeb59 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -57,18 +57,3 @@ Timeline::container()
 {
     return m_container;
 }
-
-void
-Timeline::showEffectStack( quint32 trackId )
-{
-    auto w = new EffectStack( Core::instance()->workflow()->trackInput( trackId ) );
-    w->show();
-}
-
-void
-Timeline::showEffectStack( const QString& uuid )
-{
-    auto w = new EffectStack( Core::instance()->workflow()->clipInput( uuid ) );
-    connect( w, &EffectStack::finished, Core::instance()->workflow(), [uuid]{ emit Core::instance()->workflow()->effectsUpdated( uuid ); } );
-    w->show();
-}
diff --git a/src/Gui/timeline/Timeline.h b/src/Gui/timeline/Timeline.h
index 3305751..b204bb6 100644
--- a/src/Gui/timeline/Timeline.h
+++ b/src/Gui/timeline/Timeline.h
@@ -45,10 +45,6 @@ public:
     QWidget*            container();
 
 public slots:
-
-    void showEffectStack( quint32 trackId );
-    void showEffectStack( const QString& uuid );
-
     /**
      * \brief Change the currently selected tool.
      */
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 3a17bc8..802dd79 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -394,7 +394,7 @@ Item {
 
                 onSelectedChanged: {
                     if ( selected === false ) {
-                        timeline.showEffectStack( trackId );
+                        workflow.showEffectStack( trackId );
                         selected = true;
                     }
                 }
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index d8765d7..b52eca7 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -35,6 +35,7 @@
 #include "Renderer/AbstractRenderer.h"
 #ifdef HAVE_GUI
 #include "EffectsEngine/EffectHelper.h"
+#include "Gui/effectsengine/EffectStack.h"
 #include "Gui/WorkflowFileRendererDialog.h"
 #endif
 #include "Project/Project.h"
@@ -139,25 +140,29 @@ MainWorkflow::setFps( double fps )
     emit fpsChanged( fps );
 }
 
-AbstractRenderer*
-MainWorkflow::renderer()
+void
+MainWorkflow::showEffectStack( quint32 trackId )
 {
-    return m_renderer;
+#ifdef HAVE_GUI
+    auto w = new EffectStack( m_sequenceWorkflow->trackInput( trackId ) );
+    w->show();
+#endif
 }
 
-Backend::IInput*
-MainWorkflow::clipInput( const QString& uuid )
+void
+MainWorkflow::showEffectStack( const QString& uuid )
 {
-    auto clip = m_sequenceWorkflow->clip( uuid );
-    if ( clip )
-        return clip->input();
-    return nullptr;
+#ifdef HAVE_GUI
+    auto w = new EffectStack( m_sequenceWorkflow->clip( uuid )->input() );
+    connect( w, &EffectStack::finished, Core::instance()->workflow(), [uuid]{ emit Core::instance()->workflow()->effectsUpdated( uuid ); } );
+    w->show();
+#endif
 }
 
-Backend::IInput*
-MainWorkflow::trackInput( quint32 trackId )
+AbstractRenderer*
+MainWorkflow::renderer()
 {
-    return m_sequenceWorkflow->trackInput( trackId );
+    return m_renderer;
 }
 
 Commands::AbstractUndoStack*
@@ -273,10 +278,10 @@ MainWorkflow::addEffect( const QString &clipUuid, const QString &effectId )
         return QStringLiteral( "" );
     }
 
-    auto clipI = clipInput( clipUuid );
-    if ( clipI != nullptr )
+    auto clip = m_sequenceWorkflow->clip( clipUuid );
+    if ( clip && clip->input() )
     {
-        trigger( new Commands::Effect::Add( newEffect, clipI ) );
+        trigger( new Commands::Effect::Add( newEffect, clip->input() ) );
         emit effectsUpdated( clipUuid );
         return newEffect->uuid().toString();
     }
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 8bf2900..eeb15ba 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -25,6 +25,10 @@
 #ifndef MAINWORKFLOW_H
 #define MAINWORKFLOW_H
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "Types.h"
 #include <QJsonObject>
 
@@ -157,10 +161,6 @@ class   MainWorkflow : public QObject
 
         AbstractRenderer*       renderer();
 
-        // Only for showEffectStack
-        Backend::IInput*        clipInput( const QString& uuid );
-        Backend::IInput*        trackInput( quint32 trackId );
-
         Commands::AbstractUndoStack*       undoStack();
 
     private:
@@ -206,6 +206,12 @@ class   MainWorkflow : public QObject
 
         void                            setFps( double fps );
 
+        // FIXME: We can't use #ifdef HAVE_GUI here because qml files can't find them
+        //        You'll get:
+        //        TypeError: Property 'showEffectStack' of object MainWorkflow is not a function
+        void                            showEffectStack( quint32 trackId );
+        void                            showEffectStack( const QString& uuid );
+
     signals:
         /**
          *  \brief      Used to notify a change to the timeline and preview widget cursor



More information about the Vlmc-devel mailing list