Commit bd612c91 authored by Michael Pyne's avatar Michael Pyne

Made it possible to quickly play the found song from the search bar by

pressing Enter on the keyboard.  If more than one song matches the current
search, then the top song is played.

CCMAIL:65871-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=317160
parent b25da648
......@@ -386,6 +386,15 @@ int Playlist::time() const
return time;
}
void Playlist::playFirst()
{
m_playNextItem = static_cast<PlaylistItem*>(QListViewItemIterator(
this, QListViewItemIterator::Visible).current());
action("stop")->activate();
action("play")->activate();
}
void Playlist::playNext()
{
bool random = action("randomPlay") && action<KToggleAction>("randomPlay")->isChecked();
......
......@@ -71,6 +71,7 @@ public:
virtual FileHandle currentFile() const;
virtual int count() const { return childCount(); }
virtual int time() const;
virtual void playFirst();
virtual void playNext();
virtual void playPrevious();
virtual void stop();
......
......@@ -35,7 +35,7 @@
#define widget (kapp->mainWidget())
using ActionCollection::actions;
using namespace ActionCollection;
////////////////////////////////////////////////////////////////////////////////
// public methods
......@@ -75,6 +75,11 @@ int PlaylistCollection::time() const
return currentPlaylist()->time();
}
void PlaylistCollection::playFirst()
{
currentPlaylist()->playFirst();
}
void PlaylistCollection::playPrevious()
{
currentPlaylist()->playPrevious();
......@@ -437,6 +442,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
#endif
createAction(i18n("Play First Song"), SLOT(slotPlayFirst()), "playFirst");
createAction(i18n("Open..."), SLOT(slotOpen()), "file_open", "fileopen", "CTRL+o");
createAction(i18n("Add &Folder..."), SLOT(slotAddFolder()), "openDirectory", "fileopen");
createAction(i18n("&Rename..."), SLOT(slotRename()), "renamePlaylist", "lineedit");
......
......@@ -47,6 +47,7 @@ public:
virtual FileHandle currentFile() const;
virtual int count() const;
virtual int time() const;
virtual void playFirst();
virtual void playNext();
virtual void playPrevious();
virtual void stop();
......@@ -126,6 +127,8 @@ private:
const QString &icon = QString::null,
const KShortcut &shortcut = KShortcut());
private slots:
void slotPlayFirst() { m_collection->playFirst(); }
void slotOpen() { m_collection->open(); }
void slotAddFolder() { m_collection->addFolder(); }
void slotRename() { m_collection->rename(); }
......
......@@ -35,6 +35,7 @@ public:
virtual int time() const = 0;
virtual int count() const = 0;
virtual void playFirst() = 0;
virtual void playNext() = 0;
virtual void playPrevious() = 0;
virtual void stop() = 0;
......
......@@ -20,6 +20,7 @@
#include <kiconloader.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <kaction.h>
#include <qlayout.h>
#include <qlabel.h>
......@@ -29,6 +30,9 @@
#include "searchwidget.h"
#include "collectionlist.h"
#include "actioncollection.h"
using namespace ActionCollection;
////////////////////////////////////////////////////////////////////////////////
// SearchLine public methods
......@@ -50,6 +54,8 @@ SearchLine::SearchLine(QWidget *parent, bool simple, const char *name) :
m_lineEdit = new KLineEdit(this, "searchLineEdit");
connect(m_lineEdit, SIGNAL(textChanged(const QString &)),
this, SIGNAL(signalQueryChanged()));
connect(m_lineEdit, SIGNAL(returnPressed()),
action("playFirst"), SLOT(activate()));
if(!m_simple) {
m_caseSensitive = new KComboBox(this);
......
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