Commit d3f18b52 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

qt4: preferences_widget: Use inheritance instead of switch.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 8d4f298b
...@@ -162,43 +162,6 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -162,43 +162,6 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
return p_control; return p_control;
} }
void ConfigControl::doApply( intf_thread_t *p_intf )
{
switch( getType() )
{
case CONFIG_ITEM_INTEGER:
case CONFIG_ITEM_BOOL:
{
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
assert( vicc );
config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
break;
}
case CONFIG_ITEM_FLOAT:
{
VFloatConfigControl *vfcc =
qobject_cast<VFloatConfigControl *>(this);
assert( vfcc );
config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
break;
}
case CONFIG_ITEM_STRING:
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(this);
assert( vscc );
config_PutPsz( p_intf, vscc->getName(), qtu( vscc->getValue() ) );
break;
}
case CONFIG_ITEM_KEY:
{
KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this);
assert( ksc );
ksc->doApply();
}
}
}
/******************************************************* /*******************************************************
* Simple widgets * Simple widgets
*******************************************************/ *******************************************************/
...@@ -241,6 +204,12 @@ void InterfacePreviewWidget::setPreview( enum_style e_style ) ...@@ -241,6 +204,12 @@ void InterfacePreviewWidget::setPreview( enum_style e_style )
* String-based controls * String-based controls
*************************************************************************/ *************************************************************************/
void
VStringConfigControl::doApply( intf_thread_t *p_intf )
{
config_PutPsz( p_intf, getName(), qtu( getValue() ) );
}
/*********** String **************/ /*********** String **************/
StringConfigControl::StringConfigControl( vlc_object_t *_p_this, StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
...@@ -844,6 +813,12 @@ void ModuleListConfigControl::onUpdate() ...@@ -844,6 +813,12 @@ void ModuleListConfigControl::onUpdate()
* Integer-based controls * Integer-based controls
*************************************************************************/ *************************************************************************/
void
VIntConfigControl::doApply( intf_thread_t *p_intf )
{
config_PutInt( p_intf, getName(), getValue() );
}
/*********** Integer **************/ /*********** Integer **************/
IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this, IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
...@@ -1123,6 +1098,12 @@ int BoolConfigControl::getValue() const ...@@ -1123,6 +1098,12 @@ int BoolConfigControl::getValue() const
* Float-based controls * Float-based controls
*************************************************************************/ *************************************************************************/
void
VFloatConfigControl::doApply( intf_thread_t *p_intf )
{
config_PutFloat( p_intf, getName(), getValue() );
}
/*********** Float **************/ /*********** Float **************/
FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this, FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
...@@ -1416,7 +1397,7 @@ void KeySelectorControl::setTheKey() ...@@ -1416,7 +1397,7 @@ void KeySelectorControl::setTheKey()
Qt::UserRole, shortcutValue->getValue() ); Qt::UserRole, shortcutValue->getValue() );
} }
void KeySelectorControl::doApply() void KeySelectorControl::doApply( intf_thread_t* )
{ {
QTreeWidgetItem *it; QTreeWidgetItem *it;
for( int i = 0; i < table->topLevelItemCount() ; i++ ) for( int i = 0; i < table->topLevelItemCount() ; i++ )
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
static ConfigControl * createControl( vlc_object_t*, static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*, module_config_t*,QWidget*,
QGridLayout *, int& ); QGridLayout *, int& );
void doApply( intf_thread_t *); virtual void doApply( intf_thread_t *) = 0;
protected: protected:
vlc_object_t *p_this; vlc_object_t *p_this;
module_config_t *p_item; module_config_t *p_item;
...@@ -127,6 +127,7 @@ public: ...@@ -127,6 +127,7 @@ public:
ConfigControl(a,b) {}; ConfigControl(a,b) {};
virtual int getValue() const = 0; virtual int getValue() const = 0;
virtual int getType() const { return CONFIG_ITEM_INTEGER; } virtual int getType() const { return CONFIG_ITEM_INTEGER; }
virtual void doApply( intf_thread_t *);
}; };
class IntegerConfigControl : public VIntConfigControl class IntegerConfigControl : public VIntConfigControl
...@@ -223,6 +224,7 @@ public: ...@@ -223,6 +224,7 @@ public:
ConfigControl(a,b) {}; ConfigControl(a,b) {};
virtual float getValue() const = 0; virtual float getValue() const = 0;
virtual int getType() const { return CONFIG_ITEM_FLOAT; } virtual int getType() const { return CONFIG_ITEM_FLOAT; }
virtual void doApply( intf_thread_t *);
}; };
class FloatConfigControl : public VFloatConfigControl class FloatConfigControl : public VFloatConfigControl
...@@ -270,6 +272,7 @@ public: ...@@ -270,6 +272,7 @@ public:
ConfigControl(a,b) {}; ConfigControl(a,b) {};
virtual QString getValue() const = 0; virtual QString getValue() const = 0;
virtual int getType() const { return CONFIG_ITEM_STRING; } virtual int getType() const { return CONFIG_ITEM_STRING; }
virtual void doApply( intf_thread_t *);
}; };
class StringConfigControl : public VStringConfigControl class StringConfigControl : public VStringConfigControl
...@@ -454,7 +457,7 @@ public: ...@@ -454,7 +457,7 @@ public:
virtual int getType() const { return CONFIG_ITEM_KEY; } virtual int getType() const { return CONFIG_ITEM_KEY; }
virtual void hide() { table->hide(); if( label ) label->hide(); } virtual void hide() { table->hide(); if( label ) label->hide(); }
virtual void show() { table->show(); if( label ) label->show(); } virtual void show() { table->show(); if( label ) label->show(); }
void doApply(); virtual void doApply( intf_thread_t *);
private: private:
void finish(); void finish();
QLabel *label; QLabel *label;
......
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