From: Jean-Baptiste Kempf Date: Tue, 11 Aug 2009 22:06:37 +0000 (+0200) Subject: Allow to select the style of Qt in Simple preferences. X-Git-Tag: 1.1.0-ff~4450 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4b5e73462a40229ef144db6553e1e450b8eba9c8;p=vlc Allow to select the style of Qt in Simple preferences. --- diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp index c390736fb9..d905ac87b9 100644 --- a/modules/gui/qt4/components/simple_preferences.cpp +++ b/modules/gui/qt4/components/simple_preferences.cpp @@ -40,6 +40,8 @@ #include #include +#include +#include #include #include @@ -482,7 +484,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( " VLC skins website." ) ); @@ -495,6 +497,13 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ui.languageBox->hide(); ui.assoBox->hide(); #endif + 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 ) ); + /* interface */ char *psz_intf = config_GetPsz( p_intf, "intf" ); @@ -510,6 +519,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, optionWidgets.append( ui.skins ); optionWidgets.append( ui.qt4 ); + optionWidgets.append( ui.stylesCombo ); ui.skins_zone->setEnabled( ui.skins->isChecked() ); CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) ); @@ -750,6 +760,9 @@ void SPrefsPanel::apply() config_PutPsz( p_intf, "intf", "skins2" ); if( qobject_cast(optionWidgets[qtRB])->isChecked() ) config_PutPsz( p_intf, "intf", "qt" ); + getSettings()->setValue( "MainWindow/QtStyle", + qobject_cast(optionWidgets[styleCB])->currentText() ); + break; } @@ -787,6 +800,19 @@ 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 #include diff --git a/modules/gui/qt4/components/simple_preferences.hpp b/modules/gui/qt4/components/simple_preferences.hpp index 7e0936e983..e61e06bee0 100644 --- a/modules/gui/qt4/components/simple_preferences.hpp +++ b/modules/gui/qt4/components/simple_preferences.hpp @@ -78,7 +78,7 @@ enum { spdifChB, }; enum { inputLE, cachingCoB }; -enum { skinRB, qtRB }; +enum { skinRB, qtRB, styleCB }; class ConfigControl; class QComboBox; @@ -136,6 +136,7 @@ private slots: void assoDialog(); void saveAsso(); #endif + void changeStyle( QString ); }; #endif diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp index bce9dcd774..28d10d8c71 100644 --- a/modules/gui/qt4/qt4.cpp +++ b/modules/gui/qt4/qt4.cpp @@ -451,6 +451,12 @@ static void *Thread( void *obj ) p_intf->p_sys->filepath = getSettings()->value( "filedialog-path", config_GetHomeDir() ).toString(); + /* Loads and tries to apply the preferred QStyle */ + QString s_style = getSettings()->value( "MainWindow/QtStyle", "" ).toString(); + if( s_style.compare("") != 0 ) + QApplication::setStyle( s_style ); + + /* Launch */ app.exec(); diff --git a/modules/gui/qt4/ui/sprefs_interface.ui b/modules/gui/qt4/ui/sprefs_interface.ui index 7df8576114..164221214a 100644 --- a/modules/gui/qt4/ui/sprefs_interface.ui +++ b/modules/gui/qt4/ui/sprefs_interface.ui @@ -1,8 +1,9 @@ - + + Jean-Baptiste Kempf SPrefsInterface - - + + 0 0 @@ -10,32 +11,32 @@ 657 - - + + 0 0 - + Form - - - - + + + + Instances - - - - + + + + Allow only one instance - - - + + + Enqueue files when in one instance mode @@ -43,63 +44,63 @@ - - - + + + Privacy / Network Interaction - - - - + + + + 220 0 - + Album art download policy: - - + + - - - + + + Activate update notifier - - - - + + + + 0 0 - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + days - + Every - - - + + + Qt::Horizontal - + QSizePolicy::Preferred - + 200 27 @@ -107,35 +108,35 @@ - - - + + + Save recently played items - - - + + + Filter: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 5 - - - - + + + + 0 0 - + Separate words by | (without space) @@ -143,117 +144,161 @@ - - - - Look and feel + + + + Language + + + + + + + 220 + 16777215 + + + + Menus language: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + + File associations - - - - - + + + + + 0 0 - - QFrame::NoFrame - - - This is VLC's default interface, with a native look and feel. + + + 220 + 0 + - - Qt::RichText + + Set up associations... - - true + + + + + + Qt::Horizontal - - 10 + + + 40 + 20 + - + - - - + + + + + + + Look and feel + + + + + Use custom skin - - - - + + + + 0 0 - + QFrame::NoFrame - + - + Qt::RichText - + false - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + true - + 5 - + true - - - + + + Qt::Horizontal - - - + + + true - - + + 0 0 - - + + 0 - - + + Skin resource file: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + fileSkin - - - + + + 0 0 @@ -261,14 +306,14 @@ - - - + + + 0 0 - + Choose... @@ -276,175 +321,118 @@ - - - - Use native style - - - true - - - - - - - + + + + 0 - - - - + + + + 0 0 - - - + + + Show controls in full screen mode - - - - + + + + 0 0 - + Qt::LeftToRight - + Display mode: - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - + + + Show systray icon - - - + + + Resize interface to video size - - - + + + Embed video in interface + + + + + + + Force window style: + + + - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/prefsmenu/sample_skins" /></p></body></html> - - - - - - - - - - Language - - - - - - - 220 - 16777215 - - - - Menus language: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/prefsmenu/sample_skins" /></p></body></html> - - - - - - - - - - File associations - - - - - - - 0 - 0 - + + + + This is VLC's default interface, with a native look and feel. - - - 220 - 0 - + + Use native style - - Set up associations... + + true - - - - Qt::Horizontal - - - - 40 - 20 - - - - - qt4 OneInterfaceMode artFetcher updatesBox - +