]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/simple_preferences.cpp
Qt4 - Preferences, don't remove the widgets to re-add them! Just use hide/show.....
[vlc] / modules / gui / qt4 / components / simple_preferences.cpp
index 1c2e7b8c44f9d6a6ec04e246349c5d0c8b296fb7..03ce8619148ae15be794a90ad973912ca809f810 100644 (file)
@@ -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 );  \
@@ -165,7 +166,9 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 
     switch( number )
     {
-        /* Video Panel Implementation */
+        /******************************
+         * VIDEO Panel Implementation *
+         ******************************/
         START_SPREFS_CAT( Video , qtr("General video settings") );
             CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
 
@@ -194,11 +197,14 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                             snapshotsFormat );
          END_SPREFS_CAT;
 
-         /* Audio Panel Implementation */
+        /******************************
+         * AUDIO Panel Implementation *
+         ******************************/
         START_SPREFS_CAT( Audio, qtr("General audio settings") );
 
             CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
 
+            /* General Audio Options */
             CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
                                      defaultVolume );
             CONFIG_GENERIC( "audio-language" , String , NULL,
@@ -208,6 +214,13 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
                             detectionDolby );
 
+            CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
+//          CONFIG_GENERIC( "" , Bool, NULL, ); activation of normalizer //FIXME
+            CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
+                                    volNormalizer );
+            CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
+
+            /* Audio Output Specifics */
             CONFIG_GENERIC( "aout", Module, NULL, outputModule );
 
             CONNECT( ui.outputModule, currentIndexChanged( int ), this,
@@ -220,12 +233,12 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             CONFIG_GENERIC_FILE( "dspdev" , File , ui.OSSLabel, OSSDevice,
                                  OSSBrowse );
 #else
-            CONFIG_GENERIC( "directx-audio-device", IntegerList, ui.DirectXLabel,
-                            DirectXDevice );
+            CONFIG_GENERIC( "directx-audio-device", IntegerList,
+                    ui.DirectXLabel, DirectXDevice );
 #endif
         // File exists everywhere
-            CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel, fileName,
-                                 fileBrowseButton );
+            CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.fileLabel,
+                                 fileName, fileBrowseButton );
             alsa_options = ui.alsaControl;
             oss_options = ui.OSSControl;
             directx_options = ui.DirectXControl;
@@ -233,42 +246,54 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 
         /* and hide if necessary */
 #ifdef WIN32
-        oss_options->hide();
-        alsa_options->hide();
+            oss_options->hide();
+            alsa_options->hide();
 #else
-        directx_options->hide();
+            directx_options->hide();
 #endif
 
-        updateAudioOptions( audioOutput->currentIndex() );
-
-        CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
-//         CONFIG_GENERIC( "" , Bool, NULL, ); activation of normalizer //FIXME
-        CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float , NULL,
-                 volNormalizer );
-        CONFIG_GENERIC( "audio-visual" , Module , NULL, visualisation);
+            updateAudioOptions( audioOutput->currentIndex() );
 
-
-        CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
+            /* LastFM */
+            CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
                          lastfm_user_edit );
-        CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
+            CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
                          lastfm_pass_edit );
-        ui.lastfm_user_edit->hide();
-        ui.lastfm_user_label->hide();
-        ui.lastfm_pass_edit->hide();
-        ui.lastfm_pass_label->hide();
-
-        if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
-            ui.lastfm->setCheckState( Qt::Checked );
-        else
-            ui.lastfm->setCheckState( Qt::Unchecked );
-        CONNECT( ui.lastfm, stateChanged( int ), this , lastfm_Changed( int ) );
+            ui.lastfm_user_edit->hide();
+            ui.lastfm_user_label->hide();
+            ui.lastfm_pass_edit->hide();
+            ui.lastfm_pass_label->hide();
+
+            if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
+                ui.lastfm->setCheckState( Qt::Checked );
+            else
+                ui.lastfm->setCheckState( Qt::Unchecked );
+            CONNECT( ui.lastfm, stateChanged( int ), this ,
+                    lastfm_Changed( int ) );
 
         END_SPREFS_CAT;
 
         /* Input and Codecs Panel Implementation */
         START_SPREFS_CAT( InputAndCodecs, qtr("Input & Codecs settings") );
+            inputDevice = ui.DVDDevice;
           /* Disk Devices */
-/*          CONFIG_GENERIC( );*/ //FIXME
+            {
+                ui.DVDDevice->setToolTip(
+                    qtr( "If this propriety is blank, then you have\n"
+                         "values for DVD, VCD, and CDDA.\n"
+                         "You can define a unique one or set that in"
+                         "the advanced preferences" ) );
+                char *psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
+                char *psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
+                char *psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
+                if( ( *psz_cddadiscpath == *psz_dvddiscpath )
+                   && ( *psz_dvddiscpath == *psz_vcddiscpath ) )
+                {
+                    ui.DVDDevice->setText( qfu( psz_dvddiscpath ) );
+                }
+                delete psz_cddadiscpath; delete psz_dvddiscpath;
+                delete psz_vcddiscpath;
+            }
 
           CONFIG_GENERIC_NO_BOOL( "server-port", Integer, NULL, UDPPort );
           CONFIG_GENERIC( "http-proxy", String , NULL, proxy );
@@ -309,9 +334,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             }
             if( p_config->value.psz && strcmp( p_config->value.psz, "skins2" ))
             {
-                    ui.skins->setChecked( true );
+                ui.skins->setChecked( true );
             }
-            //FIXME interface choice
+            skinInterfaceButton = ui.skins;
+            qtInterfaceButton = ui.qt4;
 
             CONFIG_GENERIC( "qt-always-video", Bool, NULL, qtAlwaysVideo );
             CONFIG_GENERIC_FILE( "skins2-last", File, NULL, fileSkin,
@@ -355,7 +381,6 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 void SPrefsPanel::updateAudioOptions( int number)
 {
     QString value = audioOutput->itemData( number ).toString();
-    msg_Dbg( p_intf, "I was here, waiting for funman, %s", qtu( value ) );
 
 #ifndef WIN32
     oss_options->hide();
@@ -380,12 +405,36 @@ void SPrefsPanel::updateAudioOptions( int number)
 
 void SPrefsPanel::apply()
 {
+    msg_Dbg( p_intf, "Trying to save the %i simple panel", number );
+    
+    /* Generic save for ever panel */
     QList<ConfigControl *>::Iterator i;
     for( i = controls.begin() ; i != controls.end() ; i++ )
     {
         ConfigControl *c = qobject_cast<ConfigControl *>(*i);
         c->doApply( p_intf );
     }
+
+    /* Devices */
+    if( number == SPrefsInputAndCodecs )
+    {
+        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( number == SPrefsInterface )
+    {
+        if( skinInterfaceButton->isChecked() )
+            config_PutPsz( p_intf, "intf", "skins2" );
+        if( qtInterfaceButton->isChecked() )
+            config_PutPsz( p_intf, "intf", "qt4" );
+    }
 }
 
 void SPrefsPanel::clean()