From: Jean-Baptiste Kempf Date: Mon, 29 Oct 2007 23:54:03 +0000 (+0000) Subject: Qt4 - Fix Simple Preference saving... X-Git-Tag: 0.9.0-test0~4753 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4d27e757c899636bc7ddad29a5685d8eb1ebdfd6;p=vlc Qt4 - Fix Simple Preference saving... Gosh, who wrote those simple Preferences ? Seriously ? ooooooooooooooops... --- diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp index c1e9c7d0ec..ec27c5e749 100644 --- a/modules/gui/qt4/components/simple_preferences.cpp +++ b/modules/gui/qt4/components/simple_preferences.cpp @@ -100,10 +100,11 @@ void SPrefsCatList::switchPanel( int i ) * The Panels *********************************************************************/ 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; ConfigControl *control; + number = _number; #define CONFIG_GENERIC( option, type, label, qcontrol ) \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ @@ -405,6 +406,8 @@ void SPrefsPanel::updateAudioOptions( int number) void SPrefsPanel::apply() { + msg_Dbg( p_intf, "Trying to save the %i simple panel", number ); + QList::Iterator i; for( i = controls.begin() ; i != controls.end() ; i++ ) { @@ -413,20 +416,31 @@ void SPrefsPanel::apply() } /* Devices */ - //FIXME is it qta or qtu ???? - char *psz_devicepath = qtu( inputDevice->text() ); - if( !EMPTY_STR( psz_devicepath ) ) + if( number == SPrefsInputAndCodecs ) { - config_PutPsz( p_intf, "dvd", psz_devicepath ); - config_PutPsz( p_intf, "vcd", psz_devicepath ); - config_PutPsz( p_intf, "cd-audio", psz_devicepath ); + char *psz_devicepath = qtu( inputDevice->text() ); + if( !EMPTY_STR( 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 */ - if( skinInterfaceButton->isChecked() ) - config_PutPsz( p_intf, "intf", "skins2" ); - if( qtInterfaceButton->isChecked() ) - config_PutPsz( p_intf, "intf", "qt4" ); + if( number == SPrefsInterface ) + { + if( skinInterfaceButton->isChecked() ) + { + 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() diff --git a/modules/gui/qt4/components/simple_preferences.hpp b/modules/gui/qt4/components/simple_preferences.hpp index f00b380740..8285c805c9 100644 --- a/modules/gui/qt4/components/simple_preferences.hpp +++ b/modules/gui/qt4/components/simple_preferences.hpp @@ -70,6 +70,8 @@ private: intf_thread_t *p_intf; QList controls; + int number; + QWidget *alsa_options; QWidget *oss_options; QWidget *directx_options; diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp index aa2101648d..1c405d1384 100644 --- a/modules/gui/qt4/dialogs/preferences.cpp +++ b/modules/gui/qt4/dialogs/preferences.cpp @@ -69,7 +69,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) /* Tree and panel initialisations */ advanced_tree = NULL; simple_tree = NULL; - simple_panel = NULL; + current_simple_panel = NULL; advanced_panel = NULL; /* Buttons */ @@ -100,6 +100,8 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) tree_panel_l->setMargin( 1 ); 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 ) { setAll(); @@ -115,32 +117,39 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) BUTTONACT( small, setSmall() ); BUTTONACT( all, setAll() ); - for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL; } void PrefsDialog::setAll() { + /* We already have a simple TREE, and we just want to hide it */ if( simple_tree ) { tree_panel_l->removeWidget( simple_tree ); simple_tree->hide(); } + /* If don't have already and advanced TREE, then create it */ if( !advanced_tree ) { + /* Creation */ advanced_tree = new PrefsTree( p_intf, tree_panel ); + /* and connections */ CONNECT( advanced_tree, currentItemChanged( QTreeWidgetItem *, 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 ); 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 ); - simple_panel->hide(); + main_panel_l->removeWidget( current_simple_panel ); + current_simple_panel->hide(); } + /* If no advanced Panel exist, create one, attach it and show it*/ if( !advanced_panel ) advanced_panel = new PrefsPanel( main_panel ); main_panel_l->addWidget( advanced_panel ); @@ -150,11 +159,13 @@ void PrefsDialog::setAll() void PrefsDialog::setSmall() { + /* If an advanced TREE exists, remove and hide it */ if( advanced_tree ) { tree_panel_l->removeWidget( advanced_tree ); advanced_tree->hide(); } + /* If no simple_tree, create one, connect it */ if( !simple_tree ) { simple_tree = new SPrefsCatList( p_intf, tree_panel ); @@ -162,36 +173,41 @@ void PrefsDialog::setSmall() currentItemChanged( int ), this, changeSimplePanel( int ) ); } + /* Attach anyway and show it */ tree_panel_l->addWidget( simple_tree ); simple_tree->show(); + /* If an Advanced PANEL exists, remove it */ if( advanced_panel ) { main_panel_l->removeWidget( advanced_panel ); advanced_panel->hide(); } - if( !simple_panel ) - simple_panel = new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat ); - main_panel_l->addWidget( simple_panel ); + if( !current_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 ); - simple_panel->show(); + current_simple_panel->show(); } void PrefsDialog::changeSimplePanel( int number ) { - if( simple_panel ) + if( current_simple_panel ) { - main_panel_l->removeWidget( simple_panel ); - simple_panel->hide(); + main_panel_l->removeWidget( current_simple_panel ); + current_simple_panel->hide(); } - simple_panel = simple_panels[number]; - if( !simple_panel ) + current_simple_panel = simple_panels[number]; + if( !current_simple_panel ) { - simple_panel = new SPrefsPanel( p_intf, main_panel, number ); - simple_panels[number] = simple_panel; + current_simple_panel = new SPrefsPanel( p_intf, main_panel, number ); + simple_panels[number] = current_simple_panel; } - main_panel_l->addWidget( simple_panel ); - simple_panel->show(); + main_panel_l->addWidget( current_simple_panel ); + current_simple_panel->show(); } void PrefsDialog::changePanel( QTreeWidgetItem *item ) @@ -252,24 +268,28 @@ void PrefsDialog::apply() { if( small->isChecked() && simple_tree ) { - 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..."); + 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 ) advanced_tree->applyAll(); + msg_Dbg( p_intf, "I was here, helping your"); config_SaveConfigFile( p_intf, NULL ); /* Delete the other panel in order to force its reload after clicking 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; advanced_panel = NULL; } - if( advanced_panel && advanced_panel->isVisible() && simple_panel ) + if( advanced_panel && advanced_panel->isVisible() && current_simple_panel ) { - delete simple_panel; - simple_panel = NULL; + delete current_simple_panel; + current_simple_panel = NULL; } } diff --git a/modules/gui/qt4/dialogs/preferences.hpp b/modules/gui/qt4/dialogs/preferences.hpp index 44099839c7..f547532920 100644 --- a/modules/gui/qt4/dialogs/preferences.hpp +++ b/modules/gui/qt4/dialogs/preferences.hpp @@ -62,7 +62,7 @@ private: QWidget *main_panel; QHBoxLayout *main_panel_l; PrefsPanel *advanced_panel; - SPrefsPanel *simple_panel; + SPrefsPanel *current_simple_panel; SPrefsPanel *simple_panels[SPrefsMax]; QWidget *tree_panel;