/* * 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; this->useStyleSheet(Wt::WLink("/resources/font-awesome/css/font-awesome.min.css")); setTitle("Arbitrateor - Audio Jukebox"); enableUpdates(true); priv_int->playerUI = new PlayerInterface(this); priv_int->playerUI->hide(); priv_int->loginUI = new LoginInterface(this); root()->addWidget(priv_int->playerUI); root()->addWidget(priv_int->loginUI); priv_int->loginUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::SlideInFromTop)); priv_int->loginUI->checkSessionValidity(); } 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)); priv_int->playerUI->updateDetailsFromServer(GroovePlayerMgr::getInstance()->currentTrack); } void WebInterface::playPauseActionFromServer(User userPausing, bool pause) { priv_int->playerUI->isPaused = pause; priv_int->playerUI->playpauseUpdated(); triggerUpdate(); } void WebInterface::songChangedFromServer(AudioTrack nextTrack) { priv_int->playerUI->updateDetailsFromServer(nextTrack); triggerUpdate(); } void WebInterface::skipVotedFromServer(User userRequestingToSkipCurrentTrack) { priv_int->playerUI->updateSkipRequestedFromServer(); //TODO: show notification triggerUpdate(); } void WebInterface::skipVoteUpdateFromServer(User userVoting, bool forSkip) { if(!forSkip) priv_int->playerUI->updateSkipDeniedFromServer(); 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->updateVotingEnded(); triggerUpdate(); } void WebInterface::voteTracksUpdatedFromServer(std::list voteableTracks) { //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged"); triggerUpdate(); }