summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2017-02-27 10:53:18 +0100
committerArno <arno@disconnect.de>2017-02-27 10:53:18 +0100
commit52384c4685a9d25ceb97b8acc36fe5844ec112b4 (patch)
treed49d3b6631f5e576a3641f6e7740c8c15521a649 /playerwidget.cpp
parent1829b80114d5cfe2e097491b658eb39f4fbe71c0 (diff)
downloadBeetPlayer-52384c4685a9d25ceb97b8acc36fe5844ec112b4.tar.gz
BeetPlayer-52384c4685a9d25ceb97b8acc36fe5844ec112b4.tar.bz2
BeetPlayer-52384c4685a9d25ceb97b8acc36fe5844ec112b4.zip
Implement previous and next
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp50
1 files changed, 44 insertions, 6 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 13cd2f5..bfe3815 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -154,11 +154,15 @@ void PlayerWidget::createActions(){
pauseA->setCheckable(true);
playAG->addAction(pauseA);
connect(pauseA, SIGNAL(triggered()), mPlayer, SLOT(pause()));
- QAction *stopA = new QAction(QIcon(":/stop.png"), tr("Stop"), this);
- stopA->setCheckable(true);
- playAG->addAction(stopA);
- stopA->trigger();
- connect(stopA, SIGNAL(triggered()), mPlayer, SLOT(stop()));
+ mStopA = new QAction(QIcon(":/stop.png"), tr("Stop"), this);
+ mStopA->setCheckable(true);
+ playAG->addAction(mStopA);
+ mStopA->trigger();
+ connect(mStopA, SIGNAL(triggered()), mPlayer, SLOT(stop()));
+ QAction *previousA = new QAction(QIcon(":/previous.png"), tr("Previous"), this);
+ connect(previousA, SIGNAL(triggered()), this, SLOT(previous()));
+ QAction *nextA = new QAction(QIcon(":/next.png"), tr("Next"), this);
+ connect(nextA, SIGNAL(triggered()), this, SLOT(next()));
QAction *addToPlayListA = new QAction(QIcon(":/belly_right.png"), tr("Add to playlist"), this);
connect(addToPlayListA, SIGNAL(triggered()), this, SLOT(addToPlayList()));
QAction *removeFromPlayListA = new QAction(QIcon(":/belly_left.png"), tr("Remove from playlist"), this);
@@ -185,7 +189,10 @@ void PlayerWidget::createActions(){
mToolBar->addWidget(spacer1);
mToolBar->addAction(mPlayA);
mToolBar->addAction(pauseA);
- mToolBar->addAction(stopA);
+ mToolBar->addAction(mStopA);
+ mToolBar->addSeparator();
+ mToolBar->addAction(previousA);
+ mToolBar->addAction(nextA);
mToolBar->addSeparator();
mToolBar->addAction(addToPlayListA);
mToolBar->addAction(removeFromPlayListA);
@@ -466,3 +473,34 @@ void PlayerWidget::volumeChanged(int volume){
void PlayerWidget::mute(bool triggered){
mPlayer->setMuted(triggered);
}
+
+void PlayerWidget::next(){
+ advance(1);
+}
+
+void PlayerWidget::previous(){
+ advance(-1);
+}
+
+void PlayerWidget::advance(int numSongs){
+ QModelIndexList sel = mPlayListView->selectionModel()->selectedRows();
+ if(sel.isEmpty()){
+ QStandardItem *root = mPlayListModel->invisibleRootItem();
+ if(root->rowCount() > 0){
+ QModelIndex first = mPlayListModel->index(0, 0);
+ mPlayListView->selectionModel()->setCurrentIndex(first, QItemSelectionModel::ClearAndSelect);
+ QString fp = first.data(FullPathRole).toString();
+ play(fp);
+ return;
+ }
+ return;
+ }
+ QModelIndex cur = sel.first();
+ QModelIndex nextIdx = mPlayListModel->index(cur.row() + numSongs, 0);
+ if(nextIdx.isValid()){
+ mPlayListView->selectionModel()->setCurrentIndex(nextIdx, QItemSelectionModel::ClearAndSelect);
+ cur = nextIdx;
+ QString fp = cur.data(FullPathRole).toString();
+ play(fp);
+ }
+}