Still converting to bootstrap 5. Converted tracks dropdown
This commit is contained in:
@@ -39,7 +39,6 @@ add_executable(lms
|
||||
ui/explore/SearchView.cpp
|
||||
ui/explore/TrackCollector.cpp
|
||||
ui/explore/TrackListHelpers.cpp
|
||||
ui/explore/TrackPopup.cpp
|
||||
ui/explore/TracksView.cpp
|
||||
ui/resource/AudioFileResource.cpp
|
||||
ui/resource/AudioTranscodeResource.cpp
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
#include "common/Template.hpp"
|
||||
#include "resource/DownloadResource.hpp"
|
||||
#include "resource/CoverResource.hpp"
|
||||
#include "Filters.hpp"
|
||||
@@ -42,7 +43,6 @@
|
||||
#include "LmsApplicationException.hpp"
|
||||
#include "MediaPlayer.hpp"
|
||||
#include "ReleaseListHelpers.hpp"
|
||||
#include "TrackPopup.hpp"
|
||||
#include "TrackStringUtils.hpp"
|
||||
|
||||
using namespace Database;
|
||||
@@ -256,7 +256,7 @@ Release::refreshView()
|
||||
else
|
||||
container = getOrAddNoDiscContainer();
|
||||
|
||||
Wt::WTemplate* entry {container->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Release.template.entry"))};
|
||||
Template* entry {container->addNew<Template>(Wt::WString::tr("Lms.Explore.Release.template.entry"))};
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(track->getName()), Wt::TextFormat::Plain);
|
||||
|
||||
@@ -289,6 +289,37 @@ Release::refreshView()
|
||||
tracksAction.emit(PlayQueueAction::Play, {trackId});
|
||||
});
|
||||
|
||||
{
|
||||
entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.Explore.template.more-btn"), Wt::TextFormat::XHTML);
|
||||
entry->bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"))
|
||||
->clicked().connect([=]
|
||||
{
|
||||
tracksAction.emit(PlayQueueAction::PlayLast, {trackId});
|
||||
});
|
||||
|
||||
auto isStarred {[=] { return Service<Scrobbling::IScrobblingService>::get()->isStarred(LmsApp->getUserId(), trackId); }};
|
||||
|
||||
Wt::WPushButton* starBtn {entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star"))};
|
||||
starBtn->clicked().connect([=]
|
||||
{
|
||||
auto transaction {LmsApp->getDbSession().createUniqueTransaction()};
|
||||
|
||||
if (isStarred())
|
||||
{
|
||||
Service<Scrobbling::IScrobblingService>::get()->unstar(LmsApp->getUserId(), trackId);
|
||||
starBtn->setText(Wt::WString::tr("Lms.Explore.star"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Service<Scrobbling::IScrobblingService>::get()->star(LmsApp->getUserId(), trackId);
|
||||
starBtn->setText(Wt::WString::tr("Lms.Explore.unstar"));
|
||||
}
|
||||
});
|
||||
|
||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink {std::make_unique<DownloadTrackResource>(trackId)});
|
||||
}
|
||||
|
||||
entry->bindString("duration", durationToString(track->getDuration()), Wt::TextFormat::Plain);
|
||||
|
||||
LmsApp->getMediaPlayer().trackLoaded.connect(entry, [=] (TrackId loadedTrackId)
|
||||
|
||||
@@ -22,26 +22,31 @@
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WImage.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "services/database/Artist.hpp"
|
||||
#include "services/database/Release.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "services/database/Session.hpp"
|
||||
#include "services/database/Track.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
|
||||
#include "common/Template.hpp"
|
||||
#include "resource/DownloadResource.hpp"
|
||||
#include "resource/CoverResource.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
#include "MediaPlayer.hpp"
|
||||
#include "TrackPopup.hpp"
|
||||
#include "TrackStringUtils.hpp"
|
||||
|
||||
using namespace Database;
|
||||
|
||||
namespace UserInterface::TrackListHelpers
|
||||
{
|
||||
std::unique_ptr<Wt::WTemplate>
|
||||
std::unique_ptr<Wt::WWidget>
|
||||
createEntry(const Database::ObjectPtr<Database::Track>& track, PlayQueueActionTrackSignal& tracksAction)
|
||||
{
|
||||
auto entry {std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Tracks.template.entry"))};
|
||||
auto entry {std::make_unique<Template>(Wt::WString::tr("Lms.Explore.Tracks.template.entry"))};
|
||||
auto* entryPtr {entry.get()};
|
||||
|
||||
Wt::WText* name {entry->bindNew<Wt::WText>("name", Wt::WString::fromUTF8(track->getName()), Wt::TextFormat::Plain)};
|
||||
@@ -95,11 +100,36 @@ namespace UserInterface::TrackListHelpers
|
||||
tracksAction.emit(PlayQueueAction::Play, {trackId});
|
||||
});
|
||||
|
||||
Wt::WText* moreBtn {entry->bindNew<Wt::WText>("more-btn", Wt::WString::tr("Lms.Explore.template.more-btn"), Wt::TextFormat::XHTML)};
|
||||
moreBtn->clicked().connect([=, &tracksAction]
|
||||
{
|
||||
displayTrackPopupMenu(*moreBtn, trackId, tracksAction);
|
||||
});
|
||||
entry->bindNew<Wt::WPushButton>("more-btn", Wt::WString::tr("Lms.Explore.template.more-btn"), Wt::TextFormat::XHTML);
|
||||
entry->bindNew<Wt::WPushButton>("play-last", Wt::WString::tr("Lms.Explore.play-last"))
|
||||
->clicked().connect([=, &tracksAction]
|
||||
{
|
||||
tracksAction.emit(PlayQueueAction::PlayLast, {trackId});
|
||||
});
|
||||
|
||||
auto isStarred {[=] { return Service<Scrobbling::IScrobblingService>::get()->isStarred(LmsApp->getUserId(), trackId); }};
|
||||
|
||||
Wt::WPushButton* starBtn {entry->bindNew<Wt::WPushButton>("star", Wt::WString::tr(isStarred() ? "Lms.Explore.unstar" : "Lms.Explore.star"))};
|
||||
starBtn->clicked().connect([=]
|
||||
{
|
||||
auto transaction {LmsApp->getDbSession().createUniqueTransaction()};
|
||||
|
||||
if (isStarred())
|
||||
{
|
||||
Service<Scrobbling::IScrobblingService>::get()->unstar(LmsApp->getUserId(), trackId);
|
||||
starBtn->setText(Wt::WString::tr("Lms.Explore.star"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Service<Scrobbling::IScrobblingService>::get()->star(LmsApp->getUserId(), trackId);
|
||||
starBtn->setText(Wt::WString::tr("Lms.Explore.unstar"));
|
||||
}
|
||||
});
|
||||
|
||||
entry->bindNew<Wt::WPushButton>("download", Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink {std::make_unique<DownloadTrackResource>(trackId)});
|
||||
}
|
||||
|
||||
LmsApp->getMediaPlayer().trackLoaded.connect(entryPtr, [=] (Database::TrackId loadedTrackId)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WWidget.h>
|
||||
#include "services/database/Object.hpp"
|
||||
#include "PlayQueueAction.hpp"
|
||||
|
||||
@@ -32,6 +32,6 @@ namespace Database
|
||||
|
||||
namespace UserInterface::TrackListHelpers
|
||||
{
|
||||
std::unique_ptr<Wt::WTemplate> createEntry(const Database::ObjectPtr<Database::Track>& track, PlayQueueActionTrackSignal& tracksAction);
|
||||
std::unique_ptr<Wt::WWidget> createEntry(const Database::ObjectPtr<Database::Track>& track, PlayQueueActionTrackSignal& tracksAction);
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "TrackPopup.hpp"
|
||||
|
||||
#include <Wt/WPopupMenu.h>
|
||||
|
||||
#include "services/database/Session.hpp"
|
||||
#include "services/database/Track.hpp"
|
||||
#include "services/database/User.hpp"
|
||||
#include "services/scrobbling/IScrobblingService.hpp"
|
||||
#include "utils/Service.hpp"
|
||||
#include "resource/DownloadResource.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
void
|
||||
displayTrackPopupMenu(Wt::WInteractWidget& target,
|
||||
Database::TrackId trackId,
|
||||
PlayQueueActionTrackSignal& tracksAction)
|
||||
{
|
||||
Wt::WPopupMenu* popup {LmsApp->createPopupMenu()};
|
||||
|
||||
popup->addItem(Wt::WString::tr("Lms.Explore.play-last"))
|
||||
->triggered().connect(&target, [=, &tracksAction]
|
||||
{
|
||||
tracksAction.emit(PlayQueueAction::PlayLast, {trackId});
|
||||
});
|
||||
|
||||
const bool isStarred {Service<Scrobbling::IScrobblingService>::get()->isStarred(LmsApp->getUserId(), trackId)};
|
||||
popup->addItem(Wt::WString::tr(isStarred ? "Lms.Explore.unstar" : "Lms.Explore.star"))
|
||||
->triggered().connect(&target, [=]
|
||||
{
|
||||
auto transaction {LmsApp->getDbSession().createUniqueTransaction()};
|
||||
|
||||
auto track {Database::Track::find(LmsApp->getDbSession(), trackId)};
|
||||
if (!track)
|
||||
return;
|
||||
|
||||
if (isStarred)
|
||||
Service<Scrobbling::IScrobblingService>::get()->unstar(LmsApp->getUserId(), trackId);
|
||||
else
|
||||
Service<Scrobbling::IScrobblingService>::get()->star(LmsApp->getUserId(), trackId);
|
||||
});
|
||||
popup->addItem(Wt::WString::tr("Lms.Explore.download"))
|
||||
->setLink(Wt::WLink {std::make_unique<DownloadTrackResource>(trackId)});
|
||||
|
||||
popup->popup(&target);
|
||||
}
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WWidget.h>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
#include "services/database/Types.hpp"
|
||||
#include "PlayQueueAction.hpp"
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
void displayTrackPopupMenu(Wt::WInteractWidget& target,
|
||||
Database::TrackId trackId,
|
||||
PlayQueueActionTrackSignal& tracksAction);
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -83,7 +83,6 @@ DownloadResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Resp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
std::string
|
||||
getArtistPathName(Database::Artist::pointer artist)
|
||||
|
||||
Reference in New Issue
Block a user