Setting window title to help browsing in history. ref #253

This commit is contained in:
emeric
2022-08-07 13:48:29 +02:00
parent 671d724241
commit 167865d077
9 changed files with 35 additions and 19 deletions
+2 -2
View File
@@ -104,7 +104,7 @@
<message id="Lms.Admin.User.user-already-exists">User already exists!</message> <message id="Lms.Admin.User.user-already-exists">User already exists!</message>
<message id="Lms.Admin.User.user-create">New user</message> <message id="Lms.Admin.User.user-create">New user</message>
<message id="Lms.Admin.User.user-created">New user created!</message> <message id="Lms.Admin.User.user-created">New user created!</message>
<message id="Lms.Admin.User.user-edit">Edit user '{1}'</message> <message id="Lms.Admin.User.user-edit">User '{1}'</message>
<message id="Lms.Admin.User.user-updated">User updated!</message> <message id="Lms.Admin.User.user-updated">User updated!</message>
<!--Wizard--> <!--Wizard-->
@@ -133,6 +133,7 @@
<message id="Lms.Explore.recently-modified">Recently modified</message> <message id="Lms.Explore.recently-modified">Recently modified</message>
<message id="Lms.Explore.recently-played">Recently played</message> <message id="Lms.Explore.recently-played">Recently played</message>
<message id="Lms.Explore.releases">Albums</message> <message id="Lms.Explore.releases">Albums</message>
<message id="Lms.Explore.search">Search</message>
<message id="Lms.Explore.star">Star</message> <message id="Lms.Explore.star">Star</message>
<message id="Lms.Explore.starred">Starred</message> <message id="Lms.Explore.starred">Starred</message>
<message id="Lms.Explore.tracklists">Playlists</message> <message id="Lms.Explore.tracklists">Playlists</message>
@@ -187,7 +188,6 @@
<!--PlayHistory--> <!--PlayHistory-->
<message id="Lms.PlayHistory.playhistory">Play History</message> <message id="Lms.PlayHistory.playhistory">Play History</message>
<!--Settings--> <!--Settings-->
<message id="Lms.Settings.audio">Audio</message> <message id="Lms.Settings.audio">Audio</message>
<message id="Lms.Settings.audio-settings-are-local">These audio settings are local to your browser!</message> <message id="Lms.Settings.audio-settings-are-local">These audio settings are local to your browser!</message>
+1
View File
@@ -133,6 +133,7 @@
<message id="Lms.Explore.recently-modified">Modifiés récemment</message> <message id="Lms.Explore.recently-modified">Modifiés récemment</message>
<message id="Lms.Explore.recently-played">Joués récemment</message> <message id="Lms.Explore.recently-played">Joués récemment</message>
<message id="Lms.Explore.releases">Albums</message> <message id="Lms.Explore.releases">Albums</message>
<message id="Lms.Explore.search">Rechercher</message>
<message id="Lms.Explore.star">Ajouter aux favoris</message> <message id="Lms.Explore.star">Ajouter aux favoris</message>
<message id="Lms.Explore.starred">Favoris</message> <message id="Lms.Explore.starred">Favoris</message>
<message id="Lms.Explore.tracklists">Playlists</message> <message id="Lms.Explore.tracklists">Playlists</message>
+1 -1
View File
@@ -133,9 +133,9 @@
<message id="Lms.Explore.recently-played">Riprodotti di recente</message> <message id="Lms.Explore.recently-played">Riprodotti di recente</message>
<message id="Lms.Explore.releases">Album</message> <message id="Lms.Explore.releases">Album</message>
<message id="Lms.Explore.search">Ricerca</message>
<message id="Lms.Explore.star">Aggiungi ai preferiti</message> <message id="Lms.Explore.star">Aggiungi ai preferiti</message>
<message id="Lms.Explore.starred">Preferiti</message> <message id="Lms.Explore.starred">Preferiti</message>
<message id="Lms.Explore.tracks">Tracce</message> <message id="Lms.Explore.tracks">Tracce</message>
<message id="Lms.Explore.type">Tipo</message> <message id="Lms.Explore.type">Tipo</message>
<message id="Lms.Explore.unstar">Rimuovi dai preferiti</message> <message id="Lms.Explore.unstar">Rimuovi dai preferiti</message>
+1
View File
@@ -130,6 +130,7 @@
<message id="Lms.Explore.recently-modified">最近更改</message> <message id="Lms.Explore.recently-modified">最近更改</message>
<message id="Lms.Explore.recently-played">最近播放</message> <message id="Lms.Explore.recently-played">最近播放</message>
<message id="Lms.Explore.releases">专辑</message> <message id="Lms.Explore.releases">专辑</message>
<message id="Lms.Explore.search">搜索</message>
<message id="Lms.Explore.star">收藏</message> <message id="Lms.Explore.star">收藏</message>
<message id="Lms.Explore.starred">已收藏</message> <message id="Lms.Explore.starred">已收藏</message>
<message id="Lms.Explore.tracklists">播放列表</message> <message id="Lms.Explore.tracklists">播放列表</message>
+18 -14
View File
@@ -106,6 +106,7 @@ getOrCreateMessageBundle()
return res; return res;
} }
static constexpr const char* titleSeparator {" | "};
static constexpr const char* defaultPath {"/releases"}; static constexpr const char* defaultPath {"/releases"};
std::unique_ptr<Wt::WApplication> std::unique_ptr<Wt::WApplication>
@@ -378,21 +379,22 @@ handlePathChange(Wt::WStackedWidget& stack, bool isAdmin)
std::string path; std::string path;
int index; int index;
bool admin; bool admin;
std::optional<Wt::WString> title;
} views[] = } views[] =
{ {
{ "/artists", IdxExplore, false }, { "/artists", IdxExplore, false, Wt::WString::tr("Lms.Explore.artists") },
{ "/artist", IdxExplore, false }, { "/artist", IdxExplore, false, std::nullopt },
{ "/releases", IdxExplore, false }, { "/releases", IdxExplore, false, Wt::WString::tr("Lms.Explore.releases") },
{ "/release", IdxExplore, false }, { "/release", IdxExplore, false, std::nullopt },
{ "/search", IdxExplore, false }, { "/search", IdxExplore, false, Wt::WString::tr("Lms.Explore.search") },
{ "/tracks", IdxExplore, false }, { "/tracks", IdxExplore, false, Wt::WString::tr("Lms.Explore.tracks") },
{ "/tracklists", IdxExplore, false }, { "/tracklists", IdxExplore, false, Wt::WString::tr("Lms.Explore.tracklists") },
{ "/tracklist", IdxExplore, false }, { "/tracklist", IdxExplore, false, std::nullopt },
{ "/playqueue", IdxPlayQueue, false }, { "/playqueue", IdxPlayQueue, false, Wt::WString::tr("Lms.PlayQueue.playqueue") },
{ "/settings", IdxSettings, false }, { "/settings", IdxSettings, false, Wt::WString::tr("Lms.Settings.settings") },
{ "/admin/database", IdxAdminDatabase, true }, { "/admin/database", IdxAdminDatabase, true, Wt::WString::tr("Lms.Admin.Database.database") },
{ "/admin/users", IdxAdminUsers, true }, { "/admin/users", IdxAdminUsers, true, Wt::WString::tr("Lms.Admin.Users.users") },
{ "/admin/user", IdxAdminUser, true }, { "/admin/user", IdxAdminUser, true, std::nullopt },
}; };
LMS_LOG(UI, DEBUG) << "Internal path changed to '" << wApp->internalPath() << "'"; LMS_LOG(UI, DEBUG) << "Internal path changed to '" << wApp->internalPath() << "'";
@@ -406,6 +408,8 @@ handlePathChange(Wt::WStackedWidget& stack, bool isAdmin)
break; break;
stack.setCurrentIndex(view.index); stack.setCurrentIndex(view.index);
if (view.title)
LmsApp->setTitle(*view.title);
return; return;
} }
} }
@@ -623,7 +627,7 @@ LmsApplication::setTitle(const Wt::WString& title)
if (title.empty()) if (title.empty())
WApplication::setTitle("LMS"); WApplication::setTitle("LMS");
else else
WApplication::setTitle(title + " | LMS"); WApplication::setTitle(Wt::WString {"LMS"} + titleSeparator + title);
} }
void void
+8 -2
View File
@@ -215,16 +215,22 @@ UserView::refreshView()
if (!user) if (!user)
throw UserNotFoundException {}; 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->setCondition("if-has-last-login", true);
t->bindString("last-login", user->getLastLogin().toString(), Wt::TextFormat::Plain); t->bindString("last-login", user->getLastLogin().toString(), Wt::TextFormat::Plain);
} }
else else
{ {
const Wt::WString title {Wt::WString::tr("Lms.Admin.User.user-create")};
LmsApp->setTitle(title);
// Login // Login
t->setCondition("if-has-login", true); t->setCondition("if-has-login", true);
t->setFormWidget(UserModel::LoginField, std::make_unique<Wt::WLineEdit>()); t->setFormWidget(UserModel::LoginField, std::make_unique<Wt::WLineEdit>());
t->bindString("title", Wt::WString::tr("Lms.Admin.User.user-create")); t->bindString("title", title);
} }
if (authPasswordService) if (authPasswordService)
+1
View File
@@ -109,6 +109,7 @@ Artist::refreshView()
if (!artist) if (!artist)
throw ArtistNotFoundException {}; throw ArtistNotFoundException {};
LmsApp->setTitle(artist->getName());
_artistId = *artistId; _artistId = *artistId;
std::size_t sectionCount{}; std::size_t sectionCount{};
+2
View File
@@ -106,6 +106,8 @@ Release::refreshView()
if (!release) if (!release)
throw ReleaseNotFoundException {}; throw ReleaseNotFoundException {};
LmsApp->setTitle(release->getName());
refreshCopyright(release); refreshCopyright(release);
refreshLinks(release); refreshLinks(release);
refreshSimilarReleases(similarReleasesIds); refreshSimilarReleases(similarReleasesIds);
+1
View File
@@ -88,6 +88,7 @@ namespace UserInterface
if (!trackList) if (!trackList)
throw TrackListNotFoundException {}; throw TrackListNotFoundException {};
LmsApp->setTitle(std::string {trackList->getName()});
_trackListId = *trackListId; _trackListId = *trackListId;
clear(); clear();