Commit 2e02fbfc authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: ConfigControl: rework layout insertion.

Moving layout insertion outside of the constructors.
We no longer need constructor for creating a QWidget,
and we did not need at all to create a widget as a sublayout
is sufficient.
Removes many constructors and conditional code. gross -100 lines.

Also fixes an IntegerRangeConfigControl declaration which definition
was on IntegerRangeSliderConfigControl.
parent 67b43ed8
......@@ -723,12 +723,14 @@ void CaptureOpenPanel::initialize()
module_config_t *p_config =
config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
vdevDshowW = new StringListConfigControl(
VLC_OBJECT(p_intf), p_config, this, dshowDevLayout, line );
VLC_OBJECT(p_intf), p_config, this );
vdevDshowW->insertIntoExistingGrid( dshowDevLayout, line );
line++;
p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
adevDshowW = new StringListConfigControl(
VLC_OBJECT(p_intf), p_config, this, dshowDevLayout, line );
VLC_OBJECT(p_intf), p_config, this );
adevDshowW->insertIntoExistingGrid( dshowDevLayout, line );
line++;
/* dshow Properties */
......
......@@ -82,83 +82,85 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
switch( p_item->i_type )
{
case CONFIG_ITEM_MODULE:
p_control = new ModuleConfigControl( p_this, p_item, parent, false,
l, line );
p_control = new ModuleConfigControl( p_this, p_item, parent, false );
break;
case CONFIG_ITEM_MODULE_CAT:
p_control = new ModuleConfigControl( p_this, p_item, parent, true,
l, line );
p_control = new ModuleConfigControl( p_this, p_item, parent, true );
break;
case CONFIG_ITEM_MODULE_LIST:
p_control = new ModuleListConfigControl( p_this, p_item, parent, false,
l, line );
p_control = new ModuleListConfigControl( p_this, p_item, parent, false );
break;
case CONFIG_ITEM_MODULE_LIST_CAT:
p_control = new ModuleListConfigControl( p_this, p_item, parent, true,
l, line );
p_control = new ModuleListConfigControl( p_this, p_item, parent, true );
break;
case CONFIG_ITEM_STRING:
if( !p_item->i_list )
p_control = new StringConfigControl( p_this, p_item, parent,
l, line, false );
p_control = new StringConfigControl( p_this, p_item, parent, false );
else
p_control = new StringListConfigControl( p_this, p_item,
parent, l, line );
p_control = new StringListConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_PASSWORD:
if( !p_item->i_list )
p_control = new StringConfigControl( p_this, p_item, parent,
l, line, true );
p_control = new StringConfigControl( p_this, p_item, parent, true );
else
p_control = new StringListConfigControl( p_this, p_item,
parent, l, line );
p_control = new StringListConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_RGB:
p_control = new ColorConfigControl( p_this, p_item, parent, l, line );
p_control = new ColorConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_INTEGER:
if( p_item->i_list )
p_control = new IntegerListConfigControl( p_this, p_item,
parent, false, l, line );
p_control = new IntegerListConfigControl( p_this, p_item, parent, false );
else if( p_item->min.i || p_item->max.i )
p_control = new IntegerRangeConfigControl( p_this, p_item, parent,
l, line );
p_control = new IntegerRangeConfigControl( p_this, p_item, parent );
else
p_control = new IntegerConfigControl( p_this, p_item, parent,
l, line );
p_control = new IntegerConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_LOADFILE:
case CONFIG_ITEM_SAVEFILE:
p_control = new FileConfigControl( p_this, p_item, parent, l, line);
p_control = new FileConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_DIRECTORY:
p_control = new DirectoryConfigControl( p_this, p_item, parent, l,
line );
p_control = new DirectoryConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_FONT:
p_control = new FontConfigControl( p_this, p_item, parent, l,
line);
p_control = new FontConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_KEY:
p_control = new KeySelectorControl( p_this, p_item, parent, l, line );
p_control = new KeySelectorControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_BOOL:
p_control = new BoolConfigControl( p_this, p_item, parent, l, line );
p_control = new BoolConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_FLOAT:
if( p_item->min.f || p_item->max.f )
p_control = new FloatRangeConfigControl( p_this, p_item, parent,
l, line );
p_control = new FloatRangeConfigControl( p_this, p_item, parent );
else
p_control = new FloatConfigControl( p_this, p_item, parent,
l, line );
p_control = new FloatConfigControl( p_this, p_item, parent );
break;
default:
break;
}
if ( p_control ) p_control->insertIntoExistingGrid( l, line );
return p_control;
}
/* Inserts controls into layouts
This is sub-optimal in the OO way, as controls's code still
depends on Layout classes. We should use layout inserters [friend]
classes, but it's unlikely we had to deal with a different layout.*/
void ConfigControl::insertInto( QBoxLayout *layout )
{
QGridLayout *sublayout = new QGridLayout();
fillGrid( sublayout, 0 );
layout->addLayout( sublayout );
}
void ConfigControl::insertIntoExistingGrid( QGridLayout *l, int line )
{
fillGrid( l, line );
}
/*******************************************************
* Simple widgets
*******************************************************/
......@@ -209,29 +211,21 @@ VStringConfigControl::doApply()
/*********** String **************/
StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line, bool pwd ) :
VStringConfigControl( _p_this, _p_item, _parent )
QWidget *_parent,
bool pwd ) :
VStringConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
text = new QLineEdit( qfu(p_item->value.psz) );
label = new QLabel( qtr(p_item->psz_text), _parent );
text = new QLineEdit( qfu(p_item->value.psz), _parent );
if( pwd ) text->setEchoMode( QLineEdit::Password );
finish();
}
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 );
layout->addWidget( text, LAST_COLUMN );
widget->setLayout( layout );
}
else
{
void StringConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->setColumnMinimumWidth( 1, 10 );
l->addWidget( text, line, LAST_COLUMN );
}
l->addWidget( text, line, LAST_COLUMN, Qt::AlignRight );
}
StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
......@@ -263,41 +257,29 @@ void StringConfigControl::finish()
/*********** File **************/
FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
VStringConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VStringConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
text = new QLineEdit( qfu(p_item->value.psz) );
browse = new QPushButton( qtr( "Browse..." ) );
QHBoxLayout *textAndButton = new QHBoxLayout();
textAndButton->setMargin( 0 );
textAndButton->addWidget( text, 2 );
textAndButton->addWidget( browse, 0 );
label = new QLabel( qtr(p_item->psz_text), p );
text = new QLineEdit( qfu(p_item->value.psz), p );
browse = new QPushButton( qtr( "Browse..." ), p );
BUTTONACT( browse, updateField() );
finish();
}
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 );
layout->insertSpacing( 1, 10 );
layout->addLayout( textAndButton, LAST_COLUMN );
widget->setLayout( layout );
}
else
{
void FileConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->setColumnMinimumWidth( 1, 10 );
l->addLayout( textAndButton, line, LAST_COLUMN );
}
QHBoxLayout *textAndButton = new QHBoxLayout();
textAndButton->setMargin( 0 );
textAndButton->addWidget( text, 2 );
textAndButton->addWidget( browse, 0 );
l->addLayout( textAndButton, line, LAST_COLUMN, 0 );
}
FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *_label, QLineEdit *_text,
......@@ -344,9 +326,8 @@ void FileConfigControl::finish()
/********* String / Directory **********/
DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_p_widget,
QGridLayout *_p_layout, int _int ) :
FileConfigControl( _p_this, _p_item, _p_widget, _p_layout, _int )
module_config_t *_p_item, QWidget *p ) :
FileConfigControl( _p_this, _p_item, p )
{}
DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
......@@ -369,26 +350,12 @@ void DirectoryConfigControl::updateField()
/********* String / Font **********/
FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent,
QGridLayout *_p_layout, int line) :
VStringConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VStringConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
font = new QFontComboBox( _parent );
label = new QLabel( qtr(p_item->psz_text), p );
font = new QFontComboBox( p );
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 );
widget->setLayout( layout );
}
else
{
_p_layout->addWidget( label, line, 0 );
_p_layout->addWidget( font, line, 1, 1, -1 );
}
if( p_item->psz_longtext )
{
......@@ -396,6 +363,12 @@ FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
}
}
void FontConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( font, line, 1, 1, -1 );
}
FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_p_label,
QFontComboBox *_p_font):
......@@ -413,30 +386,17 @@ FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
/********* String / choice list **********/
StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent,
QGridLayout *l, int line) :
VStringConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VStringConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
combo = new QComboBox();
label = new QLabel( qtr(p_item->psz_text), p );
combo = new QComboBox( p );
combo->setMinimumWidth( MINWIDTH_BOX );
combo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
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 );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
}
if( p_item->i_action )
{
......@@ -446,17 +406,26 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
for( int i = 0; i < p_item->i_action; i++ )
{
QPushButton *button =
new QPushButton( qtr( p_item->ppsz_action_text[i] ));
new QPushButton( qtr( p_item->ppsz_action_text[i] ), p );
buttons << button;
CONNECT( button, clicked(), signalMapper, map() );
signalMapper->setMapping( button, i );
l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
Qt::AlignRight );
}
CONNECT( signalMapper, mapped( int ),
this, actionRequested( int ) );
}
}
void StringListConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
int i = 0;
foreach( QPushButton *button, buttons )
l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i++,
Qt::AlignRight );
}
void StringListConfigControl::comboIndexChanged( int i_index )
{
Q_UNUSED( i_index );
......@@ -484,6 +453,7 @@ void StringListConfigControl::actionRequested( int i_action )
p_module_config->b_dirty = false;
}
}
StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
bool ) : VStringConfigControl( _p_this, _p_item )
......@@ -599,26 +569,19 @@ void setfillVLCConfigCombo( const char *configname, intf_thread_t *p_intf,
/********* Module **********/
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, bool bycat,
QGridLayout *l, int line) :
VStringConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p, bool bycat ) :
VStringConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
combo = new QComboBox();
label = new QLabel( qtr(p_item->psz_text), p );
combo = new QComboBox( p );
combo->setMinimumWidth( MINWIDTH_BOX );
finish( bycat );
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
widget->setLayout( layout );
}
else
{
}
void ModuleConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
}
l->addWidget( combo, line, LAST_COLUMN, 0 );
}
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
......@@ -692,17 +655,16 @@ QString ModuleConfigControl::getValue() const
/********* Module list **********/
ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, bool bycat,
QGridLayout *l, int line) :
VStringConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p, bool bycat ) :
VStringConfigControl( _p_this, _p_item )
{
groupBox = NULL;
/* Special Hack */
if( !p_item->psz_text ) return;
groupBox = new QGroupBox ( qtr(p_item->psz_text), _parent );
text = new QLineEdit;
groupBox = new QGroupBox ( qtr(p_item->psz_text), p );
text = new QLineEdit( p );
QGridLayout *layoutGroupBox = new QGridLayout( groupBox );
finish( bycat );
......@@ -716,22 +678,15 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
layoutGroupBox->addWidget( text, boxline, 0, 1, 2 );
if( !l )
{
widget = new QWidget( _parent );
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget( groupBox, line, 0 );
widget->setLayout( layout );
}
else
{
l->addWidget( groupBox, line, 0, 1, -1 );
}
if( p_item->psz_longtext )
text->setToolTip( formatTooltip( qtr( p_item->psz_longtext) ) );
}
void ModuleListConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( groupBox, line, 0, 1, -1 );
}
ModuleListConfigControl::~ModuleListConfigControl()
{
qDeleteAll( modules );
......@@ -834,7 +789,6 @@ void ModuleListConfigControl::changeVisibility( bool b )
foreach ( checkBoxListItem *it, modules )
it->checkBox->setVisible( b );
groupBox->setVisible( b );
ConfigControl::changeVisibility( b );
}
void ModuleListConfigControl::onUpdate()
......@@ -871,30 +825,16 @@ VIntConfigControl::doApply()
/*********** Integer **************/
IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
VIntConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VIntConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
spin = new QSpinBox; spin->setMinimumWidth( MINWIDTH_BOX );
label = new QLabel( qtr(p_item->psz_text), p );
spin = new QSpinBox( p ); spin->setMinimumWidth( MINWIDTH_BOX );
spin->setAlignment( Qt::AlignRight );
spin->setMaximumWidth( MINWIDTH_BOX );
finish();
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
widget->setLayout( layout );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
}
}
IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *_label, QSpinBox *_spin ) :
......@@ -905,6 +845,12 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
finish();
}
void IntegerConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
}
void IntegerConfigControl::finish()
{
spin->setMaximum( 2000000000 );
......@@ -931,10 +877,8 @@ int VIntConfigControl::getType() const { return CONFIG_ITEM_INTEGER; }
/********* Integer range **********/
IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
IntegerConfigControl( _p_this, _p_item, _parent, l, line )
module_config_t *_p_item, QWidget *p ) :
IntegerConfigControl( _p_this, _p_item, p )
{
finish();
}
......@@ -983,29 +927,16 @@ int IntegerRangeSliderConfigControl::getValue() const
/********* Integer / choice list **********/
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, bool,
QGridLayout *l, int line) :
VIntConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p, bool ) :
VIntConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
combo = new QComboBox();
label = new QLabel( qtr(p_item->psz_text), p );
combo = new QComboBox( p );
combo->setMinimumWidth( MINWIDTH_BOX );
module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name );
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 );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
}
if( p_item->i_action )
{
......@@ -1015,17 +946,27 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
for( int i = 0; i < p_item->i_action; i++ )
{
QPushButton *button =
new QPushButton( qfu( p_item->ppsz_action_text[i] ));
new QPushButton( qfu( p_item->ppsz_action_text[i] ), p );
buttons << button;
CONNECT( button, clicked(), signalMapper, map() );
signalMapper->setMapping( button, i );
l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i,
Qt::AlignRight );
}
CONNECT( signalMapper, mapped( int ),
this, actionRequested( int ) );
}
}
void IntegerListConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
int i = 0;
foreach( QPushButton *button, buttons )
l->addWidget( button, line, LAST_COLUMN - p_item->i_action + i++,
Qt::AlignRight );
}
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
bool ) : VIntConfigControl( _p_this, _p_item )
......@@ -1104,25 +1045,16 @@ int IntegerListConfigControl::getValue() const
/*********** Boolean **************/
BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
VIntConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VIntConfigControl( _p_this, _p_item )
{
checkbox = new QCheckBox( qtr(p_item->psz_text) );
checkbox = new QCheckBox( qtr(p_item->psz_text), p );
finish();
}
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( checkbox, 0 );
widget->setLayout( layout );
}
else
{
l->addWidget( checkbox, line, 0 );
}
void BoolConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( checkbox, line, 0, 1, -1, 0 );
}
BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
......@@ -1152,27 +1084,18 @@ int BoolConfigControl::getValue() const
/************* Color *************/
ColorConfigControl::ColorConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
VIntConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VIntConfigControl( _p_this, _p_item )
{
label = new QLabel;
color_but = new QToolButton;
label = new QLabel( p );
color_but = new QToolButton( p );
finish();
}
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( color_but, LAST_COLUMN );
widget->setLayout( layout );
}
else
{
void ColorConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( color_but, line, LAST_COLUMN, Qt::AlignRight );
}
}
ColorConfigControl::ColorConfigControl( vlc_object_t *_p_this,
......@@ -1234,30 +1157,21 @@ VFloatConfigControl::doApply()
/*********** Float **************/
FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
VFloatConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
VFloatConfigControl( _p_this, _p_item )
{
label = new QLabel( qtr(p_item->psz_text) );
spin = new QDoubleSpinBox;
label = new QLabel( qtr(p_item->psz_text), p );
spin = new QDoubleSpinBox( p );
spin->setMinimumWidth( MINWIDTH_BOX );
spin->setMaximumWidth( MINWIDTH_BOX );
spin->setAlignment( Qt::AlignRight );
finish();
}
if( !l )
{
widget = new QWidget( _parent );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
widget->setLayout( layout );
}
else
{
void FloatConfigControl::fillGrid( QGridLayout *l, int line )
{
l->addWidget( label, line, 0 );
l->addWidget( spin, line, LAST_COLUMN, Qt::AlignRight );
}
}
int VFloatConfigControl::getType() const { return CONFIG_ITEM_FLOAT; }
......@@ -1297,10 +1211,8 @@ float FloatConfigControl::getValue() const
/*********** Float with range **************/
FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
FloatConfigControl( _p_this, _p_item, _parent, l, line )
module_config_t *_p_item, QWidget *p ) :
FloatConfigControl( _p_this, _p_item, p )
{
finish();
}
......@@ -1325,23 +1237,18 @@ void FloatRangeConfigControl::finish()
* Key selector widget
**********************************************************************/
KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
ConfigControl( _p_this, _p_item, _parent )
module_config_t *_p_item, QWidget *p ) :
ConfigControl( _p_this, _p_item )
{
QWidget *keyContainer = new QWidget;
QGridLayout *gLayout = new QGridLayout( keyContainer );
label = new QLabel(
qtr( "Select or double click an action to change the associated "
"hotkey. Use delete key to remove hotkeys") );
"hotkey. Use delete key to remove hotkeys"), p );
QLabel *searchLabel = new QLabel( qtr( "Search" ) );
SearchLineEdit *actionSearch = new SearchLineEdit( keyContainer );
searchLabel = new QLabel( qtr( "Search" ), p );
actionSearch = new SearchLineEdit();
table = new QTreeWidget;
table = new QTreeWidget( p );
table->setColumnCount(3);
table->headerItem()->setText( 0, qtr( "Action" ) );
table->headerItem()->setText( 1, qtr( "Hotkey" ) );
......@@ -1355,15 +1262,18 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
finish();
CONNECT( actionSearch, textChanged( const QString& ),
this, filter( const QString& ) );
}
void KeySelectorControl::fillGrid( QGridLayout *l, int line )
{
QGridLayout *gLayout = new QGridLayout();
gLayout->addWidget( label, 0, 0, 1, 4 );
gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
gLayout->addWidget( actionSearch, 1, 2, 1, 2 );
gLayout->addWidget( table, 2, 0, 1, 4 );
l->addWidget( keyContainer, line, 0, 1, -1 );
CONNECT( actionSearch, textChanged( const QString& ),
this, filter( const QString& ) );
l->addLayout( gLayout, line, 0, 1, -1 );
}
int KeySelectorControl::getType() const { return CONFIG_ITEM_KEY; }
......@@ -1474,7 +1384,7 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
bool b_global = ( column == 2 );
/* Launch a small dialog to ask for a new key */
KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), widget, b_global );
KeyInputDialog *d = new KeyInputDialog( table, keyItem->text( 0 ), table, b_global );
d->exec();
if( d->result() == QDialog::Accepted )
......
......@@ -52,6 +52,8 @@ class QGroupBox;
class QGridLayout;
class QDialogButtonBox;
class QVBoxLayout;
class QBoxLayout;
class SearchLineEdit;
/*******************************************************
* Simple widgets
......@@ -81,26 +83,25 @@ class ConfigControl : public QObject
public:
virtual int getType() const = 0;
const char * getName() const { return p_item->psz_name; }
QWidget *getWidget() const { return widget; }
bool isAdvanced() const { return p_item->b_advanced; }
void hide() { changeVisibility( false ); }
void show() { changeVisibility( true ); }
/* ConfigControl factory */
static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*,
QGridLayout *, int line = 0 );
/* Inserts control into another layout block, using a sublayout */
void insertInto( QBoxLayout * );
/* Inserts control into an existing grid layout */
void insertIntoExistingGrid( QGridLayout*, int );
virtual void doApply() = 0;
protected:
ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
{ Q_UNUSED( p ); widget = NULL; }
ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
p_this (_p_this ), p_item( _p_conf )
{ widget = NULL; }
virtual void changeVisibility( bool b ) { if ( widget ) widget->setVisible( b ); }
p_this (_p_this ), p_item( _p_conf ) {}
virtual void changeVisibility( bool b ) { Q_UNUSED(b); };
vlc_object_t *p_this;
module_config_t *p_item;
QWidget *widget;
virtual void fillGrid( QGridLayout*, int ) {};
signals:
void changed();
#if 0
......@@ -120,8 +121,6 @@ public:
virtual int getType() const;
virtual void doApply();
protected:
VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
ConfigControl(a,b,c) {};
VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
};
......@@ -130,12 +129,9 @@ class IntegerConfigControl : public VIntConfigControl
{
Q_OBJECT
public:
IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget * );
IntegerConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSpinBox* );
IntegerConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSlider* );
virtual int getValue() const;
protected:
QSpinBox *spin;
......@@ -143,8 +139,8 @@ protected:
{
spin->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
QLabel *label;
void finish();
......@@ -153,10 +149,11 @@ private:
class IntegerRangeConfigControl : public IntegerConfigControl
{
public:
IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget * );
IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSpinBox* );
IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSlider* );
private:
void finish();
};
......@@ -173,7 +170,6 @@ protected:
{
slider->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
private:
QLabel *label;
......@@ -184,8 +180,7 @@ class IntegerListConfigControl : public VIntConfigControl
{
Q_OBJECT
public:
IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool, QGridLayout*, int );
IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
virtual int getValue() const;
......@@ -194,12 +189,13 @@ protected:
{
combo->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
void finish(module_config_t * );
QLabel *label;
QComboBox *combo;
QList<QPushButton *> buttons;
private slots:
void actionRequested( int );
......@@ -208,8 +204,7 @@ private slots:
class BoolConfigControl : public VIntConfigControl
{
public:
BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
BoolConfigControl( vlc_object_t *, module_config_t *, QWidget * );
BoolConfigControl( vlc_object_t *, module_config_t *,
QLabel *, QAbstractButton* );
virtual int getValue() const;
......@@ -218,8 +213,8 @@ protected:
virtual void changeVisibility( bool b )
{
checkbox->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
QAbstractButton *checkbox;
void finish();
......@@ -229,8 +224,7 @@ class ColorConfigControl : public VIntConfigControl
{
Q_OBJECT
public:
ColorConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
ColorConfigControl( vlc_object_t *, module_config_t *, QWidget * );
ColorConfigControl( vlc_object_t *, module_config_t *,
QLabel *, QAbstractButton* );
virtual ~ColorConfigControl() { delete color_px; }
......@@ -240,8 +234,8 @@ protected:
{
color_but->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
QLabel *label;
QAbstractButton *color_but;
......@@ -263,8 +257,6 @@ public:
virtual int getType() const;
virtual void doApply();
protected:
VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
ConfigControl(a,b,c) {};
VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
};
......@@ -273,8 +265,7 @@ class FloatConfigControl : public VFloatConfigControl
{
Q_OBJECT
public:
FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
FloatConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FloatConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QDoubleSpinBox* );
virtual float getValue() const;
......@@ -284,8 +275,8 @@ protected:
{
spin->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
QDoubleSpinBox *spin;
private:
......@@ -297,8 +288,7 @@ class FloatRangeConfigControl : public FloatConfigControl
{
Q_OBJECT
public:
FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FloatRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QDoubleSpinBox* );
private:
......@@ -316,8 +306,6 @@ public:
virtual int getType() const;
virtual void doApply();
protected:
VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
ConfigControl(a,b,c) {};
VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
};
......@@ -326,8 +314,8 @@ class StringConfigControl : public VStringConfigControl
{
Q_OBJECT
public:
StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int, bool pwd );
StringConfigControl( vlc_object_t *, module_config_t *,
QWidget *, bool pwd );
StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit*, bool pwd );
virtual QString getValue() const { return text->text(); };
......@@ -336,8 +324,8 @@ protected:
{
text->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
void finish();
QLineEdit *text;
......@@ -348,8 +336,7 @@ class FileConfigControl : public VStringConfigControl
{
Q_OBJECT
public:
FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
FileConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit *, QPushButton * );
virtual QString getValue() const { return text->text(); };
......@@ -361,8 +348,8 @@ protected:
text->setVisible( b );
browse->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
void finish();
QLineEdit *text;
QLabel *label;
......@@ -373,8 +360,7 @@ class DirectoryConfigControl : public FileConfigControl
{
Q_OBJECT
public:
DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget * );
DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit *, QPushButton * );
public slots:
......@@ -385,8 +371,7 @@ class FontConfigControl : public VStringConfigControl
{
Q_OBJECT
public:
FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int);
FontConfigControl( vlc_object_t *, module_config_t *, QWidget * );
FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QFontComboBox *);
virtual QString getValue() const { return font->currentFont().family(); }
......@@ -395,8 +380,8 @@ protected:
{
font->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
QLabel *label;
QFontComboBox *font;
};
......@@ -404,17 +389,17 @@ protected:
class ModuleConfigControl : public VStringConfigControl
{
public:
ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
QGridLayout*, int );
ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
virtual QString getValue() const;
protected:
virtual void changeVisibility( bool b )
{
combo->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
void finish( bool );
QLabel *label;
......@@ -431,8 +416,7 @@ class ModuleListConfigControl : public VStringConfigControl
Q_OBJECT
friend class ConfigControl;
public:
ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool, QGridLayout*, int );
ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
// ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
// QComboBox*, bool );
virtual ~ModuleListConfigControl();
......@@ -441,6 +425,7 @@ public slots:
void onUpdate();
protected:
virtual void changeVisibility( bool );
virtual void fillGrid( QGridLayout*, int );
private:
void finish( bool );
void checkbox_lists(module_t*);
......@@ -454,8 +439,7 @@ class StringListConfigControl : public VStringConfigControl
{
Q_OBJECT
public:
StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout*, int );
StringListConfigControl( vlc_object_t *, module_config_t *, QWidget * );
StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
virtual QString getValue() const;
......@@ -464,12 +448,13 @@ protected:
{
combo->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
QComboBox *combo;
private:
void finish(module_config_t * );
QLabel *label;
QList<QPushButton *> buttons;
private slots:
void actionRequested( int );
void comboIndexChanged( int );
......@@ -506,8 +491,7 @@ class KeySelectorControl : public ConfigControl
{
Q_OBJECT
public:
KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout*, int );
KeySelectorControl( vlc_object_t *, module_config_t *, QWidget * );
virtual int getType() const;
virtual void doApply();
protected:
......@@ -516,11 +500,13 @@ protected:
{
table->setVisible( b );
if ( label ) label->setVisible( b );
ConfigControl::changeVisibility( b );
}
virtual void fillGrid( QGridLayout*, int );
private:
void finish();
QLabel *label;
QLabel *searchLabel;
SearchLineEdit *actionSearch;
QTreeWidget *table;
QList<module_config_t *> values;
private slots:
......
......@@ -680,8 +680,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
int line = 0;
panel_label->setText( qtr( "Configure Hotkeys" ) );
control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config ,
this, gLayout, line );
control = new KeySelectorControl( VLC_OBJECT(p_intf), p_config, this );
control->insertIntoExistingGrid( gLayout, line );
controls.append( control );
line++;
......@@ -694,14 +694,16 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
p_config = config_FindConfig( VLC_OBJECT(p_intf), "hotkeys-mousewheel-mode" );
control = new IntegerListConfigControl( VLC_OBJECT(p_intf),
p_config, this, false, gLayout, line );
p_config, this, false );
control->insertIntoExistingGrid( gLayout, line );
controls.append( control );
#ifdef WIN32
line++;
p_config = config_FindConfig( VLC_OBJECT(p_intf), "qt-disable-volume-keys" );
control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this, gLayout, line );
control = new BoolConfigControl( VLC_OBJECT(p_intf), p_config, this );
control->insertIntoExistingGrid( gLayout, line );
controls.append( control );
#endif
......
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