Commit cd76b2cc authored by Daniel Faust's avatar Daniel Faust
Browse files

Fix crash when trying to save custom equalizer presets.

This also improves the UI a little bit (deactivates unusable buttons).

Also it prohibits saving a 'Manual' profile in non-english versions.
Overwriting default presets still doesn't work in non-english versions, though.

BUG:286227
FIXED-IN:2.6
parent 1020874d
......@@ -29,6 +29,7 @@ Version 2.6-Beta 1
"1.2 GB free" is shown instead of "85% used"; thicker capacity bar.
BUGFIXES:
* Fix crash when trying to save custom equalizer presets. (BR 286227)
* Fix crash due to my silly method order error. (BR 291968)
* Fix favored random track playing picking recent played songs (BR 244442)
* Fix crashes with Bookmarks (BR 283753) thanks to Charles Reiss
......
......@@ -175,6 +175,14 @@ EqualizerDialog::eqPresetChanged( int index ) //SLOT
if( index < 0 )
return;
// use offset by one since the first entry ("Off") is not part of the global list
if( index > mPresets.eqGlobalList().count() )
{
eqSavePreset();
return;
}
// new settings
AmarokConfig::setEqualizerMode( index );
AmarokConfig::setEqualizerGains( mPresets.eqCfgGetPresetVal( eqSelectedPresetName() ) );
......@@ -226,11 +234,12 @@ EqualizerDialog::eqUpdateUI( int index ) // SLOT
if( index < 0 )
return;
const bool mstate = index > 0 ? true : false;
eqBandsGroupBox->setEnabled( mstate );
eqPresetSaveBtn->setEnabled( mstate );
eqPresetDeleteBtn->setEnabled( mstate );
eqPresetResetBtn->setEnabled( mstate );
const bool enabledState = index > 0 ? true : false;
const bool userState = EqualizerPresets::eqUserList().contains( eqPresets->itemText(index) );
eqBandsGroupBox->setEnabled( enabledState );
eqPresetSaveBtn->setEnabled( enabledState );
eqPresetDeleteBtn->setEnabled( enabledState && userState );
eqPresetResetBtn->setEnabled( enabledState && !userState );
QList<int> eqGains = AmarokConfig::equalizerGains();
QListIterator<int> i( eqGains );
// Update slider values with signal blocking to prevent circular loop
......@@ -280,7 +289,7 @@ QString
EqualizerDialog::eqSelectedPresetName() const
{
const int index = eqPresets->currentIndex();
if( index <= 0 )
if( index <= 0 || index > mPresets.eqGlobalList().count() )
return QString();
// use offset by one since the first entry ("Off") is not part of the global list
......@@ -313,9 +322,8 @@ EqualizerDialog::eqSavePreset() //SLOT
{
DEBUG_BLOCK
const QString mPresetSelected = eqSelectedPresetName();
const QString mPresetName = eqPresets->currentText();
if( mPresetSelected == QLatin1String( "Manual" ) && mPresetName == QLatin1String("Manual") )
const QString presetName = eqPresets->currentText();
if( presetName == i18n("Manual") )
{
KMessageBox::detailedSorry( 0, i18n( "Cannot save this preset" ),
i18n( "Preset 'Manual' is reserved for momentary settings.\n\
......@@ -327,9 +335,9 @@ EqualizerDialog::eqSavePreset() //SLOT
QList<int> eqGains;
foreach( QSlider* mSlider, mBands )
eqGains << mSlider->value();
mPresets.eqCfgSetPresetVal( mPresetName, eqGains );
mPresets.eqCfgSetPresetVal( presetName, eqGains );
eqRepopulateUi();
eqPresets->setCurrentIndex( eqPresets->findText( mPresetName ) );
eqPresets->setCurrentIndex( eqPresets->findText( presetName ) );
}
namespace The {
......
Supports Markdown
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