Persistent radio and repeat button

This commit is contained in:
emeric
2018-10-08 13:33:44 +02:00
parent 1a6b218c77
commit ec852f8a2f
4 changed files with 55 additions and 22 deletions
+35 -10
View File
@@ -30,7 +30,6 @@
#include "LmsApplication.hpp"
namespace UserInterface {
PlayQueue::PlayQueue()
@@ -38,6 +37,12 @@ PlayQueue::PlayQueue()
{
addFunction("tr", &Wt::WTemplate::Functions::tr);
{
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
_repeatAll = LmsApp->getUser()->isRepeatAllSet();
_radioMode = LmsApp->getUser()->isRadioSet();
}
Wt::WText* clearBtn = bindNew<Wt::WText>("clear-btn", Wt::WString::tr("Lms.PlayQueue.template.clear-btn"), Wt::TextFormat::XHTML);
clearBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.clear"));
clearBtn->clicked().connect([=]
@@ -68,21 +73,29 @@ PlayQueue::PlayQueue()
addSome();
});
Wt::WText* repeatBtn = bindNew<Wt::WText>("repeat-btn", Wt::WString::tr("Lms.PlayQueue.template.repeat-btn"), Wt::TextFormat::XHTML);
repeatBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.repeat"));
repeatBtn->clicked().connect([=]
_repeatBtn = bindNew<Wt::WText>("repeat-btn", Wt::WString::tr("Lms.PlayQueue.template.repeat-btn"), Wt::TextFormat::XHTML);
_repeatBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.repeat"));
_repeatBtn->clicked().connect([=]
{
_repeatAll = !_repeatAll;
repeatBtn->toggleStyleClass("Lms-playqueue-btn-selected", _repeatAll);
});
updateRepeatBtn();
Wt::WText* radioBtn = bindNew<Wt::WText>("radio-btn", Wt::WString::tr("Lms.PlayQueue.template.radio-btn"));
radioBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.radio-mode"));
radioBtn->clicked().connect([=]
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
LmsApp->getUser().modify()->setRepeatAll(_repeatAll);
});
updateRepeatBtn();
_radioBtn = bindNew<Wt::WText>("radio-btn", Wt::WString::tr("Lms.PlayQueue.template.radio-btn"));
_radioBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.radio-mode"));
_radioBtn->clicked().connect([=]
{
_radioMode = !_radioMode;
radioBtn->toggleStyleClass("Lms-playqueue-btn-selected", _radioMode);
updateRadioBtn();
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
LmsApp->getUser().modify()->setRadio(_radioMode);
});
updateRadioBtn();
_nbTracks = bindNew<Wt::WText>("nb-tracks");
@@ -112,6 +125,18 @@ PlayQueue::PlayQueue()
}
}
void
PlayQueue::updateRepeatBtn()
{
_repeatBtn->toggleStyleClass("Lms-playqueue-btn-selected", _repeatAll);
}
void
PlayQueue::updateRadioBtn()
{
_radioBtn->toggleStyleClass("Lms-playqueue-btn-selected",_radioMode);
}
Database::TrackList::pointer
PlayQueue::getTrackList()
{
+7 -3
View File
@@ -63,6 +63,8 @@ class PlayQueue : public Wt::WTemplate
void addRadioTrack();
void updateInfo();
void updateCurrentTrack(bool selected);
void updateRepeatBtn();
void updateRadioBtn();
void load(std::size_t pos, bool play);
void stop();
@@ -70,9 +72,11 @@ class PlayQueue : public Wt::WTemplate
bool _repeatAll = false;
bool _radioMode = false;
boost::optional<Database::IdType> _tracklistId;
Wt::WContainerWidget* _entriesContainer;
Wt::WPushButton* _showMore;
Wt::WText* _nbTracks;
Wt::WContainerWidget* _entriesContainer = nullptr;
Wt::WPushButton* _showMore = nullptr;
Wt::WText* _nbTracks = nullptr;
Wt::WText* _repeatBtn = nullptr;
Wt::WText* _radioBtn = nullptr;
boost::optional<std::size_t> _trackPos; // current track position, if set
};