diff --git a/src/ui/ArtistView.cpp b/src/ui/ArtistView.cpp
index eefc62a6..1a524ba0 100644
--- a/src/ui/ArtistView.cpp
+++ b/src/ui/ArtistView.cpp
@@ -121,16 +121,16 @@ Artist::refresh()
entry->addFunction("tr", Wt::WTemplate::Functions::tr);
{
- Wt::WAnchor* coverAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/release/" + std::to_string(releaseId)));
+ Wt::WAnchor* coverAnchor = LmsApplication::createReleaseAnchor(releaseId);
Wt::WImage* cover = new Wt::WImage(coverAnchor);
- cover->setImageLink(SessionImageResource()->getReleaseUrl(release.id(), 128));
+ cover->setImageLink(LmsApp->getImageResource()->getReleaseUrl(release.id(), 128));
// Some images may not be square
cover->setWidth(128);
entry->bindWidget("cover", coverAnchor);
}
{
- Wt::WAnchor* releaseAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/release/" + std::to_string(releaseId)));
+ Wt::WAnchor* releaseAnchor = LmsApplication::createReleaseAnchor(releaseId);
Wt::WText* releaseName = new Wt::WText(releaseAnchor);
releaseName->setText(Wt::WString::fromUTF8(release->getName(), Wt::PlainText));
entry->bindWidget("name", releaseAnchor);
diff --git a/src/ui/ArtistsView.cpp b/src/ui/ArtistsView.cpp
index f801fa05..b5d1addb 100644
--- a/src/ui/ArtistsView.cpp
+++ b/src/ui/ArtistsView.cpp
@@ -93,7 +93,7 @@ Artists::addSome()
entry->bindInt("nb-release", artist->getReleases(clusterIds).size());
{
- Wt::WAnchor *artistAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/artist/" + std::to_string(artist.id())));
+ Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(artist.id());
Wt::WText *artistText = new Wt::WText(artistAnchor);
artistText->setText(Wt::WString::fromUTF8(artist->getName(), Wt::PlainText));
entry->bindWidget("name", artistAnchor);
diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp
index 75451c6c..0db39c96 100644
--- a/src/ui/LmsApplication.cpp
+++ b/src/ui/LmsApplication.cpp
@@ -17,12 +17,13 @@
* along with LMS. If not, see .
*/
-#include
+#include
#include
-#include
-#include
+#include
#include
+#include
#include
+#include
#include
#include
@@ -30,7 +31,6 @@
#include "utils/Logger.hpp"
#include "utils/Utils.hpp"
-#include "Auth.hpp"
#include "Explore.hpp"
#include "HomeView.hpp"
#include "MediaPlayer.hpp"
@@ -41,10 +41,6 @@
#include "LmsApplication.hpp"
-namespace skeletons {
- extern const char *AuthStrings_xml1;
-}
-
namespace UserInterface {
Wt::WApplication*
@@ -112,9 +108,6 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
if (firstConnection)
{
- // Hack, use the auth widget builtin strings
- builtinLocalizedStrings().useBuiltin(skeletons::AuthStrings_xml1);
-
root()->addWidget(new Settings::FirstConnectionView());
}
else
@@ -160,6 +153,18 @@ Scanner::MediaScanner& MediaScanner()
return LmsApplication::instance()->getMediaScanner();
}
+Wt::WAnchor*
+LmsApplication::createArtistAnchor(Database::id_type id)
+{
+ return new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/artist/" + std::to_string(id)));
+}
+
+Wt::WAnchor*
+LmsApplication::createReleaseAnchor(Database::id_type id)
+{
+ return new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/release/" + std::to_string(id)));
+}
+
void
LmsApplication::goHome()
{
diff --git a/src/ui/LmsApplication.hpp b/src/ui/LmsApplication.hpp
index f812cad4..59f0875a 100644
--- a/src/ui/LmsApplication.hpp
+++ b/src/ui/LmsApplication.hpp
@@ -50,6 +50,9 @@ class LmsApplication : public Wt::WApplication
void quit();
void notify(const Wt::WString& message);
+ static Wt::WAnchor* createArtistAnchor(Database::id_type id);
+ static Wt::WAnchor* createReleaseAnchor(Database::id_type id);
+
private:
LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnectionPool& connectionPool, Scanner::MediaScanner& scanner);
@@ -72,14 +75,6 @@ Wt::Dbo::Session& DboSession();
const Wt::Auth::User& CurrentAuthUser();
Database::User::pointer CurrentUser();
-ImageResource *SessionImageResource();
-TranscodeResource *SessionTranscodeResource();
-
-Scanner::MediaScanner& MediaScanner();
-
-void notify(const Wt::WString& message);
-
-
} // namespace UserInterface
#endif
diff --git a/src/ui/ReleaseView.cpp b/src/ui/ReleaseView.cpp
index 8493da75..123b7eea 100644
--- a/src/ui/ReleaseView.cpp
+++ b/src/ui/ReleaseView.cpp
@@ -99,7 +99,7 @@ Release::refresh()
}
else
{
- Wt::WAnchor *artistAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/artist/" + std::to_string(artists.front().id())));
+ Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(artists.front().id());
Wt::WText *artist = new Wt::WText(artistAnchor);
artist->setText(Wt::WString::fromUTF8(artists.front()->getName(), Wt::PlainText));
t->bindWidget("artist-name", artistAnchor);
@@ -107,7 +107,7 @@ Release::refresh()
}
Wt::WImage *cover = new Wt::WImage();
- cover->setImageLink(Wt::WLink (SessionImageResource()->getReleaseUrl(release.id(), 512)));
+ cover->setImageLink(Wt::WLink(LmsApp->getImageResource()->getReleaseUrl(release.id(), 512)));
t->bindWidget("cover", cover);
auto clusterContainers = new Wt::WContainerWidget();
@@ -161,7 +161,7 @@ Release::refresh()
if (variousArtists && track->getArtist())
{
entry->setCondition("if-has-artist", true);
- Wt::WAnchor *artistAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/artist/" + std::to_string(track->getArtist().id())));
+ Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(track->getArtist().id());
Wt::WText *artistText = new Wt::WText(artistAnchor);
artistText->setText(Wt::WString::fromUTF8(track->getArtist()->getName(), Wt::PlainText));
entry->bindWidget("artist-name", artistAnchor);
diff --git a/src/ui/ReleasesView.cpp b/src/ui/ReleasesView.cpp
index f8b9df0e..1cb5a00a 100644
--- a/src/ui/ReleasesView.cpp
+++ b/src/ui/ReleasesView.cpp
@@ -91,15 +91,15 @@ Releases::addSome()
Wt::WTemplate* entry = new Wt::WTemplate(Wt::WString::tr("template-releases-entry"), _releasesContainer);
entry->addFunction("tr", Wt::WTemplate::Functions::tr);
- Wt::WAnchor* coverAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/release/" + std::to_string(releaseId)));
+ Wt::WAnchor* coverAnchor = LmsApplication::createReleaseAnchor(releaseId);
Wt::WImage* cover = new Wt::WImage(coverAnchor);
- cover->setImageLink(SessionImageResource()->getReleaseUrl(releaseId, 128));
+ cover->setImageLink(LmsApp->getImageResource()->getReleaseUrl(releaseId, 128));
// Some images may not be square
cover->setWidth(128);
entry->bindWidget("cover", coverAnchor);
{
- Wt::WAnchor* releaseAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/release/" + std::to_string(releaseId)));
+ Wt::WAnchor* releaseAnchor = LmsApplication::createReleaseAnchor(releaseId);
Wt::WText* releaseName = new Wt::WText(releaseAnchor);
releaseName->setText(Wt::WString::fromUTF8(release->getName(), Wt::PlainText));
entry->bindWidget("release-name", releaseAnchor);
@@ -113,7 +113,7 @@ Releases::addSome()
}
else
{
- Wt::WAnchor* artistAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/artist/" + std::to_string(artists.front().id())));
+ Wt::WAnchor* artistAnchor = LmsApplication::createArtistAnchor(artists.front().id());
Wt::WText* artist = new Wt::WText(artistAnchor);
artist->setText(Wt::WString::fromUTF8(artists.front()->getName(), Wt::PlainText));
entry->bindWidget("artist-name", artistAnchor);
diff --git a/src/ui/TracksView.cpp b/src/ui/TracksView.cpp
index db82be6a..81341975 100644
--- a/src/ui/TracksView.cpp
+++ b/src/ui/TracksView.cpp
@@ -124,7 +124,7 @@ Tracks::addSome()
if (artist)
{
entry->setCondition("if-has-artist", true);
- Wt::WAnchor *artistAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/artist/" + std::to_string(track->getArtist().id())));
+ Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(track->getArtist().id());
Wt::WText *artistText = new Wt::WText(artistAnchor);
artistText->setText(Wt::WString::fromUTF8(artist->getName(), Wt::PlainText));
entry->bindWidget("artist-name", artistAnchor);
@@ -134,14 +134,14 @@ Tracks::addSome()
if (release)
{
entry->setCondition("if-has-release", true);
- Wt::WAnchor *releaseAnchor = new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/release/" + std::to_string(track->getRelease().id())));
+ Wt::WAnchor *releaseAnchor = LmsApplication::createReleaseAnchor(track->getRelease().id());
Wt::WText *releaseText = new Wt::WText(releaseAnchor);
releaseText->setText(Wt::WString::fromUTF8(release->getName(), Wt::PlainText));
entry->bindWidget("release-name", releaseAnchor);
}
Wt::WImage *cover = new Wt::WImage();
- cover->setImageLink(SessionImageResource()->getTrackUrl(track.id(), 64));
+ cover->setImageLink(LmsApp->getImageResource()->getTrackUrl(track.id(), 64));
// Some images may not be square
cover->setWidth(64);
entry->bindWidget("cover", cover);
diff --git a/src/ui/settings/DatabaseView.cpp b/src/ui/settings/DatabaseView.cpp
index 4986348c..1ee1ac28 100644
--- a/src/ui/settings/DatabaseView.cpp
+++ b/src/ui/settings/DatabaseView.cpp
@@ -267,9 +267,8 @@ DatabaseView::DatabaseView(Wt::WContainerWidget *parent)
{
model->saveData();
- MediaScanner().reschedule();
-
- notify(Wt::WString::tr("msg-notify-settings-saved"));
+ LmsApp->getMediaScanner().reschedule();
+ LmsApp->notify(Wt::WString::tr("msg-notify-settings-saved"));
}
// Udate the view: Delete any validation message in the view, etc.
@@ -285,9 +284,8 @@ DatabaseView::DatabaseView(Wt::WContainerWidget *parent)
immScanBtn->clicked().connect(std::bind([=] ()
{
- MediaScanner().scheduleImmediateScan();
-
- notify(Wt::WString::tr("msg-notify-scan-launched"));
+ LmsApp->getMediaScanner().scheduleImmediateScan();
+ LmsApp->notify(Wt::WString::tr("msg-notify-scan-launched"));
}));
updateView(model);
diff --git a/src/ui/settings/FirstConnectionView.cpp b/src/ui/settings/FirstConnectionView.cpp
index 5b1dac97..5ac4dfc9 100644
--- a/src/ui/settings/FirstConnectionView.cpp
+++ b/src/ui/settings/FirstConnectionView.cpp
@@ -149,7 +149,7 @@ FirstConnectionView::FirstConnectionView(Wt::WContainerWidget *parent)
if (model->validate())
{
model->saveData();
- notify(Wt::WString::tr("msg-settings-first-connection-done"));
+ LmsApp->notify(Wt::WString::tr("msg-settings-first-connection-done"));
saveButton->setEnabled(false);
}