HangmanGame::HangmanGame(WContainerWidget *parent): WContainerWidget(parent), game_(0), scores_(0) { session_.login().changed().connect(this, &HangmanGame::onAuthEvent); Auth::AuthModel *authModel = new Auth::AuthModel(Session::auth(), session_.users(), this); authModel->addPasswordAuth(&Session::passwordAuth()); authModel->addOAuth(Session::oAuth()); Auth::AuthWidget *authWidget = new Auth::AuthWidget(session_.login()); authWidget->setModel(authModel); authWidget->setRegistrationEnabled(true); WText *title = new WText("<h1>A Witty game: Hangman</h1>"); addWidget(title); addWidget(authWidget); mainStack_ = new WStackedWidget(); mainStack_->setStyleClass("gamestack"); addWidget(mainStack_); links_ = new WContainerWidget(); links_->setStyleClass("links"); links_->hide(); addWidget(links_); backToGameAnchor_ = new WAnchor("/play", "Gaming Grounds", links_); backToGameAnchor_->setLink(WLink(WLink::InternalPath, "/play")); scoresAnchor_ = new WAnchor("/highscores", "Highscores", links_); scoresAnchor_->setLink(WLink(WLink::InternalPath, "/highscores")); WApplication::instance()->internalPathChanged() .connect(this, &HangmanGame::handleInternalPath); authWidget->processEnvironment(); }
HomeUI::HomeUI(WContainerWidget *parent) : WContainerWidget(parent), importUI(0) { setContentAlignment(AlignCenter); session_.login().changed().connect(this, &HomeUI::onAuthEvent); Auth::AuthModel *authModel = new Auth::AuthModel(Session::auth(), session_.users(), this); authModel->addPasswordAuth(&Session::passwordAuth()); authModel->addOAuth(Session::oAuth()); Auth::AuthWidget *authWidget = new Auth::AuthWidget(session_.login()); authWidget->setModel(authModel); authWidget->setRegistrationEnabled(false); WText *title = new WText(WString::fromUTF8("<h1>数据管理平台</h1>")); addWidget(title); addWidget(authWidget); mainStack_ = new WStackedWidget(); mainStack_->setStyleClass("mainstack"); addWidget(mainStack_); links_ = new WContainerWidget(); links_->setStyleClass("links"); links_->hide(); addWidget(links_); importUIAnchor_ = new WAnchor("/dataimport", "Data Import", links_); importUIAnchor_->setLink(WLink(WLink::InternalPath, "/dataimport")); WApplication::instance()->internalPathChanged().connect(this, &HomeUI::handleInternalPath); authWidget->processEnvironment(); }