From 167865d0775d25c315f822a3ec0becfe21589500 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 7 Aug 2022 13:48:29 +0200 Subject: [PATCH] Setting window title to help browsing in history. ref #253 --- approot/messages.xml | 4 ++-- approot/messages_fr.xml | 1 + approot/messages_it.xml | 2 +- approot/messages_zh.xml | 1 + src/lms/ui/LmsApplication.cpp | 32 ++++++++++++++++------------ src/lms/ui/admin/UserView.cpp | 10 +++++++-- src/lms/ui/explore/ArtistView.cpp | 1 + src/lms/ui/explore/ReleaseView.cpp | 2 ++ src/lms/ui/explore/TrackListView.cpp | 1 + 9 files changed, 35 insertions(+), 19 deletions(-) diff --git a/approot/messages.xml b/approot/messages.xml index bb07bcc6..446b7c4b 100644 --- a/approot/messages.xml +++ b/approot/messages.xml @@ -104,7 +104,7 @@ User already exists! New user New user created! -Edit user '{1}' +User '{1}' User updated! @@ -133,6 +133,7 @@ Recently modified Recently played Albums +Search Star Starred Playlists @@ -187,7 +188,6 @@ Play History - Audio These audio settings are local to your browser! diff --git a/approot/messages_fr.xml b/approot/messages_fr.xml index 8d6a1b38..ef4a9fb1 100644 --- a/approot/messages_fr.xml +++ b/approot/messages_fr.xml @@ -133,6 +133,7 @@ Modifiés récemment Joués récemment Albums +Rechercher Ajouter aux favoris Favoris Playlists diff --git a/approot/messages_it.xml b/approot/messages_it.xml index 4a254842..2eb16b86 100644 --- a/approot/messages_it.xml +++ b/approot/messages_it.xml @@ -133,9 +133,9 @@ Riprodotti di recente Album +Ricerca Aggiungi ai preferiti Preferiti - Tracce Tipo Rimuovi dai preferiti diff --git a/approot/messages_zh.xml b/approot/messages_zh.xml index 7738c0f6..a73ab6b6 100644 --- a/approot/messages_zh.xml +++ b/approot/messages_zh.xml @@ -130,6 +130,7 @@ 最近更改 最近播放 专辑 +搜索 收藏 已收藏 播放列表 diff --git a/src/lms/ui/LmsApplication.cpp b/src/lms/ui/LmsApplication.cpp index b724204f..e458a367 100644 --- a/src/lms/ui/LmsApplication.cpp +++ b/src/lms/ui/LmsApplication.cpp @@ -106,6 +106,7 @@ getOrCreateMessageBundle() return res; } +static constexpr const char* titleSeparator {" | "}; static constexpr const char* defaultPath {"/releases"}; std::unique_ptr @@ -378,21 +379,22 @@ handlePathChange(Wt::WStackedWidget& stack, bool isAdmin) std::string path; int index; bool admin; + std::optional title; } views[] = { - { "/artists", IdxExplore, false }, - { "/artist", IdxExplore, false }, - { "/releases", IdxExplore, false }, - { "/release", IdxExplore, false }, - { "/search", IdxExplore, false }, - { "/tracks", IdxExplore, false }, - { "/tracklists", IdxExplore, false }, - { "/tracklist", IdxExplore, false }, - { "/playqueue", IdxPlayQueue, false }, - { "/settings", IdxSettings, false }, - { "/admin/database", IdxAdminDatabase, true }, - { "/admin/users", IdxAdminUsers, true }, - { "/admin/user", IdxAdminUser, true }, + { "/artists", IdxExplore, false, Wt::WString::tr("Lms.Explore.artists") }, + { "/artist", IdxExplore, false, std::nullopt }, + { "/releases", IdxExplore, false, Wt::WString::tr("Lms.Explore.releases") }, + { "/release", IdxExplore, false, std::nullopt }, + { "/search", IdxExplore, false, Wt::WString::tr("Lms.Explore.search") }, + { "/tracks", IdxExplore, false, Wt::WString::tr("Lms.Explore.tracks") }, + { "/tracklists", IdxExplore, false, Wt::WString::tr("Lms.Explore.tracklists") }, + { "/tracklist", IdxExplore, false, std::nullopt }, + { "/playqueue", IdxPlayQueue, false, Wt::WString::tr("Lms.PlayQueue.playqueue") }, + { "/settings", IdxSettings, false, Wt::WString::tr("Lms.Settings.settings") }, + { "/admin/database", IdxAdminDatabase, true, Wt::WString::tr("Lms.Admin.Database.database") }, + { "/admin/users", IdxAdminUsers, true, Wt::WString::tr("Lms.Admin.Users.users") }, + { "/admin/user", IdxAdminUser, true, std::nullopt }, }; LMS_LOG(UI, DEBUG) << "Internal path changed to '" << wApp->internalPath() << "'"; @@ -406,6 +408,8 @@ handlePathChange(Wt::WStackedWidget& stack, bool isAdmin) break; stack.setCurrentIndex(view.index); + if (view.title) + LmsApp->setTitle(*view.title); return; } } @@ -623,7 +627,7 @@ LmsApplication::setTitle(const Wt::WString& title) if (title.empty()) WApplication::setTitle("LMS"); else - WApplication::setTitle(title + " | LMS"); + WApplication::setTitle(Wt::WString {"LMS"} + titleSeparator + title); } void diff --git a/src/lms/ui/admin/UserView.cpp b/src/lms/ui/admin/UserView.cpp index 99f41e6c..64fecb36 100644 --- a/src/lms/ui/admin/UserView.cpp +++ b/src/lms/ui/admin/UserView.cpp @@ -215,16 +215,22 @@ UserView::refreshView() if (!user) throw UserNotFoundException {}; - t->bindString("title", Wt::WString::tr("Lms.Admin.User.user-edit").arg(user->getLoginName()), Wt::TextFormat::Plain); + const Wt::WString title {Wt::WString::tr("Lms.Admin.User.user-edit").arg(user->getLoginName())}; + LmsApp->setTitle(title); + + t->bindString("title", title, Wt::TextFormat::Plain); t->setCondition("if-has-last-login", true); t->bindString("last-login", user->getLastLogin().toString(), Wt::TextFormat::Plain); } else { + const Wt::WString title {Wt::WString::tr("Lms.Admin.User.user-create")}; + LmsApp->setTitle(title); + // Login t->setCondition("if-has-login", true); t->setFormWidget(UserModel::LoginField, std::make_unique()); - t->bindString("title", Wt::WString::tr("Lms.Admin.User.user-create")); + t->bindString("title", title); } if (authPasswordService) diff --git a/src/lms/ui/explore/ArtistView.cpp b/src/lms/ui/explore/ArtistView.cpp index df9d5927..778ca615 100644 --- a/src/lms/ui/explore/ArtistView.cpp +++ b/src/lms/ui/explore/ArtistView.cpp @@ -109,6 +109,7 @@ Artist::refreshView() if (!artist) throw ArtistNotFoundException {}; + LmsApp->setTitle(artist->getName()); _artistId = *artistId; std::size_t sectionCount{}; diff --git a/src/lms/ui/explore/ReleaseView.cpp b/src/lms/ui/explore/ReleaseView.cpp index 78c924ff..b4f38bf2 100644 --- a/src/lms/ui/explore/ReleaseView.cpp +++ b/src/lms/ui/explore/ReleaseView.cpp @@ -106,6 +106,8 @@ Release::refreshView() if (!release) throw ReleaseNotFoundException {}; + LmsApp->setTitle(release->getName()); + refreshCopyright(release); refreshLinks(release); refreshSimilarReleases(similarReleasesIds); diff --git a/src/lms/ui/explore/TrackListView.cpp b/src/lms/ui/explore/TrackListView.cpp index e3c76726..30a0daa8 100644 --- a/src/lms/ui/explore/TrackListView.cpp +++ b/src/lms/ui/explore/TrackListView.cpp @@ -88,6 +88,7 @@ namespace UserInterface if (!trackList) throw TrackListNotFoundException {}; + LmsApp->setTitle(std::string {trackList->getName()}); _trackListId = *trackListId; clear();