Commit 2727d339 authored by Frerich Raabe's avatar Frerich Raabe
Browse files

- 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

svn path=/trunk/kdemultimedia/juk/; revision=223216
parent f4807adc
......@@ -78,7 +78,7 @@ 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
m_statusLabel = new StatusLabel(statusBar());
......@@ -482,6 +482,14 @@ void JuK::slotPlaylistChanged()
updatePlaylistInfo();
}
void JuK::startPlayingPlaylist()
{
if(m_randomPlayAction->isChecked())
play(m_splitter->playRandomFile());
else
play(m_splitter->playFirstFile());
}
////////////////////////////////////////////////////////////////////////////////
// edit menu
////////////////////////////////////////////////////////////////////////////////
......
......@@ -139,7 +139,7 @@ private slots:
void setVolume(int volume);
void slotPlaySelectedFile() { play(m_splitter->playSelectedFile()); }
void playFirstFile() { play(m_splitter->playFirstFile()); }
void startPlayingPlaylist();
void slotToggleMenuBar() { menuBar()->isVisible() ? menuBar()->hide() : menuBar()->show(); }
private:
......
......@@ -25,6 +25,6 @@ k_dcop:
virtual void volumeMute()=0;
virtual void setVolume(int volume)=0;
virtual void playFirstFile()=0;
virtual void startPlayingPlaylist()=0;
};
#endif
......@@ -157,6 +157,15 @@ QString PlaylistSplitter::playFirstFile()
return play(i);
}
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()
{
m_nextPlaylistItem = 0;
......
......@@ -93,6 +93,12 @@ public:
*/
QString playFirstFile();
/**
* 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.
......
Markdown is supported
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