Commit 723b9879 authored by Antoine Cellerier's avatar Antoine Cellerier

Some more prefs fun:

 * preferences_widgets.cpp: implement string and int with choice list
 * other: simple prefs subtitles dialog
parent f7c69bbe
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Antoine Cellerier <dionoea@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -70,11 +71,13 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -70,11 +71,13 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
p_control = new StringConfigControl( p_this, p_item, parent, p_control = new StringConfigControl( p_this, p_item, parent,
l, line, false ); l, line, false );
else else
fprintf(stderr, "TODO\n" ); p_control = new StringListConfigControl( p_this, p_item,
parent, false, l, line );
break; break;
case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_INTEGER:
if( p_item->i_list ) if( p_item->i_list )
fprintf( stderr, "Todo\n" ); p_control = new IntegerListConfigControl( p_this, p_item,
parent, false, l, line );
else if( p_item->i_min || p_item->i_max ) else if( p_item->i_min || p_item->i_max )
fprintf( stderr, "Todo\n" ); fprintf( stderr, "Todo\n" );
else else
...@@ -128,7 +131,62 @@ void StringConfigControl::finish() ...@@ -128,7 +131,62 @@ void StringConfigControl::finish()
{ {
text->setText( qfu(p_item->psz_value) ); text->setText( qfu(p_item->psz_value) );
text->setToolTip( qfu(p_item->psz_longtext) ); text->setToolTip( qfu(p_item->psz_longtext) );
label->setToolTip( qfu(p_item->psz_longtext) ); if( label )
label->setToolTip( qfu(p_item->psz_longtext) );
}
/********* String / choice list **********/
StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, bool bycat,
QGridLayout *l, int line) :
VStringConfigControl( _p_this, _p_item, _parent )
{
label = new QLabel( qfu(p_item->psz_text) );
combo = new QComboBox();
finish( bycat );
if( !l )
{
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo );
widget->setLayout( layout );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, 1, Qt::AlignRight );
}
}
StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
bool bycat ) : VStringConfigControl( _p_this, _p_item )
{
combo = _combo;
label = _label;
finish( bycat );
}
void StringListConfigControl::finish( bool bycat )
{
combo->setEditable( false );
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
combo->addItem( qfu(p_item->ppsz_list_text ?
p_item->ppsz_list_text[i_index] :
p_item->ppsz_list[i_index] ),
QVariant( p_item->ppsz_list[i_index] ) );
if( p_item->psz_value && !strcmp( p_item->psz_value,
p_item->ppsz_list[i_index] ) )
combo->setCurrentIndex( combo->count() - 1 );
}
combo->setToolTip( qfu(p_item->psz_longtext) );
if( label )
label->setToolTip( qfu(p_item->psz_longtext) );
}
QString StringListConfigControl::getValue()
{
return combo->itemData( combo->currentIndex() ).toString();
} }
/********* Module **********/ /********* Module **********/
...@@ -203,7 +261,8 @@ void ModuleConfigControl::finish( bool bycat ) ...@@ -203,7 +261,8 @@ void ModuleConfigControl::finish( bool bycat )
} }
vlc_list_release( p_list ); vlc_list_release( p_list );
combo->setToolTip( qfu(p_item->psz_longtext) ); combo->setToolTip( qfu(p_item->psz_longtext) );
label->setToolTip( qfu(p_item->psz_longtext) ); if( label )
label->setToolTip( qfu(p_item->psz_longtext) );
} }
QString ModuleConfigControl::getValue() QString ModuleConfigControl::getValue()
...@@ -254,10 +313,62 @@ void IntegerConfigControl::finish() ...@@ -254,10 +313,62 @@ void IntegerConfigControl::finish()
spin->setMaximum( 2000000000 ); spin->setMaximum( 2000000000 );
spin->setValue( p_item->i_value ); spin->setValue( p_item->i_value );
spin->setToolTip( qfu(p_item->psz_longtext) ); spin->setToolTip( qfu(p_item->psz_longtext) );
label->setToolTip( qfu(p_item->psz_longtext) ); if( label )
label->setToolTip( qfu(p_item->psz_longtext) );
} }
int IntegerConfigControl::getValue() int IntegerConfigControl::getValue()
{ {
return spin->value(); return spin->value();
} }
/********* Integer / choice list **********/
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, bool bycat,
QGridLayout *l, int line) :
VIntConfigControl( _p_this, _p_item, _parent )
{
label = new QLabel( qfu(p_item->psz_text) );
combo = new QComboBox();
finish( bycat );
if( !l )
{
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo );
widget->setLayout( layout );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, 1, Qt::AlignRight );
}
}
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
bool bycat ) : VIntConfigControl( _p_this, _p_item )
{
combo = _combo;
label = _label;
finish( bycat );
}
void IntegerListConfigControl::finish( bool bycat )
{
combo->setEditable( false );
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
combo->addItem( qfu(p_item->ppsz_list_text[i_index] ),
QVariant( p_item->pi_list[i_index] ) );
if( p_item->i_value == p_item->pi_list[i_index] )
combo->setCurrentIndex( combo->count() - 1 );
}
combo->setToolTip( qfu(p_item->psz_longtext) );
if( label )
label->setToolTip( qfu(p_item->psz_longtext) );
}
int IntegerListConfigControl::getValue()
{
return combo->itemData( combo->currentIndex() ).toInt();
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Antoine Cellerier <dionoea@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -104,6 +105,23 @@ private: ...@@ -104,6 +105,23 @@ private:
void finish(); void finish();
}; };
class IntegerListConfigControl : public VIntConfigControl
{
public:
IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool, QGridLayout*, int );
IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
virtual ~IntegerListConfigControl() {};
virtual int getValue();
virtual void hide() { combo->hide(); label->hide(); }
virtual void show() { combo->show(); label->show(); }
private:
void finish( bool );
QLabel *label;
QComboBox *combo;
};
#if 0 #if 0
class BoolConfigControl : public VIntConfigControl class BoolConfigControl : public VIntConfigControl
{ {
...@@ -190,6 +208,23 @@ private: ...@@ -190,6 +208,23 @@ private:
QLabel *label; QLabel *label;
QComboBox *combo; QComboBox *combo;
}; };
class StringListConfigControl : public VStringConfigControl
{
public:
StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool, QGridLayout*, int );
StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
virtual ~StringListConfigControl() {};
virtual QString getValue();
virtual void hide() { combo->hide(); label->hide(); }
virtual void show() { combo->show(); label->show(); }
private:
void finish( bool );
QLabel *label;
QComboBox *combo;
};
#if 0 #if 0
struct ModuleCheckBox { struct ModuleCheckBox {
QCheckBox *checkbox; QCheckBox *checkbox;
......
...@@ -107,58 +107,56 @@ void SPrefsCatList::DoAll( bool doclean ) ...@@ -107,58 +107,56 @@ void SPrefsCatList::DoAll( bool doclean )
SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
int number ) : QWidget( _parent ), p_intf( _p_intf ) int number ) : QWidget( _parent ), p_intf( _p_intf )
{ {
switch( number ) module_config_t *p_config;
{ ConfigControl *control;
case SPrefsVideo:
{ #define CONFIG_GENERIC( option, type, label, qcontrol ) \
Ui::SPrefsVideo ui; p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
ui.setupUi( this ); if( p_config ) \
break; { \
} control = new type ## ConfigControl( VLC_OBJECT(p_intf), \
p_config, label, ui.qcontrol, false ); \
controls.append( control ); \
}
case SPrefsAudio: #define START_SPREFS_CAT( name ) \
{ case SPrefs ## name: \
Ui::SPrefsAudio ui; { \
Ui::SPrefs ## name ui; \
ui.setupUi( this ); ui.setupUi( this );
break;
}
case SPrefsInputAndCodecs: #define END_SPREFS_CAT \
{ break; \
break;
} }
case SPrefsPlaylist:
{
Ui::SPrefsPlaylist ui;
ui.setupUi( this );
break;
}
case SPrefsInterface: switch( number )
{ {
break; START_SPREFS_CAT( Video );
} END_SPREFS_CAT;
case SPrefsSubtitles: START_SPREFS_CAT( Audio );
{ END_SPREFS_CAT;
Ui::SPrefsSubtitles ui;
ui.setupUi( this );
break;
}
case SPrefsAdvanced: case SPrefsInputAndCodecs: break;
{
Ui::SPrefsTrivial ui; START_SPREFS_CAT( Playlist );
ui.setupUi( this ); END_SPREFS_CAT;
module_config_t *p_config =
config_FindConfig( VLC_OBJECT(p_intf), "memcpy" ); case SPrefsInterface: break;
ConfigControl *control =
new ModuleConfigControl( VLC_OBJECT(p_intf), START_SPREFS_CAT( Subtitles );
p_config, ui.memcpyLabel, ui.memcpyCombo, false );
controls.append( control ); CONFIG_GENERIC( "subsdec-encoding", StringList, NULL, encoding );
break; CONFIG_GENERIC( "sub-language", String, NULL, preferedLanguage );
} CONFIG_GENERIC( "freetype-font", String, NULL, font );
CONFIG_GENERIC( "freetype-color", IntegerList, NULL, fontColor );
CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList, NULL,
fontSize );
END_SPREFS_CAT;
case SPrefsAdvanced: break;
} }
} }
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="1" >
<widget class="QLineEdit" name="preferedLanguage" />
</item>
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QLabel" name="label" > <widget class="QLabel" name="label" >
<property name="text" > <property name="text" >
...@@ -88,25 +91,9 @@ ...@@ -88,25 +91,9 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="1" >
<widget class="QComboBox" name="preferedLanguage" />
</item>
<item row="1" column="1" > <item row="1" column="1" >
<widget class="QComboBox" name="encoding" /> <widget class="QComboBox" name="encoding" />
</item> </item>
<item row="3" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>501</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<pixmapfunction></pixmapfunction> <pixmapfunction></pixmapfunction>
......
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