Bug 57003 - JuK always plays first playlist entry when double-clicking playlist
Summary: JuK always plays first playlist entry when double-clicking playlist
Status: RESOLVED FIXED
Alias: None
Product: juk
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Scott Wheeler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-08 16:13 UTC by Steffen Weber
Modified: 2003-05-01 15:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Weber 2003-04-08 16:13:44 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          GCC 3.2.2 
OS:          Linux

When double-clicking on a playlist icon in the left column always the _first_ song in that playlist will be played. Because of having enabled "Random Play" I'd expect Juk to choose a random song instead.
Comment 1 Frerich Raabe 2003-05-01 15:50:28 UTC
Subject: kdemultimedia/juk

CVS commit by raabe: 

- When double-clicking on a playlist icon, check whether "Random Play" is
  enabled. If so, play a random item, instead of the first item.
CCMAIL:57003-done@bugs.kde.org


  M +9 -1      juk.cpp   1.105
  M +1 -1      juk.h   1.56
  M +1 -1      jukIface.h   1.3
  M +9 -0      playlistsplitter.cpp   1.76
  M +6 -0      playlistsplitter.h   1.57


--- kdemultimedia/juk/juk.cpp  #1.104:1.105
@@ -79,5 +79,5 @@ void JuK::setupLayout()
     // playlist item activation connection
     connect(m_splitter, SIGNAL(signalDoubleClicked()), this, SLOT(slotPlaySelectedFile()));
-    connect(m_splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(playFirstFile()));
+    connect(m_splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(startPlayingPlaylist()));
 
     // create status bar
@@ -481,4 +481,12 @@ void JuK::slotPlaylistChanged()
 
     updatePlaylistInfo();
+}
+
+void JuK::startPlayingPlaylist()
+{
+    if(m_randomPlayAction->isChecked())
+        play(m_splitter->playRandomFile());
+    else
+        play(m_splitter->playFirstFile());
 }
 

--- kdemultimedia/juk/juk.h  #1.55:1.56
@@ -140,5 +140,5 @@ private slots:
 
     void slotPlaySelectedFile() { play(m_splitter->playSelectedFile()); }
-    void playFirstFile() { play(m_splitter->playFirstFile()); }
+    void startPlayingPlaylist();
     void slotToggleMenuBar() { menuBar()->isVisible() ? menuBar()->hide() : menuBar()->show(); }
 

--- kdemultimedia/juk/jukIface.h  #1.2:1.3
@@ -26,5 +26,5 @@ k_dcop:
    virtual void setVolume(int volume)=0;
 
-   virtual void playFirstFile()=0;
+   virtual void startPlayingPlaylist()=0;
 };
 #endif

--- kdemultimedia/juk/playlistsplitter.h  #1.56:1.57
@@ -95,4 +95,10 @@ public:
 
     /**
+     * Plays a random file in the currently visible playlist and returns it's
+     * name.
+     */
+    QString playRandomFile();
+
+    /**
      * Since the player is handled at a higher level, this just clears the 
      * pointer to the currently playing item and updates the icon.

--- kdemultimedia/juk/playlistsplitter.cpp  #1.75:1.76
@@ -158,4 +158,13 @@ QString PlaylistSplitter::playFirstFile(
 }
 
+QString PlaylistSplitter::playRandomFile()
+{
+    Playlist *p = visiblePlaylist();
+    PlaylistItem *i = static_cast<PlaylistItem *>(p->firstChild());
+
+    // Not exactly random (the first item won't be taken into account)
+    return play(p->nextItem(i, true));
+}
+
 void PlaylistSplitter::stop()
 {