Commit 4b5e7346 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Allow to select the style of Qt in Simple preferences.

parent 93f25799
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QScrollArea> #include <QScrollArea>
#include <QStyleFactory>
#include <QSettings>
#include <QtAlgorithms> #include <QtAlgorithms>
#include <string> #include <string>
...@@ -482,7 +484,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -482,7 +484,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
* Interface Panel * * Interface Panel *
*******************/ *******************/
START_SPREFS_CAT( Interface, qtr("Interface Settings") ); START_SPREFS_CAT( Interface, qtr("Interface Settings") );
ui.defaultLabel->setFont( italicFont ); // ui.defaultLabel->setFont( italicFont );
ui.skinsLabel->setText( ui.skinsLabel->setText(
qtr( "This is VLC's skinnable interface. You can download other skins at" ) 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>." ) ); + QString( " <a href=\"http://www.videolan.org/vlc/skins.php\">VLC skins website</a>." ) );
...@@ -495,6 +497,13 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -495,6 +497,13 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
ui.languageBox->hide(); ui.languageBox->hide();
ui.assoBox->hide(); ui.assoBox->hide();
#endif #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 */ /* interface */
char *psz_intf = config_GetPsz( p_intf, "intf" ); char *psz_intf = config_GetPsz( p_intf, "intf" );
...@@ -510,6 +519,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -510,6 +519,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
optionWidgets.append( ui.skins ); optionWidgets.append( ui.skins );
optionWidgets.append( ui.qt4 ); optionWidgets.append( ui.qt4 );
optionWidgets.append( ui.stylesCombo );
ui.skins_zone->setEnabled( ui.skins->isChecked() ); ui.skins_zone->setEnabled( ui.skins->isChecked() );
CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) ); CONNECT( ui.skins, toggled( bool ), ui.skins_zone, setEnabled( bool ) );
...@@ -750,6 +760,9 @@ void SPrefsPanel::apply() ...@@ -750,6 +760,9 @@ void SPrefsPanel::apply()
config_PutPsz( p_intf, "intf", "skins2" ); config_PutPsz( p_intf, "intf", "skins2" );
if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() ) if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
config_PutPsz( p_intf, "intf", "qt" ); config_PutPsz( p_intf, "intf", "qt" );
getSettings()->setValue( "MainWindow/QtStyle",
qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() );
break; break;
} }
...@@ -787,6 +800,19 @@ void SPrefsPanel::lastfm_Changed( int i_state ) ...@@ -787,6 +800,19 @@ void SPrefsPanel::lastfm_Changed( int i_state )
config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ); 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 #ifdef WIN32
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QHeaderView> #include <QHeaderView>
......
...@@ -78,7 +78,7 @@ enum { ...@@ -78,7 +78,7 @@ enum {
spdifChB, spdifChB,
}; };
enum { inputLE, cachingCoB }; enum { inputLE, cachingCoB };
enum { skinRB, qtRB }; enum { skinRB, qtRB, styleCB };
class ConfigControl; class ConfigControl;
class QComboBox; class QComboBox;
...@@ -136,6 +136,7 @@ private slots: ...@@ -136,6 +136,7 @@ private slots:
void assoDialog(); void assoDialog();
void saveAsso(); void saveAsso();
#endif #endif
void changeStyle( QString );
}; };
#endif #endif
...@@ -451,6 +451,12 @@ static void *Thread( void *obj ) ...@@ -451,6 +451,12 @@ static void *Thread( void *obj )
p_intf->p_sys->filepath = p_intf->p_sys->filepath =
getSettings()->value( "filedialog-path", config_GetHomeDir() ).toString(); 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 */ /* Launch */
app.exec(); app.exec();
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment