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 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; } }
DetailManipulation::DetailManipulation(bool enhance, WContainerWidget *parent) : WContainerWidget(parent), onlySmooth(!enhance) { resize(WLength::Auto, WLength::Auto); // Image bar prepareInputImages(); WContainerWidget *imageBar = new WContainerWidget; WVBoxLayout *imageBarLayout = new WVBoxLayout(); for (size_t i = 0; i < inputImages.size(); ++i) { WImage *img = inputImages[i]->getOriginalImage(); img->setStyleClass("image_button"); img->resize(160, 120); img->setAttributeValue("onMouseOver", "this.width=192; this.height=144;"); img->setAttributeValue("onMouseOut", "this.width=160; this.height=120;"); img->clicked().connect( boost::bind(&DetailManipulation::selectImage, this, i ) ); imageBarLayout->addWidget(img); } imageBar->resize(200, WLength::Auto); imageBar->setLayout(imageBarLayout); selectedImageId = 0; // Main component imageTab = new WTabWidget(); imageTab->addTab(inputImages[selectedImageId]->getOriginalImage(), "Original"); if (onlySmooth) { imageTab->addTab(new WImage(smoothedResult[selectedImageId].second), smoothedResult[selectedImageId].first); } else { imageTab->addTab(new WImage(enhancedResult[selectedImageId].second), enhancedResult[selectedImageId].first); } imageTab->resize(600, WLength::Auto); WGridLayout *controllerLayout = new WGridLayout(); WSlider *rSlider = new WSlider(Wt::Vertical); rSlider->setRange(SLIDER_MINIMUM, SLIDER_MAXIMUM); rSlider->setTickPosition(Wt::WSlider::TicksBothSides); WDoubleSpinBox *rSpinBox = new WDoubleSpinBox(); rSpinBox->setMinimum(R_MINIMUM); rSpinBox->setMaximum(R_MAXIMUM); rSlider->sliderMoved().connect( boost::bind(&DetailManipulation::changeDoubleSpinBoxValue, this, rSpinBox, true, _1) ); rSpinBox->valueChanged().connect( boost::bind(&DetailManipulation::changeSliderValue, this, rSlider, 1.f/(R_MAXIMUM-R_MINIMUM), _1) ); controllerLayout->addWidget(rSlider, 2, 0, 6, 1); controllerLayout->addWidget(rSpinBox, 9, 0); controllerLayout->addWidget(new WText("radius"), 10, 0); WSlider *epsSlider = new WSlider(Wt::Vertical); epsSlider->setMinimum(SLIDER_MINIMUM); epsSlider->setMaximum(SLIDER_MAXIMUM); epsSlider->setRange(SLIDER_MINIMUM, SLIDER_MAXIMUM); epsSlider->setTickPosition(WSlider::TicksBothSides); WDoubleSpinBox *epsSpinBox = new WDoubleSpinBox(); epsSpinBox->setMinimum(EPS_MINIMUM); epsSpinBox->setMaximum(EPS_MAXIMUM); epsSlider->sliderMoved().connect( boost::bind(&DetailManipulation::changeDoubleSpinBoxValue, this, epsSpinBox, false, _1) ); epsSpinBox->valueChanged().connect( boost::bind(&DetailManipulation::changeSliderValue, this, epsSlider, 1.f/(EPS_MAXIMUM-EPS_MINIMUM), _1) ); controllerLayout->addWidget(epsSlider, 2, 1, 6, 1); controllerLayout->addWidget(epsSpinBox, 9, 1); controllerLayout->addWidget(new WText("epsilon"), 10, 1); WPushButton *apply = new WPushButton("Apply"); apply->clicked().connect( boost::bind(&DetailManipulation::applyEnhancement, this, rSpinBox, epsSpinBox ) ); controllerLayout->addWidget(apply, 1, 0, 1, 2); WContainerWidget *controller = new WContainerWidget(); controller->resize(120, WLength::Auto); controller->setLayout(controllerLayout); WBorderLayout *mainLayout = new WBorderLayout(this); mainLayout->addWidget(imageBar, WBorderLayout::West); mainLayout->addWidget(imageTab, WBorderLayout::Center); mainLayout->addWidget(controller, WBorderLayout::East); //setLayout(mainLayout, Wt::AlignTop | Wt::AlignJustify); /* doJavaScript( "(function () { \ var imageTags = document.getElementsByClassName(\"image_button\"); \ for (var i=0; image=imageTags[i]; ++i) { \ if (image.width>200 && image.height>0) { \ image.width = 192; \ } \ }\ })();" );*/ }