[amarok] /: Volume fadeout is now also available for pause.

Mark Kretschmann kretschmann at kde.org
Wed Jun 19 12:47:13 UTC 2013


Git commit 6d2addeba3847d773f80531e6b8048e2a774ee49 by Mark Kretschmann.
Committed on 18/06/2013 at 12:08.
Pushed by markey into branch 'master'.

Volume fadeout is now also available for pause.

We had fadeout on stop before, but as Amarok uses pause instead of stop
in its default configuration, the feature was lost for many use cases.
The new (optional) fadeout on pause fixes this.

CCMAIL: amarok-devel at kde.org

M  +1    -0    ChangeLog
M  +36   -3    src/EngineController.cpp
M  +3    -1    src/EngineController.h
M  +6    -1    src/amarokconfig.kcfg
M  +16   -2    src/configdialog/dialogs/PlaybackConfig.cpp
M  +1    -0    src/configdialog/dialogs/PlaybackConfig.h
M  +166  -160  src/configdialog/dialogs/PlaybackConfig.ui

http://commits.kde.org/amarok/6d2addeba3847d773f80531e6b8048e2a774ee49

diff --git a/ChangeLog b/ChangeLog
index cb26366..9331931 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ Amarok ChangeLog
 
 VERSION 2.8-Beta 1
   FEATURES:
+   * Volume fade-out is now also available for pause.
    * The Files browser now has a Refresh button. (BR 213666)
    * The active playlist item is animated with a soft glow effect.
    * Added an audio analyzer visualization applet.
