Skip to content

Commit

Permalink
feat: Add list of external artist urls to ArtistLinks menu
Browse files Browse the repository at this point in the history
Just a minor feature that I was missing when I was digging around in
Spotify. Also, this enables tooltips on the artist menu such that you
can preview the URL you're about to open in your web browser.

Signed-off-by: Nico Sonack <[email protected]>
  • Loading branch information
herrhotzenplotz committed Aug 8, 2023
1 parent d4a1cd7 commit d2c2fc3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/menu/artistlinks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Menu::ArtistLinks::ArtistLinks(const lib::spt::artist &artist,
{
setIcon(Icon::get("edit-find"));
setTitle("Links");
setToolTipsVisible(true);

QMenu::connect(this, &QMenu::aboutToShow,
this, &Menu::ArtistLinks::onAboutToShow);
Expand All @@ -17,6 +18,13 @@ Menu::ArtistLinks::ArtistLinks(const lib::spt::artist &artist,
this, &Menu::ArtistLinks::onDuckDuckGo);

addSeparator();

for (auto const& ext_url : artist.external_urls) {
addLink(ext_url.first, ext_url.second);
}

addSeparator();

loading = addAction("Searching...");
loading->setEnabled(false);
}
Expand All @@ -43,6 +51,7 @@ void Menu::ArtistLinks::onDuckDuckGo(bool /*checked*/)
void Menu::ArtistLinks::addLink(const std::string &title, const std::string &url)
{
auto *action = addAction(QString::fromStdString(title));
action->setToolTip(QString::fromStdString(url));
QAction::connect(action, &QAction::triggered, [this, url](bool /*checked*/)
{
Url::open(url, LinkType::Web, this);
Expand Down

0 comments on commit d2c2fc3

Please sign in to comment.