Commit 53157927 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: ConfigControl: don't instanciate unused widget per control.

Note that all current configcontrol are instanciated using the
existing gridlayout constructor by createConfigControl().
We probably can drop constructors for self contained configcontrols.
parent 28db7725
...@@ -220,6 +220,7 @@ StringConfigControl::StringConfigControl( vlc_object_t *_p_this, ...@@ -220,6 +220,7 @@ StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 ); layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 );
layout->addWidget( text, LAST_COLUMN ); layout->addWidget( text, LAST_COLUMN );
...@@ -281,6 +282,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this, ...@@ -281,6 +282,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( label, 0 );
layout->insertSpacing( 1, 10 ); layout->insertSpacing( 1, 10 );
...@@ -376,6 +378,7 @@ FontConfigControl::FontConfigControl( vlc_object_t *_p_this, ...@@ -376,6 +378,7 @@ FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
font->setCurrentFont( QFont( qfu( p_item->value.psz) ) ); font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
if( !_p_layout ) if( !_p_layout )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( label, 0 );
layout->addWidget( font, 1 ); layout->addWidget( font, 1 );
...@@ -424,6 +427,7 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, ...@@ -424,6 +427,7 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
finish( p_module_config ); finish( p_module_config );
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
l = new QGridLayout(); l = new QGridLayout();
l->addWidget( label, 0, 0 ); l->addWidget( combo, 0, LAST_COLUMN ); l->addWidget( label, 0, 0 ); l->addWidget( combo, 0, LAST_COLUMN );
widget->setLayout( l ); widget->setLayout( l );
...@@ -598,6 +602,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, ...@@ -598,6 +602,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
finish( bycat ); finish( bycat );
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN ); layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
widget->setLayout( layout ); widget->setLayout( layout );
...@@ -706,6 +711,7 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this, ...@@ -706,6 +711,7 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget( groupBox, line, 0 ); layout->addWidget( groupBox, line, 0 );
widget->setLayout( layout ); widget->setLayout( layout );
...@@ -878,6 +884,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this, ...@@ -878,6 +884,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN ); layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
widget->setLayout( layout ); widget->setLayout( layout );
...@@ -989,6 +996,7 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, ...@@ -989,6 +996,7 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
finish( p_module_config ); finish( p_module_config );
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN ); layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
widget->setLayout( layout ); widget->setLayout( layout );
...@@ -1106,6 +1114,7 @@ BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this, ...@@ -1106,6 +1114,7 @@ BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( checkbox, 0 ); layout->addWidget( checkbox, 0 );
widget->setLayout( layout ); widget->setLayout( layout );
...@@ -1154,6 +1163,7 @@ ColorConfigControl::ColorConfigControl( vlc_object_t *_p_this, ...@@ -1154,6 +1163,7 @@ ColorConfigControl::ColorConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( color_but, LAST_COLUMN ); layout->addWidget( label, 0 ); layout->addWidget( color_but, LAST_COLUMN );
widget->setLayout( layout ); widget->setLayout( layout );
...@@ -1238,6 +1248,7 @@ FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this, ...@@ -1238,6 +1248,7 @@ FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
if( !l ) if( !l )
{ {
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN ); layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
widget->setLayout( layout ); widget->setLayout( layout );
......
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf, ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
QWidget *p ) : p_this( _p_this ), p_item( _p_conf ) QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
{ {
widget = new QWidget( p ); widget = NULL;
} }
ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) : ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
p_this (_p_this ), p_item( _p_conf ) p_this (_p_this ), p_item( _p_conf )
...@@ -91,10 +91,10 @@ public: ...@@ -91,10 +91,10 @@ public:
} }
virtual int getType() const = 0; virtual int getType() const = 0;
const char * getName() const { return p_item->psz_name; } const char * getName() const { return p_item->psz_name; }
QWidget *getWidget() const { assert( widget ); return widget; } QWidget *getWidget() const { return widget; }
bool isAdvanced() const { return p_item->b_advanced; } bool isAdvanced() const { return p_item->b_advanced; }
virtual void hide() { getWidget()->hide(); }; virtual void hide() { if ( widget ) widget->hide(); };
virtual void show() { getWidget()->show(); }; virtual void show() { if ( widget ) widget->show(); };
static ConfigControl * createControl( vlc_object_t*, static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*, module_config_t*,QWidget*,
......
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