From d8db92561bd4f42d386c6910718557b031fd9c8b Mon Sep 17 00:00:00 2001 From: emeric Date: Tue, 18 Sep 2018 13:33:30 +0200 Subject: [PATCH] Implementing a repeat all funtion in the playqueue --- approot/messages.xml | 5 +++- approot/playqueue.xml | 20 +++++++++----- docroot/css/lms.css | 4 +++ src/ui/PlayQueueView.cpp | 58 +++++++++++++++++++++++++++------------- src/ui/PlayQueueView.hpp | 3 ++- 5 files changed, 62 insertions(+), 28 deletions(-) diff --git a/approot/messages.xml b/approot/messages.xml index e258382c..5a606c24 100644 --- a/approot/messages.xml +++ b/approot/messages.xml @@ -88,12 +88,15 @@ Top tracks - + +Clear {1} tracks Added {1} tracks Playing {1} tracks Play Queue Radio mode +Repeat +Shuffle Play History diff --git a/approot/playqueue.xml b/approot/playqueue.xml index 56eda2a6..b2ba1131 100644 --- a/approot/playqueue.xml +++ b/approot/playqueue.xml @@ -2,20 +2,26 @@ - + - + + + + + + + + + ${entries} @@ -26,11 +32,11 @@ - + - + diff --git a/docroot/css/lms.css b/docroot/css/lms.css index f4049419..7bf20079 100644 --- a/docroot/css/lms.css +++ b/docroot/css/lms.css @@ -248,6 +248,10 @@ a:hover { color: #337ab7; } +.Lms-playqueue-btn-selected { + color: #337ab7; +} + .Lms-playqueue-selected { font-weight: 800; } diff --git a/src/ui/PlayQueueView.cpp b/src/ui/PlayQueueView.cpp index 6011c2ed..3715e8b7 100644 --- a/src/ui/PlayQueueView.cpp +++ b/src/ui/PlayQueueView.cpp @@ -38,22 +38,25 @@ PlayQueue::PlayQueue() { addFunction("tr", &Wt::WTemplate::Functions::tr); - Wt::WText* clearBtn = bindNew("clear-btn", Wt::WString::tr("Lms.PlayQueue.clear"), Wt::TextFormat::XHTML); - - _entriesContainer = bindNew("entries"); - - _showMore = bindNew("show-more", Wt::WString::tr("Lms.Explore.show-more")); - _showMore->setHidden(true); - - Wt::WText* shuffleBtn = bindNew("shuffle-btn", Wt::WString::tr("Lms.PlayQueue.shuffle"), Wt::TextFormat::XHTML); - _radioMode = bindNew("radio-mode", Wt::WString::tr("Lms.PlayQueue.radio-mode")); - _nbTracks = bindNew("nb-tracks"); - + Wt::WText* clearBtn = bindNew("clear-btn", Wt::WString::tr("Lms.PlayQueue.template.clear-btn"), Wt::TextFormat::XHTML); + clearBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.clear")); clearBtn->clicked().connect([=] { clearTracks(); }); + _entriesContainer = bindNew("entries"); + + _showMore = bindNew("show-more", Wt::WString::tr("Lms.Explore.show-more")); + _showMore->setHidden(true); + _showMore->clicked().connect([=] + { + addSome(); + updateCurrentTrack(true); + }); + + Wt::WText* shuffleBtn = bindNew("shuffle-btn", Wt::WString::tr("Lms.PlayQueue.template.shuffle-btn"), Wt::TextFormat::XHTML); + shuffleBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.shuffle")); shuffleBtn->clicked().connect([=] { { @@ -65,12 +68,24 @@ PlayQueue::PlayQueue() addSome(); }); - _showMore->clicked().connect([=] + Wt::WText* repeatBtn = bindNew("repeat-btn", Wt::WString::tr("Lms.PlayQueue.template.repeat-btn"), Wt::TextFormat::XHTML); + repeatBtn->setToolTip(Wt::WString::tr("Lms.PlayQueue.repeat")); + repeatBtn->clicked().connect([=] { - addSome(); - updateCurrentTrack(true); + _repeatAll = !_repeatAll; + repeatBtn->toggleStyleClass("Lms-playqueue-btn-selected", _repeatAll); }); + Wt::WText* radioBtn = bindNew("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); + }); + + _nbTracks = bindNew("nb-tracks"); + LmsApp->preQuit().connect([=] { if (_tracklistId) @@ -152,12 +167,17 @@ PlayQueue::load(std::size_t pos, bool play) // If out of range, stop playing if (pos >= tracklist->getCount()) { - stop(); - return; + if (!_repeatAll) + { + stop(); + return; + } + + pos = 0; } // If last and radio mode, fill the next song - if (_radioMode->checkState() == Wt::CheckState::Checked && pos == tracklist->getCount() - 1) + if (_radioMode && pos == tracklist->getCount() - 1) addRadioTrack(); _trackPos = pos; @@ -293,7 +313,7 @@ PlayQueue::addSome() entry->bindWidget("release-name", LmsApplication::createReleaseAnchor(track->getRelease())); } - Wt::WText* playBtn = entry->bindNew("play-btn", Wt::WString::tr("Lms.PlayQueue.play"), Wt::TextFormat::XHTML); + Wt::WText* playBtn = entry->bindNew("play-btn", Wt::WString::tr("Lms.PlayQueue.template.play-btn"), Wt::TextFormat::XHTML); playBtn->clicked().connect(std::bind([=] { auto pos = _entriesContainer->indexOf(entry); @@ -301,7 +321,7 @@ PlayQueue::addSome() load(pos, true); })); - Wt::WText* delBtn = entry->bindNew("del-btn", Wt::WString::tr("Lms.PlayQueue.delete"), Wt::TextFormat::XHTML); + Wt::WText* delBtn = entry->bindNew("del-btn", Wt::WString::tr("Lms.PlayQueue.template.delete-btn"), Wt::TextFormat::XHTML); delBtn->clicked().connect(std::bind([=] { // Remove the entry n both the widget tree and the playqueue diff --git a/src/ui/PlayQueueView.hpp b/src/ui/PlayQueueView.hpp index 596486c8..03d27f55 100644 --- a/src/ui/PlayQueueView.hpp +++ b/src/ui/PlayQueueView.hpp @@ -67,8 +67,9 @@ class PlayQueue : public Wt::WTemplate void load(std::size_t pos, bool play); void stop(); + bool _repeatAll = false; + bool _radioMode = false; boost::optional _tracklistId; - Wt::WCheckBox* _radioMode; Wt::WContainerWidget* _entriesContainer; Wt::WPushButton* _showMore; Wt::WText* _nbTracks;