void AuthWidget::createOAuthLoginView() { if (!model_->oAuth().empty()) { setCondition("if:oauth", true); WContainerWidget *icons = new WContainerWidget(); icons->setInline(isInline()); for (unsigned i = 0; i < model_->oAuth().size(); ++i) { const OAuthService *auth = model_->oAuth()[i]; WImage *w = new WImage("css/oauth-" + auth->name() + ".png", icons); w->setToolTip(auth->description()); w->setStyleClass("Wt-auth-icon"); w->setVerticalAlignment(AlignMiddle); OAuthProcess *const process = auth->createProcess(auth->authenticationScope()); #ifndef WT_TARGET_JAVA w->clicked().connect(process, &OAuthProcess::startAuthenticate); #else process->connectStartAuthenticate(w->clicked()); #endif process->authenticated().connect (boost::bind(&AuthWidget::oAuthDone, this, process, _1)); WObject::addChild(process); } bindWidget("icons", icons); } }
void WDatePicker::createDefault(WLineEdit *forEdit) { WImage *icon = new WImage(WApplication::relativeResourcesUrl() + "calendar_edit.png"); icon->resize(16, 16); icon->setVerticalAlignment(AlignMiddle); if (!forEdit) { forEdit = new WLineEdit(); create(icon, forEdit); layout_->insertWidget(0, forEdit); } else create(icon, forEdit); }
void RegistrationWidget::update() { if (model_->passwordAuth()) bindString("password-description", tr("Wt.Auth.password-registration")); else bindEmpty("password-description"); updateView(model_); if (!created_) { WLineEdit *password = resolve<WLineEdit *> (RegistrationModel::ChoosePasswordField); WLineEdit *password2 = resolve<WLineEdit *> (RegistrationModel::RepeatPasswordField); WText *password2Info = resolve<WText *> (RegistrationModel::RepeatPasswordField + std::string("-info")); if (password && password2 && password2Info) model_->validatePasswordsMatchJS(password, password2, password2Info); } WAnchor *isYou = resolve<WAnchor *>("confirm-is-you"); if (!isYou) { isYou = new WAnchor(std::string("#"), tr("Wt.Auth.confirm-is-you")); isYou->hide(); bindWidget("confirm-is-you", isYou); } if (model_->isConfirmUserButtonVisible()) { if (!isYou->clicked().isConnected()) isYou->clicked().connect(this, &RegistrationWidget::confirmIsYou); isYou->show(); } else isYou->hide(); if (model_->isFederatedLoginVisible()) { if (!conditionValue("if:oauth")) { setCondition("if:oauth", true); if (model_->passwordAuth()) bindString("oauth-description", tr("Wt.Auth.or-oauth-registration")); else bindString("oauth-description", tr("Wt.Auth.oauth-registration")); WContainerWidget *icons = new WContainerWidget(); icons->addStyleClass("Wt-field"); for (unsigned i = 0; i < model_->oAuth().size(); ++i) { const OAuthService *service = model_->oAuth()[i]; WImage *w = new WImage("css/oauth-" + service->name() + ".png", icons); w->setToolTip(service->description()); w->setStyleClass("Wt-auth-icon"); w->setVerticalAlignment(AlignMiddle); OAuthProcess *const process = service->createProcess(service->authenticationScope()); w->clicked().connect(process, &OAuthProcess::startAuthenticate); process->authenticated().connect (boost::bind(&RegistrationWidget::oAuthDone, this, process, _1)); WObject::addChild(process); } bindWidget("icons", icons); } } else { setCondition("if:oauth", false); bindEmpty("icons"); } if (!created_) { WPushButton *okButton = new WPushButton(tr("Wt.Auth.register")); WPushButton *cancelButton = new WPushButton(tr("Wt.WMessageBox.Cancel")); bindWidget("ok-button", okButton); bindWidget("cancel-button", cancelButton); okButton->clicked().connect(this, &RegistrationWidget::doRegister); cancelButton->clicked().connect(this, &RegistrationWidget::close); created_ = true; } }