]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/simple_preferences.cpp
Qt: uniformize ui previews, drop xml declaration related to changes made by 2779ac98f...
[vlc] / modules / gui / qt4 / components / simple_preferences.cpp
index 729c6b0b3bb2899d0ac628416ac18d03b3f64608..1ffa0ff089c1f54510f5c808d8b139d8be2710cf 100644 (file)
 #include <QVBoxLayout>
 #include <QScrollArea>
 
+#include <QStyleFactory>
+#include <QSettings>
 #include <QtAlgorithms>
 
-#include <string>
-
 #define ICON_HEIGHT 64
 
 #ifdef WIN32
-#include "vistaassoc.h"
+# include <vlc_windows_interfaces.h>
 #endif
 
 /*********************************************************************
@@ -209,7 +209,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             ui.hwYUVBox->setVisible( false );
 #endif
 
-            CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterLabel, deinterlaceBox );
+            CONFIG_GENERIC( "deinterlace", StringList, ui.deinterLabel, deinterlaceBox );
             CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );
 
             CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
@@ -347,10 +347,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                 else
                     ui.lastfm->setChecked( false );
 
-                ui.lastfm_zone->setEnabled( ui.lastfm->isChecked() );
+                ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );
 
                 CONNECT( ui.lastfm, toggled( bool ),
-                         ui.lastfm_zone, setEnabled( bool ) );
+                         ui.lastfm_zone, setVisible( bool ) );
                 CONNECT( ui.lastfm, stateChanged( int ),
                          this, lastfm_Changed( int ) );
             }
@@ -403,6 +403,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                 free( psz_dvddiscpath );
                 free( psz_vcddiscpath );
             }
+            CONFIG_GENERIC_FILE( "dvd", File, ui.DVDLabel,
+                                 ui.DVDDevice, ui.DVDBrowse );
             CONFIG_GENERIC_FILE( "input-record-path", Directory, ui.recordLabel,
                                  ui.recordPath, ui.recordBrowse );
 
@@ -412,11 +414,21 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             CONFIG_GENERIC_NO_BOOL( "ffmpeg-pp-q", Integer, ui.ppLabel,
                                     PostProcLevel );
             CONFIG_GENERIC( "avi-index", IntegerList, ui.aviLabel, AviRepair );
-            CONFIG_GENERIC( "rtsp-tcp", Bool, NULL, RTSP_TCPBox );
+
+            /* live555 module prefs */
+            CONFIG_GENERIC( "rtsp-tcp", Bool, NULL,
+                                live555TransportRTSP_TCPRadio );
+            if ( !module_exists( "live555" ) )
+            {
+                ui.live555TransportRTSP_TCPRadio->hide();
+                ui.live555TransportHTTPRadio->hide();
+                ui.live555TransportLabel->hide();
+            }
 #ifdef WIN32
             CONFIG_GENERIC( "prefer-system-codecs", Bool, NULL, systemCodecBox );
 #else
             ui.systemCodecBox->hide();
+            ui.systemCodecLabel->hide();
 #endif
             optionWidgets.append( ui.DVDDevice );
             optionWidgets.append( ui.cachingCombo );
@@ -465,7 +477,9 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             if (module_exists ("pvr"))
                 TestCaC( "pvr-caching" );
             #endif
-            TestCaCi( "rtsp-caching", 4 ); TestCaCi( "ftp-caching", 2 );
+            if (module_exists ("livedotcom"))
+                TestCaCi( "rtsp-caching", 4 );
+            TestCaCi( "ftp-caching", 2 );
             TestCaCi( "http-caching", 4 );
             if (module_exists ("access_realrtsp"))
                 TestCaCi( "realrtsp-caching", 10 );
@@ -480,7 +494,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
          * Interface Panel *
          *******************/
         START_SPREFS_CAT( Interface, qtr("Interface Settings") );
-            ui.defaultLabel->setFont( italicFont );
+//            ui.defaultLabel->setFont( italicFont );
             ui.skinsLabel->setText(
                     qtr( "This is VLC's skinnable interface. You can download other skins at" )
                     + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">VLC skins website</a>." ) );
@@ -493,7 +507,6 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             ui.languageBox->hide();
             ui.assoBox->hide();
 #endif
-
             /* interface */
             char *psz_intf = config_GetPsz( p_intf, "intf" );
             if( psz_intf )
@@ -508,6 +521,19 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 
             optionWidgets.append( ui.skins );
             optionWidgets.append( ui.qt4 );
