Skip to content

Commit

Permalink
Add tab for related artists
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Feb 26, 2020
1 parent 488d215 commit 49a023d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,20 @@ void MainWindow::openArtist(const QString &artistId)
tabs->addTab(albumList, "Albums");
tabs->addTab(singleList, "Singles");
// Related artists
tabs->addTab(new QWidget(tabs), "Related");

auto relatedArtists = artist.relatedArtists(*spotify);
auto relatedList = new QListWidget(tabs);
for (auto &related : relatedArtists)
{
auto item = new QListWidgetItem(related.name, relatedList);
item->setData(RoleArtistId, related.id);
}
QListWidget::connect(relatedList, &QListWidget::itemClicked, [this, relatedList](QListWidgetItem *item) {
relatedList->setEnabled(false);
openArtist(item->data(RoleArtistId).toString());
relatedList->setEnabled(true);
});
tabs->addTab(relatedList, "Related");
// Rest of dock
dock->setWidget(layoutToWidget(layout));
dock->setFixedWidth(320);
addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, dock);
Expand Down

0 comments on commit 49a023d

Please sign in to comment.