Example #1
0
File: WMenu.C Project: LifeGo/wt
void WMenu::select(int index, bool changePath)
{
  int last = current_;
  setCurrent(index);

  selectVisual(current_, changePath, true);

  if (index != -1) {
    WMenuItem *item = itemAt(index);
    item->show();
    item->loadContents();

    DeletionTracker guard(this);

    if (changePath && emitPathChange_) {
      WApplication *app = wApp;
      app->internalPathChanged().emit(app->internalPath());
      if (guard.deleted())
        return;
      emitPathChange_ = false;
    }

    if (last != index) {
      item->triggered().emit(item);
      if (!guard.deleted()) {
        // item may have been deleted too
        if (ul()->indexOf(item) != -1)
          itemSelected_.emit(item);
        else
          select(-1);
      }
    }
  }
}
Example #2
0
void AuthWidget::init()
{
  registrationModel_ = 0;
  registrationEnabled_ = false;
  created_ = false;
  dialog_ = 0;
  messageBox_ = 0;

  WApplication *app = WApplication::instance();
  app->internalPathChanged().connect(this, &AuthWidget::onPathChange);
  app->theme()->apply(this, this, AuthWidgets);
}
Example #3
0
File: BlogView.C Project: Unss/wt
  BlogImpl(const std::string& basePath, dbo::SqlConnectionPool& connectionPool,
	   const std::string& rssFeedUrl, BlogView *blogView)
    : basePath_(basePath),
      rssFeedUrl_(rssFeedUrl),
      session_(connectionPool),
      blogView_(blogView),
      panel_(0),
      authorPanel_(0),
      users_(0),
      userEditor_(0),
      mustLoginWarning_(0),
      mustBeAdministratorWarning_(0),
      invalidUser_(0)
  {
    WApplication *app = wApp;

    app->messageResourceBundle().use(WApplication::appRoot() + "blog");
    app->useStyleSheet("/css/blog.css");
    app->useStyleSheet("/css/asciidoc.css");
    app->internalPathChanged().connect(this, &BlogImpl::handlePathChange);

    loginStatus_ = new WTemplate(tr("blog-login-status"), this);
    panel_ = new WStackedWidget(this);
    items_ = new WContainerWidget(this);

    session_.login().changed().connect(this, &BlogImpl::onUserChanged);

    loginWidget_ = new BlogLoginWidget(session_, basePath);
    loginWidget_->hide();

    WText *loginLink = new WText(tr("login"));
    loginLink->setStyleClass("link");
    loginLink->clicked().connect(loginWidget_, &WWidget::show);
    loginLink->clicked().connect(loginLink, &WWidget::hide);

    WText *registerLink = new WText(tr("Wt.Auth.register"));
    registerLink->setStyleClass("link");
    registerLink->clicked().connect(loginWidget_,
				    &BlogLoginWidget::registerNewUser);

    WAnchor* archiveLink = new WAnchor
      (WLink(WLink::InternalPath, basePath_ + "all"), tr("archive"));

    loginStatus_->bindWidget("login", loginWidget_);
    loginStatus_->bindWidget("login-link", loginLink);
    loginStatus_->bindWidget("register-link", registerLink);
    loginStatus_->bindString("feed-url", rssFeedUrl_);
    loginStatus_->bindWidget("archive-link", archiveLink);

    onUserChanged();

    loginWidget_->processEnvironment();
  }
Example #4
0
void AuthWidget::init()
{
    registrationModel_ = 0;
    registrationEnabled_ = false;
    created_ = false;
    dialog_ = 0;
    messageBox_ = 0;

    addFunction("id", WT_TEMPLATE_FUNCTION(id));
    addFunction("tr", WT_TEMPLATE_FUNCTION(tr));

    WApplication *app = WApplication::instance();
    app->useStyleSheet(WApplication::resourcesUrl() + "form.css");
    app->internalPathChanged().connect(this, &AuthWidget::onPathChange);
    app->builtinLocalizedStrings().useBuiltin(skeletons::Auth_xml1);
}
Example #5
0
File: WMenu.C Project: LifeGo/wt
void WMenu::setInternalPathEnabled(const std::string& basePath)
{
  WApplication *app = WApplication::instance();

  basePath_ = basePath.empty() ? app->internalPath() : basePath;
  basePath_ = Utils::append(Utils::prepend(basePath_, '/'), '/');

  if (!internalPathEnabled_) {
    internalPathEnabled_ = true;
    app->internalPathChanged().connect(this, &WMenu::handleInternalPathChange);
  }

  previousInternalPath_ = app->internalPath();
  internalPathChanged(app->internalPath());

  updateItemsInternalPath();
}
Example #6
0
void WMenu::select(int index, bool changePath)
{
  int last = current_;
  setCurrent(index);

  selectVisual(current_, changePath, true);

  if (index != -1) {
    WMenuItem *item = itemAt(index);
    item->show();
    item->loadContents();

    if (changePath && emitPathChange_) {
      WApplication *app = wApp;
      app->internalPathChanged().emit(app->internalPath());
      emitPathChange_ = false;
    }

    if (last != index) {
      item->triggered().emit(item);
      itemSelected_.emit(item);
    }
  }
}