X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fpreferences.cpp;h=2bfa9db793a3488580724f2b5ef0fa7256551e67;hb=30a0d8c1592f781f49c64f12f972e5ba67b0a5e1;hp=3853337e6a66015d605b2b8e5e61beaa71a38f7b;hpb=63631cbac17e547d7654d79a0debc09c0a354432;p=vlc diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp index 3853337e6a..2bfa9db793 100644 --- a/modules/gui/qt4/dialogs/preferences.cpp +++ b/modules/gui/qt4/dialogs/preferences.cpp @@ -28,6 +28,7 @@ #include "dialogs/preferences.hpp" #include "util/qvlcframe.hpp" +#include "dialogs/errors.hpp" #include "components/complete_preferences.hpp" #include "components/simple_preferences.hpp" @@ -39,13 +40,13 @@ #include #include -PrefsDialog *PrefsDialog::instance = NULL; - PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( parent, _p_intf ) { QGridLayout *main_layout = new QGridLayout( this ); setWindowTitle( qtr( "Preferences" ) ); + setWindowRole( "vlc-preferences" ); + setWindowModality( Qt::WindowModal ); /* Whether we want it or not, we need to destroy on close to get consistency when reset */ @@ -81,6 +82,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) /* Buttons */ QDialogButtonBox *buttonsBox = new QDialogButtonBox(); QPushButton *save = new QPushButton( qtr( "&Save" ) ); + save->setToolTip( qtr( "Save and close the dialog" ) ); QPushButton *cancel = new QPushButton( qtr( "&Cancel" ) ); QPushButton *reset = new QPushButton( qtr( "&Reset Preferences" ) ); @@ -98,7 +100,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) main_layout->setColumnMinimumWidth( 1, 10 ); main_layout->setColumnStretch( 0, 1 ); main_layout->setColumnStretch( 1, 0 ); - main_layout->setColumnStretch( 2, 3 ); + main_layout->setColumnStretch( 2, 10 ); main_layout->setRowStretch( 2, 4 ); @@ -107,11 +109,15 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) /* Margins */ tree_panel_l->setMargin( 1 ); - main_panel_l->setLayoutMargins( 6, 0, 0, 3, 3 ); + main_panel_l->setContentsMargins( 6, 0, 0, 3 ); + b_small = (p_intf->p_sys->i_screenHeight < 750); + if( b_small ) msg_Dbg( p_intf, "Small"); + setMaximumHeight( p_intf->p_sys->i_screenHeight ); for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL; - if( config_GetInt( p_intf, "qt-advanced-pref" ) == 1 ) + if( var_InheritBool( p_intf, "qt-advanced-pref" ) + || var_InheritBool( p_intf, "advanced" ) ) setAdvanced(); else setSmall(); @@ -123,7 +129,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) BUTTONACT( small, setSmall() ); BUTTONACT( all, setAdvanced() ); - resize( 750, sizeHint().height() ); + resize( 780, sizeHint().height() ); } void PrefsDialog::setAdvanced() @@ -176,7 +182,7 @@ void PrefsDialog::setSmall() /* If no simple_tree, create one, connect it */ if( !simple_tree ) { - simple_tree = new SPrefsCatList( p_intf, tree_panel ); + simple_tree = new SPrefsCatList( p_intf, tree_panel, b_small ); CONNECT( simple_tree, currentItemChanged( int ), this, changeSimplePanel( int ) ); @@ -193,7 +199,7 @@ void PrefsDialog::setSmall() if( !current_simple_panel ) { current_simple_panel = - new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat ); + new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat, b_small ); simple_panels[SPrefsDefaultCat] = current_simple_panel; main_panel_l->addWidget( current_simple_panel ); } @@ -211,7 +217,7 @@ void PrefsDialog::changeSimplePanel( int number ) current_simple_panel = simple_panels[number]; if( !current_simple_panel ) { - current_simple_panel = new SPrefsPanel( p_intf, main_panel, number ); + current_simple_panel = new SPrefsPanel( p_intf, main_panel, number, b_small ); simple_panels[number] = current_simple_panel; main_panel_l->addWidget( current_simple_panel ); } @@ -289,57 +295,18 @@ void PrefsDialog::save() } /* Save to file */ - config_SaveConfigFile( p_intf, NULL ); - - destroyPanels(); - - hide(); -} - -void PrefsDialog::destroyPanels() -{ - msg_Dbg( p_intf, "Destroying the Panels" ); - /* Delete the other panel in order to force its reload after clicking - on apply. In fact, if we don't do that, the preferences from the other - panels won't be accurate, so we would have to recreate the whole dialog, - and we don't want that.*/ - if( small->isChecked() && advanced_panel ) + if( config_SaveConfigFile( p_intf, NULL ) != 0 ) { - /* Deleting only the active panel from the advanced config doesn't work - because the data records of PrefsItemData contains still a - reference to it only cleanAll() is sure to remove all Panels! */ - advanced_tree->cleanAll(); - advanced_panel = NULL; - } - if( all->isChecked() && current_simple_panel ) - { - for( int i = 0 ; i< SPrefsMax; i++ ) - { - if( simple_panels[i] ) - { - delete simple_panels[i]; - simple_panels[i] = NULL; - } - } - current_simple_panel = NULL; + ErrorsDialog::getInstance (p_intf)->addError( qtr( "Cannot save Configuration" ), + qtr("Preferences file could not be saved") ); } + accept(); } - /* Clean the preferences, dunno if it does something really */ void PrefsDialog::cancel() { - if( small->isChecked() && simple_tree ) - { - for( int i = 0 ; i< SPrefsMax; i++ ) - if( simple_panels[i] ) simple_panels[i]->clean(); - } - else if( all->isChecked() && advanced_tree ) - { - advanced_tree->cleanAll(); - advanced_panel = NULL; - } - hide(); + reject(); } /* Reset all the preferences, when you click the button */ @@ -358,8 +325,6 @@ void PrefsDialog::reset() config_SaveConfigFile( p_intf, NULL ); getSettings()->clear(); - close(); - instance = NULL; - PrefsDialog::getInstance( p_intf )->show(); + accept(); } }