[vlc-commits] Qt: ConfigControl: don't instanciate unused widget per control.
Francois Cartegnie
git at videolan.org
Sat Mar 24 19:33:53 CET 2012
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Mar 24 18:34:15 2012 +0100| [5315792733fd4ac511ecb976dddd5813a81eaf81] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5315792733fd4ac511ecb976dddd5813a81eaf81
---
modules/gui/qt4/components/preferences_widgets.cpp | 11 +++++++++++
modules/gui/qt4/components/preferences_widgets.hpp | 8 ++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index e5da7c0..9f8391f 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -220,6 +220,7 @@ StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 );
layout->addWidget( text, LAST_COLUMN );
@@ -281,6 +282,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 );
layout->insertSpacing( 1, 10 );
@@ -376,6 +378,7 @@ FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
if( !_p_layout )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 );
layout->addWidget( font, 1 );
@@ -424,6 +427,7 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
finish( p_module_config );
if( !l )
{
+ widget = new QWidget( _parent );
l = new QGridLayout();
l->addWidget( label, 0, 0 ); l->addWidget( combo, 0, LAST_COLUMN );
widget->setLayout( l );
@@ -598,6 +602,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
finish( bycat );
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
widget->setLayout( layout );
@@ -706,6 +711,7 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget( groupBox, line, 0 );
widget->setLayout( layout );
@@ -878,6 +884,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
widget->setLayout( layout );
@@ -989,6 +996,7 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
finish( p_module_config );
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
widget->setLayout( layout );
@@ -1106,6 +1114,7 @@ BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( checkbox, 0 );
widget->setLayout( layout );
@@ -1154,6 +1163,7 @@ ColorConfigControl::ColorConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( color_but, LAST_COLUMN );
widget->setLayout( layout );
@@ -1238,6 +1248,7 @@ FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
if( !l )
{
+ widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
widget->setLayout( layout );
diff --git a/modules/gui/qt4/components/preferences_widgets.hpp b/modules/gui/qt4/components/preferences_widgets.hpp
index 9c260d2..473548c 100644
--- a/modules/gui/qt4/components/preferences_widgets.hpp
+++ b/modules/gui/qt4/components/preferences_widgets.hpp
@@ -82,7 +82,7 @@ public:
ConfigControl( vlc_object_t *_p_this, module_config_t *_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 ) :
p_this (_p_this ), p_item( _p_conf )
@@ -91,10 +91,10 @@ public:
}
virtual int getType() const = 0;
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; }
- virtual void hide() { getWidget()->hide(); };
- virtual void show() { getWidget()->show(); };
+ virtual void hide() { if ( widget ) widget->hide(); };
+ virtual void show() { if ( widget ) widget->show(); };
static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*,
More information about the vlc-commits
mailing list