LatestCommentsDialog::LatestCommentsDialog(Session* session, MediaCollection *mediaCollection, WObject* parent): WDialog{parent} { setResizable(true); setWindowTitle(wtr("menu.latest.comments")); setClosable(true); setTransient(true); setMaximumSize(700, WLength::Auto); Dbo::Transaction t(*session); Dbo::collection<CommentPtr> latestComments = session->find<Comment>().orderBy("last_updated desc").limit(5); if(!latestComments.size()) contents()->addWidget(new WText{wtr("comments.empty")}); for(CommentPtr comment: latestComments) { WContainerWidget* commentWidget = new WContainerWidget; Media media = mediaCollection->media(comment->mediaId()); WContainerWidget *header = WW<WContainerWidget>(); header->setContentAlignment(AlignCenter); WAnchor *videoLink = WW<WAnchor>("", media.title(t)).css("link-hand label label-info comment-box-element"); header->addWidget(videoLink); Dbo::ptr<AuthInfo> authInfo = session->find<AuthInfo>().where("user_id = ?").bind(comment->user().id()); header->addWidget(WW<WText>(WString("{1} ({2})").arg(authInfo->identity("loginname")).arg(comment->lastUpdated().toString())) .css("label label-success comment-box-element")); commentWidget->addWidget(header); videoLink->clicked().connect([=](WMouseEvent){ _mediaClicked.emit(media); accept(); }); commentWidget->addWidget(WW<WText>(WString::fromUTF8(comment->content())).css("well comment-text comment-box-element").setInline(false)); contents()->addWidget(WW<WContainerWidget>().css("comment-text").add(commentWidget)); } }
void WMenuItem::connectSignals() { if (!signalsConnected_) { signalsConnected_ = true; if (!contents_ || contentsLoaded()) implementStateless(&WMenuItem::selectVisual, &WMenuItem::undoSelectVisual); WAnchor *a = anchor(); if (a) { SignalBase *as; bool selectFromCheckbox = false; if (checkBox_ && !checkBox_->clicked().propagationPrevented()) { as = &checkBox_->changed(); /* * Because the checkbox is not a properly exposed form object, * we need to relay its value ourselves */ checkBox_->checked().connect(this, &WMenuItem::setCheckBox); checkBox_->unChecked().connect(this, &WMenuItem::setUnCheckBox); selectFromCheckbox = true; } else as = &a->clicked(); if (checkBox_) a->setLink(WLink()); if (contentsContainer_ && contentsContainer_->count() == 0) as->connect(this, &WMenuItem::selectNotLoaded); else { as->connect(this, &WMenuItem::selectVisual); if (!selectFromCheckbox) as->connect(this, &WMenuItem::select); } } } }
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; } }