Newer
Older
Kevin Whitaker
committed
/*
* Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com>
*
* 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"
Kevin Whitaker
committed
#include "ui/LoginInterface.h"
Kevin Whitaker
committed
#include "ui/PlayerInterface.h"
Kevin Whitaker
committed
#include <Wt/WText>
Kevin Whitaker
committed
#include <Wt/WAnimation>
Kevin Whitaker
committed
struct WebInterface::internal
{
LoginInterface* loginUI;
Kevin Whitaker
committed
PlayerInterface* playerUI;
Kevin Whitaker
committed
};
WebInterface::WebInterface(const Wt::WEnvironment& env) : Wt::WApplication(env)
{
priv_int = new internal;
setTitle("Arbitrateor - Audio Jukebox");
enableUpdates(true);
Kevin Whitaker
committed
priv_int->playerUI = new PlayerInterface(this);
priv_int->playerUI->hide();
Kevin Whitaker
committed
priv_int->loginUI = new LoginInterface(this);
Kevin Whitaker
committed
priv_int->loginUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::SlideInFromTop));
root()->addWidget(priv_int->playerUI);
Kevin Whitaker
committed
root()->addWidget(priv_int->loginUI);
}
Kevin Whitaker
committed
WebInterface::~WebInterface()
{
delete priv_int->playerUI;
delete priv_int->loginUI;
delete priv_int;
}
Kevin Whitaker
committed
void WebInterface::loginCompleted()
{
//Login completed, now bring up main inteface.
Kevin Whitaker
committed
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)
{
priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"play");
triggerUpdate();
}
Kevin Whitaker
committed
void WebInterface::songChangedFromServer(const 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::voteUpdateFromServer(User* userVoting, bool forSkip)
{
priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"vote");
triggerUpdate();
Kevin Whitaker
committed
}
Kevin Whitaker
committed
void WebInterface::voteNextSongFromServer(User* userVoting, const 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();
}
Kevin Whitaker
committed
void WebInterface::voteTracksUpdatedFromServer(std::list<const AudioTrack *> voteableTracks)
{
priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged");
triggerUpdate();
}