Commit 9ab3a054 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Preferences refreshing fix by atmo, Andre Weber.

parent c482de12
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "components/preferences_widgets.hpp" #include "components/preferences_widgets.hpp"
#include "util/customwidgets.hpp" #include "util/customwidgets.hpp"
#include <vlc_keys.h> #include <vlc_keys.h>
#include <QString> #include <QString>
...@@ -373,7 +372,10 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, ...@@ -373,7 +372,10 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
combo = new QComboBox(); combo = new QComboBox();
combo->setMinimumWidth( MINWIDTH_BOX ); combo->setMinimumWidth( MINWIDTH_BOX );
combo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); combo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
finish( bycat );
module_config_t *p_module_config = config_FindConfig( p_this, getName() );
finish( p_module_config, bycat );
if( !l ) if( !l )
{ {
l = new QGridLayout(); l = new QGridLayout();
...@@ -410,17 +412,20 @@ void StringListConfigControl::actionRequested( int i_action ) ...@@ -410,17 +412,20 @@ void StringListConfigControl::actionRequested( int i_action )
/* Supplementary check for boundaries */ /* Supplementary check for boundaries */
if( i_action < 0 || i_action >= p_item->i_action ) return; if( i_action < 0 || i_action >= p_item->i_action ) return;
module_config_t *p_module_config = config_FindConfig( p_this, getName() );
if(!p_module_config) return;
vlc_value_t val; vlc_value_t val;
val.psz_string = val.psz_string =
qtu( (combo->itemData( combo->currentIndex() ).toString() ) ); qtu( (combo->itemData( combo->currentIndex() ).toString() ) );
p_item->ppf_action[i_action]( p_this, getName(), val, val, 0 ); p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
if( p_item->b_dirty ) if( p_module_config->b_dirty )
{ {
combo->clear(); combo->clear();
finish( true ); finish( p_module_config, true );
p_item->b_dirty = VLC_FALSE; p_module_config->b_dirty = VLC_FALSE;
} }
} }
StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
...@@ -429,26 +434,31 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, ...@@ -429,26 +434,31 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
{ {
combo = _combo; combo = _combo;
label = _label; label = _label;
finish( bycat );
module_config_t *p_module_config = config_FindConfig( p_this, getName() );
finish( p_module_config, bycat );
} }
void StringListConfigControl::finish( bool bycat ) void StringListConfigControl::finish(module_config_t *p_module_config, bool bycat )
{ {
combo->setEditable( false ); combo->setEditable( false );
for( int i_index = 0; i_index < p_item->i_list; i_index++ ) if(!p_module_config) return;
for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
{ {
combo->addItem( qfu(p_item->ppsz_list_text ? combo->addItem( qfu(p_module_config->ppsz_list_text ?
p_item->ppsz_list_text[i_index] : p_module_config->ppsz_list_text[i_index] :
p_item->ppsz_list[i_index] ), p_module_config->ppsz_list[i_index] ),
QVariant( p_item->ppsz_list[i_index] ) ); QVariant( p_module_config->ppsz_list[i_index] ) );
if( p_item->value.psz && !strcmp( p_item->value.psz, if( p_item->value.psz && !strcmp( p_module_config->value.psz,
p_item->ppsz_list[i_index] ) ) p_module_config->ppsz_list[i_index] ) )
combo->setCurrentIndex( combo->count() - 1 ); combo->setCurrentIndex( combo->count() - 1 );
} }
combo->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) ); combo->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
if( label ) if( label )
label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) ); label->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
} }
QString StringListConfigControl::getValue() QString StringListConfigControl::getValue()
...@@ -826,7 +836,10 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, ...@@ -826,7 +836,10 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
label = new QLabel( qtr(p_item->psz_text) ); label = new QLabel( qtr(p_item->psz_text) );
combo = new QComboBox(); combo = new QComboBox();
combo->setMinimumWidth( MINWIDTH_BOX ); combo->setMinimumWidth( MINWIDTH_BOX );
finish( bycat );
module_config_t *p_module_config = config_FindConfig( p_this, getName() );
finish( p_module_config, bycat );
if( !l ) if( !l )
{ {
QHBoxLayout *layout = new QHBoxLayout(); QHBoxLayout *layout = new QHBoxLayout();
...@@ -838,6 +851,25 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, ...@@ -838,6 +851,25 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
l->addWidget( label, line, 0 ); l->addWidget( label, line, 0 );
l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight ); l->addWidget( combo, line, LAST_COLUMN, Qt::AlignRight );
} }
if( p_item->i_action )
{
QSignalMapper *signalMapper = new QSignalMapper(this);
/* Some stringLists like Capture listings have action associated */
for( int i = 0; i < p_item->i_action; i++ )
{
QPushButton *button =
new QPushButton( qfu( p_item->ppsz_action_text[i] ));
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 ) );
}
} }
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *_label, QComboBox *_combo, module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
...@@ -845,23 +877,50 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, ...@@ -845,23 +877,50 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
{ {
combo = _combo; combo = _combo;
label = _label; label = _label;
finish( bycat );
module_config_t *p_module_config = config_FindConfig( p_this, getName() );
finish( p_module_config, bycat );
} }
void IntegerListConfigControl::finish( bool bycat ) void IntegerListConfigControl::finish(module_config_t *p_module_config, bool bycat )
{ {
combo->setEditable( false ); combo->setEditable( false );
for( int i_index = 0; i_index < p_item->i_list; i_index++ ) if(!p_module_config) return;
for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
{ {
combo->addItem( qtr(p_item->ppsz_list_text[i_index] ), combo->addItem( qtr(p_module_config->ppsz_list_text[i_index] ),
QVariant( p_item->pi_list[i_index] ) ); QVariant( p_module_config->pi_list[i_index] ) );
if( p_item->value.i == p_item->pi_list[i_index] ) if( p_module_config->value.i == p_module_config->pi_list[i_index] )
combo->setCurrentIndex( combo->count() - 1 ); combo->setCurrentIndex( combo->count() - 1 );
} }
combo->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) ); combo->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
if( label ) if( label )
label->setToolTip( formatTooltip(qtr(p_item->psz_longtext)) ); label->setToolTip( formatTooltip(qtr(p_module_config->psz_longtext)) );
}
void IntegerListConfigControl::actionRequested( int i_action )
{
/* Supplementary check for boundaries */
if( i_action < 0 || i_action >= p_item->i_action ) return;
module_config_t *p_module_config = config_FindConfig( p_this, getName() );
if(!p_module_config) return;
vlc_value_t val;
val.i_int = combo->itemData( combo->currentIndex() ).toInt();
p_module_config->ppf_action[i_action]( p_this, getName(), val, val, 0 );
if( p_module_config->b_dirty )
{
combo->clear();
finish( p_module_config, true );
p_module_config->b_dirty = VLC_FALSE;
}
} }
int IntegerListConfigControl::getValue() int IntegerListConfigControl::getValue()
......
...@@ -163,6 +163,7 @@ private: ...@@ -163,6 +163,7 @@ private:
class IntegerListConfigControl : public VIntConfigControl class IntegerListConfigControl : public VIntConfigControl
{ {
Q_OBJECT
public: public:
IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *, IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool, QGridLayout*, int& ); bool, QGridLayout*, int& );
...@@ -173,9 +174,12 @@ public: ...@@ -173,9 +174,12 @@ public:
virtual void hide() { combo->hide(); if( label ) label->hide(); } virtual void hide() { combo->hide(); if( label ) label->hide(); }
virtual void show() { combo->show(); if( label ) label->show(); } virtual void show() { combo->show(); if( label ) label->show(); }
private: private:
void finish( bool ); void finish(module_config_t *, bool );
QLabel *label; QLabel *label;
QComboBox *combo; QComboBox *combo;
private slots:
void actionRequested( int );
}; };
class BoolConfigControl : public VIntConfigControl class BoolConfigControl : public VIntConfigControl
...@@ -384,7 +388,7 @@ public: ...@@ -384,7 +388,7 @@ public:
virtual void show() { combo->show(); if( label ) label->show(); } virtual void show() { combo->show(); if( label ) label->show(); }
QComboBox *combo; QComboBox *combo;
private: private:
void finish( bool ); void finish(module_config_t *, bool );
QLabel *label; QLabel *label;
private slots: private slots:
void actionRequested( int ); void actionRequested( int );
......
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