diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/browser/browserapplication.cpp index 89fc698a73fa2d322e397fcd4136e1d6faa081eb..9ea9fbfcf5b79989a15c67e5114e39b45808923f 100644 --- a/examples/webenginewidgets/browser/browserapplication.cpp +++ b/examples/webenginewidgets/browser/browserapplication.cpp @@ -66,9 +66,7 @@ #include <QtNetwork/QNetworkProxy> #include <QtNetwork/QSslSocket> -#if defined(QWEBENGINESETTINGS) #include <QWebEngineSettings> -#endif #include <QtCore/QDebug> @@ -203,10 +201,10 @@ void BrowserApplication::quitBrowser() */ void BrowserApplication::postLaunch() { -#if defined(QWEBENGINESETTINGS) QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation); if (directory.isEmpty()) directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); +#if defined(QWEBENGINESETTINGS_PATHS) QWebEngineSettings::setIconDatabasePath(directory); QWebEngineSettings::setOfflineStoragePath(directory); #endif @@ -228,7 +226,6 @@ void BrowserApplication::postLaunch() void BrowserApplication::loadSettings() { -#if defined(QWEBENGINESETTINGS) QSettings settings; settings.beginGroup(QLatin1String("websettings")); @@ -248,15 +245,17 @@ void BrowserApplication::loadSettings() defaultSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, fixedFont.pointSize()); defaultSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool()); + +#if defined(QTWEBENGINE_PLUGINS) defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool()); +#endif +#if defined(QTWEBENGINE_USERSTYLESHEET) QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl(); defaultSettings->setUserStyleSheetUrl(url); - - defaultSettings->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true); +#endif settings.endGroup(); -#endif } QList<BrowserMainWindow*> BrowserApplication::mainWindows() @@ -278,7 +277,7 @@ void BrowserApplication::clean() void BrowserApplication::saveSession() { -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings(); if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) return; @@ -466,7 +465,7 @@ BookmarksManager *BrowserApplication::bookmarksManager() QIcon BrowserApplication::icon(const QUrl &url) const { -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_ICONDATABASE) QIcon icon = QWebEngineSettings::iconForUrl(url); if (!icon.isNull()) return icon.pixmap(16, 16); diff --git a/examples/webenginewidgets/browser/browsermainwindow.cpp b/examples/webenginewidgets/browser/browsermainwindow.cpp index da026edf70fa9f79848814aa36b59562a7ff156b..85b16580f60dc64612bc810cc4c06a0322661090 100644 --- a/examples/webenginewidgets/browser/browsermainwindow.cpp +++ b/examples/webenginewidgets/browser/browsermainwindow.cpp @@ -68,6 +68,7 @@ #include <QtWidgets/QInputDialog> #include <QWebEngineHistory> +#include <QWebEngineSettings> #include <QtCore/QDebug> @@ -295,7 +296,7 @@ void BrowserMainWindow::setupMenu() fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); fileMenu->addSeparator(); #endif -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); action->setCheckable(true); fileMenu->addSeparator(); @@ -380,12 +381,6 @@ void BrowserMainWindow::setupMenu() viewMenu->addAction(tr("Zoom &In"), this, SLOT(slotViewZoomIn()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); viewMenu->addAction(tr("Zoom &Out"), this, SLOT(slotViewZoomOut()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); viewMenu->addAction(tr("Reset &Zoom"), this, SLOT(slotViewResetZoom()), QKeySequence(Qt::CTRL | Qt::Key_0)); -#if defined(QWEBENGINESETTINGS) - QAction *zoomTextOnlyAction = viewMenu->addAction(tr("Zoom &Text Only")); - connect(zoomTextOnlyAction, SIGNAL(toggled(bool)), this, SLOT(slotViewZoomTextOnly(bool))); - zoomTextOnlyAction->setCheckable(true); - zoomTextOnlyAction->setChecked(false); -#endif viewMenu->addSeparator(); viewMenu->addAction(tr("Page S&ource"), this, SLOT(slotViewPageSource()), tr("Ctrl+Alt+U")); @@ -701,7 +696,7 @@ void BrowserMainWindow::printRequested(QWebEngineFrame *frame) void BrowserMainWindow::slotPrivateBrowsing() { -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QWebEngineSettings *settings = QWebEngineSettings::globalSettings(); bool pb = settings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled); if (!pb) { @@ -800,15 +795,6 @@ void BrowserMainWindow::slotViewResetZoom() currentTab()->setZoomFactor(1.0); } -void BrowserMainWindow::slotViewZoomTextOnly(bool enable) -{ -#if defined(QWEBENGINESETTINGS) - if (!currentTab()) - return; - currentTab()->page()->settings()->setAttribute(QWebEngineSettings::ZoomTextOnly, enable); -#endif -} - void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) { if (makeFullScreen) { diff --git a/examples/webenginewidgets/browser/browsermainwindow.h b/examples/webenginewidgets/browser/browsermainwindow.h index 4dd1945d0d768b5d5c9efa23fbf9a817b7dfa946..6743d8e7900d00e21c68c1a3d62b749e11cd27eb 100644 --- a/examples/webenginewidgets/browser/browsermainwindow.h +++ b/examples/webenginewidgets/browser/browsermainwindow.h @@ -107,7 +107,6 @@ private slots: void slotViewZoomIn(); void slotViewZoomOut(); void slotViewResetZoom(); - void slotViewZoomTextOnly(bool enable); void slotViewToolbar(); void slotViewBookmarksBar(); void slotViewStatusbar(); diff --git a/examples/webenginewidgets/browser/downloadmanager.cpp b/examples/webenginewidgets/browser/downloadmanager.cpp index b5fdcb18503cc377c4bf90aa454e72417bbaef77..1ed27e6420f8a53e7d4d91eddf9f2f3160640a78 100644 --- a/examples/webenginewidgets/browser/downloadmanager.cpp +++ b/examples/webenginewidgets/browser/downloadmanager.cpp @@ -57,9 +57,7 @@ #include <QtCore/QDebug> -#if defined(QWEBENGINESETTINGS) #include <QWebEngineSettings> -#endif /*! DownloadItem is a widget that is displayed in the download manager list. @@ -431,7 +429,7 @@ void DownloadManager::updateRow() downloadsView->setRowHeight(row, item->minimumSizeHint().height()); bool remove = false; -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings(); if (!item->downloading() && globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) diff --git a/examples/webenginewidgets/browser/history.cpp b/examples/webenginewidgets/browser/history.cpp index caf6a4aacad6a736b2224cc17ebe182e44f87fe0..a2c25ee1276d6e12011ce596af56dd5846ddcec8 100644 --- a/examples/webenginewidgets/browser/history.cpp +++ b/examples/webenginewidgets/browser/history.cpp @@ -62,9 +62,7 @@ #if defined(QWEBENGINEHISTORYINTERFACE) #include <QWebEngineHistoryInterface> #endif -#if defined(QWEBENGINESETTINGS) #include <QWebEngineSettings> -#endif #include <QtCore/QDebug> @@ -189,7 +187,7 @@ void HistoryManager::checkForExpired() void HistoryManager::addHistoryItem(const HistoryItem &item) { -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings(); if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) return; diff --git a/examples/webenginewidgets/browser/settings.cpp b/examples/webenginewidgets/browser/settings.cpp index 6838c19aa3661eaebfa1eb7fbaeb6c5d9f71f150..49b7709e0000bad796fef8934dfe76bc11f6dad0 100644 --- a/examples/webenginewidgets/browser/settings.cpp +++ b/examples/webenginewidgets/browser/settings.cpp @@ -43,7 +43,9 @@ #include "browserapplication.h" #include "browsermainwindow.h" +#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) #include "cookiejar.h" +#endif #include "history.h" #include "networkaccessmanager.h" #include "webview.h" @@ -68,7 +70,6 @@ SettingsDialog::SettingsDialog(QWidget *parent) void SettingsDialog::loadDefaults() { -#if defined(QWEBENGINESETTINGS) QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebEngineSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFontSize); @@ -83,13 +84,13 @@ void SettingsDialog::loadDefaults() downloadsLocation->setText(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); enableJavascript->setChecked(defaultSettings->testAttribute(QWebEngineSettings::JavascriptEnabled)); +#if defined(QTWEBENGINE_PLUGINS) enablePlugins->setChecked(defaultSettings->testAttribute(QWebEngineSettings::PluginsEnabled)); #endif } void SettingsDialog::loadFromSettings() { -#if defined(QWEBENGINESETTINGS) QSettings settings; settings.beginGroup(QLatin1String("MainWindow")); QString defaultHome = QLatin1String("http://qt-project.org/"); @@ -135,6 +136,7 @@ void SettingsDialog::loadFromSettings() userStyleSheet->setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString()); settings.endGroup(); +#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) // Privacy settings.beginGroup(QLatin1String("cookies")); @@ -172,7 +174,7 @@ void SettingsDialog::loadFromSettings() break; } settings.endGroup(); - +#endif // Proxy settings.beginGroup(QLatin1String("proxy")); @@ -183,12 +185,10 @@ void SettingsDialog::loadFromSettings() proxyUserName->setText(settings.value(QLatin1String("userName")).toString()); proxyPassword->setText(settings.value(QLatin1String("password")).toString()); settings.endGroup(); -#endif } void SettingsDialog::saveToSettings() { -#if defined(QWEBENGINESETTINGS) QSettings settings; settings.beginGroup(QLatin1String("MainWindow")); settings.setValue(QLatin1String("home"), homeLineEdit->text()); @@ -225,6 +225,7 @@ void SettingsDialog::saveToSettings() settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString)); settings.endGroup(); +#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) //Privacy settings.beginGroup(QLatin1String("cookies")); @@ -262,6 +263,7 @@ void SettingsDialog::saveToSettings() settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(keepPolicy))); settings.endGroup(); +#endif // proxy settings.beginGroup(QLatin1String("proxy")); @@ -274,10 +276,11 @@ void SettingsDialog::saveToSettings() settings.endGroup(); BrowserApplication::instance()->loadSettings(); +#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) BrowserApplication::networkAccessManager()->loadSettings(); BrowserApplication::cookieJar()->loadSettings(); - BrowserApplication::historyManager()->loadSettings(); #endif + BrowserApplication::historyManager()->loadSettings(); } void SettingsDialog::accept() diff --git a/examples/webenginewidgets/browser/tabwidget.cpp b/examples/webenginewidgets/browser/tabwidget.cpp index 3cb17366fdd76e4d2a44e9724f1e931fe9c5eb60..74fb05b461c870d4691e6018513ab31f10a0e464 100644 --- a/examples/webenginewidgets/browser/tabwidget.cpp +++ b/examples/webenginewidgets/browser/tabwidget.cpp @@ -574,7 +574,7 @@ void TabWidget::closeTab(int index) #endif hasFocus = tab->hasFocus(); -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings(); if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) #endif diff --git a/examples/webenginewidgets/browser/toolbarsearch.cpp b/examples/webenginewidgets/browser/toolbarsearch.cpp index 0a94b6dba0b13b473419b3011f4be39433d23ead..eb699e60c9b65eb1ab4a7af058e33c5b16dba6b1 100644 --- a/examples/webenginewidgets/browser/toolbarsearch.cpp +++ b/examples/webenginewidgets/browser/toolbarsearch.cpp @@ -50,9 +50,7 @@ #include <QtWidgets/QMenu> #include <QtCore/QStringListModel> -#if defined(QWEBENGINESETTINGS) #include <QWebEngineSettings> -#endif /* ToolbarSearch is a very basic search widget that also contains a small history. @@ -111,7 +109,7 @@ void ToolbarSearch::searchNow() if (newList.size() >= m_maxSavedSearches) newList.removeLast(); -#if defined(QWEBENGINESETTINGS) +#if defined(QTWEBENGINE_PRIVATEBROWSING) QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings(); if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) #endif