Bug 242730 - [PATCH]amarok keeps equalizer settings even when you click cancel
Summary: [PATCH]amarok keeps equalizer settings even when you click cancel
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Unclassified
Component: Tools/Equalizer (show other bugs)
Version: 2.3.1
Platform: Unlisted Binaries Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-24 23:03 UTC by Richard Hartmann
Modified: 2010-09-04 16:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
possible solution (2.47 KB, patch)
2010-07-12 23:39 UTC, Anton Gritsay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Hartmann 2010-06-24 23:03:02 UTC
Version:           unspecified (using KDE 4.4.4) 
OS:                Linux



Reproducible: Always

Steps to Reproduce:
* Open equalizer
* Change settings
* Click cancel
* Open equalizer again

Your unsaved settings are still active.



OS: Linux (i686) release 2.6.32-5-686
Compiler: cc
Comment 1 Myriam Schweingruber 2010-06-30 10:35:04 UTC
Which exact Amarok version is this about?
Comment 3 Myriam Schweingruber 2010-06-30 14:05:57 UTC
Thank you for the fast feedback.
Comment 4 Richard Hartmann 2010-06-30 14:10:54 UTC
Thanks for triaging :)
Comment 5 Anton Gritsay 2010-07-12 23:39:58 UTC
Created attachment 49083 [details]
possible solution
Comment 6 Mark Kretschmann 2010-09-04 16:25:27 UTC
commit d6b28871ca608aa1416e8ca49b5b6771c2d57ce5
Author: Mark Kretschmann <kretschmann@kde.org>
Date:   Sat Sep 4 16:23:16 2010 +0200

    Bugfix: The equalizer dialog did not discard changes when clicking "Cancel".
    
    Many thanks to Anton Gritsay <anton@angri.ru> for the patch.
    
    BUG: 242730

diff --git a/ChangeLog b/ChangeLog
index 39f132d..4225d83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@ VERSION 2.3.2
     * Use system date/time format for default name when saving user playlists.
 
   BUGFIXES:
+    * The equalizer dialog did not discard changes when clicking "Cancel".
+      Patch by Anton Gritsay <anton@angri.ru>. (BR 242730)
     * The Last.fm service did not work without KWallet. (BR 235861)
     * Show actual KDE version in the "About Amarok" dialog, instead of the
       version used at compile time.
diff --git a/src/dialogs/EqualizerDialog.cpp b/src/dialogs/EqualizerDialog.cpp
index 8e200f8..2efd2d2 100644
--- a/src/dialogs/EqualizerDialog.cpp
+++ b/src/dialogs/EqualizerDialog.cpp
@@ -62,6 +62,28 @@ void EqualizerDialog::showOnce()
     instance()->activateWindow();
     instance()->show();
     instance()->raise();
+    instance()->eqRememberOriginalSettings();
+}
+
+void
+EqualizerDialog::eqRememberOriginalSettings()
+{
+    mOriginalPreset = eqPresets->itemText(AmarokConfig::equalizerMode());
+    mOriginalGains = AmarokConfig::equalizerGains();
+}
+
+void
+EqualizerDialog::eqRestoreOriginalSettings()
+{
+    int originalPresetIndex = eqPresets->findText( mOriginalPreset );
+    if( originalPresetIndex == -1 ) {
+        // original preset seems to be deleted. will set eq to Off
+        originalPresetIndex = 0;
+    }
+    AmarokConfig::setEqualizerMode( originalPresetIndex );
+    AmarokConfig::setEqualizerGains( mOriginalGains );
+    eqUpdateUI( originalPresetIndex );
+    The::engineController()->eqUpdate();
 }
 
 void
@@ -82,6 +104,8 @@ EqualizerDialog::eqSetupUI()
         return;
     }
 
+    connect(this, SIGNAL( cancelClicked() ), this, SLOT( eqRestoreOriginalSettings() ));
+
     // Assign slider items to vectors
     mBands.append( eqPreampSlider );
     mBands.append( eqBand0Slider );
diff --git a/src/dialogs/EqualizerDialog.h b/src/dialogs/EqualizerDialog.h
index b1472a4..cd1917a 100644
--- a/src/dialogs/EqualizerDialog.h
+++ b/src/dialogs/EqualizerDialog.h
@@ -46,6 +46,7 @@ class EqualizerDialog : public KDialog, public Ui_EqualizerDialog
         void eqSavePreset();
         void eqDeletePreset();
         void eqRestorePreset();
+        void eqRestoreOriginalSettings();
 
     private:
         EqualizerDialog();
@@ -53,6 +54,8 @@ class EqualizerDialog : public KDialog, public Ui_EqualizerDialog
         QVector<QSlider*> mBands;
         QVector<QLabel*> mBandsValues;
         QVector<QLabel*> mBandsLabels;
+        QList<int> mOriginalGains;
+        QString mOriginalPreset;
 
         void eqSetupUI();
         void eqUpdateToolTips();
@@ -60,6 +63,7 @@ class EqualizerDialog : public KDialog, public Ui_EqualizerDialog
         bool eqCfgDeletePreset( QString & mPresetName );
         bool eqCfgRestorePreset( QString mPresetName );
         void eqCfgSetPresetVal( QString & mPresetName, QList<int> & mPresetValues);
+        void eqRememberOriginalSettings();
         QList<int> eqCfgGetPresetVal ( QString mPresetName );
         QStringList eqGlobalList();