Switched to C++20
This commit is contained in:
+1
-1
@@ -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")
|
||||||
|
|||||||
@@ -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,175 +40,173 @@
|
|||||||
|
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using namespace Scrobbling::ListenBrainz;
|
|
||||||
|
|
||||||
std::optional<Wt::Json::Object> listenToJsonPayload(Database::Session& session, const Scrobbling::Listen& listen, const Wt::WDateTime& timePoint)
|
|
||||||
{
|
|
||||||
auto transaction{ session.createReadTransaction() };
|
|
||||||
|
|
||||||
const Database::Track::pointer track{ Database::Track::find(session, listen.trackId) };
|
|
||||||
if (!track)
|
|
||||||
return std::nullopt;
|
|
||||||
|
|
||||||
auto artists{ track->getArtists({Database::TrackArtistLinkType::Artist}) };
|
|
||||||
if (artists.empty())
|
|
||||||
artists = track->getArtists({ Database::TrackArtistLinkType::ReleaseArtist });
|
|
||||||
|
|
||||||
if (artists.empty())
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Track cannot be scrobbled since it does not have any artist");
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
Wt::Json::Object additionalInfo;
|
|
||||||
additionalInfo["listening_from"] = "LMS";
|
|
||||||
additionalInfo["duration_ms"] = std::chrono::duration_cast<std::chrono::milliseconds>(track->getDuration()).count();
|
|
||||||
if (track->getRelease())
|
|
||||||
{
|
|
||||||
if (auto MBID{ track->getRelease()->getMBID() })
|
|
||||||
additionalInfo["release_mbid"] = Wt::Json::Value{ std::string {MBID->getAsString()} };
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
Wt::Json::Array artistMBIDs;
|
|
||||||
for (const Database::Artist::pointer& artist : artists)
|
|
||||||
{
|
|
||||||
if (auto MBID{ artist->getMBID() })
|
|
||||||
artistMBIDs.push_back(Wt::Json::Value{ std::string {MBID->getAsString()} });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!artistMBIDs.empty())
|
|
||||||
additionalInfo["artist_mbids"] = std::move(artistMBIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto MBID{ track->getTrackMBID() })
|
|
||||||
additionalInfo["track_mbid"] = Wt::Json::Value{ std::string {MBID->getAsString()} };
|
|
||||||
|
|
||||||
if (auto MBID{ track->getRecordingMBID() })
|
|
||||||
additionalInfo["recording_mbid"] = Wt::Json::Value{ std::string {MBID->getAsString()} };
|
|
||||||
|
|
||||||
if (const std::optional<std::size_t> trackNumber{ track->getTrackNumber() })
|
|
||||||
additionalInfo["tracknumber"] = Wt::Json::Value{ static_cast<long long int>(*trackNumber) };
|
|
||||||
|
|
||||||
Wt::Json::Object trackMetadata;
|
|
||||||
trackMetadata["additional_info"] = std::move(additionalInfo);
|
|
||||||
trackMetadata["artist_name"] = Wt::Json::Value{ artists.front()->getName() };
|
|
||||||
trackMetadata["track_name"] = Wt::Json::Value{ track->getName() };
|
|
||||||
if (track->getRelease())
|
|
||||||
trackMetadata["release_name"] = Wt::Json::Value{ track->getRelease()->getName() };
|
|
||||||
|
|
||||||
Wt::Json::Object payload;
|
|
||||||
payload["track_metadata"] = std::move(trackMetadata);
|
|
||||||
if (timePoint.isValid())
|
|
||||||
payload["listened_at"] = Wt::Json::Value{ static_cast<long long int>(timePoint.toTime_t()) };
|
|
||||||
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string listenToJsonString(Database::Session& session, const Scrobbling::Listen& listen, const Wt::WDateTime& timePoint, std::string_view listenType)
|
|
||||||
{
|
|
||||||
std::string res;
|
|
||||||
|
|
||||||
std::optional<Wt::Json::Object> payload{ listenToJsonPayload(session, listen, timePoint) };
|
|
||||||
if (!payload)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
Wt::Json::Object root;
|
|
||||||
root["listen_type"] = Wt::Json::Value{ std::string {listenType} };
|
|
||||||
root["payload"] = Wt::Json::Array{ std::move(*payload) };
|
|
||||||
|
|
||||||
res = Wt::Json::serialize(root);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::size_t> parseListenCount(std::string_view msgBody)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Wt::Json::Object root;
|
|
||||||
Wt::Json::parse(std::string{ msgBody }, root);
|
|
||||||
|
|
||||||
const Wt::Json::Object& payload{ static_cast<const Wt::Json::Object&>(root.get("payload")) };
|
|
||||||
return static_cast<int>(payload.get("count"));
|
|
||||||
}
|
|
||||||
catch (const Wt::WException& e)
|
|
||||||
{
|
|
||||||
LOG(ERROR, "Cannot parse listen count response: " << e.what());
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Database::TrackId tryGetMatchingTrack(Database::Session& session, const Listen& listen)
|
|
||||||
{
|
|
||||||
using namespace Database;
|
|
||||||
|
|
||||||
auto transaction{ session.createReadTransaction() };
|
|
||||||
|
|
||||||
// first try to match using track MBID, and then fallback on possibly ambiguous info
|
|
||||||
if (listen.trackMBID)
|
|
||||||
{
|
|
||||||
const auto tracks{ Track::findByMBID(session, *listen.trackMBID) };
|
|
||||||
// if duplicated files, do not record it (let the user correct its database)
|
|
||||||
if (tracks.size() == 1)
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Matched listen '" << listen << "' using track MBID");
|
|
||||||
return tracks.front()->getId();
|
|
||||||
}
|
|
||||||
else if (tracks.size() > 1)
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Too many matches for listen '" << listen << "' using track MBID!");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen.recordingMBID)
|
|
||||||
{
|
|
||||||
const auto tracks{ Track::findByRecordingMBID(session, *listen.recordingMBID) };
|
|
||||||
// if duplicated files, do not record it (let the user correct its database)
|
|
||||||
if (tracks.size() == 1)
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Matched listen '" << listen << "' using recording MBID");
|
|
||||||
return tracks.front()->getId();
|
|
||||||
}
|
|
||||||
else if (tracks.size() > 1)
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Too many matches for listen '" << listen << "' using recording MBID!");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(!listen.trackName.empty() && !listen.artistName.empty());
|
|
||||||
|
|
||||||
// TODO check release MBID?
|
|
||||||
Track::FindParameters params;
|
|
||||||
params.setName(listen.trackName);
|
|
||||||
params.setReleaseName(listen.releaseName);
|
|
||||||
params.setArtistName(listen.artistName);
|
|
||||||
if (listen.trackNumber)
|
|
||||||
params.setTrackNumber(*listen.trackNumber);
|
|
||||||
|
|
||||||
const auto tracks{ Track::findIds(session, params) };
|
|
||||||
// conservative behavior: in case of multiple matches: reject
|
|
||||||
if (tracks.results.size() == 1)
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Matched listen '" << listen << "' using metadata");
|
|
||||||
return tracks.results.front();
|
|
||||||
}
|
|
||||||
else if (tracks.results.size() > 1)
|
|
||||||
{
|
|
||||||
LOG(DEBUG, "Too many matches for listen '" << listen << "' using metadata");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(DEBUG, "No match for listen '" << listen << "'");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Scrobbling::ListenBrainz
|
namespace Scrobbling::ListenBrainz
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::optional<Wt::Json::Object> listenToJsonPayload(Database::Session& session, const Scrobbling::Listen& listen, const Wt::WDateTime& timePoint)
|
||||||
|
{
|
||||||
|
auto transaction{ session.createReadTransaction() };
|
||||||
|
|
||||||
|
const Database::Track::pointer track{ Database::Track::find(session, listen.trackId) };
|
||||||
|
if (!track)
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
auto artists{ track->getArtists({Database::TrackArtistLinkType::Artist}) };
|
||||||
|
if (artists.empty())
|
||||||
|
artists = track->getArtists({ Database::TrackArtistLinkType::ReleaseArtist });
|
||||||
|
|
||||||
|
if (artists.empty())
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Track cannot be scrobbled since it does not have any artist");
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wt::Json::Object additionalInfo;
|
||||||
|
additionalInfo["listening_from"] = "LMS";
|
||||||
|
additionalInfo["duration_ms"] = std::chrono::duration_cast<std::chrono::milliseconds>(track->getDuration()).count();
|
||||||
|
if (track->getRelease())
|
||||||
|
{
|
||||||
|
if (auto MBID{ track->getRelease()->getMBID() })
|
||||||
|
additionalInfo["release_mbid"] = Wt::Json::Value{ std::string {MBID->getAsString()} };
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Wt::Json::Array artistMBIDs;
|
||||||
|
for (const Database::Artist::pointer& artist : artists)
|
||||||
|
{
|
||||||
|
if (auto MBID{ artist->getMBID() })
|
||||||
|
artistMBIDs.push_back(Wt::Json::Value{ std::string {MBID->getAsString()} });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!artistMBIDs.empty())
|
||||||
|
additionalInfo["artist_mbids"] = std::move(artistMBIDs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto MBID{ track->getTrackMBID() })
|
||||||
|
additionalInfo["track_mbid"] = Wt::Json::Value{ std::string {MBID->getAsString()} };
|
||||||
|
|
||||||
|
if (auto MBID{ track->getRecordingMBID() })
|
||||||
|
additionalInfo["recording_mbid"] = Wt::Json::Value{ std::string {MBID->getAsString()} };
|
||||||
|
|
||||||
|
if (const std::optional<std::size_t> trackNumber{ track->getTrackNumber() })
|
||||||
|
additionalInfo["tracknumber"] = Wt::Json::Value{ static_cast<long long int>(*trackNumber) };
|
||||||
|
|
||||||
|
Wt::Json::Object trackMetadata;
|
||||||
|
trackMetadata["additional_info"] = std::move(additionalInfo);
|
||||||
|
trackMetadata["artist_name"] = Wt::Json::Value{ artists.front()->getName() };
|
||||||
|
trackMetadata["track_name"] = Wt::Json::Value{ track->getName() };
|
||||||
|
if (track->getRelease())
|
||||||
|
trackMetadata["release_name"] = Wt::Json::Value{ track->getRelease()->getName() };
|
||||||
|
|
||||||
|
Wt::Json::Object payload;
|
||||||
|
payload["track_metadata"] = std::move(trackMetadata);
|
||||||
|
if (timePoint.isValid())
|
||||||
|
payload["listened_at"] = Wt::Json::Value{ static_cast<long long int>(timePoint.toTime_t()) };
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string listenToJsonString(Database::Session& session, const Scrobbling::Listen& listen, const Wt::WDateTime& timePoint, std::string_view listenType)
|
||||||
|
{
|
||||||
|
std::string res;
|
||||||
|
|
||||||
|
std::optional<Wt::Json::Object> payload{ listenToJsonPayload(session, listen, timePoint) };
|
||||||
|
if (!payload)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
Wt::Json::Object root;
|
||||||
|
root["listen_type"] = Wt::Json::Value{ std::string {listenType} };
|
||||||
|
root["payload"] = Wt::Json::Array{ std::move(*payload) };
|
||||||
|
|
||||||
|
res = Wt::Json::serialize(root);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::size_t> parseListenCount(std::string_view msgBody)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Wt::Json::Object root;
|
||||||
|
Wt::Json::parse(std::string{ msgBody }, root);
|
||||||
|
|
||||||
|
const Wt::Json::Object& payload{ static_cast<const Wt::Json::Object&>(root.get("payload")) };
|
||||||
|
return static_cast<int>(payload.get("count"));
|
||||||
|
}
|
||||||
|
catch (const Wt::WException& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR, "Cannot parse listen count response: " << e.what());
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Database::TrackId tryGetMatchingTrack(Database::Session& session, const Listen& listen)
|
||||||
|
{
|
||||||
|
using namespace Database;
|
||||||
|
|
||||||
|
auto transaction{ session.createReadTransaction() };
|
||||||
|
|
||||||
|
// first try to match using track MBID, and then fallback on possibly ambiguous info
|
||||||
|
if (listen.trackMBID)
|
||||||
|
{
|
||||||
|
const auto tracks{ Track::findByMBID(session, *listen.trackMBID) };
|
||||||
|
// if duplicated files, do not record it (let the user correct its database)
|
||||||
|
if (tracks.size() == 1)
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Matched listen '" << listen << "' using track MBID");
|
||||||
|
return tracks.front()->getId();
|
||||||
|
}
|
||||||
|
else if (tracks.size() > 1)
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Too many matches for listen '" << listen << "' using track MBID!");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen.recordingMBID)
|
||||||
|
{
|
||||||
|
const auto tracks{ Track::findByRecordingMBID(session, *listen.recordingMBID) };
|
||||||
|
// if duplicated files, do not record it (let the user correct its database)
|
||||||
|
if (tracks.size() == 1)
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Matched listen '" << listen << "' using recording MBID");
|
||||||
|
return tracks.front()->getId();
|
||||||
|
}
|
||||||
|
else if (tracks.size() > 1)
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Too many matches for listen '" << listen << "' using recording MBID!");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!listen.trackName.empty() && !listen.artistName.empty());
|
||||||
|
|
||||||
|
// TODO check release MBID?
|
||||||
|
Track::FindParameters params;
|
||||||
|
params.setName(listen.trackName);
|
||||||
|
params.setReleaseName(listen.releaseName);
|
||||||
|
params.setArtistName(listen.artistName);
|
||||||
|
if (listen.trackNumber)
|
||||||
|
params.setTrackNumber(*listen.trackNumber);
|
||||||
|
|
||||||
|
const auto tracks{ Track::findIds(session, params) };
|
||||||
|
// conservative behavior: in case of multiple matches: reject
|
||||||
|
if (tracks.results.size() == 1)
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Matched listen '" << listen << "' using metadata");
|
||||||
|
return tracks.results.front();
|
||||||
|
}
|
||||||
|
else if (tracks.results.size() > 1)
|
||||||
|
{
|
||||||
|
LOG(DEBUG, "Too many matches for listen '" << listen << "' using metadata");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(DEBUG, "No match for listen '" << listen << "'");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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
@@ -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());
|
||||||
|
|
||||||
|
|||||||
@@ -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"),
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
@@ -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())
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() };
|
||||||
|
|||||||
@@ -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())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
+100
-107
@@ -31,142 +31,135 @@
|
|||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
#include "ModalManager.hpp"
|
#include "ModalManager.hpp"
|
||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface
|
||||||
|
|
||||||
using namespace Database;
|
|
||||||
|
|
||||||
void
|
|
||||||
Filters::showDialog()
|
|
||||||
{
|
{
|
||||||
auto dialog {std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.template.add-filter"))};
|
using namespace Database;
|
||||||
Wt::WWidget* dialogPtr {dialog.get()};
|
|
||||||
dialog->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
|
||||||
dialog->addFunction("id", &Wt::WTemplate::Functions::id);
|
|
||||||
|
|
||||||
Wt::WComboBox* typeCombo {dialog->bindNew<Wt::WComboBox>("type")};
|
void Filters::showDialog()
|
||||||
Wt::WComboBox* valueCombo {dialog->bindNew<Wt::WComboBox>("value")};
|
{
|
||||||
|
auto dialog{ std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.template.add-filter")) };
|
||||||
|
Wt::WWidget* dialogPtr{ dialog.get() };
|
||||||
|
dialog->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
dialog->addFunction("id", &Wt::WTemplate::Functions::id);
|
||||||
|
|
||||||
Wt::WPushButton* addBtn {dialog->bindNew<Wt::WPushButton>("add-btn", Wt::WString::tr("Lms.Explore.add-filter"))};
|
Wt::WComboBox* typeCombo{ dialog->bindNew<Wt::WComboBox>("type") };
|
||||||
addBtn->clicked().connect([=]
|
Wt::WComboBox* valueCombo{ dialog->bindNew<Wt::WComboBox>("value") };
|
||||||
{
|
|
||||||
const std::string type {typeCombo->valueText().toUTF8()};
|
|
||||||
const std::string value {valueCombo->valueText().toUTF8()};
|
|
||||||
|
|
||||||
// TODO use a model to store the cluster.id() values
|
Wt::WPushButton* addBtn{ dialog->bindNew<Wt::WPushButton>("add-btn", Wt::WString::tr("Lms.Explore.add-filter")) };
|
||||||
ClusterId clusterId {};
|
addBtn->clicked().connect([this, typeCombo, valueCombo, dialogPtr]
|
||||||
|
{
|
||||||
|
const std::string type{ typeCombo->valueText().toUTF8() };
|
||||||
|
const std::string value{ valueCombo->valueText().toUTF8() };
|
||||||
|
|
||||||
{
|
// TODO use a model to store the cluster.id() values
|
||||||
auto transaction {LmsApp->getDbSession().createReadTransaction()};
|
ClusterId clusterId{};
|
||||||
|
|
||||||
ClusterType::pointer clusterType {ClusterType::find(LmsApp->getDbSession(), type)};
|
{
|
||||||
if (!clusterType)
|
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
|
||||||
return;
|
|
||||||
|
|
||||||
Cluster::pointer cluster {clusterType->getCluster(value)};
|
ClusterType::pointer clusterType{ ClusterType::find(LmsApp->getDbSession(), type) };
|
||||||
if (!cluster)
|
if (!clusterType)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clusterId = cluster->getId();
|
Cluster::pointer cluster{ clusterType->getCluster(value) };
|
||||||
}
|
if (!cluster)
|
||||||
|
return;
|
||||||
|
|
||||||
add(clusterId);
|
clusterId = cluster->getId();
|
||||||
LmsApp->getModalManager().dispose(dialogPtr);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
Wt::WPushButton* cancelBtn {dialog->bindNew<Wt::WPushButton>("cancel-btn", Wt::WString::tr("Lms.cancel"))};
|
add(clusterId);
|
||||||
cancelBtn->clicked().connect([=]
|
LmsApp->getModalManager().dispose(dialogPtr);
|
||||||
{
|
});
|
||||||
LmsApp->getModalManager().dispose(dialogPtr);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
Wt::WPushButton* cancelBtn{ dialog->bindNew<Wt::WPushButton>("cancel-btn", Wt::WString::tr("Lms.cancel")) };
|
||||||
|
cancelBtn->clicked().connect([=]
|
||||||
|
{
|
||||||
|
LmsApp->getModalManager().dispose(dialogPtr);
|
||||||
|
});
|
||||||
|
|
||||||
// Populate data
|
// Populate data
|
||||||
{
|
{
|
||||||
auto transaction {LmsApp->getDbSession().createReadTransaction()};
|
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
|
||||||
|
|
||||||
const auto clusterTypesIds {ClusterType::findUsed(LmsApp->getDbSession())};
|
const auto clusterTypesIds{ ClusterType::findUsed(LmsApp->getDbSession()) };
|
||||||
for (const ClusterTypeId clusterTypeId : clusterTypesIds.results)
|
for (const ClusterTypeId clusterTypeId : clusterTypesIds.results)
|
||||||
{
|
{
|
||||||
const auto clusterType {ClusterType::find(LmsApp->getDbSession(), clusterTypeId)};
|
const auto clusterType{ ClusterType::find(LmsApp->getDbSession(), clusterTypeId) };
|
||||||
typeCombo->addItem(Wt::WString::fromUTF8(std::string{ clusterType->getName() }));
|
typeCombo->addItem(Wt::WString::fromUTF8(std::string{ clusterType->getName() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clusterTypesIds.results.empty())
|
if (!clusterTypesIds.results.empty())
|
||||||
{
|
{
|
||||||
const auto clusterType {ClusterType::find(LmsApp->getDbSession(), clusterTypesIds.results.front())};
|
const auto clusterType{ ClusterType::find(LmsApp->getDbSession(), clusterTypesIds.results.front()) };
|
||||||
|
|
||||||
for (const Cluster::pointer& cluster : clusterType->getClusters())
|
for (const Cluster::pointer& cluster : clusterType->getClusters())
|
||||||
{
|
{
|
||||||
if (std::find(std::cbegin(_clusterIds), std::cend(_clusterIds), cluster->getId()) == _clusterIds.end())
|
if (std::find(std::cbegin(_clusterIds), std::cend(_clusterIds), cluster->getId()) == _clusterIds.end())
|
||||||
valueCombo->addItem(Wt::WString::fromUTF8(std::string{ cluster->getName() }));
|
valueCombo->addItem(Wt::WString::fromUTF8(std::string{ cluster->getName() }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typeCombo->changed().connect([=]
|
typeCombo->changed().connect([this, typeCombo, valueCombo]
|
||||||
{
|
{
|
||||||
const std::string name {typeCombo->valueText().toUTF8()};
|
const std::string name{ typeCombo->valueText().toUTF8() };
|
||||||
|
|
||||||
valueCombo->clear();
|
valueCombo->clear();
|
||||||
|
|
||||||
auto transaction {LmsApp->getDbSession().createReadTransaction()};
|
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
|
||||||
|
|
||||||
auto clusterType {ClusterType::find(LmsApp->getDbSession(), name)};
|
auto clusterType{ ClusterType::find(LmsApp->getDbSession(), name) };
|
||||||
for (const Cluster::pointer& cluster : clusterType->getClusters())
|
for (const Cluster::pointer& cluster : clusterType->getClusters())
|
||||||
{
|
{
|
||||||
if (std::find(std::cbegin(_clusterIds), std::cend(_clusterIds), cluster->getId()) == _clusterIds.end())
|
if (std::find(std::cbegin(_clusterIds), std::cend(_clusterIds), cluster->getId()) == _clusterIds.end())
|
||||||
valueCombo->addItem(Wt::WString::fromUTF8(std::string{ cluster->getName() }));
|
valueCombo->addItem(Wt::WString::fromUTF8(std::string{ cluster->getName() }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
Wt::WInteractWidget* filter {};
|
Wt::WInteractWidget* filter{};
|
||||||
|
|
||||||
{
|
{
|
||||||
auto cluster {Utils::createCluster(clusterId, true)};
|
auto cluster{ Utils::createCluster(clusterId, true) };
|
||||||
if (!cluster)
|
if (!cluster)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
filter = _filters->addWidget(std::move(cluster));
|
filter = _filters->addWidget(std::move(cluster));
|
||||||
}
|
}
|
||||||
|
|
||||||
_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));
|
||||||
_sigUpdated.emit();
|
_sigUpdated.emit();
|
||||||
});
|
});
|
||||||
|
|
||||||
LmsApp->notifyMsg(Notification::Type::Info,
|
LmsApp->notifyMsg(Notification::Type::Info,
|
||||||
Wt::WString::tr("Lms.Explore.filters"),
|
Wt::WString::tr("Lms.Explore.filters"),
|
||||||
Wt::WString::tr("Lms.Explore.filter-added"), std::chrono::seconds {2});
|
Wt::WString::tr("Lms.Explore.filter-added"), std::chrono::seconds{ 2 });
|
||||||
|
|
||||||
_sigUpdated.emit();
|
_sigUpdated.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Filters::Filters()
|
|
||||||
: Wt::WTemplate {Wt::WString::tr("Lms.Explore.template.filters")}
|
|
||||||
{
|
|
||||||
addFunction("tr", &Functions::tr);
|
|
||||||
|
|
||||||
// Filters
|
|
||||||
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>("clusters");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Filters::Filters()
|
||||||
|
: Wt::WTemplate{ Wt::WString::tr("Lms.Explore.template.filters") }
|
||||||
|
{
|
||||||
|
addFunction("tr", &Functions::tr);
|
||||||
|
|
||||||
|
// Filters
|
||||||
|
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>("clusters");
|
||||||
|
}
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
@@ -30,21 +30,22 @@
|
|||||||
|
|
||||||
namespace UserInterface
|
namespace UserInterface
|
||||||
{
|
{
|
||||||
class Filters : public Wt::WTemplate
|
class Filters : public Wt::WTemplate
|
||||||
{
|
{
|
||||||
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; }
|
|
||||||
|
|
||||||
private:
|
Wt::Signal<>& updated() { return _sigUpdated; }
|
||||||
void showDialog();
|
|
||||||
|
|
||||||
Wt::WContainerWidget *_filters;
|
private:
|
||||||
Wt::Signal<> _sigUpdated;
|
void showDialog();
|
||||||
std::vector<Database::ClusterId> _clusterIds;
|
|
||||||
};
|
Wt::WContainerWidget* _filters;
|
||||||
|
Wt::Signal<> _sigUpdated;
|
||||||
|
std::vector<Database::ClusterId> _clusterIds;
|
||||||
|
};
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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() };
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user