Commit 9e7f5e07 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: remove Sprefs hack that has lived and been abused for too long...

parent b266c9b8
...@@ -296,33 +296,29 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -296,33 +296,29 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout()); QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
#ifdef WIN32 #ifdef WIN32
audioControl( DirectX ); audioControl( DirectX );
optionWidgets.append( DirectXControl ); optionWidgets["directxW" ] = DirectXControl;
CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList, CONFIG_GENERIC_NO_UI( "directx-audio-device", StringList,
DirectXLabel, DirectXDevice ); DirectXLabel, DirectXDevice );
#elif defined( __OS2__ ) #elif defined( __OS2__ )
audioControl( kai ); audioControl( kai );
optionWidgets.append( kaiControl ); optionWidgets["kaiW"] = kaiControl;
CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel, CONFIG_GENERIC_NO_UI( "kai-audio-device", StringList, kaiLabel,
kaiDevice ); kaiDevice );
#else #else
if( module_exists( "alsa" ) ) if( module_exists( "alsa" ) )
{ {
audioControl( alsa ); audioControl( alsa );
optionWidgets.append( alsaControl ); optionWidgets["alsaW"] = alsaControl;
CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel, CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
alsaDevice ); alsaDevice );
} }
else
optionWidgets.append( NULL );
if( module_exists( "oss" ) ) if( module_exists( "oss" ) )
{ {
audioControl2( OSS ); audioControl2( OSS );
optionWidgets.append( OSSControl ); optionWidgets["ossW"] = OSSControl;
CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice, CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
OSSBrowse ); OSSBrowse );
} }
else
optionWidgets.append( NULL );
#endif #endif
#undef audioControl2 #undef audioControl2
...@@ -366,14 +362,14 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -366,14 +362,14 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel, CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
ui.fileName, ui.fileBrowseButton ); ui.fileName, ui.fileBrowseButton );
optionWidgets.append( ui.fileControl ); optionWidgets["fileW"] = ui.fileControl;
optionWidgets.append( ui.outputModule ); optionWidgets["audioOutCoB"] = ui.outputModule;
optionWidgets.append( ui.volNormBox ); optionWidgets["normalizerChB"] = ui.volNormBox;
/*Little mofification of ui.volumeValue to compile with Qt < 4.3 */ /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons); ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
optionWidgets.append( ui.volumeValue ); optionWidgets["volLW"] = ui.volumeValue;
optionWidgets.append( ui.headphoneEffect ); optionWidgets["headphoneB"] = ui.headphoneEffect;
optionWidgets.append( ui.spdifBox ); optionWidgets["spdifChB"] = ui.spdifBox;
updateAudioOptions( ui.outputModule->currentIndex() ); updateAudioOptions( ui.outputModule->currentIndex() );
/* LastFM */ /* LastFM */
...@@ -481,8 +477,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -481,8 +477,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
else else
FreeLibrary( hdxva2_dll ); FreeLibrary( hdxva2_dll );
#endif #endif
optionWidgets.append( ui.DVDDeviceComboBox ); optionWidgets["inputLE"] = ui.DVDDeviceComboBox;
optionWidgets.append( ui.cachingCombo ); optionWidgets["cachingCoB"] = ui.cachingCombo;
CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox ); CONFIG_GENERIC( "avcodec-skiploopfilter", IntegerList, ui.filterLabel, loopFilterBox );
CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox ); CONFIG_GENERIC( "sout-x264-tune", StringList, ui.x264Label, tuneBox );
CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox ); CONFIG_GENERIC( "sout-x264-preset", StringList, ui.x264Label, presetBox );
...@@ -560,8 +556,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -560,8 +556,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
} }
free( psz_intf ); free( psz_intf );
optionWidgets.append( ui.skins ); optionWidgets["skinRB"] = ui.skins;
optionWidgets.append( ui.qt ); optionWidgets["qtRB"] = ui.qt;
#if !defined( WIN32) #if !defined( WIN32)
ui.stylesCombo->addItem( qtr("System's default") ); ui.stylesCombo->addItem( qtr("System's default") );
ui.stylesCombo->addItems( QStyleFactory::keys() ); ui.stylesCombo->addItems( QStyleFactory::keys() );
...@@ -572,11 +568,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -572,11 +568,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
ui.stylesCombo->setCurrentIndex( 0 ); /* default */ ui.stylesCombo->setCurrentIndex( 0 ); /* default */
CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) ); CONNECT( ui.stylesCombo, currentIndexChanged( QString ), this, changeStyle( QString ) );
optionWidgets.append( ui.stylesCombo ); optionWidgets["styleCB"] = ui.stylesCombo;
#else #else
ui.stylesCombo->hide(); ui.stylesCombo->hide();
ui.stylesLabel->hide(); ui.stylesLabel->hide();
optionWidgets.append( NULL );
#endif #endif
radioGroup = new QButtonGroup(this); radioGroup = new QButtonGroup(this);
radioGroup->addButton( ui.qt, 0 ); radioGroup->addButton( ui.qt, 0 );
...@@ -681,8 +676,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -681,8 +676,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 ); ui.shadowCheck->setChecked( config_GetInt( p_intf, "freetype-shadow-opacity" ) > 0 );
ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 ); ui.backgroundCheck->setChecked( config_GetInt( p_intf, "freetype-background-opacity" ) > 0 );
optionWidgets.append( ui.shadowCheck ); optionWidgets["shadowCB"] = ui.shadowCheck;
optionWidgets.append( ui.backgroundCheck ); optionWidgets["backgroundCB"] = ui.backgroundCheck;
END_SPREFS_CAT; END_SPREFS_CAT;
...@@ -757,22 +752,22 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -757,22 +752,22 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
void SPrefsPanel::updateAudioOptions( int number) void SPrefsPanel::updateAudioOptions( int number)
{ {
QString value = qobject_cast<QComboBox *>(optionWidgets[audioOutCoB]) QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
->itemData( number ).toString(); ->itemData( number ).toString();
#ifdef WIN32 #ifdef WIN32
optionWidgets[directxW]->setVisible( ( value == "directsound" ) ); optionWidgets["directxW"]->setVisible( ( value == "directsound" ) );
#elif defined( __OS2__ ) #elif defined( __OS2__ )
optionWidgets[kaiW]->setVisible( ( value == "kai" ) ); optionWidgets["kaiW"]->setVisible( ( value == "kai" ) );
#else #else
/* optionWidgets[ossW] can be NULL */ /* optionWidgets["ossW] can be NULL */
if( optionWidgets[ossW] ) if( optionWidgets["ossW"] )
optionWidgets[ossW]->setVisible( ( value == "oss" ) ); optionWidgets["ossW"]->setVisible( ( value == "oss" ) );
/* optionWidgets[alsaW] can be NULL */ /* optionWidgets["alsaW] can be NULL */
if( optionWidgets[alsaW] ) if( optionWidgets["alsaW"] )
optionWidgets[alsaW]->setVisible( ( value == "alsa" ) ); optionWidgets["alsaW"]->setVisible( ( value == "alsa" ) );
#endif #endif
optionWidgets[fileW]->setVisible( ( value == "aout_file" ) ); optionWidgets["fileW"]->setVisible( ( value == "aout_file" ) );
optionWidgets[spdifChB]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" || optionWidgets["spdifChB"]->setVisible( ( value == "alsa" || value == "oss" || value == "auhal" ||
value == "directsound" || value == "waveout" ) ); value == "directsound" || value == "waveout" ) );
} }
...@@ -784,7 +779,7 @@ SPrefsPanel::~SPrefsPanel() ...@@ -784,7 +779,7 @@ SPrefsPanel::~SPrefsPanel()
void SPrefsPanel::updateAudioVolume( int volume ) void SPrefsPanel::updateAudioVolume( int volume )
{ {
qobject_cast<QSpinBox *>(optionWidgets[volLW]) qobject_cast<QSpinBox *>(optionWidgets["volLW"])
->setValue( volume * 100 / AOUT_VOLUME_DEFAULT ); ->setValue( volume * 100 / AOUT_VOLUME_DEFAULT );
} }
...@@ -806,7 +801,7 @@ void SPrefsPanel::apply() ...@@ -806,7 +801,7 @@ void SPrefsPanel::apply()
{ {
/* Device default selection */ /* Device default selection */
QByteArray devicepath = QByteArray devicepath =
qobject_cast<QComboBox *>(optionWidgets[inputLE])->currentText().toUtf8(); qobject_cast<QComboBox *>(optionWidgets["inputLE"])->currentText().toUtf8();
if( devicepath.size() > 0 ) if( devicepath.size() > 0 )
{ {
config_PutPsz( p_intf, "dvd", devicepath ); config_PutPsz( p_intf, "dvd", devicepath );
...@@ -816,7 +811,7 @@ void SPrefsPanel::apply() ...@@ -816,7 +811,7 @@ void SPrefsPanel::apply()
#define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor ) #define CaC( name, factor ) config_PutInt( p_intf, name, i_comboValue * factor )
/* Caching */ /* Caching */
QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets[cachingCoB]); QComboBox *cachingCombo = qobject_cast<QComboBox *>(optionWidgets["cachingCoB"]);
int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt(); int i_comboValue = cachingCombo->itemData( cachingCombo->currentIndex() ).toInt();
if( i_comboValue ) if( i_comboValue )
{ {
...@@ -832,14 +827,14 @@ void SPrefsPanel::apply() ...@@ -832,14 +827,14 @@ void SPrefsPanel::apply()
/* Interfaces */ /* Interfaces */
case SPrefsInterface: case SPrefsInterface:
{ {
if( qobject_cast<QRadioButton *>(optionWidgets[skinRB])->isChecked() ) if( qobject_cast<QRadioButton *>(optionWidgets["skinRB"])->isChecked() )
config_PutPsz( p_intf, "intf", "skins2,any" ); config_PutPsz( p_intf, "intf", "skins2,any" );
else else
//if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() ) //if( qobject_cast<QRadioButton *>(optionWidgets[qtRB])->isChecked() )
config_PutPsz( p_intf, "intf", "" ); config_PutPsz( p_intf, "intf", "" );
if( qobject_cast<QComboBox *>(optionWidgets[styleCB]) ) if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) )
getSettings()->setValue( "MainWindow/QtStyle", getSettings()->setValue( "MainWindow/QtStyle",
qobject_cast<QComboBox *>(optionWidgets[styleCB])->currentText() ); qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() );
break; break;
} }
...@@ -847,14 +842,14 @@ void SPrefsPanel::apply() ...@@ -847,14 +842,14 @@ void SPrefsPanel::apply()
case SPrefsAudio: case SPrefsAudio:
{ {
bool b_checked = bool b_checked =
qobject_cast<QCheckBox *>(optionWidgets[normalizerChB])->isChecked(); qobject_cast<QCheckBox *>(optionWidgets["normalizerChB"])->isChecked();
if( b_checked && !qs_filter.contains( "normvol" ) ) if( b_checked && !qs_filter.contains( "normvol" ) )
qs_filter.append( "normvol" ); qs_filter.append( "normvol" );
if( !b_checked && qs_filter.contains( "normvol" ) ) if( !b_checked && qs_filter.contains( "normvol" ) )
qs_filter.removeAll( "normvol" ); qs_filter.removeAll( "normvol" );
b_checked = b_checked =
qobject_cast<QCheckBox *>(optionWidgets[headphoneB])->isChecked(); qobject_cast<QCheckBox *>(optionWidgets["headphoneB"])->isChecked();
if( b_checked && !qs_filter.contains( "headphone" ) ) if( b_checked && !qs_filter.contains( "headphone" ) )
qs_filter.append( "headphone" ); qs_filter.append( "headphone" );
...@@ -866,7 +861,7 @@ void SPrefsPanel::apply() ...@@ -866,7 +861,7 @@ void SPrefsPanel::apply()
} }
case SPrefsSubtitles: case SPrefsSubtitles:
{ {
bool b_checked = qobject_cast<QCheckBox *>(optionWidgets[shadowCB])->isChecked(); bool b_checked = qobject_cast<QCheckBox *>(optionWidgets["shadowCB"])->isChecked();
if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) { if( b_checked && config_GetInt( p_intf, "freetype-shadow-opacity" ) == 0 ) {
config_PutInt( p_intf, "freetype-shadow-opacity", 128 ); config_PutInt( p_intf, "freetype-shadow-opacity", 128 );
} }
...@@ -874,7 +869,7 @@ void SPrefsPanel::apply() ...@@ -874,7 +869,7 @@ void SPrefsPanel::apply()
config_PutInt( p_intf, "freetype-shadow-opacity", 0 ); config_PutInt( p_intf, "freetype-shadow-opacity", 0 );
} }
b_checked = qobject_cast<QCheckBox *>(optionWidgets[backgroundCB])->isChecked(); b_checked = qobject_cast<QCheckBox *>(optionWidgets["backgroundCB"])->isChecked();
if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) { if( b_checked && config_GetInt( p_intf, "freetype-background-opacity" ) == 0 ) {
config_PutInt( p_intf, "freetype-background-opacity", 128 ); config_PutInt( p_intf, "freetype-background-opacity", 128 );
} }
......
...@@ -63,26 +63,6 @@ enum { ...@@ -63,26 +63,6 @@ enum {
CachingHigher = 1000 CachingHigher = 1000
}; };
enum {
#ifdef WIN32
directxW,
#elif defined( __OS2__)
kaiW,
#else
alsaW,
ossW,
#endif
fileW,
audioOutCoB,
normalizerChB,
volLW,
headphoneB,
spdifChB,
};
enum { inputLE, cachingCoB };
enum { skinRB, qtRB, styleCB };
enum { shadowCB, backgroundCB };
class ConfigControl; class ConfigControl;
class QComboBox; class QComboBox;
class QLineEdit; class QLineEdit;
...@@ -123,7 +103,7 @@ private: ...@@ -123,7 +103,7 @@ private:
int number; int number;
QWidgetList optionWidgets; QHash<QString, QWidget*> optionWidgets;
QStringList qs_filter; QStringList qs_filter;
QButtonGroup *radioGroup; QButtonGroup *radioGroup;
......
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