]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/simple_preferences.cpp
qt4 simple preferences: only show the options of the selected audio output module
[vlc] / modules / gui / qt4 / components / simple_preferences.cpp
index 18c1f9ea213cd5433adc4247af33d5e7806a0249..2d35fb1bdeabfe9eb9eb261b8765c677bf54cdea 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "components/simple_preferences.hpp"
 #include "components/preferences_widgets.hpp"
-#include "qt4.hpp"
 
 #include "ui/sprefs_audio.h"
 #include "ui/sprefs_input.h"
@@ -167,7 +166,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     {
         /* Video Panel Implementation */
         START_SPREFS_CAT( Video , qtr("General video settings") );
-           CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
+            CONFIG_GENERIC( "video", Bool, NULL, enableVideo );
 
             CONFIG_GENERIC( "fullscreen", Bool, NULL, fullscreen );
             CONFIG_GENERIC( "overlay", Bool, NULL, overlay );
@@ -196,37 +195,48 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 
          /* Audio Panel Implementation */
         START_SPREFS_CAT( Audio, qtr("General audio settings") );
-#ifdef WIN32
-            ui.OSSBrowse->hide();
-            ui.OSSDevice->hide();
-            ui.OSSLabel->hide();
-            ui.alsaDevice->hide();
-            ui.alsaLabel->hide();
-#else
-            ui.DirectXLabel->setVisible( false );
-            ui.DirectXDevice->setVisible( false );
-#endif
-         CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
 
-         CONFIG_GENERIC_NO_BOOL( "volume" ,  IntegerRangeSlider, NULL,
+        CONFIG_GENERIC( "audio", Bool, NULL, enableAudio );
+
+        CONFIG_GENERIC_NO_BOOL( "volume" ,  IntegerRangeSlider, NULL,
                  defaultVolume );
-         CONFIG_GENERIC( "audio-language" , String , NULL,
+        CONFIG_GENERIC( "audio-language" , String , NULL,
                     preferredAudioLanguage );
 
-         CONFIG_GENERIC( "spdif" , Bool , NULL, spdifBox );
-         CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
+        CONFIG_GENERIC( "spdif" , Bool , NULL, spdifBox );
+        CONFIG_GENERIC( "force-dolby-surround" , IntegerList , NULL,
                     detectionDolby );
 
          CONFIG_GENERIC( "aout" , Module , NULL, outputModule );
+         CONNECT( control, Updated(), this, AudioDeviceChanged() );
+         QString aout_value = (dynamic_cast<ModuleConfigControl*>(control))->getValue();
 #ifndef WIN32
-         CONFIG_GENERIC( "alsadev" , StringList , NULL, alsaDevice );
-         CONFIG_GENERIC_FILE( "dspdev" , File , NULL, OSSDevice, OSSBrowse );
+         CONFIG_GENERIC( "alsadev" , StringList , ui.alsaLabel, alsaDevice );
+         alsa_options = control;
+         CONFIG_GENERIC_FILE( "dspdev" , File , ui.OSSLabel, OSSDevice,
+                 OSSBrowse );
+         oss_options = control;
 #else
-         CONFIG_GENERIC( "directx-audio-device" , IntegerList, NULL,
+         CONFIG_GENERIC( "directx-audio-device" , IntegerList, ui.DirectXLabel,
                  DirectXDevice );
+         directx_options = control;
 #endif
-         CONFIG_GENERIC_FILE( "audiofile-file" , File , NULL, FileName,
+         CONFIG_GENERIC_FILE( "audiofile-file" , File , ui.FileLabel, FileName,
                  fileBrowseButton );
+         file_options = control;
+
+#ifdef WIN32
+            ui.OSSBrowse->hide();
+            ui.OSSDevice->hide();
+            ui.OSSLabel->hide();
+            ui.alsaDevice->hide();
+            ui.alsaLabel->hide();
+#else
+            ui.DirectXLabel->setVisible( false );
+            ui.DirectXDevice->setVisible( false );
+#endif
+
+        updateAudioOptions( aout_value );
 
          CONFIG_GENERIC( "headphone-dolby" , Bool , NULL, headphoneEffect );
 //         CONFIG_GENERIC( "" , Bool, NULL, ); activation of normalizer //FIXME
@@ -256,7 +266,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 #endif
           CONFIG_GENERIC( "timeshift-force", Bool, NULL, timeshiftBox );
           CONFIG_GENERIC( "dump-force", Bool, NULL, DumpBox );
-//        CONFIG_GENERIC( "", Bool, NULL, RecordBox ); //FIXME activate record 
+//        CONFIG_GENERIC( "", Bool, NULL, RecordBox ); //FIXME activate record
         END_SPREFS_CAT;
 
         /* Interface Panel */
@@ -284,11 +294,11 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             //FIXME interface choice
 
             CONFIG_GENERIC( "qt-always-video", Bool, NULL, qtAlwaysVideo );
-            CONFIG_GENERIC_FILE( "skins2-last", File, NULL, fileSkin, 
+            CONFIG_GENERIC_FILE( "skins2-last", File, NULL, fileSkin,
                     skinBrowse );
 #if defined( WIN32 ) || defined(HAVE_DBUS_3)
             CONFIG_GENERIC( "one-instance", Bool, NULL, OneInterfaceMode );
-            CONFIG_GENERIC( "playlist-enqueue", Bool, NULL, 
+            CONFIG_GENERIC( "playlist-enqueue", Bool, NULL,
                     EnqueueOneInterfaceMode );
 #else
             ui.OneInterfaceBox->hide();
@@ -322,6 +332,36 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
     this->setLayout(panel_layout);
 }
 
+void SPrefsPanel::AudioDeviceChanged()
+{
+    ModuleConfigControl *module_config =
+            dynamic_cast<ModuleConfigControl*>( sender() );
+    updateAudioOptions( module_config->getValue() );
+}
+
+void SPrefsPanel::updateAudioOptions( QString value )
+{
+#ifndef WIN32
+    alsa_options->hide();
+    oss_options->hide();
+#else
+    directx_options->hide();
+#endif
+    file_options->hide();
+
+    if( value == "aout_file" )
+        file_options->show();
+#ifndef WIN32
+    else if( value == "alsa" )
+        alsa_options->show();
+    else if( value == "oss" )
+        oss_options->show();
+#else
+    else if( value == "directx" )
+        directx_options->show();
+#endif
+}
+
 void SPrefsPanel::apply()
 {
     QList<ConfigControl *>::Iterator i;