[vlmc-devel] EffectHelper: Don't expose filterInfo

Yikai Lu git at videolan.org
Mon Aug 7 19:18:20 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Aug  8 00:54:42 2017 +0900| [cf9820a0296c290e7c3c482ec9b09ece1803685d] | committer: Yikai Lu

EffectHelper: Don't expose filterInfo

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

 src/Commands/Commands.cpp                      |  8 ++++----
 src/EffectsEngine/EffectHelper.cpp             | 27 +++++++++++++++++++++++++-
 src/EffectsEngine/EffectHelper.h               | 11 ++++++++---
 src/Gui/effectsengine/EffectInstanceWidget.cpp | 13 +++++--------
 src/Gui/effectsengine/EffectWidget.cpp         | 11 +++++------
 src/Gui/effectsengine/EffectWidget.h           |  9 ++++-----
 6 files changed, 52 insertions(+), 27 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 80d92f0b..98b5fde2 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -456,7 +456,7 @@ Commands::Effect::Add::Add( std::shared_ptr<EffectHelper> const& helper, Backend
 void
 Commands::Effect::Add::retranslate()
 {
-    setText( tr( "Adding effect %1" ).arg( QString::fromStdString( m_helper->filterInfo()->name() ) ) );
+    setText( tr( "Adding effect %1" ).arg( m_helper->name() ) );
 }
 
 void
@@ -487,7 +487,7 @@ Commands::Effect::Move::Move( std::shared_ptr<EffectHelper> const& helper, std::
 void
 Commands::Effect::Move::retranslate()
 {
-    setText( tr( "Moving effect %1" ).arg( QString::fromStdString( m_helper->filterInfo()->name() ) ) );
+    setText( tr( "Moving effect %1" ).arg( m_helper->name() ) );
 }
 
 void
@@ -530,7 +530,7 @@ Commands::Effect::Resize::Resize( std::shared_ptr<EffectHelper> const& helper, q
 void
 Commands::Effect::Resize::retranslate()
 {
-    setText( tr( "Resizing effect %1" ).arg( QString::fromStdString( m_helper->filterInfo()->name() ) ) );
+    setText( tr( "Resizing effect %1" ).arg( m_helper->name() ) );
 }
 
 void
@@ -555,7 +555,7 @@ Commands::Effect::Remove::Remove( std::shared_ptr<EffectHelper> const& helper )
 void
 Commands::Effect::Remove::retranslate()
 {
-    setText( tr( "Deleting effect %1" ).arg( QString::fromStdString( m_helper->filterInfo()->name() ) ) );
+    setText( tr( "Deleting effect %1" ).arg( m_helper->name() ) );
 }
 
 void
diff --git a/src/EffectsEngine/EffectHelper.cpp b/src/EffectsEngine/EffectHelper.cpp
index cda7259a..0552020a 100644
--- a/src/EffectsEngine/EffectHelper.cpp
+++ b/src/EffectsEngine/EffectHelper.cpp
@@ -121,6 +121,7 @@ EffectHelper::initParams()
         auto val = m_settings.createVar( type, QString::fromStdString( paramInfo->identifier() ),
                                          defaultValue( paramInfo->identifier().c_str(), type ), paramInfo->name().c_str(),
                                          paramInfo->description().c_str(), flags );
+        m_parameters << val;
 
         connect( val, &SettingValue::changed, this, [this, val]( const QVariant& variant ) { set( val, variant ); } );
     }
@@ -182,6 +183,12 @@ EffectHelper::value( const QString& key )
     return m_settings.value( key );
 }
 
+const QList<SettingValue*>&
+EffectHelper::parameters() const
+{
+    return m_parameters;
+}
+
 void
 EffectHelper::loadFromVariant( const QVariant& variant )
 {
@@ -288,7 +295,25 @@ EffectHelper::filterInfo()
 }
 
 QString
-EffectHelper::identifier()
+EffectHelper::identifier() const
 {
     return QString::fromStdString( m_filter->identifier() );
 }
+
+QString
+EffectHelper::name() const
+{
+    return QString::fromStdString( m_filterInfo->name() );
+}
+
+QString
+EffectHelper::description() const
+{
+    return QString::fromStdString( m_filterInfo->description() );
+}
+
+QString
+EffectHelper::author() const
+{
+    return QString::fromStdString( m_filterInfo->author() );
+}
diff --git a/src/EffectsEngine/EffectHelper.h b/src/EffectsEngine/EffectHelper.h
index 7db1e203..f9fab62a 100644
--- a/src/EffectsEngine/EffectHelper.h
+++ b/src/EffectsEngine/EffectHelper.h
@@ -69,14 +69,16 @@ class   EffectHelper : public Workflow::Helper
 
         void                setTarget( Backend::IInput* input );
 
-        Backend::IInfo*                 filterInfo();
-
-        QString                         identifier();
+        QString                         identifier() const;
+        QString                         name() const;
+        QString                         description() const;
+        QString                         author() const;
 
         std::shared_ptr<Backend::IFilter>               filter();
         const std::shared_ptr<Backend::IFilter>         filter() const;
 
         SettingValue*                   value( const QString& key );
+        const QList<SettingValue*>&     parameters() const;
 
         // Handle one filter.
         void                            loadFromVariant( const QVariant& variant );
@@ -91,7 +93,10 @@ class   EffectHelper : public Workflow::Helper
         Backend::IInfo*             m_filterInfo;
 
         Settings                    m_settings;
+        QList<SettingValue*>        m_parameters;
+
 
+        Backend::IInfo*             filterInfo();
         void                        set( SettingValue* value, const QVariant& variant );
         QVariant                    defaultValue( const char* id, SettingValue::Type type );
         void                        initParams();
diff --git a/src/Gui/effectsengine/EffectInstanceWidget.cpp b/src/Gui/effectsengine/EffectInstanceWidget.cpp
index f8f5b2e3..ebababd6 100644
--- a/src/Gui/effectsengine/EffectInstanceWidget.cpp
+++ b/src/Gui/effectsengine/EffectInstanceWidget.cpp
@@ -58,16 +58,13 @@ EffectInstanceWidget::setEffectHelper( std::shared_ptr<EffectHelper> const& help
 {
     clear();
     m_helper = helper;
-    m_ui->effectWidget->setFilterInfo( helper->filterInfo() );
+    m_ui->effectWidget->setEffectHelper( helper );
 
-    for ( auto param : helper->filterInfo()->paramInfos() )
+    for ( auto param : helper->parameters() )
     {
-        SettingValue*               s = helper->value( QString::fromStdString( param->identifier() ) );
-        ISettingsCategoryWidget*    widget = widgetFactory( s );
-        QLabel*                     label = new QLabel( tr( s->name() ), this );
-        m_widgets.push_back( label );
-        m_widgets.push_back( widget );
-        widget->setToolTip( s->description() );
+        ISettingsCategoryWidget*    widget = widgetFactory( param );
+        QLabel*                     label = new QLabel( param->name(), this );
+        widget->setToolTip( param->description() );
         m_ui->settingsLayout->addRow( label , widget );
         m_settings.push_back( widget );
     }
diff --git a/src/Gui/effectsengine/EffectWidget.cpp b/src/Gui/effectsengine/EffectWidget.cpp
index 4b2ddb97..1b227148 100644
--- a/src/Gui/effectsengine/EffectWidget.cpp
+++ b/src/Gui/effectsengine/EffectWidget.cpp
@@ -24,8 +24,7 @@
 # include "config.h"
 #endif
 
-#include "Backend/IFilter.h"
-#include "Backend/IInfo.h"
+#include "EffectsEngine/EffectHelper.h"
 #include "EffectWidget.h"
 #include "ui/EffectWidget.h"
 
@@ -42,12 +41,12 @@ EffectWidget::~EffectWidget()
 }
 
 void
-EffectWidget::setFilterInfo( Backend::IInfo* info )
+EffectWidget::setEffectHelper( std::shared_ptr<EffectHelper> const& effect )
 {
     clear();
-    m_ui->nameValueLabel->setText( QString::fromStdString( info->name() ) );
-    m_ui->descValueLabel->setText( QString::fromStdString( info->description() ) );
-    m_ui->authorValueLabel->setText( QString::fromStdString( info->author() ) );
+    m_ui->nameValueLabel->setText( effect->name() );
+    m_ui->descValueLabel->setText( effect->description() );
+    m_ui->authorValueLabel->setText( effect->author());
 
 }
 
diff --git a/src/Gui/effectsengine/EffectWidget.h b/src/Gui/effectsengine/EffectWidget.h
index 6631a141..dd829e6c 100644
--- a/src/Gui/effectsengine/EffectWidget.h
+++ b/src/Gui/effectsengine/EffectWidget.h
@@ -25,15 +25,14 @@
 
 #include <QWidget>
 
+#include <memory>
+
 namespace Ui
 {
     class EffectWidget;
 }
 
-namespace Backend
-{
-class IInfo;
-}
+class EffectHelper;
 
 class EffectWidget : public QWidget
 {
@@ -42,7 +41,7 @@ class EffectWidget : public QWidget
     public:
         explicit EffectWidget( QWidget *parent = 0 );
         ~EffectWidget();
-        void                setFilterInfo( Backend::IInfo* info );
+        void                setEffectHelper( std::shared_ptr<EffectHelper> const& effect );
         void                clear();
 
     private:



More information about the Vlmc-devel mailing list