summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-05-11 18:55:43 +0200
committerArno <arno@disconnect.de>2018-05-11 18:55:43 +0200
commita8d5afb9c4b061bc8657600312d4a5c6cab4c71f (patch)
tree8dbc62f30079cd04a6d8c505d19c3619f4bcf0fc /playerwidget.cpp
parent16f77383fdd7fe8c02d8e9f96a52d340269bf7c2 (diff)
downloadBeetPlayer-a8d5afb9c4b061bc8657600312d4a5c6cab4c71f.tar.gz
BeetPlayer-a8d5afb9c4b061bc8657600312d4a5c6cab4c71f.tar.bz2
BeetPlayer-a8d5afb9c4b061bc8657600312d4a5c6cab4c71f.zip
Fix logic when we start playing
If nothing is selected in the song view, but it's populated, don't give up early. Select the first one and try to continue.
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index f6ad0d6..f944e64 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -478,25 +478,25 @@ void PlayerWidget::rightCurrentChanged(const QModelIndex &cur, const QModelIndex
}
void PlayerWidget::doPlay(){
- if(mPlayer->state() == QMediaPlayer::PausedState || mPlayer->state() == QMediaPlayer::StoppedState){
- mPlayer->play();
- mPlayA->setChecked(true);
- emit playModeChanged(tr("Playing"));
- emit setWinTitle(mCurWinTitle);
- mTrayIcon->setIcon(QIcon(":/play.png"));
- mTrayIcon->setToolTip(mCurToolTip);
- return;
- }
int playListCount = mSongModel->rowCount();
if(playListCount == 0){
emit message(tr("Playlist is empty! Dazed and confused, but trying to continue..."));
doStop();
return;
}
+
+ if(mPlayer->state() == QMediaPlayer::PausedState){
+ mPlayer->play();
+ mPlayA->setChecked(true);
+ emit playModeChanged(tr("Playing"));
+ return;
+ }
QModelIndexList sel = mSongView->selectionModel()->selectedRows();
- if(sel.isEmpty()){
- mSongView->selectionModel()->select(mSongModel->index(0, 0), QItemSelectionModel::SelectCurrent);
- sel = mSongView->selectionModel()->selectedRows();
+ if(mPlayer->state() == QMediaPlayer::StoppedState){
+ if(sel.isEmpty()){
+ mSongView->selectionModel()->setCurrentIndex(mSongModel->index(0, 0), QItemSelectionModel::SelectCurrent);
+ sel = mSongView->selectionModel()->selectedRows();
+ }
}
playCurrent(sel.first());
}
@@ -739,6 +739,10 @@ void PlayerWidget::playCurrent(const QModelIndex &index){
mPlayer->stop();
QString fullPath = index.data(CollectionWidget::FullPathRole).toString();
play(fullPath);
+ mPlayer->play();
+ mPlayA->setChecked(true);
+ emit playModeChanged(tr("Playing"));
+ emit setWinTitle(mCurWinTitle);
mTrayIcon->setIcon(QIcon(":/play.png"));
mTrayIcon->setToolTip(mCurToolTip);
}