summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2017-03-05 17:51:48 +0100
committerArno <arno@disconnect.de>2017-03-05 17:51:48 +0100
commitee0b460145fd1edd0f76bbbf3680b9ebea927940 (patch)
tree3de9268a6faf02d2f7cf0538af9233781c24d423 /playerwidget.cpp
parent2ff72f033af3f24ffb816bc19a34fc794f585775 (diff)
downloadBeetPlayer-ee0b460145fd1edd0f76bbbf3680b9ebea927940.tar.gz
BeetPlayer-ee0b460145fd1edd0f76bbbf3680b9ebea927940.tar.bz2
BeetPlayer-ee0b460145fd1edd0f76bbbf3680b9ebea927940.zip
Fix play Button
Print a statusbar message when the playlist is empty. If it isn't empty, but nothing is selected, select the first entry and play it.
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index ebbbc16..77afffc 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -196,7 +196,7 @@ void PlayerWidget::createActions(){
mPlayA = new QAction(QIcon(":/play.png"), tr("Play"), this);
mPlayA->setCheckable(true);
playAG->addAction(mPlayA);
- connect(mPlayA, SIGNAL(triggered()), mPlayer, SLOT(play()));
+ connect(mPlayA, SIGNAL(triggered()), this, SLOT(doPlay()));
QAction *pauseA = new QAction(QIcon(":/pause.png"), tr("Pause"), this);
pauseA->setCheckable(true);
playAG->addAction(pauseA);
@@ -531,6 +531,21 @@ void PlayerWidget::viewDoubleClicked(const QModelIndex &idx){
}
}
+void PlayerWidget::doPlay(){
+ int playListCount = mPlayListModel->rowCount();
+ if(playListCount == 0){
+ emit message(tr("Playlist is empty! Dazed and confused, but trying to continue..."));
+ mStopA->trigger();
+ return;
+ }
+ QModelIndexList sel = mPlayListView->selectionModel()->selectedRows();
+ if(sel.isEmpty()){
+ mPlayListView->selectionModel()->select(mPlayListModel->index(0, 0), QItemSelectionModel::SelectCurrent);
+ sel = mPlayListView->selectionModel()->selectedRows();
+ }
+ playCurrent(sel.first());
+}
+
void PlayerWidget::recurse(const QModelIndex &parent){
for(int i = 0; i < mCurrentModel->rowCount(parent); ++i){
QModelIndex cur = mCurrentModel->index(i, 0, parent);
@@ -761,7 +776,8 @@ void PlayerWidget::play(const QString &fullPath){
mCurrentTE->append(QString("%1 %2").arg(tr("Genre:"), -20).arg(genre));
mCurrentTE->append(QString("%1 %2").arg(tr("Track:"), -20).arg(track, 3, 10, QChar('0')));
mCurrentTE->append(QString("%1 %2").arg(tr("Year:"), -20).arg(year, 4, 10));
- mPlayA->trigger();
+ mPlayer->play();
+ mPlayA->setChecked(true);
}
void PlayerWidget::volumeChanged(int volume){