diff --git a/src/lms/ui/PlayQueue.cpp b/src/lms/ui/PlayQueue.cpp index 3361f8b5..191a6942 100644 --- a/src/lms/ui/PlayQueue.cpp +++ b/src/lms/ui/PlayQueue.cpp @@ -301,11 +301,7 @@ PlayQueue::updateCurrentTrack(bool selected) if (!entry) return; - if (selected) - entry->addStyleClass("bg-dark"); - else - entry->removeStyleClass("bg-dark"); - + entry->toggleStyleClass("Lms-entry-playing", selected); } std::size_t diff --git a/src/lms/ui/explore/ReleaseView.cpp b/src/lms/ui/explore/ReleaseView.cpp index d6836c65..509be1b9 100644 --- a/src/lms/ui/explore/ReleaseView.cpp +++ b/src/lms/ui/explore/ReleaseView.cpp @@ -323,16 +323,15 @@ Release::refreshView() LmsApp->getMediaPlayer().trackLoaded.connect(entry, [=] (TrackId loadedTrackId) { - entry->bindString("is-playing", loadedTrackId == trackId ? "Lms-entry-playing" : ""); + entry->toggleStyleClass("Lms-entry-playing", loadedTrackId == trackId); }); if (auto trackIdLoaded {LmsApp->getMediaPlayer().getTrackLoaded()}) { - if (*trackIdLoaded == trackId) - entry->bindString("is-playing", "Lms-entry-playing"); + entry->toggleStyleClass("Lms-entry-playing", *trackIdLoaded == trackId); } else - entry->bindString("is-playing", ""); + entry->removeStyleClass("Lms-entry-playing"); } } diff --git a/src/lms/ui/explore/TrackListHelpers.cpp b/src/lms/ui/explore/TrackListHelpers.cpp index 3670c053..fdb681d3 100644 --- a/src/lms/ui/explore/TrackListHelpers.cpp +++ b/src/lms/ui/explore/TrackListHelpers.cpp @@ -30,6 +30,7 @@ #include "services/scrobbling/IScrobblingService.hpp" #include "services/database/Session.hpp" #include "services/database/Track.hpp" +#include "utils/Logger.hpp" #include "utils/Service.hpp" #include "common/Template.hpp" @@ -84,14 +85,14 @@ namespace UserInterface::TrackListHelpers tracksAction.emit(PlayQueueAction::Play, {trackId}); }); - { - entry->bindNew("more-btn", Wt::WString::tr("Lms.Explore.template.more-btn"), Wt::TextFormat::XHTML); - entry->bindNew("play-last", Wt::WString::tr("Lms.Explore.play-last")) - ->clicked().connect([=, &tracksAction] - { - tracksAction.emit(PlayQueueAction::PlayLast, {trackId}); - }); + entry->bindNew("more-btn", Wt::WString::tr("Lms.Explore.template.more-btn"), Wt::TextFormat::XHTML); + entry->bindNew("play-last", Wt::WString::tr("Lms.Explore.play-last")) + ->clicked().connect([=, &tracksAction] + { + tracksAction.emit(PlayQueueAction::PlayLast, {trackId}); + }); + { auto isStarred {[=] { return Service::get()->isStarred(LmsApp->getUserId(), trackId); }}; Wt::WPushButton* starBtn {entry->bindNew("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star"))}; @@ -111,21 +112,22 @@ namespace UserInterface::TrackListHelpers } }); - entry->bindNew("download", Wt::WString::tr("Lms.Explore.download")) - ->setLink(Wt::WLink {std::make_unique(trackId)}); } + entry->bindNew("download", Wt::WString::tr("Lms.Explore.download")) + ->setLink(Wt::WLink {std::make_unique(trackId)}); + LmsApp->getMediaPlayer().trackLoaded.connect(entryPtr, [=] (Database::TrackId loadedTrackId) { - entryPtr->bindString("is-playing", loadedTrackId == trackId ? "Lms-entry-playing" : ""); + entryPtr->toggleStyleClass("Lms-entry-playing", loadedTrackId == trackId); }); if (auto trackIdLoaded {LmsApp->getMediaPlayer().getTrackLoaded()}) { - entry->bindString("is-playing", *trackIdLoaded == trackId ? "Lms-entry-playing" : ""); + entryPtr->toggleStyleClass("Lms-entry-playing", *trackIdLoaded == trackId); } else - entry->bindString("is-playing", ""); + entry->removeStyleClass("Lms-entry-playing"); return entry; }