Commit 289c1790 authored by Kevin Whitaker's avatar Kevin Whitaker

Implement UI for track skipping.

parent 1186b7a4
......@@ -74,13 +74,14 @@ void WebInterface::songChangedFromServer(AudioTrack nextTrack)
void WebInterface::skipVotedFromServer(User userRequestingToSkipCurrentTrack)
{
//priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"skip");
priv_int->playerUI->updateSkipRequestedFromServer();
//TODO: show notification
triggerUpdate();
}
void WebInterface::skipVoteUpdateFromServer(User userVoting, bool forSkip)
{
//priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"vote");
if(!forSkip) priv_int->playerUI->updateSkipDeniedFromServer();
triggerUpdate();
}
......@@ -92,7 +93,7 @@ void WebInterface::voteNextSongFromServer(User userVoting, AudioTrack trackVoted
void WebInterface::voteNextPollClosedFromServer()
{
//priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"voteclosed");
priv_int->playerUI->updateVotingEnded();
triggerUpdate();
}
......
......@@ -52,10 +52,18 @@ PlayerInterface::PlayerInterface(WebInterface* app)
isPaused = groove_playlist_playing(GroovePlayerMgr::getInstance()->currentPlaylist)==0;
playpause->clicked().connect(this, &PlayerInterface::playpauseClicked);
skipRequest = new Wt::WPushButton();
skipRequest->clicked().connect(this, &PlayerInterface::skipRequestClicked);
skipRequest->setTextFormat(Wt::XHTMLText);
skipRequest->decorationStyle().font().setFamily(Wt::WFont::Default,"FontAwesome");
skipRequest->setText(""); //cancel skip? 
skipRequest->setText("");
skipDeny = new Wt::WPushButton();
skipDeny->clicked().connect(this, &PlayerInterface::skipDenyClicked);
skipDeny->setTextFormat(Wt::XHTMLText);
skipDeny->decorationStyle().font().setFamily(Wt::WFont::Default,"FontAwesome");
skipDeny->setText("");
skipDeny->setHidden(true);
skipControls->addWidget(skipRequest);
skipControls->addWidget(skipDeny);
interfaceLayout->addWidget(playControlWidget);
interfaceLayout->addWidget(currentTrackProgress);
......@@ -79,14 +87,49 @@ void PlayerInterface::playpauseClicked()
}
}
void PlayerInterface::skipRequestClicked()
{
if(!isPaused)
{
GroovePlayerMgr::getInstance()->lastInternalEvents.push_back(GroovePlayerMgr::PlayerEvent() = {GroovePlayerMgr::PlayerEventType::SKIP_REQUESTED, app->currentUser, std::list<AudioTrack>{GroovePlayerMgr::getInstance()->currentTrack}});
}
}
void PlayerInterface::skipDenyClicked()
{
if(!isPaused)
{
GroovePlayerMgr::getInstance()->lastInternalEvents.push_back(GroovePlayerMgr::PlayerEvent() = {GroovePlayerMgr::PlayerEventType::SKIP_VOTE_CAST_AGAINST, app->currentUser, std::list<AudioTrack>{GroovePlayerMgr::getInstance()->currentTrack}});
}
}
void PlayerInterface::updateSkipRequestedFromServer()
{
skipRequest->setHidden(true);
skipDeny->setHidden(false);
}
void PlayerInterface::updateSkipDeniedFromServer()
{
skipDeny->setHidden(true);
skipRequest->setHidden(false);
}
void PlayerInterface::updateVotingEnded()
{
skipRequest->setEnabled(false);
}
void PlayerInterface::playpauseUpdated()
{
if(isPaused)
{
skipRequest->setEnabled(false);
playpause->setText(Wt::WString::fromUTF8("&#61515;"));
}
else
{
if(!GroovePlayerMgr::getInstance()->voteEndedButNotNextTrackYet) skipRequest->setEnabled(true);
playpause->setText(Wt::WString::fromUTF8("&#61516;"));
}
}
......@@ -119,5 +162,13 @@ void PlayerInterface::updateDetailsFromServer(AudioTrack track)
trackProgress->start();
}
playpauseUpdated();
if(GroovePlayerMgr::getInstance()->currentSkipRequester.size() > 0)
{
updateSkipRequestedFromServer();
}
else
{
updateSkipDeniedFromServer();
}
currentTrackDetails->updateWithTrackDetails(track);
}
......@@ -50,6 +50,7 @@ public:
Wt::WPushButton* playpause;
Wt::WContainerWidget* skipControls;
Wt::WPushButton* skipRequest;
Wt::WPushButton* skipDeny;
bool isPaused = false;
//TODO:put in controls for requesting/admin skip and adding users as admin.
......@@ -60,8 +61,13 @@ public:
void playpauseClicked();
void playpauseUpdated();
void skipRequestClicked();
void skipDenyClicked();
void updateDetailsFromServer(AudioTrack track);
void updateProgressFromTimer();
void updateSkipRequestedFromServer();
void updateSkipDeniedFromServer();
void updateVotingEnded();
};
#endif // PLAYERINTERFACE_H
......@@ -31,7 +31,7 @@ TrackDetails::TrackDetails()
metaLayout = new Wt::WVBoxLayout();
coverData = new Wt::WMemoryResource();
albumCover = new Wt::WImage();
albumCover->setMinimumSize(Wt::WLength(100,Wt::WLength::Pixel),Wt::WLength(100,Wt::WLength::Pixel));
albumCover->setMinimumSize(Wt::WLength(75,Wt::WLength::Pixel),Wt::WLength(75,Wt::WLength::Pixel));
albumCover->setMaximumSize(Wt::WLength(200,Wt::WLength::Pixel),Wt::WLength(200,Wt::WLength::Pixel));
mainLayout->addWidget(albumCover);
mainLayout->addSpacing(Wt::WLength(10, Wt::WLength::Pixel));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment