Bug 217081 - Add a shortcut to restart the song currently played
Summary: Add a shortcut to restart the song currently played
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 2.2.1
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-02 16:36 UTC by Guido Schmidt
Modified: 2010-08-13 21:13 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.3.2


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guido Schmidt 2009-12-02 16:36:40 UTC
Version:           2.2.1 (using 4.3.3 (KDE 4.3.3) "release 3", KDE:43 / openSUSE_11.2)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.31.5-0.1-desktop

When I practice playing an instrument I often need to restart the song that is currently played. (My old CD-Player does this by simply pressing the play-button. It has an extra button for pause). I'm fine not having a button for that restart-function.

Expected Behaviour: When I press a shortcut, the song that is currently played starts right from the beginning.
Comment 1 Dan Meltzer 2009-12-02 23:29:40 UTC
Press "Back" or the shortcut assigned to it.  This should restart the current song.
Comment 2 Guido Schmidt 2009-12-03 03:04:51 UTC
No, it makes Amarok jump to the previous song.
Comment 3 Myriam Schweingruber 2009-12-03 11:50:19 UTC
*** Bug 217152 has been marked as a duplicate of this bug. ***
Comment 4 Myriam Schweingruber 2009-12-03 11:50:46 UTC
Changing status
Comment 5 Kevin Funk 2010-07-08 18:56:13 UTC
commit e4ecaf468202c801e52f8717af32e989ba69f14d
Author: Kevin Funk <krf@electrostorm.net>
Date:   Thu Jul 8 18:50:16 2010 +0200

    Add "Restart current track" shortcut
    BUG: 217081

diff --git a/ChangeLog b/ChangeLog
index 338d228..d95c5f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ Amarok ChangeLog
 
 VERSION 2.3.2-Beta 1
   FEATURES:
+    * Shortcuts: Added "Replay current track" shortcut. (BR 217081)
     * Edit filter dialog: added "added" and "last played" date filters.
     * File browser: added forward and back buttons for accessing navigate history.
     * Organize Dialog: added a way to save multiple file formats as presets. (BR 122672)
diff --git a/src/EngineController.cpp b/src/EngineController.cpp
index 7c15ab9..f17ac7b 100644
--- a/src/EngineController.cpp
+++ b/src/EngineController.cpp
@@ -405,6 +405,14 @@ EngineController::play( const Meta::TrackPtr& track, uint offset )
 }
 
 void
+EngineController::replay() // slot
+{
+    DEBUG_BLOCK
+
+    seek( 0 );
+}
+
+void
 EngineController::playUrl( const KUrl &url, uint offset )
 {
     DEBUG_BLOCK
diff --git a/src/EngineController.h b/src/EngineController.h
index 4efdc14..2060bd5 100644
--- a/src/EngineController.h
+++ b/src/EngineController.h
@@ -201,6 +201,13 @@ public slots:
     void play( const Meta::TrackPtr&, uint offset = 0 );
 
     /**
+     * Replays the current track
+     *
+     * This is a convenience method, calls seek( 0 ) actually
+     */
+    void replay();
+
+    /**
      * Pauses the current track
      *
      * This happens asynchronously.  Use EngineObserver to find out when it actually happens.
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 178a78f..6593870 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -802,6 +802,13 @@ MainWindow::createActions()
     connect( action, SIGNAL( triggered( bool ) ), pa, SLOT( back() ) );
 
     action = new KAction( this );
+    ac->addAction( "replay", action );
+    action->setIcon( KIcon("media-playback-start") );
+    action->setText( i18n( "Restart current track" ) );
+    action->setGlobalShortcut( KShortcut() );
+    connect( action, SIGNAL( triggered( bool ) ), ec, SLOT(replay()) );
+
+    action = new KAction( this );
     ac->addAction( "repopulate", action );
     action->setText( i18n( "Repopulate Playlist" ) );
     action->setIcon( KIcon("view-refresh-amarok") );
Comment 6 Guido Schmidt 2010-08-13 21:13:20 UTC
Thanks Kevin! That is so nice!
Guido