QtMainWindow::QtMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtMainWindow), webInspectorWindow(new QtWebInspector()), mainWindowCallback(NULL), cur_tbrp(0), m_alertDialog(0), m_LogicalDpiX(0), m_LogicalDpiY(0), firstShow(true) //TODO: m_SyncStatusDlg { #ifdef OS_WINDOWS_DESKTOP QPixmap icon(":/images/rho.png"); QApplication::setWindowIcon(icon); #endif ui->setupUi(this); #ifdef RHODES_WIN32 ui->menuSimulate->clear(); ui->menuSimulate->setTitle("Navigate"); ui->menuSimulate->insertAction(0, ui->actionBack); #endif QWebSettings* qs = QWebSettings::globalSettings(); qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); qs->setOfflineStorageDefaultQuota(1024*1024*1024); rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR; qs->enablePersistentStorage(rs_dir.c_str()); this->ui->webView->setContextMenuPolicy(Qt::NoContextMenu); this->ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->ui->webView->page()->mainFrame()->securityOrigin().setDatabaseQuota(1024*1024*1024); this->main_webView = this->ui->webView; this->main_webInspector = webInspectorWindow->webInspector(); this->cur_webInspector = this->main_webInspector; this->move(0,0); this->ui->toolBar->hide(); this->ui->toolBarRight->hide(); // connecting WebInspector main_webInspector->setPage(ui->webView->page()); #ifdef OS_SYMBIAN QWebViewKineticScroller *newScroller = new QWebViewKineticScroller(); newScroller->setWidget(this->ui->webView); QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView); #endif #if defined(RHODES_EMULATOR) webInspectorWindow->show(); #endif }
QtMainWindow::QtMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtMainWindow), webInspectorWindow(new QtWebInspector()), cb(NULL), cur_tbrp(0), m_alertDialog(0), m_LogicalDpiX(0), m_LogicalDpiY(0) //TODO: m_SyncStatusDlg { #ifdef OS_WINDOWS_DESKTOP QPixmap icon(":/images/rho.png"); QApplication::setWindowIcon(icon); #endif ui->setupUi(this); QWebSettings* qs = QWebSettings::globalSettings(); //this->ui->webView->settings(); qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); qs->setAttribute(QWebSettings::LocalStorageEnabled, true); qs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); qs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); qs->setOfflineStorageDefaultQuota(1024*1024*1024); rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR; qs->setOfflineWebApplicationCachePath(rs_dir.c_str()); qs->setLocalStoragePath(rs_dir.c_str()); qs->setOfflineStoragePath(rs_dir.c_str()); this->ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->ui->webView->page()->mainFrame()->securityOrigin().setDatabaseQuota(1024*1024*1024); this->main_webView = this->ui->webView; this->main_webInspector = webInspectorWindow->webInspector(); this->cur_webInspector = this->main_webInspector; this->move(0,0); this->ui->toolBar->hide(); this->ui->toolBarRight->hide(); // connecting WebInspector main_webInspector->setPage(ui->webView->page()); #ifdef OS_SYMBIAN QWebViewKineticScroller *newScroller = new QWebViewKineticScroller(); newScroller->setWidget(this->ui->webView); QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView); #endif webInspectorWindow->show(); }
void QtWebKitWebBackend::optionChanged(const QString &option) { if (option == QLatin1String("Cache/PagesInMemoryLimit")) { QWebSettings::setMaximumPagesInCache(SettingsManager::getValue(QLatin1String("Cache/PagesInMemoryLimit")).toInt()); } if (!(option.startsWith(QLatin1String("Browser/")) || option.startsWith(QLatin1String("Content/")))) { return; } QWebSettings *globalSettings = QWebSettings::globalSettings(); globalSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true); globalSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); globalSettings->setAttribute(QWebSettings::AutoLoadImages, SettingsManager::getValue(QLatin1String("Browser/EnableImages")).toBool()); globalSettings->setAttribute(QWebSettings::PluginsEnabled, SettingsManager::getValue(QLatin1String("Browser/EnablePlugins")).toString() != QLatin1String("disabled")); globalSettings->setAttribute(QWebSettings::JavaEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableJava")).toBool()); globalSettings->setAttribute(QWebSettings::JavascriptEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableJavaScript")).toBool()); globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanAccessClipboard")).toBool()); globalSettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, true); globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanOpenWindows")).toBool()); globalSettings->setAttribute(QWebSettings::LocalStorageEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableLocalStorage")).toBool()); globalSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableOfflineStorageDatabase")).toBool()); globalSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableOfflineWebApplicationCache")).toBool()); globalSettings->setAttribute(QWebSettings::ZoomTextOnly, SettingsManager::getValue(QLatin1String("Content/ZoomTextOnly")).toBool()); globalSettings->setFontSize(QWebSettings::DefaultFontSize, SettingsManager::getValue(QLatin1String("Content/DefaultFontSize")).toInt()); globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, SettingsManager::getValue(QLatin1String("Content/DefaultFixedFontSize")).toInt()); globalSettings->setFontSize(QWebSettings::MinimumFontSize, SettingsManager::getValue(QLatin1String("Content/MinimumFontSize")).toInt()); globalSettings->setFontFamily(QWebSettings::StandardFont, SettingsManager::getValue(QLatin1String("Content/StandardFont")).toString()); globalSettings->setFontFamily(QWebSettings::FixedFont, SettingsManager::getValue(QLatin1String("Content/FixedFont")).toString()); globalSettings->setFontFamily(QWebSettings::SerifFont, SettingsManager::getValue(QLatin1String("Content/SerifFont")).toString()); globalSettings->setFontFamily(QWebSettings::SansSerifFont, SettingsManager::getValue(QLatin1String("Content/SansSerifFont")).toString()); globalSettings->setFontFamily(QWebSettings::CursiveFont, SettingsManager::getValue(QLatin1String("Content/CursiveFont")).toString()); globalSettings->setFontFamily(QWebSettings::FantasyFont, SettingsManager::getValue(QLatin1String("Content/FantasyFont")).toString()); globalSettings->setOfflineStorageDefaultQuota(SettingsManager::getValue(QLatin1String("Browser/OfflineStorageLimit")).toInt() * 1024); globalSettings->setOfflineWebApplicationCacheQuota(SettingsManager::getValue(QLatin1String("Content/OfflineWebApplicationCacheLimit")).toInt() * 1024); }
QtMainWindow::QtMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtMainWindow), webInspectorWindow(new QtWebInspector()), mainWindowCallback(NULL), cur_tbrp(0), m_alertDialog(0), m_LogicalDpiX(0), m_LogicalDpiY(0), firstShow(true), m_bFirstLoad(true), toolBarSeparatorWidth(0) //TODO: m_SyncStatusDlg { #ifdef OS_WINDOWS_DESKTOP QPixmap icon(":/images/rho.png"); QApplication::setWindowIcon(icon); #endif ui->setupUi(this); #ifdef OS_WINDOWS_DESKTOP ui->menuSimulate->clear(); ui->menuSimulate->setTitle("Navigate"); ui->menuSimulate->insertAction(0, ui->actionBack); #endif QWebSettings* qs = QWebSettings::globalSettings(); qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); qs->setOfflineStorageDefaultQuota(1024*1024*1024); rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR; qs->enablePersistentStorage(rs_dir.c_str()); this->ui->webView->setContextMenuPolicy(Qt::NoContextMenu); this->ui->webView->setPage(new QtWebPage()); setUpWebPage(this->ui->webView->page()); this->main_webView = this->ui->webView; this->main_webInspector = webInspectorWindow->webInspector(); this->cur_webInspector = this->main_webInspector; this->move(0,0); this->ui->toolBar->hide(); this->ui->toolBarRight->hide(); this->main_webView->hide(); //this->ui->centralWidget->hide(); //this->ui->centralWidget->setStyleSheet("background-color: yellow"); //this->ui->centralWidget->setStyleSheet("QWidget {background-image: url(test.jpg)}" ); #ifdef RHODES_EMULATOR int width = RHOSIMCONF().getInt("screen_width"); int height = RHOSIMCONF().getInt("screen_height"); #else int width = RHOCONF().getInt("screen_width"); int height = RHOCONF().getInt("screen_height"); #endif if ((width>0) && (height>0)) this->setSize(width, height); else if (width>0) this->setSize(width, this->height()); else if (height>0) this->setSize(this->width(), height); #if defined(RHODES_EMULATOR) // connecting WebInspector main_webInspector->setPage(ui->webView->page()); #endif #ifdef OS_SYMBIAN QWebViewKineticScroller *newScroller = new QWebViewKineticScroller(); newScroller->setWidget(this->ui->webView); QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView); #endif #if defined(RHODES_EMULATOR) webInspectorWindow->show(); #endif }
bool WebSettings::initWebSettings() { if (!localSettingsLoaded) return false; qDebug("webOS::WebSettings::initWebSettings"); QWebSettings* globalWebSettings = QWebSettings::globalSettings(); QSettings settings; if (settings.value(WEB_SETTINGS_KEY_PERSISTENT_STORAGE).toBool()) { QString path = settings.value(WEB_SETTINGS_KEY_PERSISTENT_STORAGE_PATH).toString(); if (!path.isEmpty()) { globalWebSettings->setAttribute(QWebSettings::LocalStorageEnabled, true); globalWebSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); globalWebSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); globalWebSettings->setIconDatabasePath(path); globalWebSettings->setOfflineWebApplicationCachePath(path); globalWebSettings->setOfflineStoragePath(QString("%1/Databases").arg(path)); globalWebSettings->setLocalStoragePath(QString("%1/LocalStorage").arg(path)); } } if (settings.contains(WEB_SETTINGS_KEY_AUTO_LOAD_IMAGES)) globalWebSettings->setAttribute(QWebSettings::AutoLoadImages, settings.value(WEB_SETTINGS_KEY_AUTO_LOAD_IMAGES).toBool()); if (settings.contains(WEB_SETTINGS_KEY_DNS_PREFETCH)) globalWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, settings.value(WEB_SETTINGS_KEY_DNS_PREFETCH).toBool()); if (settings.contains(WEB_SETTINGS_KEY_ICON_DATABASE_PATH)) globalWebSettings->setIconDatabasePath(settings.value(WEB_SETTINGS_KEY_ICON_DATABASE_PATH).toString()); if (settings.contains(WEB_SETTINGS_KEY_JAVASCRIPT)) globalWebSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(WEB_SETTINGS_KEY_JAVASCRIPT).toBool()); if (settings.contains(WEB_SETTINGS_KEY_PLUGINS)) globalWebSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(WEB_SETTINGS_KEY_PLUGINS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_PRIVATE_BROWSING)) globalWebSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, settings.value(WEB_SETTINGS_KEY_PRIVATE_BROWSING).toBool()); if (settings.contains(WEB_SETTINGS_KEY_JAVASCRIPT_CAN_OPEN_WINDOWS)) globalWebSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, settings.value(WEB_SETTINGS_KEY_JAVASCRIPT_CAN_OPEN_WINDOWS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_JAVASCRIPT_CAN_CLOSE_WINDOWS)) globalWebSettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value(WEB_SETTINGS_KEY_JAVASCRIPT_CAN_CLOSE_WINDOWS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_JAVASCRIPT_CAN_ACCESS_CLIPBOARD)) globalWebSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, settings.value(WEB_SETTINGS_KEY_JAVASCRIPT_CAN_ACCESS_CLIPBOARD).toBool()); if (settings.contains(WEB_SETTINGS_KEY_DEVELOPER_EXTRAS)) globalWebSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, settings.value(WEB_SETTINGS_KEY_DEVELOPER_EXTRAS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_SPACIAL_NAVIGATION)) globalWebSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, settings.value(WEB_SETTINGS_KEY_SPACIAL_NAVIGATION).toBool()); if (settings.contains(WEB_SETTINGS_KEY_LINKS_INCLUDED_IN_FOCUS_CHAIN)) globalWebSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, settings.value(WEB_SETTINGS_KEY_LINKS_INCLUDED_IN_FOCUS_CHAIN).toBool()); if (settings.contains(WEB_SETTINGS_KEY_ZOOM_TEXT_ONLY)) globalWebSettings->setAttribute(QWebSettings::ZoomTextOnly, settings.value(WEB_SETTINGS_KEY_ZOOM_TEXT_ONLY).toBool()); if (settings.contains(WEB_SETTINGS_KEY_PRINT_ELEMENT_BACKGROUNDS)) globalWebSettings->setAttribute(QWebSettings::PrintElementBackgrounds, settings.value(WEB_SETTINGS_KEY_PRINT_ELEMENT_BACKGROUNDS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_OFFLINE_STORAGE_DATABASE)) { bool offlineStorageDatabaseEnabled = settings.value(WEB_SETTINGS_KEY_OFFLINE_STORAGE_DATABASE).toBool(); globalWebSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, offlineStorageDatabaseEnabled); if (offlineStorageDatabaseEnabled && settings.contains(WEB_SETTINGS_KEY_OFFLINE_STORAGE_DATABASE_PATH)) globalWebSettings->setOfflineStoragePath(settings.value(WEB_SETTINGS_KEY_OFFLINE_STORAGE_DATABASE_PATH).toString()); } if (settings.contains(WEB_SETTINGS_KEY_OFFLINE_WEBAPP_CACHE)) { bool offlineWebApplicationCachedEnabled = settings.value(WEB_SETTINGS_KEY_OFFLINE_WEBAPP_CACHE).toBool(); globalWebSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, offlineWebApplicationCachedEnabled); if (offlineWebApplicationCachedEnabled && settings.contains(WEB_SETTINGS_KEY_OFFLINE_WEBAPP_CACHE_PATH)) globalWebSettings->setOfflineWebApplicationCachePath(settings.value(WEB_SETTINGS_KEY_OFFLINE_WEBAPP_CACHE_PATH).toString()); } if (settings.contains(WEB_SETTINGS_KEY_LOCAL_STORAGE)) { bool localStorageEnabled = settings.value(WEB_SETTINGS_KEY_LOCAL_STORAGE).toBool(); globalWebSettings->setAttribute(QWebSettings::LocalStorageEnabled, localStorageEnabled); if (localStorageEnabled && settings.contains(WEB_SETTINGS_KEY_LOCAL_STORAGE_PATH)) globalWebSettings->setLocalStoragePath(settings.value(WEB_SETTINGS_KEY_LOCAL_STORAGE_PATH).toString()); } if (settings.contains(WEB_SETTINGS_KEY_LOCAL_CONTENT_CAN_ACCESS_REMOTE_URLS)) globalWebSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, settings.value(WEB_SETTINGS_KEY_LOCAL_CONTENT_CAN_ACCESS_REMOTE_URLS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_LOCAL_CONTENT_CAN_ACCESS_FILE_URLS)) globalWebSettings->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, settings.value(WEB_SETTINGS_KEY_LOCAL_CONTENT_CAN_ACCESS_FILE_URLS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_XSS_AUDITING)) globalWebSettings->setAttribute(QWebSettings::XSSAuditingEnabled, settings.value(WEB_SETTINGS_KEY_XSS_AUDITING).toBool()); if (settings.contains(WEB_SETTINGS_KEY_ACCELERATED_COMPOSITING)) globalWebSettings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, settings.value(WEB_SETTINGS_KEY_ACCELERATED_COMPOSITING).toBool()); if (settings.contains(WEB_SETTINGS_KEY_WEBGL)) globalWebSettings->setAttribute(QWebSettings::WebGLEnabled, settings.value(WEB_SETTINGS_KEY_WEBGL).toBool()); if (settings.contains(WEB_SETTINGS_KEY_TILE_BACKING_STORE)) globalWebSettings->setAttribute(QWebSettings::TiledBackingStoreEnabled, settings.value(WEB_SETTINGS_KEY_TILE_BACKING_STORE).toBool()); if (settings.contains(WEB_SETTINGS_KEY_FRAME_FLATTENING)) globalWebSettings->setAttribute(QWebSettings::FrameFlatteningEnabled, settings.value(WEB_SETTINGS_KEY_FRAME_FLATTENING).toBool()); if (settings.contains(WEB_SETTINGS_KEY_SITE_SPECIFIC_QUIRKS)) globalWebSettings->setAttribute(QWebSettings::SiteSpecificQuirksEnabled, settings.value(WEB_SETTINGS_KEY_SITE_SPECIFIC_QUIRKS).toBool()); if (settings.contains(WEB_SETTINGS_KEY_MAX_PAGES_IN_CACHE)) globalWebSettings->setMaximumPagesInCache(settings.value(WEB_SETTINGS_KEY_MAX_PAGES_IN_CACHE).toInt()); if (settings.contains(WEB_SETTINGS_KEY_OBJ_CACHE_CAPACITY_MIN) && settings.contains(WEB_SETTINGS_KEY_OBJ_CACHE_CAPACITY_MAX) && settings.contains(WEB_SETTINGS_KEY_OBJ_CACHE_CAPACITY_OVERALL)) { globalWebSettings->setObjectCacheCapacities( stringToBytes(settings.value(WEB_SETTINGS_KEY_OBJ_CACHE_CAPACITY_MIN).toString()), stringToBytes(settings.value(WEB_SETTINGS_KEY_OBJ_CACHE_CAPACITY_MAX).toString()), stringToBytes(settings.value(WEB_SETTINGS_KEY_OBJ_CACHE_CAPACITY_OVERALL).toString())); } if (settings.contains(WEB_SETTINGS_KEY_OFFLINE_STORAGE_QUOTA)) globalWebSettings->setOfflineStorageDefaultQuota(stringToBytes(settings.value(WEB_SETTINGS_KEY_OFFLINE_STORAGE_QUOTA).toString())); if (settings.contains(WEB_SETTINGS_KEY_OFFLINE_WEBAPP_QUOTA)) globalWebSettings->setOfflineStorageDefaultQuota(stringToBytes(settings.value(WEB_SETTINGS_KEY_OFFLINE_WEBAPP_QUOTA).toString())); QStringList supplementalPath; if (settings.contains(WEB_SETTINGS_KEY_PLUGIN_SUPPLEMENTAL_PATH)) supplementalPath.append(settings.value(WEB_SETTINGS_KEY_PLUGIN_SUPPLEMENTAL_PATH).toString()); if (settings.contains(WEB_SETTINGS_KEY_PLUGIN_SUPPLEMENTAL_USER_PATH)) supplementalPath.append(settings.value(WEB_SETTINGS_KEY_PLUGIN_SUPPLEMENTAL_USER_PATH).toString()); #if QT_VERSION < QT_VERSION_CHECK(5,0,0) if (!supplementalPath.isEmpty()) globalWebSettings->setPluginSupplementalPath(supplementalPath.join(QLatin1String(":"))); if (settings.contains(WEB_SETTINGS_KEY_FULLSCREEN_API)) globalWebSettings->setAttribute(QWebSettings::FullScreenEnabled, settings.value(WEB_SETTINGS_KEY_FULLSCREEN_API).toBool()); #endif return true; }
QtMainWindow::QtMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtMainWindow), webInspectorWindow(new QtWebInspector()), mainWindowCallback(NULL), cur_tbrp(0), m_alertDialog(0), m_LogicalDpiX(0), m_LogicalDpiY(0), firstShow(true), m_bFirstLoad(true), toolBarSeparatorWidth(0), m_proxy(QNetworkProxy(QNetworkProxy::DefaultProxy)), m_logView(0) //TODO: m_SyncStatusDlg { #if !defined(RHODES_EMULATOR) QPixmap icon(QCoreApplication::applicationDirPath().append(QDir::separator()).append("icon.png")); QApplication::setWindowIcon(icon); QApplication::setApplicationDisplayName(QString::fromStdString(RHOCONF().getString("title_text"))); QApplication::setApplicationName(QString::fromStdString(RHOCONF().getString("app_name"))); QApplication::setApplicationVersion(QString::fromStdString(RHOCONF().getString("app_version"))); QApplication::setOrganizationName(QString::fromStdString(RHOCONF().getString("org_name"))); #elif defined(OS_WINDOWS_DESKTOP) QPixmap icon(":/images/rho.png"); QApplication::setWindowIcon(icon); #endif QApplication::setStyle(new QtCustomStyle()); ui->setupUi(this); #ifdef OS_WINDOWS_DESKTOP ui->menuSimulate->clear(); ui->menuSimulate->setTitle("Navigate"); ui->menuSimulate->insertAction(0, ui->actionBack); #endif QWebSettings* qs = QWebSettings::globalSettings(); qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); qs->setOfflineStorageDefaultQuota(1024*1024*1024); rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR; qs->enablePersistentStorage(rs_dir.c_str()); this->ui->webView->setContextMenuPolicy(Qt::NoContextMenu); this->ui->webView->setPage(new QtWebPage()); this->ui->webView->setAttribute(Qt::WA_AcceptTouchEvents, false); setUpWebPage(this->ui->webView->page()); this->main_webView = this->ui->webView; this->main_webInspector = webInspectorWindow->webInspector(); this->cur_webInspector = this->main_webInspector; this->move(0,0); this->ui->toolBar->hide(); this->ui->toolBarRight->hide(); this->main_webView->hide(); //this->ui->centralWidget->hide(); //this->ui->centralWidget->setStyleSheet("background-color: yellow"); //this->ui->centralWidget->setStyleSheet("QWidget {background-image: url(test.jpg)}" ); #ifdef RHODES_EMULATOR int width = RHOSIMCONF().getInt("screen_width"); int height = RHOSIMCONF().getInt("screen_height"); #else int width = RHOCONF().getInt("screen_width"); int height = RHOCONF().getInt("screen_height"); #endif if ((width>0) && (height>0)) this->setSize(width, height); else if (width>0) this->setSize(width, this->height()); else if (height>0) this->setSize(this->width(), height); #if defined(RHODES_EMULATOR) // connecting WebInspector main_webInspector->setPage(ui->webView->page()); #endif #ifdef OS_SYMBIAN QWebViewKineticScroller *newScroller = new QWebViewKineticScroller(); newScroller->setWidget(this->ui->webView); QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView); #endif #if defined(RHODES_EMULATOR) webInspectorWindow->show(); #endif if (RHOCONF().isExist("http_proxy_host")) { setProxy(QString::fromStdString(RHOCONF().getString("http_proxy_host")), QString::fromStdString(RHOCONF().getString("http_proxy_port")), QString::fromStdString(RHOCONF().getString("http_proxy_login")), QString::fromStdString(RHOCONF().getString("http_proxy_password"))); } else { unsetProxy(); } }
bool Kludget::loadSettings(const KludgetInfo &i, bool loadPage) { info = i; #if 1 qDebug("path: %s", qPrintable(info.path)); qDebug("name: %s", qPrintable(info.name)); qDebug("config: %s", qPrintable(info.configFile)); qDebug("instance config: %s", qPrintable(info.instancePreferenceFile)); qDebug("storage: %s", qPrintable(info.storagePath)); qDebug("contentSrc: %s", qPrintable(info.contentSrc)); #endif if (!QFile::exists(info.configFile)) { KLog::log("Kludget::load fail"); KLog::log("config file not found"); return false; } window->setWindowTitle(info.id + ":" + QString::number(QApplication::applicationPid())); // access KDocument access; access.openDocument(info.storagePath + "/access.xml"); bool accessLocal = access.getValue("kludget/access/local", "0").toInt(); bool accessNetwork = access.getValue("kludget/access/network", "0").toInt(); bool accessPlugins = access.getValue("kludget/access/plugins", "0").toInt(); bool accessSystem = access.getValue("kludget/access/system", "0").toInt(); // engine KDocument engine; engine.openDocument(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/" + ENGINE_CONFIG_FILE); // instance settings settings->setPath(info.instancePreferenceFile); #if defined(WIN32) settings->loadPreferences(":resources/xml/widgetPreferences.xml"); #else settings->loadPreferences(":resources/xml/widgetPreferences_linux.xml"); #endif settings->loadPreferences(info.configFile); settings->loadPreferences(info.path + "/" + PREFERENCE_FILE); // position int x = settings->read("kludget/x", window->x()).toInt(); int y = settings->read("kludget/y", window->y()).toInt(); window->move(x, y); resize(settings->read("kludget/width", info.width).toInt(), settings->read("kludget/height", info.height).toInt()); window->setOpacity(settings->read("kludget/opacity", 200).toInt()); window->setIgnoreDrag(settings->read("kludget/ignoreDrag", "0").toInt()); window->setIgnoreMouse(settings->read("kludget/ignoreMouse", "0").toInt()); window->setWindowLevel(settings->read("kludget/windowLevel", "0").toInt()); window->setSnapToScreen(settings->read("kludget/snapToScreen", "0").toInt()); window->view()->setGrayed(settings->read("kludget/grayScaled", "0").toInt()); #if 0 window->view()->setTinted(settings->read("kludget/tinted", "0").toInt()); window->view()->setTintColor(QColor(settings->read("kludget/tintColor", "#c0c0c0").toString())); window->view()->setTintMode(settings->read("kludget/tintMode", "14").toInt()); #endif // zoom window->setZoomFactor(settings->read("kludget/zoom", 1).toDouble()); window->view()->page()->setViewportSize(window->view()->page()->viewportSize()); window->autoSize(true); setProperty("identifier", info.id); setProperty("instance", info.instance); setupContextMenu(); QWebSettings *webSettings = window->view()->page()->settings(); #if 0 webSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); webSettings->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); webSettings->setOfflineStoragePath(info.storagePath); webSettings->setOfflineStorageDefaultQuota(5000000); #endif webSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); webSettings->setAttribute(QWebSettings::PluginsEnabled, accessPlugins); webSettings->setWebGraphic(QWebSettings::MissingImageGraphic, QPixmap()); webSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); webSettings->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true); webSettings->setUserStyleSheetUrl(QUrl::fromLocalFile(":resources/style/widget.css")); // network settings KNetwork *net = KNetwork::instance(); net->loadSettings(); net->setAccess(accessNetwork, accessLocal, QUrl::fromLocalFile(QFileInfo(info.contentSrc).absolutePath())); // system settings system->setEnableCommands(accessSystem); if (engine.getValue("kludget/general/runInShell", "0").toInt()) system->setShellPath(engine.getValue("kludget/general/shellPath", "")); // plugin KLog::log("plugin"); if (!plugin.isLoaded() && accessPlugins && info.pluginPath != "") { plugin.setFileName(info.pluginPath + "/" + info.pluginExecutable); KLog::log(QString("loading %1").arg(plugin.fileName())); if (plugin.load()) { typedef void (*initWithWebView)(QWebView*); initWithWebView init = (initWithWebView)plugin.resolve("initWithWebView"); if (init) { init((QWebView*)window->view()); KLog::log(QString("plugin loaded %1").arg(plugin.fileName())); } } else { KLog::log(QString("unable to load %1").arg(plugin.fileName())); } } // drop window->view()->setAcceptDrops(true); if (loadPage) { window->hide(); QUrl url = QUrl::fromLocalFile(info.contentSrc); if (!QFile::exists(info.contentSrc)) { url = QUrl(info.contentSrc); if (url.scheme().toLower() == "http") { window->view()->load(url); } else if (info.contentHtml == "") { KLog::log("Kludget::load fail"); KLog::log(QString("content source not found. ") + info.contentSrc); return false; } } if (info.contentHtml != "") window->view()->setHtml(info.contentHtml); else window->view()->load(url); KLog::log(QString("Kludget::load ") + info.id); #if 0 QString defaultBg = info.path + "/Default.png"; if (QFile::exists(defaultBg)) //window->view()->setTransitionLayer(QImage(defaultBg)); #endif } ipcClient.connectToServer(); return true; }
static void configureHtml5OfflineStorage() { BEDROCK_PROVISIONING::BedrockProvisioning * provisioning = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning(); QWebSettings * globalSettings = QWebSettings::globalSettings(); // Enable all kinds of persistent storage, then fine-tune using // bedrock provisioning attributes. QWebSettings::enablePersistentStorage(); // Local and database storage (using the global javascript localStorage // and openDatabase items) is shared across pages and browser invocations, // but it tied to the domain of the page in which the javascript code is // running. This allows webpages hosted at, say, cnn.com to store data // using the same keys as webpages hosted at bbc.co.uk without conflict. // // Note that local and database storage is persisted in directories // beneath the application's private directory, so it is not shared // with other browsers. bool localStorageEnabled = provisioning->valueAsInt("Html5LocalStorage") != 0; bool databaseStorageEnabled = provisioning->valueAsInt("Html5DatabaseStorage") != 0; globalSettings->setAttribute( QWebSettings::LocalStorageEnabled, localStorageEnabled); globalSettings->setAttribute( QWebSettings::OfflineStorageDatabaseEnabled, databaseStorageEnabled); // There is no separate QWebSettings method to configure // the default quota for local storage databases. // It appears that both local storage and database storage // use the same default quota. if (localStorageEnabled || databaseStorageEnabled) { globalSettings->setOfflineStorageDefaultQuota( provisioning->valueAsInt64("Html5DatabaseStorageMaxSize")); } // The application cache allows websites to specify a manifest file in // the outermost <html> element. The manifest file defines which files // may be stored at the client and used when the network is inaccessible. // // Webkit stores the application cache in a single SQLite database // named ApplicationCache.db. By default this database is located // in the application's private directory, so it is not shared with // other browsers. bool applicationCacheEnabled = provisioning->valueAsInt("Html5ApplicationCache") != 0; globalSettings->setAttribute( QWebSettings::OfflineWebApplicationCacheEnabled, applicationCacheEnabled); if (applicationCacheEnabled) { globalSettings->setOfflineWebApplicationCacheQuota( provisioning->valueAsInt64("Html5ApplicationCacheMaxSize")); } }