summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
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){