+#if !defined(NDEBUG) || !defined( WIN32)
+            ui.stylesCombo->addItem( qtr("System's default") );
+            ui.stylesCombo->addItems( QStyleFactory::keys() );
+            ui.stylesCombo->setCurrentIndex( ui.stylesCombo->findText(
+                        getSettings()->value( "MainWindow/QtStyle", "" ).toString() ) );
+            ui.stylesCombo->insertSeparator( 1 );
+
+            CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
+            optionWidgets.append( ui.stylesCombo );
+#else
+            ui.stylesCombo->hide();
+            optionWidgets.append( NULL );
+#endif
 
             ui.skins_zone->setEnabled( ui.skins->isChecked() );
             CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
@@ -520,7 +546,11 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                     addWidget( preview, 1, 0, 1, 2 );
             CONNECT( ui.displayModeBox, currentIndexChanged( int ),
                      preview, setPreview( int ) );
-            
+            InterfacePreviewWidget *skinspreview = new InterfacePreviewWidget( this );
+            skinspreview->setPreview(3); /* skins_preview resource index */
+            ( (QGridLayout *) ui.LooknfeelBox->layout() )->
+                    addWidget( skinspreview, 7, 0, 1, 2 );
+
             CONFIG_GENERIC( "qt-display-mode", IntegerList, ui.displayLabel,
                             displayModeBox );
             CONFIG_GENERIC( "embedded-video", Bool, NULL, embedVideo );
@@ -538,12 +568,12 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
             CONFIG_GENERIC( "qt-updates-notif", Bool, NULL, updatesBox );
             CONFIG_GENERIC_NO_BOOL( "qt-updates-days", Integer, NULL,
                     updatesDays );
-            ui.updatenotifier_zone->setEnabled( ui.updatesBox->isChecked() );
+            ui.updatesDays->setEnabled( ui.updatesBox->isChecked() );
             CONNECT( ui.updatesBox, toggled( bool ),
-                     ui.updatenotifier_zone, setEnabled( bool ) );
+                     ui.updatesDays, setEnabled( bool ) );
 #else
             ui.updatesBox->hide();
-            ui.updatenotifier_zone->hide();
+            ui.updatesDays->hide();
 #endif
             /* ONE INSTANCE options */
 #if defined( WIN32 ) || defined( HAVE_DBUS ) || defined(__APPLE__)
@@ -576,8 +606,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                             encoding );
             CONFIG_GENERIC( "sub-language", String, ui.subLangLabel,
                             preferredLanguage );
-            CONFIG_GENERIC_FILE( "freetype-font", File, ui.fontLabel, ui.font,
-                            ui.fontBrowse );
+            CONFIG_GENERIC_NO_BOOL( "freetype-font", Font, ui.fontLabel, font );
             CONFIG_GENERIC( "freetype-color", IntegerList, ui.fontColorLabel,
                             fontColor );
             CONFIG_GENERIC( "freetype-rel-fontsize", IntegerList,
@@ -694,13 +723,14 @@ void SPrefsPanel::apply()
     case SPrefsInputAndCodecs:
     {
         /* Device default selection */
-        const char *psz_devicepath =
-              qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->text() );
+        char *psz_devicepath =
+            strdup( qtu( qobject_cast<QLineEdit *>(optionWidgets[inputLE] )->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 );
+            free( psz_devicepath );
         }
 
 #define CaCi( name, int ) config_PutInt( p_intf, name, int * i_comboValue )
@@ -749,6 +779,10 @@ void SPrefsPanel::apply()
             config_PutPsz( p_intf, "intf", "skins2" );
         if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
             config_PutPsz( p_intf, "intf", "qt" );
+        if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) )
+            getSettings()->setValue( "MainWindow/QtStyle",
+                qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
+
         break;
     }
 
@@ -786,10 +820,24 @@ void SPrefsPanel::lastfm_Changed( int i_state )
         config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
 }
 
+void SPrefsPanel::changeStyle( QString s_style )
+{
+    QApplication::setStyle( s_style );
+
+    /* force refresh on all widgets */
+    QWidgetList widgets = QApplication::allWidgets();
+    QWidgetList::iterator it = widgets.begin();
+    while( it != widgets.end() ) {
+        (*it)->update();
+        it++;
+    };
+}
+
 #ifdef WIN32
 #include <QDialogButtonBox>
 #include <QHeaderView>
 #include "util/registry.hpp"
+#include <string>
 
 bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
                            QTreeWidgetItem* parent, QVLCRegistry *qvReg )