Upgrade from Wt3 to Wt4
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WApplication>
|
||||
#include <Wt/WAnchor>
|
||||
#include <Wt/WImage>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WImage.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -36,9 +35,8 @@
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
Artist::Artist(Filters* filters, Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_filters(filters)
|
||||
Artist::Artist(Filters* filters)
|
||||
: _filters(filters)
|
||||
{
|
||||
wApp->internalPathChanged().connect(std::bind([=]
|
||||
{
|
||||
@@ -60,81 +58,73 @@ Artist::refresh()
|
||||
|
||||
clear();
|
||||
|
||||
Database::Artist::id_type artistId;
|
||||
if (!readAs(wApp->internalPathNextPart("/artist/"), artistId))
|
||||
auto artistId = readAs<Database::Artist::id_type>(wApp->internalPathNextPart("/artist/"));
|
||||
if (!artistId)
|
||||
return;
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
auto artist = Database::Artist::getById(DboSession(), artistId);
|
||||
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
auto artist = Database::Artist::getById(LmsApp->getDboSession(), *artistId);
|
||||
if (!artist)
|
||||
{
|
||||
LmsApp->goHome();
|
||||
return;
|
||||
}
|
||||
|
||||
auto t = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artist.template"), this);
|
||||
Wt::WTemplate* t = addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artist.template"));
|
||||
t->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
auto clusterContainers = new Wt::WContainerWidget();
|
||||
t->bindWidget("clusters", clusterContainers);
|
||||
Wt::WContainerWidget* clusterContainers = t->bindNew<Wt::WContainerWidget>("clusters");
|
||||
|
||||
{
|
||||
auto clusters = artist->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artist.template.cluster-entry"), clusterContainers);
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||
Wt::WTemplate* entry = clusterContainers->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artist.template.cluster-entry"));
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::TextFormat::Plain);
|
||||
}
|
||||
}
|
||||
|
||||
t->bindString("name", Wt::WString::fromUTF8(artist->getName()), Wt::PlainText);
|
||||
t->bindString("name", Wt::WString::fromUTF8(artist->getName()), Wt::TextFormat::Plain);
|
||||
{
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Artist.play"), Wt::XHTMLText);
|
||||
t->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = t->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Artist.play"), Wt::TextFormat::XHTML);
|
||||
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
artistPlay.emit(artistId);
|
||||
artistPlay.emit(*artistId);
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Artist.add"), Wt::XHTMLText);
|
||||
t->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = t->bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Artist.add"), Wt::TextFormat::XHTML);
|
||||
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
artistAdd.emit(artistId);
|
||||
artistAdd.emit(*artistId);
|
||||
}));
|
||||
}
|
||||
|
||||
auto releasesContainer = new Wt::WContainerWidget();
|
||||
t->bindWidget("releases", releasesContainer);
|
||||
Wt::WContainerWidget* releasesContainer = t->bindNew<Wt::WContainerWidget>("releases");
|
||||
|
||||
auto releases = artist->getReleases(_filters->getClusterIds());
|
||||
for (auto release : releases)
|
||||
{
|
||||
auto releaseId = release.id();
|
||||
|
||||
Wt::WTemplate* entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artist.template.entry"), releasesContainer);
|
||||
Wt::WTemplate* entry = releasesContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artist.template.entry"));
|
||||
entry->addFunction("tr", Wt::WTemplate::Functions::tr);
|
||||
|
||||
{
|
||||
Wt::WAnchor* coverAnchor = LmsApplication::createReleaseAnchor(release, false);
|
||||
Wt::WImage* cover = new Wt::WImage(coverAnchor);
|
||||
Wt::WAnchor* anchor = entry->bindWidget("cover", LmsApplication::createReleaseAnchor(release, false));
|
||||
|
||||
auto cover = std::make_unique<Wt::WImage>();
|
||||
cover->setImageLink(LmsApp->getImageResource()->getReleaseUrl(release.id(), 128));
|
||||
// Some images may not be square
|
||||
cover->setWidth(128);
|
||||
entry->bindWidget("cover", coverAnchor);
|
||||
anchor->setImage(std::move(cover));
|
||||
}
|
||||
|
||||
{
|
||||
Wt::WAnchor* releaseAnchor = LmsApplication::createReleaseAnchor(release);
|
||||
entry->bindWidget("name", releaseAnchor);
|
||||
}
|
||||
entry->bindWidget("name", LmsApplication::createReleaseAnchor(release));
|
||||
|
||||
if (release->hasVariousArtists())
|
||||
entry->setCondition("if-has-various-artists", true);
|
||||
@@ -153,15 +143,13 @@ Artist::refresh()
|
||||
}
|
||||
}
|
||||
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Artist.play"), Wt::XHTMLText);
|
||||
entry->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Artist.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
releasePlay.emit(releaseId);
|
||||
}));
|
||||
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Artist.add"), Wt::XHTMLText);
|
||||
entry->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = entry->bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Artist.add"), Wt::TextFormat::XHTML);
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
releaseAdd.emit(releaseId);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WSignal>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
@@ -29,7 +29,7 @@ class Filters;
|
||||
class Artist : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
Artist(Filters* filters, Wt::WContainerWidget* parent = 0);
|
||||
Artist(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> artistAdd;
|
||||
Wt::Signal<Database::id_type> artistPlay;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WAnchor>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -34,24 +34,20 @@ namespace UserInterface {
|
||||
|
||||
using namespace Database;
|
||||
|
||||
Artists::Artists(Filters* filters, Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
Artists::Artists(Filters* filters)
|
||||
: Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artists.template")),
|
||||
_filters(filters)
|
||||
{
|
||||
auto container = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artists.template"), this);
|
||||
container->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
_search = new Wt::WLineEdit();
|
||||
container->bindWidget("search", _search);
|
||||
_search = bindNew<Wt::WLineEdit>("search");
|
||||
_search->setPlaceholderText(Wt::WString::tr("Lms.Explore.search-placeholder"));
|
||||
_search->textInput().connect(this, &Artists::refresh);
|
||||
|
||||
_artistsContainer = new Wt::WContainerWidget();
|
||||
container->bindWidget("artists", _artistsContainer);
|
||||
_artistsContainer = bindNew<Wt::WContainerWidget>("artists");
|
||||
|
||||
_showMore = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.template.show-more"));
|
||||
_showMore = bindNew<Wt::WTemplate>("show-more", Wt::WString::tr("Lms.Explore.template.show-more"));
|
||||
_showMore->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
container->bindWidget("show-more", _showMore);
|
||||
|
||||
_showMore->clicked().connect(std::bind([=]
|
||||
{
|
||||
@@ -77,24 +73,20 @@ Artists::addSome()
|
||||
|
||||
auto clusterIds = _filters->getClusterIds();
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
bool moreResults;
|
||||
auto artists = Artist::getByFilter(DboSession(),
|
||||
auto artists = Artist::getByFilter(LmsApp->getDboSession(),
|
||||
clusterIds,
|
||||
searchKeywords,
|
||||
_artistsContainer->count(), 20, moreResults);
|
||||
|
||||
for (auto artist : artists)
|
||||
{
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artists.template.entry"), _artistsContainer);
|
||||
Wt::WTemplate* entry = _artistsContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artists.template.entry"));
|
||||
|
||||
entry->bindInt("nb-release", artist->getReleases(clusterIds).size());
|
||||
|
||||
{
|
||||
Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(artist);
|
||||
entry->bindWidget("name", artistAnchor);
|
||||
}
|
||||
entry->bindWidget("name", LmsApplication::createArtistAnchor(artist));
|
||||
}
|
||||
|
||||
_showMore->setHidden(!moreResults);
|
||||
|
||||
@@ -19,18 +19,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WSignal>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
|
||||
class Artists : public Wt::WContainerWidget
|
||||
class Artists : public Wt::WTemplate
|
||||
{
|
||||
public:
|
||||
Artists(Filters* filters, Wt::WContainerWidget* parent = 0);
|
||||
Artists(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> artistAdd;
|
||||
Wt::Signal<Database::id_type> artistPlay;
|
||||
|
||||
+29
-39
@@ -17,9 +17,9 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WStackedWidget>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WStackedWidget.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
@@ -70,54 +70,44 @@ handlePathChange(Wt::WStackedWidget* stack)
|
||||
}
|
||||
}
|
||||
|
||||
Explore::Explore(Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent)
|
||||
Explore::Explore()
|
||||
: Wt::WTemplate(Wt::WString::tr("Lms.Explore.template"))
|
||||
{
|
||||
auto container = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.template"), this);
|
||||
|
||||
_filters = new Filters();
|
||||
container->bindWidget("filters", _filters);
|
||||
_filters = bindNew<Filters>("filters");
|
||||
|
||||
// Contents
|
||||
Wt::WStackedWidget* stack = new Wt::WStackedWidget();
|
||||
container->bindWidget("contents", stack);
|
||||
|
||||
auto artists = new Artists(_filters);
|
||||
stack->addWidget(artists);
|
||||
Wt::WStackedWidget* stack = bindNew<Wt::WStackedWidget>("contents");
|
||||
|
||||
auto artists = std::make_unique<Artists>(_filters);
|
||||
artists->artistAdd.connect(this, &Explore::handleArtistAdd);
|
||||
artists->artistPlay.connect(this, &Explore::handleArtistPlay);
|
||||
stack->addWidget(std::move(artists));
|
||||
|
||||
auto artist = new Artist(_filters);
|
||||
stack->addWidget(artist);
|
||||
|
||||
auto artist = std::make_unique<Artist>(_filters);
|
||||
artist->artistAdd.connect(this, &Explore::handleArtistAdd);
|
||||
artist->artistPlay.connect(this, &Explore::handleArtistPlay);
|
||||
artist->releaseAdd.connect(this, &Explore::handleReleaseAdd);
|
||||
artist->releasePlay.connect(this, &Explore::handleReleasePlay);
|
||||
stack->addWidget(std::move(artist));
|
||||
|
||||
auto releases = new Releases(_filters);
|
||||
stack->addWidget(releases);
|
||||
|
||||
auto releases = std::make_unique<Releases>(_filters);
|
||||
releases->releaseAdd.connect(this, &Explore::handleReleaseAdd);
|
||||
releases->releasePlay.connect(this, &Explore::handleReleasePlay);
|
||||
stack->addWidget(std::move(releases));
|
||||
|
||||
auto release = new Release(_filters);
|
||||
stack->addWidget(release);
|
||||
|
||||
auto release = std::make_unique<Release>(_filters);
|
||||
release->releaseAdd.connect(this, &Explore::handleReleaseAdd);
|
||||
release->releasePlay.connect(this, &Explore::handleReleasePlay);
|
||||
release->trackAdd.connect(this, &Explore::handleTrackAdd);
|
||||
release->trackPlay.connect(this, &Explore::handleTrackPlay);
|
||||
stack->addWidget(std::move(release));
|
||||
|
||||
auto tracks = new Tracks(_filters);
|
||||
stack->addWidget(tracks);
|
||||
|
||||
auto tracks = std::make_unique<Tracks>(_filters);
|
||||
tracks->trackAdd.connect(this, &Explore::handleTrackAdd);
|
||||
tracks->trackPlay.connect(this, &Explore::handleTrackPlay);
|
||||
tracks->tracksAdd.connect(this, &Explore::handleTracksAdd);
|
||||
tracks->tracksPlay.connect(this, &Explore::handleTracksPlay);
|
||||
|
||||
stack->addWidget(std::move(tracks));
|
||||
|
||||
wApp->internalPathChanged().connect(std::bind([=]
|
||||
{
|
||||
@@ -175,49 +165,49 @@ static std::vector<Database::Track::pointer> getTrack(Wt::Dbo::Session& session,
|
||||
void
|
||||
Explore::handleArtistAdd(Database::id_type id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
tracksAdd.emit(getArtistTracks(DboSession(), id, _filters->getClusterIds()));
|
||||
tracksAdd.emit(getArtistTracks(LmsApp->getDboSession(), id, _filters->getClusterIds()));
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleArtistPlay(Database::id_type id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
tracksPlay.emit(getArtistTracks(DboSession(), id, _filters->getClusterIds()));
|
||||
tracksPlay.emit(getArtistTracks(LmsApp->getDboSession(), id, _filters->getClusterIds()));
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleReleaseAdd(Database::id_type id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
tracksAdd.emit(getReleaseTracks(DboSession(), id, _filters->getClusterIds()));
|
||||
tracksAdd.emit(getReleaseTracks(LmsApp->getDboSession(), id, _filters->getClusterIds()));
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleReleasePlay(Database::id_type id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
tracksPlay.emit(getReleaseTracks(DboSession(), id, _filters->getClusterIds()));
|
||||
tracksPlay.emit(getReleaseTracks(LmsApp->getDboSession(), id, _filters->getClusterIds()));
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleTrackAdd(Database::id_type id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
tracksAdd.emit(getTrack(DboSession(), id));
|
||||
tracksAdd.emit(getTrack(LmsApp->getDboSession(), id));
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleTrackPlay(Database::id_type id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
tracksPlay.emit(getTrack(DboSession(), id));
|
||||
tracksPlay.emit(getTrack(LmsApp->getDboSession(), id));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -27,22 +27,22 @@ namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
|
||||
class Explore : public Wt::WContainerWidget
|
||||
class Explore : public Wt::WTemplate
|
||||
{
|
||||
public:
|
||||
Explore(Wt::WContainerWidget *parent = 0);
|
||||
Explore();
|
||||
|
||||
Wt::Signal<std::vector<Database::Track::pointer>> tracksAdd;
|
||||
Wt::Signal<std::vector<Database::Track::pointer>> tracksPlay;
|
||||
|
||||
private:
|
||||
|
||||
void handleArtistAdd(Database::id_type id);
|
||||
void handleArtistPlay(Database::id_type id);
|
||||
void handleReleaseAdd(Database::id_type id);
|
||||
void handleReleasePlay(Database::id_type id);
|
||||
void handleTrackAdd(Database::id_type id);
|
||||
void handleTrackPlay(Database::id_type id);
|
||||
void handleArtistAdd(Database::Artist::id_type id);
|
||||
void handleArtistPlay(Database::Artist::id_type id);
|
||||
void handleReleaseAdd(Database::Release::id_type id);
|
||||
void handleReleasePlay(Database::Release::id_type id);
|
||||
void handleTrackAdd(Database::Track::id_type id);
|
||||
void handleTrackPlay(Database::Track::id_type id);
|
||||
void handleTracksAdd(std::vector<Database::Track::pointer> tracks);
|
||||
void handleTracksPlay(std::vector<Database::Track::pointer> tracks);
|
||||
|
||||
|
||||
+25
-44
@@ -17,10 +17,10 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WComboBox>
|
||||
#include <Wt/WDialog>
|
||||
#include <Wt/WPushButton>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WComboBox.h>
|
||||
#include <Wt/WDialog.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "Filters.hpp"
|
||||
|
||||
@@ -31,32 +31,25 @@ namespace UserInterface {
|
||||
void
|
||||
Filters::showDialog()
|
||||
{
|
||||
auto dialog = new Wt::WDialog(Wt::WString::tr("Lms.Explore.add-filter"));
|
||||
auto dialog = std::make_shared<Wt::WDialog>(Wt::WString::tr("Lms.Explore.add-filter"));
|
||||
|
||||
auto container = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.template.add-filter"));
|
||||
Wt::WTemplate* container = dialog->contents()->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.template.add-filter"));
|
||||
container->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
dialog->contents()->addWidget(container);
|
||||
Wt::WComboBox* typeCombo = container->bindNew<Wt::WComboBox>("type");
|
||||
Wt::WComboBox* valueCombo = container->bindNew<Wt::WComboBox>("value");
|
||||
|
||||
auto typeCombo = new Wt::WComboBox();
|
||||
container->bindWidget("type", typeCombo);
|
||||
Wt::WPushButton* addBtn = container->bindNew<Wt::WPushButton>("add-btn", Wt::WString::tr("Lms.add"));
|
||||
addBtn->clicked().connect(dialog.get(), &Wt::WDialog::accept);
|
||||
|
||||
auto valueCombo = new Wt::WComboBox();
|
||||
container->bindWidget("value", valueCombo);
|
||||
|
||||
auto addBtn = new Wt::WPushButton(Wt::WString::tr("Lms.add"));
|
||||
container->bindWidget("add-btn", addBtn);
|
||||
addBtn->clicked().connect(dialog, &Wt::WDialog::accept);
|
||||
|
||||
auto cancelBtn = new Wt::WPushButton(Wt::WString::tr("Lms.cancel"));
|
||||
container->bindWidget("cancel-btn", cancelBtn);
|
||||
cancelBtn->clicked().connect(dialog, &Wt::WDialog::reject);
|
||||
Wt::WPushButton* cancelBtn = container->bindNew<Wt::WPushButton>("cancel-btn", Wt::WString::tr("Lms.cancel"));
|
||||
cancelBtn->clicked().connect(dialog.get(), &Wt::WDialog::reject);
|
||||
|
||||
// Populate data
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
auto types = Database::ClusterType::getAll(DboSession());
|
||||
auto types = Database::ClusterType::getAll(LmsApp->getDboSession());
|
||||
|
||||
for (auto type : types)
|
||||
typeCombo->addItem(Wt::WString::fromUTF8(type->getName()));
|
||||
@@ -81,9 +74,9 @@ Filters::showDialog()
|
||||
|
||||
valueCombo->clear();
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
auto clusterType = Database::ClusterType::getByName(DboSession(), name);
|
||||
auto clusterType = Database::ClusterType::getByName(LmsApp->getDboSession(), name);
|
||||
|
||||
auto values = clusterType->getClusters();
|
||||
for (auto value : values)
|
||||
@@ -94,24 +87,22 @@ Filters::showDialog()
|
||||
}));
|
||||
|
||||
dialog->setModal(true);
|
||||
#if WT_VERSION >= 0x03030700
|
||||
dialog->setMovable(false);
|
||||
#endif
|
||||
|
||||
dialog->setResizable(false);
|
||||
dialog->setClosable(false);
|
||||
|
||||
dialog->finished().connect(std::bind([=]
|
||||
{
|
||||
if (dialog->result() != Wt::WDialog::Accepted)
|
||||
if (dialog->result() != Wt::DialogCode::Accepted)
|
||||
return;
|
||||
|
||||
auto type = typeCombo->valueText().toUTF8();
|
||||
auto value = valueCombo->valueText().toUTF8();
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
auto clusterType = Database::ClusterType::getByName(DboSession(), type);
|
||||
auto clusterType = Database::ClusterType::getByName(LmsApp->getDboSession(), type);
|
||||
if (!clusterType)
|
||||
return;
|
||||
|
||||
@@ -123,8 +114,7 @@ Filters::showDialog()
|
||||
_filterIds.insert(clusterId);
|
||||
_sigUpdated.emit();
|
||||
|
||||
auto filterBtn = new Wt::WPushButton(Wt::WString::fromUTF8(value));
|
||||
_filters->addWidget(filterBtn);
|
||||
Wt::WPushButton* filterBtn = _filters->addNew<Wt::WPushButton>(Wt::WString::fromUTF8(value), Wt::TextFormat::Plain);
|
||||
|
||||
filterBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
@@ -137,23 +127,14 @@ Filters::showDialog()
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
Filters::Filters(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent)
|
||||
Filters::Filters()
|
||||
: Wt::WTemplate(Wt::WString::tr("Lms.Explore.template.filters"))
|
||||
{
|
||||
auto container = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.template.filters"), this);
|
||||
|
||||
// Filters
|
||||
Wt::WPushButton *addFilterBtn = new Wt::WPushButton(Wt::WText::tr("Lms.Explore.add-filter"));
|
||||
container->bindWidget("add-filter", addFilterBtn);
|
||||
|
||||
_filters = new Wt::WContainerWidget();
|
||||
container->bindWidget("filters", _filters);
|
||||
|
||||
addFilterBtn->clicked().connect(std::bind([this]
|
||||
{
|
||||
showDialog();
|
||||
}));
|
||||
Wt::WPushButton *addFilterBtn = bindNew<Wt::WPushButton>("add-filter", Wt::WText::tr("Lms.Explore.add-filter"));
|
||||
addFilterBtn->clicked().connect(this, &Filters::showDialog);
|
||||
|
||||
_filters = bindNew<Wt::WContainerWidget>("filters");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WSignal>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WSignal.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -28,21 +29,21 @@
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters : public Wt::WContainerWidget
|
||||
class Filters : public Wt::WTemplate
|
||||
{
|
||||
public:
|
||||
Filters(Wt::WContainerWidget *parent = 0);
|
||||
Filters();
|
||||
|
||||
std::set<Database::Cluster::id_type> getClusterIds() const { return _filterIds; }
|
||||
|
||||
Wt::Signal<void>& updated() { return _sigUpdated; }
|
||||
Wt::Signal<>& updated() { return _sigUpdated; }
|
||||
|
||||
private:
|
||||
|
||||
void showDialog();
|
||||
|
||||
Wt::WContainerWidget *_filters;
|
||||
Wt::Signal<void> _sigUpdated;
|
||||
Wt::Signal<> _sigUpdated;
|
||||
std::set<Database::Cluster::id_type> _filterIds;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WApplication>
|
||||
#include <Wt/WAnchor>
|
||||
#include <Wt/WImage>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WApplication.h>
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WImage.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -36,9 +36,8 @@
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
Release::Release(Filters* filters, Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_filters(filters)
|
||||
Release::Release(Filters* filters)
|
||||
: _filters(filters)
|
||||
{
|
||||
wApp->internalPathChanged().connect(std::bind([=]
|
||||
{
|
||||
@@ -60,24 +59,23 @@ Release::refresh()
|
||||
|
||||
clear();
|
||||
|
||||
Database::Release::id_type releaseId;
|
||||
|
||||
if (!readAs(wApp->internalPathNextPart("/release/"), releaseId))
|
||||
auto releaseId = readAs<Database::Release::id_type>(wApp->internalPathNextPart("/release/"));
|
||||
if (!releaseId)
|
||||
return;
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
auto release = Database::Release::getById(DboSession(), releaseId);
|
||||
auto release = Database::Release::getById(LmsApp->getDboSession(), *releaseId);
|
||||
if (!release)
|
||||
{
|
||||
LmsApp->goHome();
|
||||
return;
|
||||
}
|
||||
|
||||
auto t = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Release.template"), this);
|
||||
Wt::WTemplate* t = addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Release.template"));
|
||||
t->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
t->bindString("name", Wt::WString::fromUTF8(release->getName()), Wt::PlainText);
|
||||
t->bindString("name", Wt::WString::fromUTF8(release->getName()), Wt::TextFormat::Plain);
|
||||
|
||||
boost::optional<int> year = release->getReleaseYear();
|
||||
if (year)
|
||||
@@ -103,49 +101,40 @@ Release::refresh()
|
||||
else if (artists.size() == 1)
|
||||
{
|
||||
t->setCondition("if-has-artist", true);
|
||||
Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(artists.front());
|
||||
t->bindWidget("artist-name", artistAnchor);
|
||||
t->bindWidget("artist-name", LmsApplication::createArtistAnchor(artists.front()));
|
||||
}
|
||||
}
|
||||
|
||||
Wt::WImage *cover = new Wt::WImage();
|
||||
cover->setImageLink(Wt::WLink(LmsApp->getImageResource()->getReleaseUrl(release.id(), 512)));
|
||||
t->bindWidget("cover", cover);
|
||||
|
||||
auto clusterContainers = new Wt::WContainerWidget();
|
||||
t->bindWidget("clusters", clusterContainers);
|
||||
t->bindNew<Wt::WImage>("cover", Wt::WLink(LmsApp->getImageResource()->getReleaseUrl(release.id(), 512)));
|
||||
|
||||
Wt::WContainerWidget* clusterContainers = t->bindNew<Wt::WContainerWidget>("clusters");
|
||||
{
|
||||
auto clusters = release->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Release.template.cluster-entry"), clusterContainers);
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||
Wt::WTemplate* entry = clusterContainers->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Release.template.cluster-entry"));
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::TextFormat::Plain);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Release.play"), Wt::XHTMLText);
|
||||
t->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = t->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Release.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
releasePlay.emit(releaseId);
|
||||
releasePlay.emit(*releaseId);
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Release.add"), Wt::XHTMLText);
|
||||
t->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = t->bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Release.add"), Wt::TextFormat::XHTML);
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
releaseAdd.emit(releaseId);
|
||||
releaseAdd.emit(*releaseId);
|
||||
}));
|
||||
}
|
||||
|
||||
auto tracksContainer = new Wt::WContainerWidget();
|
||||
t->bindWidget("tracks", tracksContainer);
|
||||
Wt::WContainerWidget* tracksContainer = t->bindNew<Wt::WContainerWidget>("tracks");
|
||||
|
||||
auto clusterIds = _filters->getClusterIds();
|
||||
auto tracks = release->getTracks(clusterIds);
|
||||
@@ -156,15 +145,13 @@ Release::refresh()
|
||||
{
|
||||
auto trackId = track.id();
|
||||
|
||||
Wt::WTemplate* entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Release.template.entry"), tracksContainer);
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(track->getName()), Wt::PlainText);
|
||||
Wt::WTemplate* entry = tracksContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Release.template.entry"));
|
||||
entry->bindString("name", Wt::WString::fromUTF8(track->getName()), Wt::TextFormat::Plain);
|
||||
|
||||
if (variousArtists && track->getArtist())
|
||||
{
|
||||
entry->setCondition("if-has-artist", true);
|
||||
Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(track->getArtist());
|
||||
entry->bindWidget("artist-name", artistAnchor);
|
||||
entry->bindWidget("artist-name", LmsApplication::createArtistAnchor(track->getArtist()));
|
||||
}
|
||||
|
||||
auto trackNumber = track->getTrackNumber();
|
||||
@@ -182,15 +169,13 @@ Release::refresh()
|
||||
entry->bindInt("disc-number", *discNumber);
|
||||
}
|
||||
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Release.play"), Wt::XHTMLText);
|
||||
entry->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Release.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
trackPlay.emit(trackId);
|
||||
}));
|
||||
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Release.add"), Wt::XHTMLText);
|
||||
entry->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = entry->bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Release.add"), Wt::TextFormat::XHTML);
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
trackAdd.emit(trackId);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
@@ -27,7 +27,7 @@ class Filters;
|
||||
class Release : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
Release(Filters* filters, Wt::WContainerWidget* parent = 0);
|
||||
Release(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> releaseAdd;
|
||||
Wt::Signal<Database::id_type> releasePlay;
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WApplication>
|
||||
#include <Wt/WAnchor>
|
||||
#include <Wt/WImage>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WApplication.h>
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WImage.h>
|
||||
#include <Wt/WText.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -38,25 +38,20 @@ namespace UserInterface {
|
||||
|
||||
using namespace Database;
|
||||
|
||||
Releases::Releases(Filters* filters, Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_filters(filters)
|
||||
Releases::Releases(Filters* filters)
|
||||
: Wt::WTemplate(Wt::WString::tr("Lms.Explore.Releases.template")),
|
||||
_filters(filters)
|
||||
{
|
||||
auto container = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Releases.template"), this);
|
||||
container->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
_search = new Wt::WLineEdit();
|
||||
container->bindWidget("search", _search);
|
||||
_search = bindNew<Wt::WLineEdit>("search");
|
||||
_search->setPlaceholderText(Wt::WString::tr("Lms.Explore.search-placeholder"));
|
||||
_search->textInput().connect(this, &Releases::refresh);
|
||||
|
||||
_releasesContainer = new Wt::WContainerWidget();
|
||||
container->bindWidget("releases", _releasesContainer);
|
||||
_releasesContainer = bindNew<Wt::WContainerWidget>("releases");
|
||||
|
||||
_showMore = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.show-more"));
|
||||
_showMore = bindNew<Wt::WTemplate>("show-more", Wt::WString::tr("Lms.Explore.show-more"));
|
||||
_showMore->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
container->bindWidget("show-more", _showMore);
|
||||
|
||||
_showMore->clicked().connect(std::bind([=]
|
||||
{
|
||||
addSome();
|
||||
@@ -81,29 +76,24 @@ Releases::addSome()
|
||||
|
||||
auto clusterIds = _filters->getClusterIds();
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
bool moreResults;
|
||||
auto releases = Release::getByFilter(DboSession(), clusterIds, searchKeywords, _releasesContainer->count(), 20, moreResults);
|
||||
auto releases = Release::getByFilter(LmsApp->getDboSession(), clusterIds, searchKeywords, _releasesContainer->count(), 20, moreResults);
|
||||
|
||||
for (auto release : releases)
|
||||
{
|
||||
auto releaseId = release.id();
|
||||
|
||||
Wt::WTemplate* entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Releases.template.entry"), _releasesContainer);
|
||||
Wt::WTemplate* entry = _releasesContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Releases.template.entry"));
|
||||
entry->addFunction("tr", Wt::WTemplate::Functions::tr);
|
||||
|
||||
Wt::WAnchor* coverAnchor = LmsApplication::createReleaseAnchor(release, false);
|
||||
Wt::WImage* cover = new Wt::WImage(coverAnchor);
|
||||
cover->setImageLink(LmsApp->getImageResource()->getReleaseUrl(releaseId, 128));
|
||||
// Some images may not be square
|
||||
cover->setWidth(128);
|
||||
entry->bindWidget("cover", coverAnchor);
|
||||
Wt::WAnchor* anchor = entry->bindWidget("cover", LmsApplication::createReleaseAnchor(release, false));
|
||||
auto cover = std::make_unique<Wt::WImage>();
|
||||
cover->setImageLink(LmsApp->getImageResource()->getReleaseUrl(release.id(), 128));
|
||||
anchor->setImage(std::move(cover));
|
||||
|
||||
{
|
||||
Wt::WAnchor* releaseAnchor = LmsApplication::createReleaseAnchor(release);
|
||||
entry->bindWidget("release-name", releaseAnchor);
|
||||
}
|
||||
entry->bindWidget("release-name", LmsApplication::createReleaseAnchor(release));
|
||||
|
||||
auto artists = release->getArtists();
|
||||
if (artists.size() > 1)
|
||||
@@ -114,19 +104,16 @@ Releases::addSome()
|
||||
else if (artists.size() == 1)
|
||||
{
|
||||
entry->setCondition("if-has-artist", true);
|
||||
Wt::WAnchor* artistAnchor = LmsApplication::createArtistAnchor(artists.front());
|
||||
entry->bindWidget("artist-name", artistAnchor);
|
||||
entry->bindWidget("artist-name", LmsApplication::createArtistAnchor(artists.front()));
|
||||
}
|
||||
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Releases.play"), Wt::XHTMLText);
|
||||
entry->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Releases.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
releasePlay.emit(releaseId);
|
||||
}));
|
||||
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Releases.add"), Wt::XHTMLText);
|
||||
entry->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = entry->bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Releases.add"), Wt::TextFormat::XHTML);
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
releaseAdd.emit(releaseId);
|
||||
|
||||
@@ -19,18 +19,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WText.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
|
||||
class Releases : public Wt::WContainerWidget
|
||||
class Releases : public Wt::WTemplate
|
||||
{
|
||||
public:
|
||||
Releases(Filters* filters, Wt::WContainerWidget* parent = 0);
|
||||
Releases(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> releaseAdd;
|
||||
Wt::Signal<Database::id_type> releasePlay;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Wt/WAnchor>
|
||||
#include <Wt/WImage>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WImage.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -37,41 +37,34 @@ namespace UserInterface {
|
||||
|
||||
using namespace Database;
|
||||
|
||||
Tracks::Tracks(Filters* filters, Wt::WContainerWidget* parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_filters(filters)
|
||||
Tracks::Tracks(Filters* filters)
|
||||
: Wt::WTemplate(Wt::WString::tr("Lms.Explore.Tracks.template")),
|
||||
_filters(filters)
|
||||
{
|
||||
auto container = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Tracks.template"), this);
|
||||
container->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
_search = new Wt::WLineEdit();
|
||||
container->bindWidget("search", _search);
|
||||
_search = bindNew<Wt::WLineEdit>("search");
|
||||
_search->setPlaceholderText(Wt::WString::tr("Lms.Explore.search-placeholder"));
|
||||
_search->textInput().connect(this, &Tracks::refresh);
|
||||
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Tracks.play"), Wt::XHTMLText);
|
||||
container->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Tracks.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
tracksPlay.emit(getTracks());
|
||||
}));
|
||||
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Tracks.add"), Wt::XHTMLText);
|
||||
container->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Tracks.add"), Wt::TextFormat::XHTML);
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
tracksAdd.emit(getTracks());
|
||||
}));
|
||||
|
||||
_tracksContainer = new Wt::WContainerWidget();
|
||||
container->bindWidget("tracks", _tracksContainer);
|
||||
_tracksContainer = bindNew<Wt::WContainerWidget>("tracks");
|
||||
|
||||
_showMore = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.template.show-more"));
|
||||
_showMore = bindNew<Wt::WTemplate>("show-more", Wt::WString::tr("Lms.Explore.template.show-more"));
|
||||
_showMore->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
container->bindWidget("show-more", _showMore);
|
||||
|
||||
_showMore->clicked().connect(std::bind([=]
|
||||
{
|
||||
addSome();
|
||||
@@ -88,9 +81,9 @@ Tracks::getTracks(int offset, int size, bool& moreResults)
|
||||
auto searchKeywords = splitString(_search->text().toUTF8(), " ");
|
||||
auto clusterIds = _filters->getClusterIds();
|
||||
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
return Track::getByFilter(DboSession(), clusterIds, searchKeywords, offset, size, moreResults);
|
||||
return Track::getByFilter(LmsApp->getDboSession(), clusterIds, searchKeywords, offset, size, moreResults);
|
||||
}
|
||||
|
||||
std::vector<Database::Track::pointer>
|
||||
@@ -110,7 +103,7 @@ Tracks::refresh()
|
||||
void
|
||||
Tracks::addSome()
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
bool moreResults;
|
||||
auto tracks = getTracks(_tracksContainer->count(), 20, moreResults);
|
||||
@@ -118,41 +111,35 @@ Tracks::addSome()
|
||||
for (auto track : tracks)
|
||||
{
|
||||
auto trackId = track.id();
|
||||
Wt::WTemplate* entry = new Wt::WTemplate(Wt::WString::tr("Lms.Explore.Tracks.template.entry"), _tracksContainer);
|
||||
Wt::WTemplate* entry = _tracksContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Tracks.template.entry"));
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(track->getName()), Wt::PlainText);
|
||||
entry->bindString("name", Wt::WString::fromUTF8(track->getName()), Wt::TextFormat::Plain);
|
||||
|
||||
auto artist = track->getArtist();
|
||||
if (artist)
|
||||
{
|
||||
entry->setCondition("if-has-artist", true);
|
||||
Wt::WAnchor *artistAnchor = LmsApplication::createArtistAnchor(track->getArtist());
|
||||
entry->bindWidget("artist-name", artistAnchor);
|
||||
entry->bindWidget("artist-name", LmsApplication::createArtistAnchor(track->getArtist()));
|
||||
}
|
||||
|
||||
auto release = track->getRelease();
|
||||
if (release)
|
||||
{
|
||||
entry->setCondition("if-has-release", true);
|
||||
Wt::WAnchor *releaseAnchor = LmsApplication::createReleaseAnchor(track->getRelease());
|
||||
entry->bindWidget("release-name", releaseAnchor);
|
||||
entry->bindWidget("release-name", LmsApplication::createReleaseAnchor(track->getRelease()));
|
||||
}
|
||||
|
||||
Wt::WImage *cover = new Wt::WImage();
|
||||
cover->setImageLink(LmsApp->getImageResource()->getTrackUrl(track.id(), 64));
|
||||
Wt::WImage* cover = entry->bindNew<Wt::WImage>("cover", LmsApp->getImageResource()->getTrackUrl(track.id(), 64));
|
||||
// Some images may not be square
|
||||
cover->setWidth(64);
|
||||
entry->bindWidget("cover", cover);
|
||||
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Tracks.play"), Wt::XHTMLText);
|
||||
entry->bindWidget("play-btn", playBtn);
|
||||
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.Tracks.play"), Wt::TextFormat::XHTML);
|
||||
playBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
trackPlay.emit(trackId);
|
||||
}));
|
||||
|
||||
auto addBtn = new Wt::WText(Wt::WString::tr("Lms.Explore.Tracks.add"), Wt::XHTMLText);
|
||||
entry->bindWidget("add-btn", addBtn);
|
||||
Wt::WText* addBtn = entry->bindNew<Wt::WText>("add-btn", Wt::WString::tr("Lms.Explore.Tracks.add"), Wt::TextFormat::XHTML);
|
||||
addBtn->clicked().connect(std::bind([=]
|
||||
{
|
||||
trackAdd.emit(trackId);
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
class Tracks : public Wt::WContainerWidget
|
||||
class Tracks : public Wt::WTemplate
|
||||
{
|
||||
public:
|
||||
Tracks(Filters* filters, Wt::WContainerWidget* parent = 0);
|
||||
Tracks(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> trackAdd;
|
||||
Wt::Signal<Database::id_type> trackPlay;
|
||||
|
||||
Reference in New Issue
Block a user