diff options
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r-- | playerwidget.cpp | 18 |
1 files changed, 18 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(); +} |