summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index f589f4d..cc6af7c 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -48,6 +48,7 @@
#include "collectionfavoritesview.h"
#include "collectionfoldersview.h"
#include "collectionwebradioview.h"
+#include "collectionwidgetproxy.h"
PlayerWidget::PlayerWidget(QSplashScreen *splash, QWidget *parent) : QWidget(parent), mDurSecs(0), mPlayListLength(0), mIsStream(false), mModelType(DoNotCare){
mStarting = true;
@@ -101,10 +102,10 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
qApp->processEvents();
albumsView->populate();
cIdx = mCollectionStack->addWidget(albumsView);
- QAction *viewByAlbumsA = new QAction(QIcon(":/album.png"), tr("View by album"), this);
- viewByAlbumsA->setCheckable(true);
- connect(viewByAlbumsA, &QAction::triggered, [this, cIdx] { mCollectionStack->setCurrentIndex(cIdx); });
- bottomTBG->addAction(viewByAlbumsA);
+ mViewByAlbumsA = new QAction(QIcon(":/album.png"), tr("View by album"), this);
+ mViewByAlbumsA->setCheckable(true);
+ connect(mViewByAlbumsA, &QAction::triggered, [this, cIdx] { mCollectionStack->setCurrentIndex(cIdx); });
+ bottomTBG->addAction(mViewByAlbumsA);
//dates view
CollectionDatesView *datesView = new CollectionDatesView;;
datesView->setHeaders(QStringList() << tr("Date added"));
@@ -180,6 +181,9 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
connect(searchMBA, &QAction::triggered, [this, curW] { searchMusicbrainz(curW->view()->selectionModel()->currentIndex()); });
curW->view()->addAction(searchMBA);
}
+ QAction *gotoAlbumA = new QAction(QIcon(":/next.png"), tr("Goto album"), this);
+ connect(gotoAlbumA, &QAction::triggered, this, &PlayerWidget::gotoAlbum);
+ artistsView->view()->addAction(gotoAlbumA);
//left widget
QWidget *leftWidget = new QWidget;
@@ -985,3 +989,20 @@ void PlayerWidget::aboutDlg(){
aboutText.append(tr("<tr><td>License</td><td style=\"padding-left: 30px\">GPL 2 or later</td></tr></table>"));
QMessageBox::about(this, title, aboutText);
}
+
+void PlayerWidget::gotoAlbum(){
+ CollectionArtistsView *artistView = mCollectionStack->findChild<CollectionArtistsView*>("artists");
+ CollectionAlbumsView *albumView = mCollectionStack->findChild<CollectionAlbumsView*>("albums");
+ QString album = artistView->view()->selectionModel()->currentIndex().data(AlbumRole).toString();
+ if(!album.isEmpty()){
+ const CollectionWidgetProxy *proxy = qobject_cast<const CollectionWidgetProxy*>(albumView->view()->model());
+ QModelIndexList albumIdxs = proxy->match(proxy->index(0, 0, QModelIndex()), AlbumRole, album);
+ if(!albumIdxs.isEmpty()){
+ mViewByAlbumsA->trigger();
+ QModelIndex albumIdx = albumIdxs.first();
+ albumView->view()->selectionModel()->select(albumIdx, QItemSelectionModel::ClearAndSelect);
+ albumView->view()->scrollTo(albumIdx, QAbstractItemView::PositionAtCenter);
+ albumView->view()->expand(albumIdx);
+ }
+ }
+}