当前位置: 首页>>代码示例>>C++>>正文


C++ QWebSettings::setMaximumPagesInCache方法代码示例

本文整理汇总了C++中QWebSettings::setMaximumPagesInCache方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebSettings::setMaximumPagesInCache方法的具体用法?C++ QWebSettings::setMaximumPagesInCache怎么用?C++ QWebSettings::setMaximumPagesInCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWebSettings的用法示例。


在下文中一共展示了QWebSettings::setMaximumPagesInCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pal

BrowserWidget::BrowserWidget(QWidget *parent, QSettings *settings, QObject *jsProxy):
    QGraphicsView(parent),
    scene(0),
    jsProxy(jsProxy),
    zoomStepFactor              (settings->value("browser/zoom_step_factor").toFloat()),
    homePageUrl                 (settings->value("browser/home_page_url").toString()),
    errorPageUrl                (settings->value("browser/error_url").toString()),
    unsupportedPageUrl          (settings->value("browser/unsupported_url").toString()),
    pagesInFastHistory          (settings->value("browser/pages_in_fast_history").toInt()),
    freezeForMsecsWhenZooming   (settings->value("browser/freeze_time_when_zoom_ms").toInt()),
    freezeForMsecsWhenDragging  (settings->value("browser/freeze_time_when_drag_ms").toInt()),
    maxDragDistanceToEmitClick  (settings->value("browser/click_if_drag_at_most_px").toInt()),
    dragDistance(maxDragDistanceToEmitClick)
{
    
    webView = new QGraphicsWebView();
    webPage = new BrowserWebPage();
    webView->setPage(webPage);
    
    newScene();
    
    // visual settings
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setFrameShape(QFrame::NoFrame);
    setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
    webView->setResizesToContents(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    QPalette pal(palette());
    pal.setColor(QPalette::Base, Qt::white);
    setPalette(pal);

    // web settings
    QWebSettings *globalSettings = QWebSettings::globalSettings();
    globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
    globalSettings->setAttribute(QWebSettings::TiledBackingStoreEnabled, true);
    globalSettings->setMaximumPagesInCache(pagesInFastHistory);
    webView->page()->history()->setMaximumItemCount(pagesInFastHistory);
    webView->page()->setForwardUnsupportedContent(true);
    
    // connects
    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanging(QUrl)));
    connect(webView, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
    connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(newScene()));
    connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
    connect(webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
    connect(webView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
                                                 this, SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&))
    );
    connect(&unfreezeTimer, SIGNAL(timeout()), this, SLOT(unfreezeTiles()));
    unfreezeTimer.setSingleShot(true);
    
    connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptBinding()));
    addJavaScriptBinding();
}
开发者ID:gabrys,项目名称:ffbrowser,代码行数:55,代码来源:browserwidget.cpp

示例2: initWebSettings


//.........这里部分代码省略.........
        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;
}
开发者ID:ericblade-owo,项目名称:WebKitSupplemental,代码行数:101,代码来源:weboswebsettings.cpp


注:本文中的QWebSettings::setMaximumPagesInCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。