Commit cf9820a0 authored by luyikei's avatar luyikei

EffectHelper: Don't expose filterInfo

parent 21f21b65
...@@ -456,7 +456,7 @@ Commands::Effect::Add::Add( std::shared_ptr<EffectHelper> const& helper, Backend ...@@ -456,7 +456,7 @@ Commands::Effect::Add::Add( std::shared_ptr<EffectHelper> const& helper, Backend
void void
Commands::Effect::Add::retranslate() 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 void
...@@ -487,7 +487,7 @@ Commands::Effect::Move::Move( std::shared_ptr<EffectHelper> const& helper, std:: ...@@ -487,7 +487,7 @@ Commands::Effect::Move::Move( std::shared_ptr<EffectHelper> const& helper, std::
void void
Commands::Effect::Move::retranslate() 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 void
...@@ -530,7 +530,7 @@ Commands::Effect::Resize::Resize( std::shared_ptr<EffectHelper> const& helper, q ...@@ -530,7 +530,7 @@ Commands::Effect::Resize::Resize( std::shared_ptr<EffectHelper> const& helper, q
void void
Commands::Effect::Resize::retranslate() 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 void
...@@ -555,7 +555,7 @@ Commands::Effect::Remove::Remove( std::shared_ptr<EffectHelper> const& helper ) ...@@ -555,7 +555,7 @@ Commands::Effect::Remove::Remove( std::shared_ptr<EffectHelper> const& helper )
void void
Commands::Effect::Remove::retranslate() 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 void
......
...@@ -121,6 +121,7 @@ EffectHelper::initParams() ...@@ -121,6 +121,7 @@ EffectHelper::initParams()
auto val = m_settings.createVar( type, QString::fromStdString( paramInfo->identifier() ), auto val = m_settings.createVar( type, QString::fromStdString( paramInfo->identifier() ),
defaultValue( paramInfo->identifier().c_str(), type ), paramInfo->name().c_str(), defaultValue( paramInfo->identifier().c_str(), type ), paramInfo->name().c_str(),
paramInfo->description().c_str(), flags ); paramInfo->description().c_str(), flags );
m_parameters << val;
connect( val, &SettingValue::changed, this, [this, val]( const QVariant& variant ) { set( val, variant ); } ); connect( val, &SettingValue::changed, this, [this, val]( const QVariant& variant ) { set( val, variant ); } );
} }
...@@ -182,6 +183,12 @@ EffectHelper::value( const QString& key ) ...@@ -182,6 +183,12 @@ EffectHelper::value( const QString& key )
return m_settings.value( key ); return m_settings.value( key );
} }
const QList<SettingValue*>&
EffectHelper::parameters() const
{
return m_parameters;
}
void void
EffectHelper::loadFromVariant( const QVariant& variant ) EffectHelper::loadFromVariant( const QVariant& variant )
{ {
...@@ -288,7 +295,25 @@ EffectHelper::filterInfo() ...@@ -288,7 +295,25 @@ EffectHelper::filterInfo()
} }
QString QString
EffectHelper::identifier() EffectHelper::identifier() const
{ {
return QString::fromStdString( m_filter->identifier() ); 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() );
}
...@@ -69,14 +69,16 @@ class EffectHelper : public Workflow::Helper ...@@ -69,14 +69,16 @@ class EffectHelper : public Workflow::Helper
void setTarget( Backend::IInput* input ); void setTarget( Backend::IInput* input );
Backend::IInfo* filterInfo(); QString identifier() const;
QString name() const;
QString identifier(); QString description() const;
QString author() const;
std::shared_ptr<Backend::IFilter> filter(); std::shared_ptr<Backend::IFilter> filter();
const std::shared_ptr<Backend::IFilter> filter() const; const std::shared_ptr<Backend::IFilter> filter() const;
SettingValue* value( const QString& key ); SettingValue* value( const QString& key );
const QList<SettingValue*>& parameters() const;
// Handle one filter. // Handle one filter.
void loadFromVariant( const QVariant& variant ); void loadFromVariant( const QVariant& variant );
...@@ -91,7 +93,10 @@ class EffectHelper : public Workflow::Helper ...@@ -91,7 +93,10 @@ class EffectHelper : public Workflow::Helper
Backend::IInfo* m_filterInfo; Backend::IInfo* m_filterInfo;
Settings m_settings; Settings m_settings;
QList<SettingValue*> m_parameters;
Backend::IInfo* filterInfo();
void set( SettingValue* value, const QVariant& variant ); void set( SettingValue* value, const QVariant& variant );
QVariant defaultValue( const char* id, SettingValue::Type type ); QVariant defaultValue( const char* id, SettingValue::Type type );
void initParams(); void initParams();
......
...@@ -58,16 +58,13 @@ EffectInstanceWidget::setEffectHelper( std::shared_ptr<EffectHelper> const& help ...@@ -58,16 +58,13 @@ EffectInstanceWidget::setEffectHelper( std::shared_ptr<EffectHelper> const& help
{ {
clear(); clear();
m_helper = helper; 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( param );
ISettingsCategoryWidget* widget = widgetFactory( s ); QLabel* label = new QLabel( param->name(), this );
QLabel* label = new QLabel( tr( s->name() ), this ); widget->setToolTip( param->description() );
m_widgets.push_back( label );
m_widgets.push_back( widget );
widget->setToolTip( s->description() );
m_ui->settingsLayout->addRow( label , widget ); m_ui->settingsLayout->addRow( label , widget );
m_settings.push_back( widget ); m_settings.push_back( widget );
} }
......
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
# include "config.h" # include "config.h"
#endif #endif
#include "Backend/IFilter.h" #include "EffectsEngine/EffectHelper.h"
#include "Backend/IInfo.h"
#include "EffectWidget.h" #include "EffectWidget.h"
#include "ui/EffectWidget.h" #include "ui/EffectWidget.h"
...@@ -42,12 +41,12 @@ EffectWidget::~EffectWidget() ...@@ -42,12 +41,12 @@ EffectWidget::~EffectWidget()
} }
void void
EffectWidget::setFilterInfo( Backend::IInfo* info ) EffectWidget::setEffectHelper( std::shared_ptr<EffectHelper> const& effect )
{ {
clear(); clear();
m_ui->nameValueLabel->setText( QString::fromStdString( info->name() ) ); m_ui->nameValueLabel->setText( effect->name() );
m_ui->descValueLabel->setText( QString::fromStdString( info->description() ) ); m_ui->descValueLabel->setText( effect->description() );
m_ui->authorValueLabel->setText( QString::fromStdString( info->author() ) ); m_ui->authorValueLabel->setText( effect->author());
} }
......
...@@ -25,15 +25,14 @@ ...@@ -25,15 +25,14 @@
#include <QWidget> #include <QWidget>
#include <memory>
namespace Ui namespace Ui
{ {
class EffectWidget; class EffectWidget;
} }
namespace Backend class EffectHelper;
{
class IInfo;
}
class EffectWidget : public QWidget class EffectWidget : public QWidget
{ {
...@@ -42,7 +41,7 @@ class EffectWidget : public QWidget ...@@ -42,7 +41,7 @@ class EffectWidget : public QWidget
public: public:
explicit EffectWidget( QWidget *parent = 0 ); explicit EffectWidget( QWidget *parent = 0 );
~EffectWidget(); ~EffectWidget();
void setFilterInfo( Backend::IInfo* info ); void setEffectHelper( std::shared_ptr<EffectHelper> const& effect );
void clear(); void clear();
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment