]> git.sesse.net Git - vlc/commitdiff
Qt4 - Preferences. Add an apply button and warnings to force saving
authorJean-Baptiste Kempf <jb@videolan.org>
Wed, 2 May 2007 22:55:45 +0000 (22:55 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 2 May 2007 22:55:45 +0000 (22:55 +0000)
and rebuilding when switching details depth.

modules/gui/qt4/dialogs/preferences.cpp
modules/gui/qt4/dialogs/preferences.hpp

index 7a3e99a0b0553ec1dee33fcfe288c301ed2fd8b7..510b7ed874f3cab55a0b8c23266bd2d1b7035800 100644 (file)
@@ -59,6 +59,9 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     /* Choice for types */
     types = new QGroupBox( "Show settings" );
     types->setAlignment( Qt::AlignHCenter );
+    types->setToolTip( qtr("You have to apply the preferences before\n"
+                            "switching settings details if you want\n"
+                            "to keep them") );
     QHBoxLayout *types_l = new QHBoxLayout(0);
     types_l->setSpacing( 3 ); types_l->setMargin( 3 );
     small = new QRadioButton( "Basic", types ); types_l->addWidget( small );
@@ -75,10 +78,12 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     /* Buttons */
     QDialogButtonBox *buttonsBox = new QDialogButtonBox();
     QPushButton *save = new QPushButton( qtr( "&Save" ) );
+    QPushButton *apply = new QPushButton( qtr( "&Apply" ) );
     QPushButton *cancel = new QPushButton( qtr( "&Cancel" ) );
     QPushButton *reset = new QPushButton( qtr( "&Reset Preferences" ) );
 
     buttonsBox->addButton( save, QDialogButtonBox::AcceptRole );
+    buttonsBox->addButton( apply, QDialogButtonBox::AcceptRole );
     buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole );
     buttonsBox->addButton( reset, QDialogButtonBox::ActionRole );
 
@@ -110,6 +115,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     }
 
     BUTTONACT( save, save() );
+    BUTTONACT( apply, apply() );
     BUTTONACT( cancel, cancel() );
     BUTTONACT( reset, reset() );
     BUTTONACT( small, setSmall() );
@@ -243,6 +249,12 @@ void PrefsDialog::showModulePrefs( char *psz_module )
 }
 
 void PrefsDialog::save()
+{
+    apply();
+    hide();
+}
+
+void PrefsDialog::apply()
 {
     if( small->isChecked() && simple_tree )
     {
@@ -252,7 +264,14 @@ void PrefsDialog::save()
     else if( all->isChecked() && advanced_tree )
         advanced_tree->applyAll();
     config_SaveConfigFile( p_intf, NULL );
-    hide();
+
+    /* Delete the other panel in order to force its reload after clicking 
+       on apply - UGLY but will work for now. */
+    if( simple_panel->isVisible() )
+        delete advanced_panel;
+    if( advanced_panel->isVisible() )
+        delete simple_panel;
+
 }
 
 void PrefsDialog::cancel()
index dd3cc22581e0688a68c88f20f825e192f4bf8836..44099839c72b535bd1479f0b5c9eb237e2c93131 100644 (file)
@@ -82,6 +82,7 @@ private slots:
      void setAll();
      void setSmall();
      void save();
+     void apply();
      void cancel();
      void reset();
      void close(){ save(); };