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
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
......
......@@ -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() );
}
......@@ -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();
......
......@@ -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 );
}
......
......@@ -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());
}
......
......@@ -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:
......
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