Persistent radio and repeat button
This commit is contained in:
@@ -35,11 +35,7 @@ User::audioBitrates =
|
||||
};
|
||||
|
||||
User::User()
|
||||
: _maxAudioBitrate(audioBitrates.back()),
|
||||
_type(Type::REGULAR),
|
||||
_audioBitrate(defaultAudioBitrate),
|
||||
_audioEncoding(AudioEncoding::AUTO),
|
||||
_curPlayingTrackPos(0)
|
||||
: _maxAudioBitrate(audioBitrates.back())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+12
-4
@@ -76,6 +76,8 @@ class User : public Wt::Dbo::Dbo<User>
|
||||
void setAudioEncoding(AudioEncoding encoding) { _audioEncoding = encoding; }
|
||||
void setMaxAudioBitrate(std::size_t bitrate);
|
||||
void setCurPlayingTrackPos(std::size_t pos) { _curPlayingTrackPos = pos; }
|
||||
void setRadio(bool val) { _radio = val; }
|
||||
void setRepeatAll(bool val) { _repeatAll = val; }
|
||||
|
||||
// read
|
||||
bool isAdmin() const { return _type == Type::ADMIN; }
|
||||
@@ -84,6 +86,8 @@ class User : public Wt::Dbo::Dbo<User>
|
||||
AudioEncoding getAudioEncoding() const { return _audioEncoding; }
|
||||
std::size_t getMaxAudioBitrate() const;
|
||||
std::size_t getCurPlayingTrackPos() const { return _curPlayingTrackPos; }
|
||||
bool isRepeatAllSet() const { return _repeatAll; }
|
||||
bool isRadioSet() const { return _radio; }
|
||||
|
||||
Wt::Dbo::ptr<TrackList> getQueuedTrackList() const;
|
||||
Wt::Dbo::ptr<TrackList> getPlayedTrackList() const;
|
||||
@@ -97,6 +101,8 @@ class User : public Wt::Dbo::Dbo<User>
|
||||
Wt::Dbo::field(a, _audioEncoding, "audio_encoding");
|
||||
// User's dynamic data
|
||||
Wt::Dbo::field(a, _curPlayingTrackPos, "cur_playing_track_pos");
|
||||
Wt::Dbo::field(a, _repeatAll, "repeat_all");
|
||||
Wt::Dbo::field(a, _radio, "radio");
|
||||
Wt::Dbo::hasMany(a, _tracklists, Wt::Dbo::ManyToOne, "user");
|
||||
}
|
||||
|
||||
@@ -106,14 +112,16 @@ class User : public Wt::Dbo::Dbo<User>
|
||||
|
||||
// Admin defined settings
|
||||
int _maxAudioBitrate;
|
||||
Type _type;
|
||||
Type _type = Type::REGULAR;
|
||||
|
||||
// User defined settings
|
||||
int _audioBitrate;
|
||||
AudioEncoding _audioEncoding;
|
||||
int _audioBitrate = defaultAudioBitrate;
|
||||
AudioEncoding _audioEncoding = AudioEncoding::AUTO;
|
||||
|
||||
// User's dynamic data
|
||||
int _curPlayingTrackPos; // Current track position in queue
|
||||
int _curPlayingTrackPos = 0; // Current track position in queue
|
||||
bool _repeatAll = false;
|
||||
bool _radio = false;
|
||||
|
||||
Wt::Dbo::collection< Wt::Dbo::ptr<TrackList> > _tracklists;
|
||||
|
||||
|
||||
+35
-10
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user