App::App(const WEnvironment& environment) : BaseApp(environment, my_appCookieName) { // Set up the db string postgresConnectionString; readConfigurationProperty("DB", postgresConnectionString); postgres.connect(postgresConnectionString); dbSession().setConnection(postgres); log("notice") << "Mapping classes"; mapModels(dbSession()); // Load the message bundles messageResourceBundle().use(appRoot() + "messages/App"); messageResourceBundle().use(appRoot() + "messages/MainWindow"); messageResourceBundle().use(appRoot() + "messages/LoginWindow"); messageResourceBundle().use(appRoot() + "messages/ButtonBar"); messageResourceBundle().use(appRoot() + "messages/AdminIndex", false); messageResourceBundle().use(appRoot() + "messages/UserList", false); messageResourceBundle().use(appRoot() + "messages/UserEdit", false); // Set up our signals _userChanged = new UserChangedSignal(this); _statusTextChanged = new MessageSignal(this); internalPathChanged().connect(this, &App::rememberHistory); // Set up the general URL handling _url2ActionMapper = new URL2Action(this); // Set up the UI useStyleSheet(resourcesUrl() + "/themes/" + cssTheme() + "/forms.css"); useStyleSheet(resourcesUrl() + "/themes/" + cssTheme() + "/fonts.css"); useStyleSheet(resourcesUrl() + "/themes/" + cssTheme() + "/controlPanel.css"); setTitle(WString::tr("main-title")); _mainWindow = new MainWindow(root()); _statusTextChanged->connect(_mainWindow, &MainWindow::setStatusText); setBodyClass("yui-skin-sam"); // Fire an internal path changed event off as user may have navigated straight here internalPathChanged().emit(app()->internalPath()); }
std::vector<WLinkedCssStyleSheet> WBootstrapTheme::styleSheets() const { std::vector<WLinkedCssStyleSheet> result; std::string themeDir = resourcesUrl(); std::stringstream themeVersionDir; themeVersionDir << themeDir << static_cast<unsigned int>(version_) << "/"; result.push_back(WLinkedCssStyleSheet (WLink(themeVersionDir.str() + "bootstrap.css"))); WApplication *app = WApplication::instance(); if (responsive_) { if (version_ == BootstrapVersion::v2) result.push_back(WLinkedCssStyleSheet (WLink(themeVersionDir.str() + "bootstrap-responsive.css"))); else if (app) { WString v = app->metaHeader(MetaHeaderType::Meta, "viewport"); if (v.empty()) app->addMetaHeader("viewport", "width=device-width, initial-scale=1"); } } result.push_back(WLinkedCssStyleSheet (WLink(themeVersionDir.str() + "wt.css"))); return result; }
std::vector<WCssStyleSheet> WBootstrapTheme::styleSheets() const { std::vector<WCssStyleSheet> result; std::string themeDir = resourcesUrl(); result.push_back(WCssStyleSheet(WLink(themeDir + "bootstrap.css"))); result.push_back(WCssStyleSheet(WLink(themeDir + "bootstrap-responsive.css"))); result.push_back(WCssStyleSheet(WLink(themeDir + "wt.css"))); return result; }
std::vector<WCssStyleSheet> WCssTheme::styleSheets() const { std::vector<WCssStyleSheet> result; if (!name_.empty()) { std::string themeDir = resourcesUrl(); WApplication *app = WApplication::instance(); result.push_back(WCssStyleSheet(WLink(themeDir + "wt.css"))); if (app->environment().agentIsIE()) result.push_back(WCssStyleSheet(WLink(themeDir + "wt_ie.css"))); if (app->environment().agent() == WEnvironment::IE6) result.push_back(WCssStyleSheet(WLink(themeDir + "wt_ie6.css"))); } return result; }
const QString& PathUtils::qmlBaseUrl() { static const QString staticResourcePath = resourcesUrl() + "qml/"; return staticResourcePath; }
QUrl PathUtils::resourcesUrl(const QString& relativeUrl) { return QUrl(resourcesUrl() + relativeUrl); }
void WCssTheme::apply(WWidget *widget, WWidget *child, int widgetRole) const { switch (widgetRole) { case MenuItemIconRole: child->addStyleClass("Wt-icon"); break; case MenuItemCheckBoxRole: child->addStyleClass("Wt-chkbox"); break; case MenuItemCloseRole: widget->addStyleClass("Wt-closable"); child->addStyleClass("closeicon"); break; case DialogCoverRole: child->setStyleClass("Wt-dialogcover"); break; case DialogTitleBarRole: child->addStyleClass("titlebar"); break; case DialogBodyRole: child->addStyleClass("body"); break; case DialogFooterRole: child->addStyleClass("footer"); break; case DialogCloseIconRole: child->addStyleClass("closeicon"); break; case TableViewRowContainerRole: { WAbstractItemView *view = dynamic_cast<WAbstractItemView *>(widget); std::string backgroundImage; if (view->alternatingRowColors()) backgroundImage = "stripes/stripe-"; else backgroundImage = "no-stripes/no-stripe-"; backgroundImage = resourcesUrl() + backgroundImage + boost::lexical_cast<std::string> (static_cast<int>(view->rowHeight().toPixels())) + "px.gif"; child->decorationStyle().setBackgroundImage(WLink(backgroundImage)); break; } case DatePickerPopupRole: child->addStyleClass("Wt-datepicker"); break; case PanelTitleBarRole: child->addStyleClass("titlebar"); break; case PanelBodyRole: child->addStyleClass("body"); break; case AuthWidgets: WApplication *app = WApplication::instance(); app->useStyleSheet(WApplication::relativeResourcesUrl() + "form.css"); app->builtinLocalizedStrings().useBuiltin(skeletons::AuthCssTheme_xml1); break; } }