Switched to C++20

This commit is contained in:
emeric
2024-02-01 22:34:36 +01:00
parent 82be2e1a41
commit 6cfa4e9de6
26 changed files with 365 additions and 378 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ project(lms)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules/) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules/)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if (UNIX) if (UNIX)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
-3
View File
@@ -110,9 +110,6 @@ cmake_push_check_state()
set(CMAKE_REQUIRED_QUIET ${Filesystem_FIND_QUIETLY}) set(CMAKE_REQUIRED_QUIET ${Filesystem_FIND_QUIETLY})
# All of our tests required C++17 or later
set(CMAKE_CXX_STANDARD 17)
# Normalize and check the component list we were given # Normalize and check the component list we were given
set(want_components ${Filesystem_FIND_COMPONENTS}) set(want_components ${Filesystem_FIND_COMPONENTS})
if(Filesystem_FIND_COMPONENTS STREQUAL "") if(Filesystem_FIND_COMPONENTS STREQUAL "")
@@ -68,7 +68,7 @@ namespace Av::Transcoding
{ {
Wt::Http::ResponseContinuation* continuation{ response.createContinuation() }; Wt::Http::ResponseContinuation* continuation{ response.createContinuation() };
continuation->waitForMoreData(); continuation->waitForMoreData();
_transcoder.asyncRead(_buffer.data(), _buffer.size(), [=](std::size_t nbBytesRead) _transcoder.asyncRead(_buffer.data(), _buffer.size(), [this, continuation](std::size_t nbBytesRead)
{ {
LMS_LOG(TRANSCODING, DEBUG, "Have " << nbBytesRead << " more bytes to send back"); LMS_LOG(TRANSCODING, DEBUG, "Have " << nbBytesRead << " more bytes to send back");
@@ -131,9 +131,9 @@ namespace Feedback::ListenBrainz
request.message.addBodyText(Wt::Json::serialize(root)); request.message.addBodyText(Wt::Json::serialize(root));
request.message.addHeader("Content-Type", "application/json"); request.message.addHeader("Content-Type", "application/json");
request.onSuccessFunc = [=](std::string_view /*msgBody*/) request.onSuccessFunc = [this, type, starredTrackId](std::string_view /*msgBody*/)
{ {
_strand.dispatch([=] _strand.dispatch([this, type, starredTrackId]
{ {
onFeedbackSent(type, starredTrackId); onFeedbackSent(type, starredTrackId);
}); });
@@ -404,7 +404,7 @@ namespace Feedback::ListenBrainz
} }
}); });
}; };
request.onFailureFunc = [=, &context] request.onFailureFunc = [this, &context]
{ {
onSyncEnded(context); onSyncEnded(context);
}; };
@@ -139,7 +139,7 @@ namespace Scanner
void ScannerService::requestImmediateScan(bool force) void ScannerService::requestImmediateScan(bool force)
{ {
abortScan(); abortScan();
_ioService.post([=]() _ioService.post([this, force]
{ {
if (_abortScan) if (_abortScan)
return; return;
@@ -156,7 +156,7 @@ namespace Scanner
void ScannerService::requestReload() void ScannerService::requestReload()
{ {
abortScan(); abortScan();
_ioService.post([=]() _ioService.post([this]()
{ {
if (_abortScan) if (_abortScan)
return; return;
@@ -234,7 +234,7 @@ namespace Scanner
void ScannerService::scheduleScan(bool force, const Wt::WDateTime& dateTime) void ScannerService::scheduleScan(bool force, const Wt::WDateTime& dateTime)
{ {
auto cb{ [=](boost::system::error_code ec) auto cb{ [this, force](boost::system::error_code ec)
{ {
if (ec) if (ec)
return; return;
@@ -40,10 +40,10 @@
#include "Utils.hpp" #include "Utils.hpp"
namespace Scrobbling::ListenBrainz
{
namespace namespace
{ {
using namespace Scrobbling::ListenBrainz;
std::optional<Wt::Json::Object> listenToJsonPayload(Database::Session& session, const Scrobbling::Listen& listen, const Wt::WDateTime& timePoint) std::optional<Wt::Json::Object> listenToJsonPayload(Database::Session& session, const Scrobbling::Listen& listen, const Wt::WDateTime& timePoint)
{ {
auto transaction{ session.createReadTransaction() }; auto transaction{ session.createReadTransaction() };
@@ -207,8 +207,6 @@ namespace
} }
} }
namespace Scrobbling::ListenBrainz
{
ListensSynchronizer::ListensSynchronizer(boost::asio::io_context& ioContext, Database::Db& db, Http::IClient& client) ListensSynchronizer::ListensSynchronizer(boost::asio::io_context& ioContext, Database::Db& db, Http::IClient& client)
: _ioContext{ ioContext } : _ioContext{ ioContext }
, _db{ db } , _db{ db }
@@ -244,13 +242,13 @@ namespace Scrobbling::ListenBrainz
saveListen(timedListen, Database::SyncState::PendingAdd); saveListen(timedListen, Database::SyncState::PendingAdd);
request.priority = Http::ClientRequestParameters::Priority::Normal; request.priority = Http::ClientRequestParameters::Priority::Normal;
request.onSuccessFunc = [=](std::string_view) request.onSuccessFunc = [this, timedListen](std::string_view)
{ {
_strand.dispatch([=] _strand.dispatch([this, timedListen]
{ {
if (saveListen(timedListen, Database::SyncState::Synchronized)) if (saveListen(timedListen, Database::SyncState::Synchronized))
{ {
UserContext& context{ getUserContext(listen.userId) }; UserContext& context{ getUserContext(timedListen.userId) };
if (context.listenCount) if (context.listenCount)
(*context.listenCount)++; (*context.listenCount)++;
} }
@@ -484,11 +482,11 @@ namespace Scrobbling::ListenBrainz
Http::ClientGETRequestParameters request; Http::ClientGETRequestParameters request;
request.relativeUrl = "/1/user/" + std::string{ context.listenBrainzUserName } + "/listen-count"; request.relativeUrl = "/1/user/" + std::string{ context.listenBrainzUserName } + "/listen-count";
request.priority = Http::ClientRequestParameters::Priority::Low; request.priority = Http::ClientRequestParameters::Priority::Low;
request.onSuccessFunc = [=, &context](std::string_view msgBody) request.onSuccessFunc = [this, &context](std::string_view msgBody)
{ {
_strand.dispatch([=, &context] const auto listenCount{ parseListenCount(msgBody) };
_strand.dispatch([this, listenCount, &context]
{ {
const auto listenCount = parseListenCount(msgBody);
if (listenCount) if (listenCount)
LOG(DEBUG, "Listen count for listenbrainz user '" << context.listenBrainzUserName << "' = " << *listenCount); LOG(DEBUG, "Listen count for listenbrainz user '" << context.listenBrainzUserName << "' = " << *listenCount);
@@ -520,7 +518,7 @@ namespace Scrobbling::ListenBrainz
Http::ClientGETRequestParameters request; Http::ClientGETRequestParameters request;
request.relativeUrl = "/1/user/" + context.listenBrainzUserName + "/listens?max_ts=" + std::to_string(context.maxDateTime.toTime_t()); request.relativeUrl = "/1/user/" + context.listenBrainzUserName + "/listens?max_ts=" + std::to_string(context.maxDateTime.toTime_t());
request.priority = Http::ClientRequestParameters::Priority::Low; request.priority = Http::ClientRequestParameters::Priority::Low;
request.onSuccessFunc = [=, &context](std::string_view msgBody) request.onSuccessFunc = [this, &context](std::string_view msgBody)
{ {
processGetListensResponse(msgBody, context); processGetListensResponse(msgBody, context);
if (context.fetchedListenCount >= _maxSyncListenCount || !context.maxDateTime.isValid()) if (context.fetchedListenCount >= _maxSyncListenCount || !context.maxDateTime.isValid())
@@ -531,7 +529,7 @@ namespace Scrobbling::ListenBrainz
enqueGetListens(context); enqueGetListens(context);
}; };
request.onFailureFunc = [=, &context] request.onFailureFunc = [this, &context]
{ {
onSyncEnded(context); onSyncEnded(context);
}; };
+1 -1
View File
@@ -66,7 +66,7 @@ namespace Http
{ {
_client.done().connect([this](Wt::AsioWrapper::error_code ec, const Wt::Http::Message& msg) _client.done().connect([this](Wt::AsioWrapper::error_code ec, const Wt::Http::Message& msg)
{ {
_strand.dispatch([=, msg = std::move(msg)] _strand.dispatch([this, ec, msg = std::move(msg)]
{ {
onClientDone(ec, msg); onClientDone(ec, msg);
}); });
+1 -1
View File
@@ -171,7 +171,7 @@ Auth::Auth()
{ {
auto model {std::make_shared<AuthModel>()}; auto model {std::make_shared<AuthModel>()};
auto processAuth = [=]() auto processAuth = [this, model]
{ {
updateModel(model.get()); updateModel(model.get());
+3 -3
View File
@@ -448,12 +448,12 @@ namespace UserInterface
_playQueue = mainStack->addWidget(std::move(playQueue)); _playQueue = mainStack->addWidget(std::move(playQueue));
mainStack->addNew<SettingsView>(); mainStack->addNew<SettingsView>();
searchEdit->enterPressed().connect([=] searchEdit->enterPressed().connect([this]
{ {
setInternalPath("/search", true); setInternalPath("/search", true);
}); });
searchEdit->textInput().connect([=] searchEdit->textInput().connect([this, explore, searchEdit]
{ {
setInternalPath("/search", true); setInternalPath("/search", true);
explore->search(searchEdit->text()); explore->search(searchEdit->text());
@@ -518,7 +518,7 @@ namespace UserInterface
const bool isAdmin{ getUserType() == Database::UserType::ADMIN }; const bool isAdmin{ getUserType() == Database::UserType::ADMIN };
if (isAdmin) if (isAdmin)
{ {
_scannerEvents.scanComplete.connect([=](const Scanner::ScanStats& stats) _scannerEvents.scanComplete.connect([this](const Scanner::ScanStats& stats)
{ {
notifyMsg(Notification::Type::Info, notifyMsg(Notification::Type::Info,
Wt::WString::tr("Lms.Admin.Database.database"), Wt::WString::tr("Lms.Admin.Database.database"),
+1 -1
View File
@@ -25,7 +25,7 @@ namespace UserInterface
ModalManager::ModalManager() ModalManager::ModalManager()
: _closed{ this, "closed" } : _closed{ this, "closed" }
{ {
_closed.connect([=](const std::string& id) _closed.connect([this](const std::string& id)
{ {
LMS_LOG(UI, DEBUG, "Received closed for id '" << id << "'"); LMS_LOG(UI, DEBUG, "Received closed for id '" << id << "'");
for (int i{}; i < count(); ++i) for (int i{}; i < count(); ++i)
+1 -1
View File
@@ -80,7 +80,7 @@ namespace UserInterface
{ {
NotificationWidget* notification{ addNew<NotificationWidget>(type, category, message, duration) }; NotificationWidget* notification{ addNew<NotificationWidget>(type, category, message, duration) };
notification->closed.connect([=] notification->closed.connect([this, notification]
{ {
removeWidget(notification); removeWidget(notification);
}); });
+11 -11
View File
@@ -126,13 +126,13 @@ namespace UserInterface
addFunction("tr", &Wt::WTemplate::Functions::tr); addFunction("tr", &Wt::WTemplate::Functions::tr);
Wt::WPushButton* clearBtn{ bindNew<Wt::WPushButton>("clear-btn", Wt::WString::tr("Lms.PlayQueue.template.clear-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* clearBtn{ bindNew<Wt::WPushButton>("clear-btn", Wt::WString::tr("Lms.PlayQueue.template.clear-btn"), Wt::TextFormat::XHTML) };
clearBtn->clicked().connect([=] clearBtn->clicked().connect([this]
{ {
clearTracks(); clearTracks();
}); });
Wt::WPushButton* saveBtn{ bindNew<Wt::WPushButton>("save-btn", Wt::WString::tr("Lms.PlayQueue.template.save-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* saveBtn{ bindNew<Wt::WPushButton>("save-btn", Wt::WString::tr("Lms.PlayQueue.template.save-btn"), Wt::TextFormat::XHTML) };
saveBtn->clicked().connect([=] saveBtn->clicked().connect([this]
{ {
saveAsTrackList(); saveAsTrackList();
}); });
@@ -145,7 +145,7 @@ namespace UserInterface
}); });
Wt::WPushButton* shuffleBtn{ bindNew<Wt::WPushButton>("shuffle-btn", Wt::WString::tr("Lms.PlayQueue.template.shuffle-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* shuffleBtn{ bindNew<Wt::WPushButton>("shuffle-btn", Wt::WString::tr("Lms.PlayQueue.template.shuffle-btn"), Wt::TextFormat::XHTML) };
shuffleBtn->clicked().connect([=] shuffleBtn->clicked().connect([this]
{ {
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
@@ -163,7 +163,7 @@ namespace UserInterface
}); });
_repeatBtn = bindNew<Wt::WCheckBox>("repeat-btn"); _repeatBtn = bindNew<Wt::WCheckBox>("repeat-btn");
_repeatBtn->clicked().connect([=] _repeatBtn->clicked().connect([this]
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
@@ -177,7 +177,7 @@ namespace UserInterface
} }
_radioBtn = bindNew<Wt::WCheckBox>("radio-btn"); _radioBtn = bindNew<Wt::WCheckBox>("radio-btn");
_radioBtn->clicked().connect([=] _radioBtn->clicked().connect([this]
{ {
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
@@ -203,7 +203,7 @@ namespace UserInterface
_nbTracks = bindNew<Wt::WText>("track-count"); _nbTracks = bindNew<Wt::WText>("track-count");
_duration = bindNew<Wt::WText>("duration"); _duration = bindNew<Wt::WText>("duration");
LmsApp->getMediaPlayer().settingsLoaded.connect([=] LmsApp->getMediaPlayer().settingsLoaded.connect([this]
{ {
if (_mediaPlayerSettingsLoaded) if (_mediaPlayerSettingsLoaded)
return; return;
@@ -220,7 +220,7 @@ namespace UserInterface
loadTrack(trackPos, false); loadTrack(trackPos, false);
}); });
LmsApp->preQuit().connect([=] LmsApp->preQuit().connect([this]
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
@@ -537,7 +537,7 @@ namespace UserInterface
entry->bindString("duration", Utils::durationToString(track->getDuration()), Wt::TextFormat::Plain); entry->bindString("duration", Utils::durationToString(track->getDuration()), Wt::TextFormat::Plain);
Wt::WPushButton* playBtn{ entry->bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.template.play-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* playBtn{ entry->bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.template.play-btn"), Wt::TextFormat::XHTML) };
playBtn->clicked().connect([=] playBtn->clicked().connect([this, entry]
{ {
const std::optional<std::size_t> pos{ _entriesContainer->getIndexOf(*entry) }; const std::optional<std::size_t> pos{ _entriesContainer->getIndexOf(*entry) };
if (pos) if (pos)
@@ -546,7 +546,7 @@ namespace UserInterface
Wt::WPushButton* delBtn{ entry->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.template.delete-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* delBtn{ entry->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.template.delete-btn"), Wt::TextFormat::XHTML) };
delBtn->setToolTip(Wt::WString::tr("Lms.delete")); delBtn->setToolTip(Wt::WString::tr("Lms.delete"));
delBtn->clicked().connect([=] delBtn->clicked().connect([this, tracklistEntryId, entry]
{ {
// Remove the entry n both the widget tree and the playqueue // Remove the entry n both the widget tree and the playqueue
{ {
@@ -572,7 +572,7 @@ namespace UserInterface
entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.template.more-btn"), Wt::TextFormat::XHTML); entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.template.more-btn"), Wt::TextFormat::XHTML);
entry->bindNew<Wt::WPushButton>("play", Wt::WString::tr("Lms.Explore.play")) entry->bindNew<Wt::WPushButton>("play", Wt::WString::tr("Lms.Explore.play"))
->clicked().connect([=] ->clicked().connect([this, entry]
{ {
const std::optional<std::size_t> pos{ _entriesContainer->getIndexOf(*entry) }; const std::optional<std::size_t> pos{ _entriesContainer->getIndexOf(*entry) };
if (pos) if (pos)
@@ -734,7 +734,7 @@ namespace UserInterface
replaceTrackList->updateView(replaceTrackListModel.get()); replaceTrackList->updateView(replaceTrackListModel.get());
auto* saveBtn{ modal->bindNew<Wt::WPushButton>("save-btn", Wt::WString::tr("Lms.save")) }; auto* saveBtn{ modal->bindNew<Wt::WPushButton>("save-btn", Wt::WString::tr("Lms.save")) };
saveBtn->clicked().connect([=] saveBtn->clicked().connect([=, this]
{ {
bool success{}; bool success{};
switch (contentStack->currentIndex()) switch (contentStack->currentIndex())
+1 -1
View File
@@ -131,7 +131,7 @@ InitWizardView::InitWizardView()
Wt::WPushButton* saveButton = bindNew<Wt::WPushButton>("create-btn", Wt::WString::tr("Lms.create")); Wt::WPushButton* saveButton = bindNew<Wt::WPushButton>("create-btn", Wt::WString::tr("Lms.create"));
saveButton->clicked().connect([=] saveButton->clicked().connect([=, this]
{ {
updateModel(model.get()); updateModel(model.get());
+7 -7
View File
@@ -44,7 +44,7 @@ namespace UserInterface
auto mediaLibraryModal{ std::make_unique<MediaLibraryModal>(Database::MediaLibraryId{}) }; auto mediaLibraryModal{ std::make_unique<MediaLibraryModal>(Database::MediaLibraryId{}) };
MediaLibraryModal* mediaLibraryModalPtr{ mediaLibraryModal.get() }; MediaLibraryModal* mediaLibraryModalPtr{ mediaLibraryModal.get() };
mediaLibraryModalPtr->saved().connect(this, [=](Database::MediaLibraryId newMediaLibraryId) mediaLibraryModalPtr->saved().connect(this, [this, mediaLibraryModalPtr](Database::MediaLibraryId newMediaLibraryId)
{ {
Wt::WTemplate* entry{ addEntry() }; Wt::WTemplate* entry{ addEntry() };
updateEntry(newMediaLibraryId, entry); updateEntry(newMediaLibraryId, entry);
@@ -53,7 +53,7 @@ namespace UserInterface
LmsApp->getModalManager().dispose(mediaLibraryModalPtr); LmsApp->getModalManager().dispose(mediaLibraryModalPtr);
}); });
mediaLibraryModalPtr->cancelled().connect(this, [=] mediaLibraryModalPtr->cancelled().connect(this, [mediaLibraryModalPtr]
{ {
LmsApp->getModalManager().dispose(mediaLibraryModalPtr); LmsApp->getModalManager().dispose(mediaLibraryModalPtr);
}); });
@@ -95,7 +95,7 @@ namespace UserInterface
Wt::WWidget* modalPtr{ modal.get() }; Wt::WWidget* modalPtr{ modal.get() };
auto* delBtn{ modal->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.delete")) }; auto* delBtn{ modal->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.delete")) };
delBtn->clicked().connect([=] delBtn->clicked().connect([=, this]
{ {
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
@@ -138,12 +138,12 @@ namespace UserInterface
Wt::WPushButton* editBtn{ entry->bindNew<Wt::WPushButton>("edit-btn", Wt::WString::tr("Lms.template.edit-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* editBtn{ entry->bindNew<Wt::WPushButton>("edit-btn", Wt::WString::tr("Lms.template.edit-btn"), Wt::TextFormat::XHTML) };
editBtn->setToolTip(Wt::WString::tr("Lms.edit")); editBtn->setToolTip(Wt::WString::tr("Lms.edit"));
editBtn->clicked().connect([=] editBtn->clicked().connect([this, mediaLibraryId, entry]
{ {
auto mediaLibraryModal{ std::make_unique<MediaLibraryModal>(mediaLibraryId) }; auto mediaLibraryModal{ std::make_unique<MediaLibraryModal>(mediaLibraryId) };
MediaLibraryModal* mediaLibraryModalPtr{ mediaLibraryModal.get() }; MediaLibraryModal* mediaLibraryModalPtr{ mediaLibraryModal.get() };
mediaLibraryModalPtr->saved().connect(this, [=](Database::MediaLibraryId newMediaLibraryId) mediaLibraryModalPtr->saved().connect(this, [=, this](Database::MediaLibraryId newMediaLibraryId)
{ {
updateEntry(newMediaLibraryId, entry); updateEntry(newMediaLibraryId, entry);
@@ -154,7 +154,7 @@ namespace UserInterface
LmsApp->getModalManager().dispose(mediaLibraryModalPtr); LmsApp->getModalManager().dispose(mediaLibraryModalPtr);
}); });
mediaLibraryModalPtr->cancelled().connect(this, [=] mediaLibraryModalPtr->cancelled().connect(this, [mediaLibraryModalPtr]
{ {
LmsApp->getModalManager().dispose(mediaLibraryModalPtr); LmsApp->getModalManager().dispose(mediaLibraryModalPtr);
}); });
@@ -164,7 +164,7 @@ namespace UserInterface
Wt::WPushButton* delBtn{ entry->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.template.trash-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* delBtn{ entry->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.template.trash-btn"), Wt::TextFormat::XHTML) };
delBtn->setToolTip(Wt::WString::tr("Lms.delete")); delBtn->setToolTip(Wt::WString::tr("Lms.delete"));
delBtn->clicked().connect([=] delBtn->clicked().connect([this, mediaLibraryId, entry]
{ {
showDeleteLibraryModal(mediaLibraryId, entry); showDeleteLibraryModal(mediaLibraryId, entry);
}); });
+2 -2
View File
@@ -189,7 +189,7 @@ namespace UserInterface
setFormWidget(MediaLibraryModel::DirectoryField, std::make_unique<Wt::WLineEdit>()); setFormWidget(MediaLibraryModel::DirectoryField, std::make_unique<Wt::WLineEdit>());
Wt::WPushButton* saveBtn{ bindNew<Wt::WPushButton>("save-btn", Wt::WString::tr(mediaLibraryId.isValid() ? "Lms.save" : "Lms.create")) }; Wt::WPushButton* saveBtn{ bindNew<Wt::WPushButton>("save-btn", Wt::WString::tr(mediaLibraryId.isValid() ? "Lms.save" : "Lms.create")) };
saveBtn->clicked().connect(this, [=] saveBtn->clicked().connect(this, [this, mediaLibraryId, model]
{ {
updateModel(model.get()); updateModel(model.get());
@@ -205,7 +205,7 @@ namespace UserInterface
}); });
Wt::WPushButton* cancelBtn{ bindNew<Wt::WPushButton>("cancel-btn", Wt::WString::tr("Lms.cancel")) }; Wt::WPushButton* cancelBtn{ bindNew<Wt::WPushButton>("cancel-btn", Wt::WString::tr("Lms.cancel")) };
cancelBtn->clicked().connect(this, [=] {cancelled().emit();}); cancelBtn->clicked().connect(this, [this] { cancelled().emit(); });
updateView(model.get()); updateView(model.get());
} }
+2 -2
View File
@@ -101,14 +101,14 @@ namespace UserInterface
Wt::WPushButton* delBtn = entry->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.template.trash-btn"), Wt::TextFormat::XHTML); Wt::WPushButton* delBtn = entry->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.template.trash-btn"), Wt::TextFormat::XHTML);
delBtn->setToolTip(Wt::WString::tr("Lms.delete")); delBtn->setToolTip(Wt::WString::tr("Lms.delete"));
delBtn->clicked().connect([=] delBtn->clicked().connect([this, userId, entry]
{ {
auto modal{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Admin.Users.template.delete-user")) }; auto modal{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Admin.Users.template.delete-user")) };
modal->addFunction("tr", &Wt::WTemplate::Functions::tr); modal->addFunction("tr", &Wt::WTemplate::Functions::tr);
Wt::WWidget* modalPtr{ modal.get() }; Wt::WWidget* modalPtr{ modal.get() };
auto* delBtn{ modal->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.delete")) }; auto* delBtn{ modal->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.delete")) };
delBtn->clicked().connect([=] delBtn->clicked().connect([=, this]
{ {
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
+7 -7
View File
@@ -139,7 +139,7 @@ namespace UserInterface
{ {
const Database::ClusterId clusterId = cluster->getId(); const Database::ClusterId clusterId = cluster->getId();
Wt::WInteractWidget* entry{ clusterContainers->addWidget(Utils::createCluster(clusterId)) }; Wt::WInteractWidget* entry{ clusterContainers->addWidget(Utils::createCluster(clusterId)) };
entry->clicked().connect([=] entry->clicked().connect([this, clusterId]
{ {
_filters.add(clusterId); _filters.add(clusterId);
}); });
@@ -150,23 +150,23 @@ namespace UserInterface
bindString("name", Wt::WString::fromUTF8(artist->getName()), Wt::TextFormat::Plain); bindString("name", Wt::WString::fromUTF8(artist->getName()), Wt::TextFormat::Plain);
bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML) bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::Play, { _artistId }); _playQueueController.processCommand(PlayQueueController::Command::Play, { _artistId });
}); });
bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, { _artistId }); _playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, { _artistId });
}); });
bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayNext, { _artistId }); _playQueueController.processCommand(PlayQueueController::Command::PlayNext, { _artistId });
}); });
bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _artistId }); _playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _artistId });
}); });
@@ -174,10 +174,10 @@ namespace UserInterface
->setLink(Wt::WLink{ std::make_unique<DownloadArtistResource>(_artistId) }); ->setLink(Wt::WLink{ std::make_unique<DownloadArtistResource>(_artistId) });
{ {
auto isStarred{ [=] { return Service<Feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), _artistId); } }; auto isStarred{ [this] { return Service<Feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), _artistId); } };
Wt::WPushButton* starBtn{ bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) }; Wt::WPushButton* starBtn{ bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
starBtn->clicked().connect([=] starBtn->clicked().connect([=, this]
{ {
if (isStarred()) if (isStarred())
{ {
+1 -1
View File
@@ -44,7 +44,7 @@ Artists::Artists(Filters& filters)
auto bindMenuItem {[this](const std::string& var, const Wt::WString& title, ArtistCollector::Mode mode) auto bindMenuItem {[this](const std::string& var, const Wt::WString& title, ArtistCollector::Mode mode)
{ {
auto *menuItem {bindNew<Wt::WPushButton>(var, title)}; auto *menuItem {bindNew<Wt::WPushButton>(var, title)};
menuItem->clicked().connect([=] menuItem->clicked().connect([=, this]
{ {
refreshView(mode); refreshView(mode);
_currentActiveItem->removeStyleClass("active"); _currentActiveItem->removeStyleClass("active");
+7 -14
View File
@@ -31,12 +31,11 @@
#include "Utils.hpp" #include "Utils.hpp"
#include "ModalManager.hpp" #include "ModalManager.hpp"
namespace UserInterface { namespace UserInterface
{
using namespace Database; using namespace Database;
void void Filters::showDialog()
Filters::showDialog()
{ {
auto dialog{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.template.add-filter")) }; auto dialog{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.template.add-filter")) };
Wt::WWidget* dialogPtr{ dialog.get() }; Wt::WWidget* dialogPtr{ dialog.get() };
@@ -47,7 +46,7 @@ Filters::showDialog()
Wt::WComboBox* valueCombo{ dialog->bindNew<Wt::WComboBox>("value") }; Wt::WComboBox* valueCombo{ dialog->bindNew<Wt::WComboBox>("value") };
Wt::WPushButton* addBtn{ dialog->bindNew<Wt::WPushButton>("add-btn", Wt::WString::tr("Lms.Explore.add-filter")) }; Wt::WPushButton* addBtn{ dialog->bindNew<Wt::WPushButton>("add-btn", Wt::WString::tr("Lms.Explore.add-filter")) };
addBtn->clicked().connect([=] addBtn->clicked().connect([this, typeCombo, valueCombo, dialogPtr]
{ {
const std::string type{ typeCombo->valueText().toUTF8() }; const std::string type{ typeCombo->valueText().toUTF8() };
const std::string value{ valueCombo->valueText().toUTF8() }; const std::string value{ valueCombo->valueText().toUTF8() };
@@ -79,7 +78,6 @@ Filters::showDialog()
LmsApp->getModalManager().dispose(dialogPtr); LmsApp->getModalManager().dispose(dialogPtr);
}); });
// Populate data // Populate data
{ {
auto transaction{ LmsApp->getDbSession().createReadTransaction() }; auto transaction{ LmsApp->getDbSession().createReadTransaction() };
@@ -103,7 +101,7 @@ Filters::showDialog()
} }
} }
typeCombo->changed().connect([=] typeCombo->changed().connect([this, typeCombo, valueCombo]
{ {
const std::string name{ typeCombo->valueText().toUTF8() }; const std::string name{ typeCombo->valueText().toUTF8() };
@@ -122,8 +120,7 @@ Filters::showDialog()
LmsApp->getModalManager().show(std::move(dialog)); LmsApp->getModalManager().show(std::move(dialog));
} }
void void Filters::add(ClusterId clusterId)
Filters::add(ClusterId clusterId)
{ {
if (std::find(std::cbegin(_clusterIds), std::cend(_clusterIds), clusterId) != std::cend(_clusterIds)) if (std::find(std::cbegin(_clusterIds), std::cend(_clusterIds), clusterId) != std::cend(_clusterIds))
return; return;
@@ -140,7 +137,7 @@ Filters::add(ClusterId clusterId)
_clusterIds.push_back(clusterId); _clusterIds.push_back(clusterId);
filter->clicked().connect([=] filter->clicked().connect([this, filter, clusterId]
{ {
_filters->removeWidget(filter); _filters->removeWidget(filter);
_clusterIds.erase(std::remove_if(std::begin(_clusterIds), std::end(_clusterIds), [clusterId](ClusterId id) { return id == clusterId; }), std::end(_clusterIds)); _clusterIds.erase(std::remove_if(std::begin(_clusterIds), std::end(_clusterIds), [clusterId](ClusterId id) { return id == clusterId; }), std::end(_clusterIds));
@@ -165,8 +162,4 @@ Filters::Filters()
_filters = bindNew<Wt::WContainerWidget>("clusters"); _filters = bindNew<Wt::WContainerWidget>("clusters");
} }
} // namespace UserInterface } // namespace UserInterface
+2 -1
View File
@@ -35,8 +35,9 @@ namespace UserInterface
public: public:
Filters(); Filters();
void add(Database::ClusterId clusterId);
const std::vector<Database::ClusterId>& getClusterIds() const { return _clusterIds; } const std::vector<Database::ClusterId>& getClusterIds() const { return _clusterIds; }
void add(Database::ClusterId clusterId);
Wt::Signal<>& updated() { return _sigUpdated; } Wt::Signal<>& updated() { return _sigUpdated; }
private: private:
+14 -16
View File
@@ -271,7 +271,7 @@ namespace UserInterface
{ {
const ClusterId clusterId{ cluster->getId() }; const ClusterId clusterId{ cluster->getId() };
Wt::WInteractWidget* entry{ clusterContainers->addWidget(Utils::createCluster(clusterId)) }; Wt::WInteractWidget* entry{ clusterContainers->addWidget(Utils::createCluster(clusterId)) };
entry->clicked().connect([=] entry->clicked().connect([this, clusterId]
{ {
_filters.add(clusterId); _filters.add(clusterId);
}); });
@@ -280,25 +280,25 @@ namespace UserInterface
} }
bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML) bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::Play, { _releaseId }); _playQueueController.processCommand(PlayQueueController::Command::Play, { _releaseId });
}); });
bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, { _releaseId }); _playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, { _releaseId });
}); });
bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayNext, { _releaseId }); _playQueueController.processCommand(PlayQueueController::Command::PlayNext, { _releaseId });
}); });
bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _releaseId }); _playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _releaseId });
}); });
@@ -307,16 +307,16 @@ namespace UserInterface
->setLink(Wt::WLink{ std::make_unique<DownloadReleaseResource>(_releaseId) }); ->setLink(Wt::WLink{ std::make_unique<DownloadReleaseResource>(_releaseId) });
bindNew<Wt::WPushButton>("release-info", Wt::WString::tr("Lms.Explore.release-info")) bindNew<Wt::WPushButton>("release-info", Wt::WString::tr("Lms.Explore.release-info"))
->clicked().connect([=] ->clicked().connect([this]
{ {
showReleaseInfoModal(_releaseId); showReleaseInfoModal(_releaseId);
}); });
{ {
auto isStarred{ [=] { return Service<Feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), _releaseId); } }; auto isStarred{ [this] { return Service<Feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), _releaseId); } };
Wt::WPushButton* starBtn{ bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) }; Wt::WPushButton* starBtn{ bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
starBtn->clicked().connect([=] starBtn->clicked().connect([=, this]
{ {
if (isStarred()) if (isStarred())
{ {
@@ -410,7 +410,7 @@ namespace UserInterface
} }
Wt::WPushButton* playBtn{ entry->bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.template.play-btn"), Wt::TextFormat::XHTML) }; Wt::WPushButton* playBtn{ entry->bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.template.play-btn"), Wt::TextFormat::XHTML) };
playBtn->clicked().connect([=] playBtn->clicked().connect([this, trackId]
{ {
_playQueueController.playTrackInRelease(trackId); _playQueueController.playTrackInRelease(trackId);
}); });
@@ -418,17 +418,17 @@ namespace UserInterface
{ {
entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.template.more-btn"), Wt::TextFormat::XHTML); entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.template.more-btn"), Wt::TextFormat::XHTML);
entry->bindNew<Wt::WPushButton>("play", Wt::WString::tr("Lms.Explore.play")) entry->bindNew<Wt::WPushButton>("play", Wt::WString::tr("Lms.Explore.play"))
->clicked().connect([=] ->clicked().connect([this, trackId]
{ {
_playQueueController.playTrackInRelease(trackId); _playQueueController.playTrackInRelease(trackId);
}); });
entry->bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next")) entry->bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"))
->clicked().connect([=] ->clicked().connect([this, trackId]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayNext, { trackId }); _playQueueController.processCommand(PlayQueueController::Command::PlayNext, { trackId });
}); });
entry->bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last")) entry->bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"))
->clicked().connect([=] ->clicked().connect([this, trackId]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { trackId }); _playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { trackId });
}); });
@@ -436,10 +436,8 @@ namespace UserInterface
auto isStarred{ [=] { return Service<Feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), trackId); } }; auto isStarred{ [=] { return Service<Feedback::IFeedbackService>::get()->isStarred(LmsApp->getUserId(), trackId); } };
Wt::WPushButton* starBtn{ entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) }; Wt::WPushButton* starBtn{ entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star")) };
starBtn->clicked().connect([=] starBtn->clicked().connect([=, this]
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
if (isStarred()) if (isStarred())
{ {
Service<Feedback::IFeedbackService>::get()->unstar(LmsApp->getUserId(), trackId); Service<Feedback::IFeedbackService>::get()->unstar(LmsApp->getUserId(), trackId);
@@ -456,7 +454,7 @@ namespace UserInterface
->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) }); ->setLink(Wt::WLink{ std::make_unique<DownloadTrackResource>(trackId) });
entry->bindNew<Wt::WPushButton>("track-info", Wt::WString::tr("Lms.Explore.track-info")) entry->bindNew<Wt::WPushButton>("track-info", Wt::WString::tr("Lms.Explore.track-info"))
->clicked().connect([=] { TrackListHelpers::showTrackInfoModal(trackId, _filters); }); ->clicked().connect([this, trackId] { TrackListHelpers::showTrackInfoModal(trackId, _filters); });
} }
entry->bindString("duration", Utils::durationToString(track->getDuration()), Wt::TextFormat::Plain); entry->bindString("duration", Utils::durationToString(track->getDuration()), Wt::TextFormat::Plain);
+4 -4
View File
@@ -47,7 +47,7 @@ namespace UserInterface
auto bindMenuItem{ [this](const std::string& var, const Wt::WString& title, ReleaseCollector::Mode mode) auto bindMenuItem{ [this](const std::string& var, const Wt::WString& title, ReleaseCollector::Mode mode)
{ {
auto* menuItem {bindNew<Wt::WPushButton>(var, title)}; auto* menuItem {bindNew<Wt::WPushButton>(var, title)};
menuItem->clicked().connect([=] menuItem->clicked().connect([this, mode, menuItem]
{ {
refreshView(mode); refreshView(mode);
_currentActiveItem->removeStyleClass("active"); _currentActiveItem->removeStyleClass("active");
@@ -76,17 +76,17 @@ namespace UserInterface
}); });
bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, getAllReleases()); _playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, getAllReleases());
}); });
bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayNext, getAllReleases()); _playQueueController.processCommand(PlayQueueController::Command::PlayNext, getAllReleases());
}); });
bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, getAllReleases()); _playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, getAllReleases());
}); });
+2 -2
View File
@@ -77,7 +77,7 @@ namespace UserInterface
auto bindMenuItem{ [this](std::size_t index, const std::string& var, const Wt::WString& title) auto bindMenuItem{ [this](std::size_t index, const std::string& var, const Wt::WString& title)
{ {
Wt::WPushButton* menuItem {bindNew<Wt::WPushButton>(var, title)}; Wt::WPushButton* menuItem {bindNew<Wt::WPushButton>(var, title)};
menuItem->clicked().connect([=] menuItem->clicked().connect([this, menuItem, index]
{ {
_stack->setCurrentIndex(index); _stack->setCurrentIndex(index);
_currentActiveItem->removeStyleClass("active"); _currentActiveItem->removeStyleClass("active");
@@ -96,7 +96,7 @@ namespace UserInterface
bindMenuItem(1, "artists", Wt::WString::tr("Lms.Explore.artists")); bindMenuItem(1, "artists", Wt::WString::tr("Lms.Explore.artists"));
bindMenuItem(2, "tracks", Wt::WString::tr("Lms.Explore.tracks")); bindMenuItem(2, "tracks", Wt::WString::tr("Lms.Explore.tracks"));
filters.updated().connect([=] filters.updated().connect([this]
{ {
refreshView(); refreshView();
}); });
+6 -6
View File
@@ -108,7 +108,7 @@ namespace UserInterface
{ {
const ClusterId clusterId{ cluster->getId() }; const ClusterId clusterId{ cluster->getId() };
Wt::WInteractWidget* entry{ clusterContainers->addWidget(Utils::createCluster(clusterId)) }; Wt::WInteractWidget* entry{ clusterContainers->addWidget(Utils::createCluster(clusterId)) };
entry->clicked().connect([=] entry->clicked().connect([this, clusterId]
{ {
_filters.add(clusterId); _filters.add(clusterId);
}); });
@@ -117,19 +117,19 @@ namespace UserInterface
} }
bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML) bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML)
->clicked().connect([=] ->clicked().connect([this, trackListId]
{ {
_playQueueController.processCommand(PlayQueueController::Command::Play, *trackListId); _playQueueController.processCommand(PlayQueueController::Command::Play, *trackListId);
}); });
bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this, trackListId]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, *trackListId); _playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, *trackListId);
}); });
bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this, trackListId]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, *trackListId); _playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, *trackListId);
}); });
@@ -138,14 +138,14 @@ namespace UserInterface
->setLink(Wt::WLink{ std::make_unique<DownloadTrackListResource>(*trackListId) }); ->setLink(Wt::WLink{ std::make_unique<DownloadTrackListResource>(*trackListId) });
bindNew<Wt::WPushButton>("delete", Wt::WString::tr("Lms.delete")) bindNew<Wt::WPushButton>("delete", Wt::WString::tr("Lms.delete"))
->clicked().connect([=] ->clicked().connect([this, trackListId]
{ {
auto modal{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.TrackList.template.delete-tracklist")) }; auto modal{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.TrackList.template.delete-tracklist")) };
modal->addFunction("tr", &Wt::WTemplate::Functions::tr); modal->addFunction("tr", &Wt::WTemplate::Functions::tr);
Wt::WWidget* modalPtr{ modal.get() }; Wt::WWidget* modalPtr{ modal.get() };
auto* delBtn{ modal->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.delete")) }; auto* delBtn{ modal->bindNew<Wt::WPushButton>("del-btn", Wt::WString::tr("Lms.delete")) };
delBtn->clicked().connect([=] delBtn->clicked().connect([this, trackListId, modalPtr]
{ {
{ {
auto transaction{ LmsApp->getDbSession().createWriteTransaction() }; auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
+1 -1
View File
@@ -44,7 +44,7 @@ namespace UserInterface
auto bindMenuItem {[this](const std::string& var, const Wt::WString& title, Mode mode) auto bindMenuItem {[this](const std::string& var, const Wt::WString& title, Mode mode)
{ {
auto *menuItem {bindNew<Wt::WPushButton>(var, title)}; auto *menuItem {bindNew<Wt::WPushButton>(var, title)};
menuItem->clicked().connect([=] menuItem->clicked().connect([this, mode, menuItem]
{ {
_mode = mode; _mode = mode;
refreshView(); refreshView();
+5 -5
View File
@@ -47,7 +47,7 @@ namespace UserInterface
auto bindMenuItem{ [this](const std::string& var, const Wt::WString& title, TrackCollector::Mode mode) auto bindMenuItem{ [this](const std::string& var, const Wt::WString& title, TrackCollector::Mode mode)
{ {
auto* menuItem {bindNew<Wt::WPushButton>(var, title)}; auto* menuItem {bindNew<Wt::WPushButton>(var, title)};
menuItem->clicked().connect([=] menuItem->clicked().connect([this, mode, menuItem]
{ {
refreshView(mode); refreshView(mode);
_currentActiveItem->removeStyleClass("active"); _currentActiveItem->removeStyleClass("active");
@@ -70,23 +70,23 @@ namespace UserInterface
bindMenuItem("all", Wt::WString::tr("Lms.Explore.all"), TrackCollector::Mode::All); bindMenuItem("all", Wt::WString::tr("Lms.Explore.all"), TrackCollector::Mode::All);
bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML) bindNew<Wt::WPushButton>("play-btn", Wt::WString::tr("Lms.Explore.play"), Wt::TextFormat::XHTML)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::Play, getAllTracks()); _playQueueController.processCommand(PlayQueueController::Command::Play, getAllTracks());
}); });
bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-shuffled", Wt::WString::tr("Lms.Explore.play-shuffled"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, getAllTracks()); _playQueueController.processCommand(PlayQueueController::Command::PlayShuffled, getAllTracks());
}); });
bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-next", Wt::WString::tr("Lms.Explore.play-next"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayNext, getAllTracks()); _playQueueController.processCommand(PlayQueueController::Command::PlayNext, getAllTracks());
}); });
bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain) bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"), Wt::TextFormat::Plain)
->clicked().connect([=] ->clicked().connect([this]
{ {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, getAllTracks()); _playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, getAllTracks());
}); });