void SettingsDialog::loadDefaults() { QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebEngineSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFontSize); standardFont = QFont(standardFontFamily, standardFontSize); standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); QString fixedFontFamily = defaultSettings->fontFamily(QWebEngineSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize); fixedFont = QFont(fixedFontFamily, fixedFontSize); fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); downloadsLocation->setText(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); enableJavascript->setChecked(defaultSettings->testAttribute(QWebEngineSettings::JavascriptEnabled)); #if defined(QTWEBENGINE_PLUGINS) enablePlugins->setChecked(defaultSettings->testAttribute(QWebEngineSettings::PluginsEnabled)); #endif enableScrollAnimator->setChecked(defaultSettings->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)); persistentDataPath->setText(QWebEngineProfile::defaultProfile()->persistentStoragePath()); sessionCookiesCombo->setCurrentIndex(QWebEngineProfile::defaultProfile()->persistentCookiesPolicy()); httpUserAgent->setText(QWebEngineProfile::defaultProfile()->httpUserAgent()); }
void BrowserApplication::loadSettings() { #if defined(QWEBENGINESETTINGS) QSettings settings; settings.beginGroup(QLatin1String("websettings")); QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebEngineSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFontSize); QFont standardFont = QFont(standardFontFamily, standardFontSize); standardFont = qvariant_cast<QFont>(settings.value(QLatin1String("standardFont"), standardFont)); defaultSettings->setFontFamily(QWebEngineSettings::StandardFont, standardFont.family()); defaultSettings->setFontSize(QWebEngineSettings::DefaultFontSize, standardFont.pointSize()); QString fixedFontFamily = defaultSettings->fontFamily(QWebEngineSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize); QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); fixedFont = qvariant_cast<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont)); defaultSettings->setFontFamily(QWebEngineSettings::FixedFont, fixedFont.family()); defaultSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, fixedFont.pointSize()); defaultSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool()); defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool()); QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl(); defaultSettings->setUserStyleSheetUrl(url); defaultSettings->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true); settings.endGroup(); #endif }
void BrowserApplication::loadSettings() { QSettings settings; settings.beginGroup(QLatin1String("websettings")); QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings(); QWebEngineProfile *defaultProfile = QWebEngineProfile::defaultProfile(); QString standardFontFamily = defaultSettings->fontFamily(QWebEngineSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFontSize); QFont standardFont = QFont(standardFontFamily, standardFontSize); standardFont = qvariant_cast<QFont>(settings.value(QLatin1String("standardFont"), standardFont)); defaultSettings->setFontFamily(QWebEngineSettings::StandardFont, standardFont.family()); defaultSettings->setFontSize(QWebEngineSettings::DefaultFontSize, standardFont.pointSize()); QString fixedFontFamily = defaultSettings->fontFamily(QWebEngineSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize); QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); fixedFont = qvariant_cast<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont)); defaultSettings->setFontFamily(QWebEngineSettings::FixedFont, fixedFont.family()); defaultSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, fixedFont.pointSize()); defaultSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool()); defaultSettings->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, settings.value(QLatin1String("enableScrollAnimator"), true).toBool()); defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool()); defaultSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); if (! sawStyleSheetCommandLineOption) { m_stylesheetFilename = settings.value(QLatin1String("userStyleSheetFile")).toString(); m_stylesheetRules = settings.value(QLatin1String("userStyleSheetRules")).toString(); emit reloadStyleSheet(); } if (! m_stylesheetFilename.isEmpty()) { m_fileSystemWatcher->addPath(m_stylesheetFilename); connect(m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, &BrowserApplication::reloadStylesheet); } defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString()); defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString()); settings.endGroup(); settings.beginGroup(QLatin1String("proxy")); QNetworkProxy proxy; if (settings.value(QLatin1String("enabled"), false).toBool()) { if (settings.value(QLatin1String("type"), 0).toInt() == 0) proxy = QNetworkProxy::Socks5Proxy; else proxy = QNetworkProxy::HttpProxy; proxy.setHostName(settings.value(QLatin1String("hostName")).toString()); proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt()); proxy.setUser(settings.value(QLatin1String("userName")).toString()); proxy.setPassword(settings.value(QLatin1String("password")).toString()); } QNetworkProxy::setApplicationProxy(proxy); settings.endGroup(); }
QFont WebEngineHelpViewer::viewerFont() const { QWebEngineSettings *webSettings = m_widget->settings(); return QFont(webSettings->fontFamily(QWebEngineSettings::StandardFont), webSettings->fontSize(QWebEngineSettings::DefaultFontSize)); }