From 57ac8c441a0b43dd013c9263e4411fe596b3c175 Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Wed, 23 Feb 2011 23:59:12 +0000 Subject: [PATCH] Play/Pause when pressing space (on playlistview). Fixes issue 244 --- src/playlist/playlistview.cpp | 19 ++++++++++++------- src/playlist/playlistview.h | 3 ++- src/ui/mainwindow.cpp | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index ca1eb9d59..768140f59 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -435,20 +435,25 @@ void PlaylistView::keyPressEvent(QKeyEvent* event) { RemoveSelected(); event->accept(); } else if (event->key() == Qt::Key_Enter || - event->key() == Qt::Key_Return || - event->key() == Qt::Key_Space) { + event->key() == Qt::Key_Return) { if (currentIndex().isValid()) - emit PlayPauseItem(currentIndex()); + emit PlayItem(currentIndex()); + event->accept(); + } else if(event->key() == Qt::Key_Space) { + emit PlayPause(); event->accept(); } else if(event->key() == Qt::Key_Left) { emit SeekTrack(-1); + event->accept(); } else if(event->key() == Qt::Key_Right) { emit SeekTrack(1); + event->accept(); } else if(event->modifiers() == Qt::NoModifier // No modifier keys currently pressed... - // ... and key pressed is something related to text - && ( (event->key() >= Qt::Key_A && event->key() <= Qt::Key_Z) - || event->key() == Qt::Key_Backspace )) { - emit FocusOnFilterSignal(event); + // ... and key pressed is something related to text + && ( (event->key() >= Qt::Key_A && event->key() <= Qt::Key_Z) + || event->key() == Qt::Key_Backspace )) { + emit FocusOnFilterSignal(event); + event->accept(); } else { QTreeView::keyPressEvent(event); } diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index 120a2593e..1e04de1de 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -86,7 +86,8 @@ class PlaylistView : public QTreeView { void DynamicModeChanged(bool dynamic); signals: - void PlayPauseItem(const QModelIndex& index); + void PlayItem(const QModelIndex& index); + void PlayPause(); void RightClicked(const QPoint& global_pos, const QModelIndex& index); void SeekTrack(int gap); void FocusOnFilterSignal(QKeyEvent *event); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 4ff58cfc8..983df33e5 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -405,7 +405,8 @@ MainWindow::MainWindow( connect(playlists_, SIGNAL(PlayRequested(QModelIndex)), SLOT(PlayIndex(QModelIndex))); connect(ui_->playlist->view(), SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex))); - connect(ui_->playlist->view(), SIGNAL(PlayPauseItem(QModelIndex)), SLOT(PlayIndex(QModelIndex))); + connect(ui_->playlist->view(), SIGNAL(PlayItem(QModelIndex)), SLOT(PlayIndex(QModelIndex))); + connect(ui_->playlist->view(), SIGNAL(PlayPause()), player_, SLOT(PlayPause())); connect(ui_->playlist->view(), SIGNAL(RightClicked(QPoint,QModelIndex)), SLOT(PlaylistRightClick(QPoint,QModelIndex))); connect(ui_->playlist->view(), SIGNAL(SeekTrack(int)), ui_->track_slider, SLOT(Seek(int)));