]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/preferences.cpp
Qt: add a tooltip for people who don't get that save will close the dialog.
[vlc] / modules / gui / qt4 / dialogs / preferences.cpp
index 09a873f22efac55b9f60e20db98af81f3df40a63..06b2f5cd82f83fe17c6a8a55ac0305a440899ae2 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 #include "dialogs/preferences.hpp"
-#include "dialogs_provider.hpp"
 #include "util/qvlcframe.hpp"
 
 #include "components/complete_preferences.hpp"
@@ -35,9 +35,7 @@
 #include <QHBoxLayout>
 #include <QGroupBox>
 #include <QRadioButton>
-#include <QVBoxLayout>
 #include <QPushButton>
-#include <QCheckBox>
 #include <QMessageBox>
 #include <QDialogButtonBox>
 
@@ -49,6 +47,10 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
     QGridLayout *main_layout = new QGridLayout( this );
     setWindowTitle( qtr( "Preferences" ) );
 
+    /* Whether we want it or not, we need to destroy on close to get
+       consistency when reset */
+    setAttribute( Qt::WA_DeleteOnClose );
+
     /* Create Panels */
     tree_panel = new QWidget;
     tree_panel_l = new QHBoxLayout;
@@ -58,13 +60,15 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
     main_panel->setLayout( main_panel_l );
 
     /* Choice for types */
-    types = new QGroupBox( "Show settings" );
+    types = new QGroupBox( qtr("Show settings") );
     types->setAlignment( Qt::AlignHCenter );
     QHBoxLayout *types_l = new QHBoxLayout;
     types_l->setSpacing( 3 ); types_l->setMargin( 3 );
-    small = new QRadioButton( qtr("Basic"), types );
+    small = new QRadioButton( qtr( "Simple" ), types );
+    small->setToolTip( qtr( "Switch to simple preferences view" ) );
     types_l->addWidget( small );
     all = new QRadioButton( qtr("All"), types ); types_l->addWidget( all );
+    all->setToolTip( qtr( "Switch to full preferences view" ) );
     types->setLayout( types_l );
     small->setChecked( true );
 
@@ -77,6 +81,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" ) );
 
@@ -94,7 +99,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 );
 
@@ -105,9 +110,12 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
     tree_panel_l->setMargin( 1 );
     main_panel_l->setLayoutMargins( 6, 0, 0, 3, 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( config_GetInt( p_intf, "qt-advanced-pref" ) || config_GetInt( p_intf, "advanced" ) )
         setAdvanced();
     else
         setSmall();
@@ -119,7 +127,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()
@@ -172,7 +180,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 ) );
@@ -189,7 +197,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 );
     }
@@ -207,7 +215,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 );
     }
@@ -218,6 +226,7 @@ void PrefsDialog::changeSimplePanel( int number )
 /* Changing from one Advanced Panel to another */
 void PrefsDialog::changeAdvPanel( QTreeWidgetItem *item )
 {
+    if( item == NULL ) return;
     PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>();
 
     if( advanced_panel )
@@ -343,8 +352,7 @@ void PrefsDialog::reset()
     int ret = QMessageBox::question(
                  this,
                  qtr( "Reset Preferences" ),
-                 qtr( "This will reset your VLC media player preferences.\n"
-                      "Are you sure you want to continue?" ),
+                 qtr( "Are you sure you want to reset your VLC media player preferences?" ),
                  QMessageBox::Ok | QMessageBox::Cancel,
                  QMessageBox::Ok);
 
@@ -352,7 +360,10 @@ void PrefsDialog::reset()
     {
         config_ResetAll( p_intf );
         config_SaveConfigFile( p_intf, NULL );
-        /* FIXME reset the panels */
-        destroyPanels();
+        getSettings()->clear();
+
+        close();
+        instance = NULL;
+        PrefsDialog::getInstance( p_intf )->show();
     }
 }