summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-08-18 18:19:48 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-08-19 10:16:04 +0200
commitafd4c43bcef467da03d89d5468742a1dcbfa04fa (patch)
tree40e76f4472d79c2365f63c8af66f164e2bafbbb1
parent89c41f52f6d90d9cad2b054908ef51238c6612a9 (diff)
Re-enable some qwebenginesetting features in browser example
We now have the QWebEngineSettings class and can re-enable the features that were previously disabled in the browser that depended on it. Change-Id: I525dd1a4b5c380ad4c6060f276440e069f633897 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--examples/webenginewidgets/browser/browserapplication.cpp17
-rw-r--r--examples/webenginewidgets/browser/browsermainwindow.cpp20
-rw-r--r--examples/webenginewidgets/browser/browsermainwindow.h1
-rw-r--r--examples/webenginewidgets/browser/downloadmanager.cpp4
-rw-r--r--examples/webenginewidgets/browser/history.cpp4
-rw-r--r--examples/webenginewidgets/browser/settings.cpp15
-rw-r--r--examples/webenginewidgets/browser/tabwidget.cpp2
-rw-r--r--examples/webenginewidgets/browser/toolbarsearch.cpp4
8 files changed, 24 insertions, 43 deletions
diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/browser/browserapplication.cpp
index 89fc698a..9ea9fbfc 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 da026edf..85b16580 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 4dd1945d..6743d8e7 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 b5fdcb18..1ed27e64 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 caf6a4aa..a2c25ee1 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 6838c19a..49b7709e 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 3cb17366..74fb05b4 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 0a94b6db..eb699e60 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