diff --git a/src/EngineController.cpp b/src/EngineController.cpp
index 8bd464a..f503464 100644
--- a/src/EngineController.cpp
+++ b/src/EngineController.cpp
@@ -1,7 +1,7 @@
 /****************************************************************************************
  * Copyright (c) 2004 Frederik Holljen <fh at ez.no>                                       *
  * Copyright (c) 2004,2005 Max Howell <max.howell at methylblue.com>                       *
- * Copyright (c) 2004-2010 Mark Kretschmann <kretschmann at kde.org>                       *
+ * Copyright (c) 2004-2013 Mark Kretschmann <kretschmann at kde.org>                       *
  * Copyright (c) 2006,2008 Ian Monroe <ian at monroe.nu>                                   *
  * Copyright (c) 2008 Jason A. Donenfeld <Jason at zx2c4.com>                              *
  * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn at kde.org>                                *
@@ -77,6 +77,7 @@ EngineController::EngineController()
     , m_playWhenFetched( true )
     , m_volume( 0 )
     , m_currentAudioCdTrack( 0 )
+    , m_pauseTimer( new QTimer( this ) )
     , m_lastStreamStampPosition( -1 )
     , m_ignoreVolumeChangeAction ( false )
     , m_ignoreVolumeChangeObserve ( false )
@@ -92,6 +93,9 @@ EngineController::EngineController()
     connect( this, SIGNAL(trackFinishedPlaying(Meta::TrackPtr,double)),
              SLOT(slotTrackFinishedPlaying(Meta::TrackPtr,double)) );
     new PowerManager( this ); // deals with inhibiting suspend etc.
+
+    m_pauseTimer->setSingleShot( true );
+    connect( m_pauseTimer, SIGNAL(timeout()), SLOT(slotPause() ) );
 }
 
 EngineController::~EngineController()
@@ -362,6 +366,8 @@ EngineController::play() //SLOT
         }
         else
         {
+            m_pauseTimer->stop();
+            m_fader.data()->setVolume( 1.0 );
             m_media.data()->play();
             emit trackPlaying( m_currentTrack );
             return;
@@ -484,6 +490,8 @@ EngineController::playUrl( const KUrl &url, uint offset, bool startPaused )
         if( startPaused )
             m_media.data()->pause();
         else
+            m_pauseTimer->stop();
+            m_fader.data()->setVolume( 1.0 );
             m_media.data()->play();
     }
 }
@@ -491,7 +499,32 @@ EngineController::playUrl( const KUrl &url, uint offset, bool startPaused )
 void
 EngineController::pause() //SLOT
 {
-    m_media.data()->pause();
+    if( AmarokConfig::fadeoutOnPause() )
+    {
+        m_fader.data()->fadeOut( AmarokConfig::fadeoutLength() );
+        m_pauseTimer->start( AmarokConfig::fadeoutLength() );
+        return;
+    }
+
+    slotPause();
+}
+
+void
+EngineController::slotPause()
+{
+    if( AmarokConfig::fadeoutOnPause() )
+    {
+        // Reset VolumeFaderEffect to full volume
+        m_fader.data()->setVolume( 1.0 );
+
+        // Wait a bit before pausing the pipeline. Necessary for the new fader setting to take effect.
+        QTimer::singleShot( 1000, m_media.data(), SLOT(pause()) );
+    }
+    else
+    {
+        m_media.data()->pause();
+    }
+
     emit paused();
 }
 
@@ -511,7 +544,7 @@ EngineController::stop( bool forceInstant, bool playingWillContinue ) //SLOT
     bool doFadeOut = !forceInstant
                   && !m_fadeouter
                   && m_media.data()->state() == Phonon::PlayingState
-                  && AmarokConfig::fadeout()
+                  && AmarokConfig::fadeoutOnStop()
                   && AmarokConfig::fadeoutLength() > 0
                   && m_fader;
 
diff --git a/src/EngineController.h b/src/EngineController.h
index 745a8a1..c4fae9a 100644
--- a/src/EngineController.h
+++ b/src/EngineController.h
@@ -1,7 +1,7 @@
 /****************************************************************************************
  * Copyright (c) 2004 Frederik Holljen <fh at ez.no>                                       *
  * Copyright (c) 2004,2005 Max Howell <max.howell at methylblue.com>                       *
- * Copyright (c) 2004-2010 Mark Kretschmann <kretschmann at kde.org>                       *
+ * Copyright (c) 2004-2013 Mark Kretschmann <kretschmann at kde.org>                       *
  * Copyright (c) 2008 Jason A. Donenfeld <Jason at zx2c4.com>                              *
  * Copyright (c) 2009 Artur Szymiec <artur.szymiec at gmail.com>                           *
  *                                                                                      *
@@ -473,6 +473,7 @@ private slots:
     void slotTrackLengthChanged( qint64 );
     void slotMetaDataChanged();
     void slotSeekableChanged( bool );
+    void slotPause();
 
     /**
      * For volume/mute changes from the phonon side
@@ -564,6 +565,7 @@ private:
     bool m_playWhenFetched;
     int m_volume;
     int m_currentAudioCdTrack;
+    QTimer *m_pauseTimer;
 
     QList<QVariantMap> m_metaDataHistory; // against metadata spam
     // last position (in ms) when the song changed (within the current stream) or -1 for non-stream
diff --git a/src/amarokconfig.kcfg b/src/amarokconfig.kcfg
index c299e05..6b4cefe 100644
--- a/src/amarokconfig.kcfg
+++ b/src/amarokconfig.kcfg
@@ -200,11 +200,16 @@
         <whatsthis>Mute/Unmute sound.</whatsthis>
         <default>false</default>
     </entry>
-    <entry key="Fadeout" type="Bool">
+    <entry key="FadeoutOnStop" type="Bool">
         <label>Whether to fade out tracks when pressing stop.</label>
         <whatsthis>Enable/Disable fadeout.</whatsthis>
         <default>true</default>
     </entry>
+    <entry key="FadeoutOnPause" type="Bool">
+        <label>Whether to fade out tracks when pressing pause.</label>
+        <whatsthis>Enable/Disable fadeout.</whatsthis>
+        <default>true</default>
+    </entry>
     <entry key="Fadeout Length" type="Int">
         <label>Length of fadeout, in milliseconds</label>
         <whatsthis>The length of the fadeout in milliseconds.</whatsthis>
diff --git a/src/configdialog/dialogs/PlaybackConfig.cpp b/src/configdialog/dialogs/PlaybackConfig.cpp
index 1d1a0cd..c765933 100644
--- a/src/configdialog/dialogs/PlaybackConfig.cpp
+++ b/src/configdialog/dialogs/PlaybackConfig.cpp
@@ -33,14 +33,18 @@ PlaybackConfig::PlaybackConfig( QWidget* parent )
     setupUi( this );
 
     connect( findChild<QPushButton*>( "pushButtonPhonon" ), SIGNAL(clicked()), SLOT(configurePhonon()) );
+    connect( kcfg_FadeoutOnStop, SIGNAL(toggled(bool)), SLOT(setFadeoutState()) );
+    connect( kcfg_FadeoutOnPause, SIGNAL(toggled(bool)), SLOT(setFadeoutState()) );
 
     EngineController *engine = EngineController::instance();
     Q_ASSERT( engine );
     if( !engine->supportsFadeout() )
     {
         QString toolTip = i18n( "Current Phonon backend does not support volume fading" );
-        kcfg_Fadeout->setEnabled( false );
-        kcfg_Fadeout->setToolTip( toolTip );
+        kcfg_FadeoutOnStop->setEnabled( false );
+        kcfg_FadeoutOnStop->setToolTip( toolTip );
+        kcfg_FadeoutOnPause->setEnabled( false );
+        kcfg_FadeoutOnPause->setToolTip( toolTip );
     }
 }
 
@@ -85,4 +89,14 @@ PlaybackConfig::configurePhonon() //SLOT
     KCM.exec();
 }
 
+void
+PlaybackConfig::setFadeoutState() //SLOT
+{
+    const bool enabled = kcfg_FadeoutOnPause->isChecked() || kcfg_FadeoutOnStop->isChecked();
+
+    fadeoutLengthLabel->setEnabled( enabled );
+    kcfg_FadeoutLength->setEnabled( enabled );
+}
+
+
 #include "PlaybackConfig.moc"
diff --git a/src/configdialog/dialogs/PlaybackConfig.h b/src/configdialog/dialogs/PlaybackConfig.h
index 4f63bf4..61c7576 100644
--- a/src/configdialog/dialogs/PlaybackConfig.h
+++ b/src/configdialog/dialogs/PlaybackConfig.h
@@ -35,6 +35,7 @@ class PlaybackConfig : public ConfigDialogBase, public Ui_PlaybackConfig
 
     private Q_SLOTS:
         void configurePhonon();
+        void setFadeoutState();
 };
 
 #endif
diff --git a/src/configdialog/dialogs/PlaybackConfig.ui b/src/configdialog/dialogs/PlaybackConfig.ui
index dc2d41d..2bbcba7 100644
--- a/src/configdialog/dialogs/PlaybackConfig.ui
+++ b/src/configdialog/dialogs/PlaybackConfig.ui
@@ -6,84 +6,18 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>292</width>
-    <height>375</height>
+    <width>358</width>
+    <height>410</height>
    </rect>
   </property>
-  <layout class="QGridLayout" name="gridLayout_5">
+  <layout class="QGridLayout" name="gridLayout_2">
    <item row="0" column="0">
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
       <string>General</string>
      </property>
-     <layout class="QGridLayout" name="gridLayout_3">
-      <item row="0" column="1">
-       <widget class="QGroupBox" name="kcfg_Fadeout">
-        <property name="toolTip">
-         <string>If checked, Amarok will slowly fade the volume of the playing track on stop or at the end of the playlist, rather than stopping playback immediately</string>
-        </property>
-        <property name="whatsThis">
-         <string><b>Quit Behavior</b>
-<p>On exit, Amarok can slowly fade the volume of the playing track (which is configurable), or stop playback immediately.</p></string>
-        </property>
-        <property name="title">
-         <string>&Fadeout on stop</string>
-        </property>
-        <property name="flat">
-         <bool>true</bool>
-        </property>
-        <property name="checkable">
-         <bool>true</bool>
-        </property>
-        <property name="checked">
-         <bool>false</bool>
-        </property>
-        <layout class="QGridLayout" name="gridLayout">
-         <item row="0" column="0">
-          <widget class="QLabel" name="fadeoutLengthLabel">
-           <property name="enabled">
-            <bool>false</bool>
-           </property>
-           <property name="text">
-            <string>Fadeout &duration:</string>
-           </property>
-           <property name="buddy">
-            <cstring>kcfg_FadeoutLength</cstring>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="1">
-          <widget class="QSpinBox" name="kcfg_FadeoutLength">
-           <property name="enabled">
-            <bool>false</bool>
-           </property>
-           <property name="toolTip">
-            <string>The length of the fadeout, in milliseconds.</string>
-           </property>
-           <property name="whatsThis">
-            <string>The length of the fadeout, in milliseconds.</string>
-           </property>
-           <property name="suffix">
-            <string> ms</string>
-           </property>
-           <property name="minimum">
-            <number>100</number>
-           </property>
-           <property name="maximum">
-            <number>99999999</number>
-           </property>
-           <property name="singleStep">
-            <number>100</number>
-           </property>
-           <property name="value">
-            <number>100</number>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-      <item row="1" column="1">
+     <layout class="QHBoxLayout" name="horizontalLayout_4">
+      <item>
        <widget class="QCheckBox" name="kcfg_ResumePlayback">
         <property name="toolTip">
          <string>If checked, Amarok will<br>resume playback from where you left it the previous session -- just like a tape-player.</string>
@@ -99,84 +33,114 @@
      </layout>
     </widget>
    </item>
-   <item row="2" column="0">
-    <widget class="QGroupBox" name="groupBox_2">
+   <item row="1" column="0">
+    <widget class="QGroupBox" name="groupBox_4">
      <property name="title">
-      <string>Sound System Configuration</string>
+      <string>Volume Fading</string>
      </property>
-     <layout class="QVBoxLayout" name="verticalLayout">
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout">
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QCheckBox" name="kcfg_FadeoutOnStop">
+        <property name="text">
+         <string>Fadeout on stop</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QCheckBox" name="kcfg_FadeoutOnPause">
+        <property name="text">
+         <string>Fadeout on pause</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_3">
         <item>
-         <spacer name="horizontalSpacer">
+         <spacer name="horizontalSpacer_4">
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
+          <property name="sizeType">
+           <enum>QSizePolicy::Minimum</enum>
+          </property>
           <property name="sizeHint" stdset="0">
            <size>
-            <width>40</width>
+            <width>30</width>
             <height>20</height>
            </size>
           </property>
          </spacer>
         </item>
         <item>
-         <widget class="QPushButton" name="pushButtonPhonon">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="toolTip">
-           <string>Phonon is the audio system used by Amarok.</string>
-          </property>
-          <property name="whatsThis">
-           <string>Phonon is the audio system used by Amarok.</string>
-          </property>
-          <property name="text">
-           <string>Configure Phonon</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer_2">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>40</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
+         <layout class="QHBoxLayout" name="horizontalLayout_2">
+          <item>
+           <widget class="QLabel" name="fadeoutLengthLabel">
+            <property name="enabled">
+             <bool>true</bool>
+            </property>
+            <property name="text">
+             <string>&Duration:</string>
+            </property>
+            <property name="buddy">
+             <cstring>kcfg_FadeoutLength</cstring>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QSpinBox" name="kcfg_FadeoutLength">
+            <property name="enabled">
+             <bool>true</bool>
+            </property>
+            <property name="toolTip">
+             <string>The length of the fadeout, in milliseconds.</string>
+            </property>
+            <property name="whatsThis">
+             <string>The length of the fadeout, in milliseconds.</string>
+            </property>
+            <property name="suffix">
+             <string> ms</string>
+            </property>
+            <property name="minimum">
+             <number>100</number>
+            </property>
+            <property name="maximum">
+             <number>99999999</number>
+            </property>
+            <property name="singleStep">
+             <number>100</number>
+            </property>
+            <property name="value">
+             <number>100</number>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_3">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>13</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
         </item>
        </layout>
       </item>
-      <item>
-       <spacer name="verticalSpacer">
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>20</width>
-          <height>5</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
      </layout>
     </widget>
    </item>
-   <item row="1" column="0">
+   <item row="2" column="0">
     <widget class="QGroupBox" name="groupBox_3">
      <property name="title">
       <string>System Suspend Options</string>
      </property>
-     <layout class="QVBoxLayout" name="verticalLayout_2">
-      <item>
+     <layout class="QGridLayout" name="gridLayout_5">
+      <item row="0" column="0">
        <widget class="QCheckBox" name="kcfg_InhibitSuspend">
         <property name="toolTip">
          <string>If enabled, Amarok will prevent the system from automatically suspending if it is playing a track</string>
@@ -189,7 +153,7 @@
         </property>
        </widget>
       </item>
-      <item>
+      <item row="1" column="0">
        <widget class="QCheckBox" name="kcfg_PauseOnSuspend">
         <property name="toolTip">
          <string>If enabled, Amarok will pause the currently playing track on suspend</string>
@@ -205,44 +169,86 @@
      </layout>
     </widget>
    </item>
+   <item row="3" column="0">
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Sound System Configuration</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_3">
+      <item row="0" column="0">
+       <layout class="QVBoxLayout" name="verticalLayout">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout">
+          <item>
+           <spacer name="horizontalSpacer">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>165</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pushButtonPhonon">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="toolTip">
+             <string>Phonon is the audio system used by Amarok.</string>
+            </property>
+            <property name="whatsThis">
+             <string>Phonon is the audio system used by Amarok.</string>
+            </property>
+            <property name="text">
+             <string>Configure Phonon</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_2">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>165</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>1</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <tabstops>
   <tabstop>kcfg_FadeoutLength</tabstop>
  </tabstops>
  <resources/>
- <connections>
-  <connection>
-   <sender>kcfg_Fadeout</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>fadeoutLengthLabel</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>68</x>
-     <y>223</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>291</x>
-     <y>225</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>kcfg_Fadeout</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>kcfg_FadeoutLength</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>61</x>
-     <y>223</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>291</x>
-     <y>225</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
+ <connections/>
 </ui>



More information about the Amarok-devel mailing list