Commit 4d27e757 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Fix Simple Preference saving...

Gosh, who wrote those simple Preferences ? Seriously ?
ooooooooooooooops...
parent 632c8544
...@@ -100,10 +100,11 @@ void SPrefsCatList::switchPanel( int i ) ...@@ -100,10 +100,11 @@ void SPrefsCatList::switchPanel( int i )
* The Panels * The Panels
*********************************************************************/ *********************************************************************/
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 )
{ {
module_config_t *p_config; module_config_t *p_config;
ConfigControl *control; ConfigControl *control;
number = _number;
#define CONFIG_GENERIC( option, type, label, qcontrol ) \ #define CONFIG_GENERIC( option, type, label, qcontrol ) \
p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
...@@ -405,6 +406,8 @@ void SPrefsPanel::updateAudioOptions( int number) ...@@ -405,6 +406,8 @@ void SPrefsPanel::updateAudioOptions( int number)
void SPrefsPanel::apply() void SPrefsPanel::apply()
{ {
msg_Dbg( p_intf, "Trying to save the %i simple panel", number );
QList<ConfigControl *>::Iterator i; QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ ) for( i = controls.begin() ; i != controls.end() ; i++ )
{ {
...@@ -413,20 +416,31 @@ void SPrefsPanel::apply() ...@@ -413,20 +416,31 @@ void SPrefsPanel::apply()
} }
/* Devices */ /* Devices */
//FIXME is it qta or qtu ???? if( number == SPrefsInputAndCodecs )
char *psz_devicepath = qtu( inputDevice->text() );
if( !EMPTY_STR( psz_devicepath ) )
{ {
config_PutPsz( p_intf, "dvd", psz_devicepath ); char *psz_devicepath = qtu( inputDevice->text() );
config_PutPsz( p_intf, "vcd", psz_devicepath ); if( !EMPTY_STR( psz_devicepath ) )
config_PutPsz( p_intf, "cd-audio", psz_devicepath ); {
config_PutPsz( p_intf, "dvd", psz_devicepath );
config_PutPsz( p_intf, "vcd", psz_devicepath );
config_PutPsz( p_intf, "cd-audio", psz_devicepath );
}
} }
/* Interfaces */ /* Interfaces */
if( skinInterfaceButton->isChecked() ) if( number == SPrefsInterface )
config_PutPsz( p_intf, "intf", "skins2" ); {
if( qtInterfaceButton->isChecked() ) if( skinInterfaceButton->isChecked() )
config_PutPsz( p_intf, "intf", "qt4" ); {
msg_Dbg( p_intf, "hehehe skins" );
config_PutPsz( p_intf, "intf", "skins2" );
}
if( qtInterfaceButton->isChecked() )
{
msg_Dbg( p_intf, "hhhheeee qt" );
config_PutPsz( p_intf, "intf", "qt4" );
}
}
} }
void SPrefsPanel::clean() void SPrefsPanel::clean()
......
...@@ -70,6 +70,8 @@ private: ...@@ -70,6 +70,8 @@ private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
QList<ConfigControl *> controls; QList<ConfigControl *> controls;
int number;
QWidget *alsa_options; QWidget *alsa_options;
QWidget *oss_options; QWidget *oss_options;
QWidget *directx_options; QWidget *directx_options;
......
...@@ -69,7 +69,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -69,7 +69,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
/* Tree and panel initialisations */ /* Tree and panel initialisations */
advanced_tree = NULL; advanced_tree = NULL;
simple_tree = NULL; simple_tree = NULL;
simple_panel = NULL; current_simple_panel = NULL;
advanced_panel = NULL; advanced_panel = NULL;
/* Buttons */ /* Buttons */
...@@ -100,6 +100,8 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -100,6 +100,8 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
tree_panel_l->setMargin( 1 ); tree_panel_l->setMargin( 1 );
main_panel_l->setMargin( 3 ); main_panel_l->setMargin( 3 );
for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL;
if( config_GetInt( p_intf, "qt-advanced-pref") == 1 ) if( config_GetInt( p_intf, "qt-advanced-pref") == 1 )
{ {
setAll(); setAll();
...@@ -115,32 +117,39 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -115,32 +117,39 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
BUTTONACT( small, setSmall() ); BUTTONACT( small, setSmall() );
BUTTONACT( all, setAll() ); BUTTONACT( all, setAll() );
for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL;
} }
void PrefsDialog::setAll() void PrefsDialog::setAll()
{ {
/* We already have a simple TREE, and we just want to hide it */
if( simple_tree ) if( simple_tree )
{ {
tree_panel_l->removeWidget( simple_tree ); tree_panel_l->removeWidget( simple_tree );
simple_tree->hide(); simple_tree->hide();
} }
/* If don't have already and advanced TREE, then create it */
if( !advanced_tree ) if( !advanced_tree )
{ {
/* Creation */
advanced_tree = new PrefsTree( p_intf, tree_panel ); advanced_tree = new PrefsTree( p_intf, tree_panel );
/* and connections */
CONNECT( advanced_tree, CONNECT( advanced_tree,
currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *), currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *),
this, changePanel( QTreeWidgetItem * ) ); this, changePanel( QTreeWidgetItem * ) );
} }
/* Add the Advanced tree to the tree_panel, even if it is already inside,
since it can't hurt. And show it. */
tree_panel_l->addWidget( advanced_tree ); tree_panel_l->addWidget( advanced_tree );
advanced_tree->show(); advanced_tree->show();
if( simple_panel ) /* Remove the simple current panel from the main panels*/
if( current_simple_panel )
{ {
main_panel_l->removeWidget( simple_panel ); main_panel_l->removeWidget( current_simple_panel );
simple_panel->hide(); current_simple_panel->hide();
} }
/* If no advanced Panel exist, create one, attach it and show it*/
if( !advanced_panel ) if( !advanced_panel )
advanced_panel = new PrefsPanel( main_panel ); advanced_panel = new PrefsPanel( main_panel );
main_panel_l->addWidget( advanced_panel ); main_panel_l->addWidget( advanced_panel );
...@@ -150,11 +159,13 @@ void PrefsDialog::setAll() ...@@ -150,11 +159,13 @@ void PrefsDialog::setAll()
void PrefsDialog::setSmall() void PrefsDialog::setSmall()
{ {
/* If an advanced TREE exists, remove and hide it */
if( advanced_tree ) if( advanced_tree )
{ {
tree_panel_l->removeWidget( advanced_tree ); tree_panel_l->removeWidget( advanced_tree );
advanced_tree->hide(); advanced_tree->hide();
} }
/* If no simple_tree, create one, connect it */
if( !simple_tree ) if( !simple_tree )
{ {
simple_tree = new SPrefsCatList( p_intf, tree_panel ); simple_tree = new SPrefsCatList( p_intf, tree_panel );
...@@ -162,36 +173,41 @@ void PrefsDialog::setSmall() ...@@ -162,36 +173,41 @@ void PrefsDialog::setSmall()
currentItemChanged( int ), currentItemChanged( int ),
this, changeSimplePanel( int ) ); this, changeSimplePanel( int ) );
} }
/* Attach anyway and show it */
tree_panel_l->addWidget( simple_tree ); tree_panel_l->addWidget( simple_tree );
simple_tree->show(); simple_tree->show();
/* If an Advanced PANEL exists, remove it */
if( advanced_panel ) if( advanced_panel )
{ {
main_panel_l->removeWidget( advanced_panel ); main_panel_l->removeWidget( advanced_panel );
advanced_panel->hide(); advanced_panel->hide();
} }
if( !simple_panel ) if( !current_simple_panel )
simple_panel = new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat ); {
main_panel_l->addWidget( simple_panel ); current_simple_panel = new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat );
simple_panels[SPrefsDefaultCat] = current_simple_panel;
}
main_panel_l->addWidget( current_simple_panel );
small->setChecked( true ); small->setChecked( true );
simple_panel->show(); current_simple_panel->show();
} }
void PrefsDialog::changeSimplePanel( int number ) void PrefsDialog::changeSimplePanel( int number )
{ {
if( simple_panel ) if( current_simple_panel )
{ {
main_panel_l->removeWidget( simple_panel ); main_panel_l->removeWidget( current_simple_panel );
simple_panel->hide(); current_simple_panel->hide();
} }
simple_panel = simple_panels[number]; current_simple_panel = simple_panels[number];
if( !simple_panel ) if( !current_simple_panel )
{ {
simple_panel = new SPrefsPanel( p_intf, main_panel, number ); current_simple_panel = new SPrefsPanel( p_intf, main_panel, number );
simple_panels[number] = simple_panel; simple_panels[number] = current_simple_panel;
} }
main_panel_l->addWidget( simple_panel ); main_panel_l->addWidget( current_simple_panel );
simple_panel->show(); current_simple_panel->show();
} }
void PrefsDialog::changePanel( QTreeWidgetItem *item ) void PrefsDialog::changePanel( QTreeWidgetItem *item )
...@@ -252,24 +268,28 @@ void PrefsDialog::apply() ...@@ -252,24 +268,28 @@ void PrefsDialog::apply()
{ {
if( small->isChecked() && simple_tree ) if( small->isChecked() && simple_tree )
{ {
for( int i = 0 ; i< SPrefsMax; i++ ) msg_Dbg( p_intf, "I was here, helping you or not...");
if( simple_panels[i] ) simple_panels[i]->apply(); for( int i = 0 ; i< SPrefsMax; i++ ){
if( simple_panels[i] ){ simple_panels[i]->apply();
msg_Dbg( p_intf, "I was here, helping you or not...2");}
}
} }
else if( all->isChecked() && advanced_tree ) else if( all->isChecked() && advanced_tree )
advanced_tree->applyAll(); advanced_tree->applyAll();
msg_Dbg( p_intf, "I was here, helping your");
config_SaveConfigFile( p_intf, NULL ); config_SaveConfigFile( p_intf, NULL );
/* Delete the other panel in order to force its reload after clicking /* Delete the other panel in order to force its reload after clicking
on apply - UGLY but will work for now. */ on apply - UGLY but will work for now. */
if( simple_panel && simple_panel->isVisible() && advanced_panel ) if( current_simple_panel && current_simple_panel->isVisible() && advanced_panel )
{ {
delete advanced_panel; delete advanced_panel;
advanced_panel = NULL; advanced_panel = NULL;
} }
if( advanced_panel && advanced_panel->isVisible() && simple_panel ) if( advanced_panel && advanced_panel->isVisible() && current_simple_panel )
{ {
delete simple_panel; delete current_simple_panel;
simple_panel = NULL; current_simple_panel = NULL;
} }
} }
......
...@@ -62,7 +62,7 @@ private: ...@@ -62,7 +62,7 @@ private:
QWidget *main_panel; QWidget *main_panel;
QHBoxLayout *main_panel_l; QHBoxLayout *main_panel_l;
PrefsPanel *advanced_panel; PrefsPanel *advanced_panel;
SPrefsPanel *simple_panel; SPrefsPanel *current_simple_panel;
SPrefsPanel *simple_panels[SPrefsMax]; SPrefsPanel *simple_panels[SPrefsMax];
QWidget *tree_panel; QWidget *tree_panel;
......
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