/* * Copyright (C) 2017 Kevin Whitaker * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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 this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include "WebInterface.h" #include "ui/LoginInterface.h" #include "ui/PlayerInterface.h" #include #include struct WebInterface::internal { LoginInterface* loginUI; PlayerInterface* playerUI; }; WebInterface::WebInterface(const Wt::WEnvironment& env) : Wt::WApplication(env) { priv_int = new internal; setTitle("Arbitrateor - Audio Jukebox"); enableUpdates(true); priv_int->playerUI = new PlayerInterface(this); priv_int->playerUI->hide(); priv_int->loginUI = new LoginInterface(this); priv_int->loginUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::SlideInFromTop)); root()->addWidget(priv_int->playerUI); root()->addWidget(priv_int->loginUI); } WebInterface::~WebInterface() { delete priv_int->playerUI; delete priv_int->loginUI; delete priv_int; } void WebInterface::loginCompleted() { //Login completed, now bring up main inteface. priv_int->loginUI->animateHide(Wt::WAnimation(Wt::WAnimation::AnimationEffect::Fade)); priv_int->playerUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::Fade, Wt::WAnimation::TimingFunction::EaseIn, 500)); //TODO: request current player state. } void WebInterface::playPauseActionFromServer(User userPausing, bool pause) { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"play"); triggerUpdate(); } void WebInterface::songChangedFromServer(AudioTrack nextTrack) { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"change"); triggerUpdate(); } void WebInterface::skipVotedFromServer(User userRequestingToSkipCurrentTrack) { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"skip"); triggerUpdate(); } void WebInterface::skipVoteUpdateFromServer(User userVoting, bool forSkip) { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"vote"); triggerUpdate(); } void WebInterface::voteNextSongFromServer(User userVoting, AudioTrack trackVoted) { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"nextvote"); triggerUpdate(); } void WebInterface::voteNextPollClosedFromServer() { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"voteclosed"); triggerUpdate(); } void WebInterface::voteTracksUpdatedFromServer(std::list voteableTracks) { priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged"); triggerUpdate(); }