diff options
-rw-r--r-- | playerwidget.cpp | 18 | ||||
-rw-r--r-- | playerwidget.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp index e9349f3..be4eb62 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -208,6 +208,11 @@ void PlayerWidget::setupGui(QSplashScreen *splash){ QAction *searchMBA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Search Musicbrainz"), this); connect(searchMBA, &QAction::triggered, [this, curW] { searchMusicbrainz(curW->view()->selectionModel()->currentIndex()); }); curW->view()->addAction(searchMBA); + if(name == "favorites"){ + QAction *addAllFavsA = new QAction((QIcon(":/shuffle.png")), tr("Clear and Add all"), this); + connect(addAllFavsA, &QAction::triggered, this, &PlayerWidget::clearAndAddAllFavorites); + curW->customActions()->addAction(addAllFavsA); + } curW->view()->addActions(curW->customActions()->actions()); } } @@ -1067,3 +1072,16 @@ void PlayerWidget::addToFavorites(const QModelIndexList &idxs){ fav->populate(); } } + +void PlayerWidget::clearAndAddAllFavorites(){ + mSongModel->clear(); + mSongModel->setHorizontalHeaderLabels(QStringList() << "Song"); + CollectionWidget *favWidget = qobject_cast<CollectionWidget*>(mCollectionStack->currentWidget()); + QStandardItemModel *m = favWidget->model(); + QStandardItem *root = m->invisibleRootItem(); + for(int i = 0; i < root->rowCount(); ++i){ + QModelIndex curIdx = m->indexFromItem(root->child(i, 0)); + addSong(curIdx); + } + shufflePlayList(); +} diff --git a/playerwidget.h b/playerwidget.h index 180c232..5859cb1 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -71,6 +71,7 @@ class PlayerWidget : public QWidget { void gotoAlbum(); void setCollectionIndex(int collectionIndex, bool isWebradio); void addToFavorites(const QModelIndexList &idxs); + void clearAndAddAllFavorites(); signals: void viewModeChanged(const QString &viewMode); |