summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-08-06 17:45:07 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-08-20 18:15:21 +0200
commit68f3331b98d4d9996732117549cbdf4ea80cac70 (patch)
tree1a43dcad4e6f9f96852e113413cba065f9fd283b /examples
parentccfeac7d1e474408e2cae169714326f6198eb17c (diff)
demo browser: Fix the compilation with QtWebEngine.
This makes the demo compile, but not link since most of the methods aren't implemented yet. Also disable downloads and printing since they require a bit more work to instead use the page directly. Change-Id: I59adfe07fda077c6909f70f12800a4cfa6a6dad2 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/widgets/browser/bookmarks.cpp2
-rw-r--r--examples/widgets/browser/browser.pro2
-rw-r--r--examples/widgets/browser/browserapplication.cpp38
-rw-r--r--examples/widgets/browser/browsermainwindow.cpp55
-rw-r--r--examples/widgets/browser/browsermainwindow.h4
-rw-r--r--examples/widgets/browser/cookiejar.cpp10
-rw-r--r--examples/widgets/browser/downloadmanager.cpp6
-rw-r--r--examples/widgets/browser/history.cpp14
-rw-r--r--examples/widgets/browser/history.h4
-rw-r--r--examples/widgets/browser/settings.cpp16
-rw-r--r--examples/widgets/browser/tabwidget.cpp16
-rw-r--r--examples/widgets/browser/tabwidget.h16
-rw-r--r--examples/widgets/browser/toolbarsearch.cpp6
-rw-r--r--examples/widgets/browser/webview.cpp54
-rw-r--r--examples/widgets/browser/webview.h10
15 files changed, 127 insertions, 126 deletions
diff --git a/examples/widgets/browser/bookmarks.cpp b/examples/widgets/browser/bookmarks.cpp
index be4127b03..adc35bd50 100644
--- a/examples/widgets/browser/bookmarks.cpp
+++ b/examples/widgets/browser/bookmarks.cpp
@@ -58,7 +58,7 @@
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QToolButton>
-#include <QWebSettings>
+#include <QWebEngineSettings>
#include <QtCore/QDebug>
diff --git a/examples/widgets/browser/browser.pro b/examples/widgets/browser/browser.pro
index 97559ed3d..8de546daf 100644
--- a/examples/widgets/browser/browser.pro
+++ b/examples/widgets/browser/browser.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = browser
-QT += webkitwidgets network widgets printsupport
+QT += webenginewidgets network widgets printsupport
qtHaveModule(uitools):!embedded: QT += uitools
else: DEFINES += QT_NO_UITOOLS
diff --git a/examples/widgets/browser/browserapplication.cpp b/examples/widgets/browser/browserapplication.cpp
index 5230e58f9..18b1d0d75 100644
--- a/examples/widgets/browser/browserapplication.cpp
+++ b/examples/widgets/browser/browserapplication.cpp
@@ -66,7 +66,7 @@
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QSslSocket>
-#include <QWebSettings>
+#include <QWebEngineSettings>
#include <QtCore/QDebug>
@@ -204,8 +204,8 @@ void BrowserApplication::postLaunch()
QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
if (directory.isEmpty())
directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName();
- QWebSettings::setIconDatabasePath(directory);
- QWebSettings::setOfflineStoragePath(directory);
+ QWebEngineSettings::setIconDatabasePath(directory);
+ QWebEngineSettings::setOfflineStoragePath(directory);
setWindowIcon(QIcon(QLatin1String(":browser.svg")));
@@ -227,28 +227,28 @@ void BrowserApplication::loadSettings()
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
- QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
- int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
+ 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(QWebSettings::StandardFont, standardFont.family());
- defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize());
+ defaultSettings->setFontFamily(QWebEngineSettings::StandardFont, standardFont.family());
+ defaultSettings->setFontSize(QWebEngineSettings::DefaultFontSize, standardFont.pointSize());
- QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
- int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
+ 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(QWebSettings::FixedFont, fixedFont.family());
- defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize());
+ defaultSettings->setFontFamily(QWebEngineSettings::FixedFont, fixedFont.family());
+ defaultSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, fixedFont.pointSize());
- defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
+ 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(QWebSettings::DnsPrefetchEnabled, true);
+ defaultSettings->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
settings.endGroup();
}
@@ -272,8 +272,8 @@ void BrowserApplication::clean()
void BrowserApplication::saveSession()
{
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
+ if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
return;
clean();
@@ -434,7 +434,7 @@ HistoryManager *BrowserApplication::historyManager()
{
if (!s_historyManager) {
s_historyManager = new HistoryManager();
- QWebHistoryInterface::setDefaultInterface(s_historyManager);
+ QWebEngineHistoryInterface::setDefaultInterface(s_historyManager);
}
return s_historyManager;
}
@@ -449,7 +449,7 @@ BookmarksManager *BrowserApplication::bookmarksManager()
QIcon BrowserApplication::icon(const QUrl &url) const
{
- QIcon icon = QWebSettings::iconForUrl(url);
+ QIcon icon = QWebEngineSettings::iconForUrl(url);
if (!icon.isNull())
return icon.pixmap(16, 16);
if (m_defaultIcon.isNull())
diff --git a/examples/widgets/browser/browsermainwindow.cpp b/examples/widgets/browser/browsermainwindow.cpp
index ae9896c67..7bddbb2b7 100644
--- a/examples/widgets/browser/browsermainwindow.cpp
+++ b/examples/widgets/browser/browsermainwindow.cpp
@@ -67,8 +67,7 @@
#include <QtWidgets/QToolBar>
#include <QtWidgets/QInputDialog>
-#include <QWebFrame>
-#include <QWebHistory>
+#include <QWebEngineHistory>
#include <QtCore/QDebug>
@@ -123,8 +122,8 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags)
m_autoSaver, SLOT(changeOccurred()));
connect(m_tabWidget, SIGNAL(geometryChangeRequested(QRect)),
this, SLOT(geometryChangeRequested(QRect)));
- connect(m_tabWidget, SIGNAL(printRequested(QWebFrame*)),
- this, SLOT(printRequested(QWebFrame*)));
+ connect(m_tabWidget, SIGNAL(printRequested(QWebEngineFrame*)),
+ this, SLOT(printRequested(QWebEngineFrame*)));
connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)),
menuBar(), SLOT(setVisible(bool)));
connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)),
@@ -288,20 +287,20 @@ void BrowserMainWindow::setupMenu()
QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
QAction *m_undo = editMenu->addAction(tr("&Undo"));
m_undo->setShortcuts(QKeySequence::Undo);
- m_tabWidget->addWebAction(m_undo, QWebPage::Undo);
+ m_tabWidget->addWebAction(m_undo, QWebEnginePage::Undo);
QAction *m_redo = editMenu->addAction(tr("&Redo"));
m_redo->setShortcuts(QKeySequence::Redo);
- m_tabWidget->addWebAction(m_redo, QWebPage::Redo);
+ m_tabWidget->addWebAction(m_redo, QWebEnginePage::Redo);
editMenu->addSeparator();
QAction *m_cut = editMenu->addAction(tr("Cu&t"));
m_cut->setShortcuts(QKeySequence::Cut);
- m_tabWidget->addWebAction(m_cut, QWebPage::Cut);
+ m_tabWidget->addWebAction(m_cut, QWebEnginePage::Cut);
QAction *m_copy = editMenu->addAction(tr("&Copy"));
m_copy->setShortcuts(QKeySequence::Copy);
- m_tabWidget->addWebAction(m_copy, QWebPage::Copy);
+ m_tabWidget->addWebAction(m_copy, QWebEnginePage::Copy);
QAction *m_paste = editMenu->addAction(tr("&Paste"));
m_paste->setShortcuts(QKeySequence::Paste);
- m_tabWidget->addWebAction(m_paste, QWebPage::Paste);
+ m_tabWidget->addWebAction(m_paste, QWebEnginePage::Paste);
editMenu->addSeparator();
QAction *m_find = editMenu->addAction(tr("&Find"));
@@ -348,11 +347,11 @@ void BrowserMainWindow::setupMenu()
shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period));
shortcuts.append(Qt::Key_Escape);
m_stop->setShortcuts(shortcuts);
- m_tabWidget->addWebAction(m_stop, QWebPage::Stop);
+ m_tabWidget->addWebAction(m_stop, QWebEnginePage::Stop);
m_reload = viewMenu->addAction(tr("Reload Page"));
m_reload->setShortcuts(QKeySequence::Refresh);
- m_tabWidget->addWebAction(m_reload, QWebPage::Reload);
+ m_tabWidget->addWebAction(m_reload, QWebEnginePage::Reload);
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));
@@ -378,12 +377,12 @@ void BrowserMainWindow::setupMenu()
QList<QAction*> historyActions;
m_historyBack = new QAction(tr("Back"), this);
- m_tabWidget->addWebAction(m_historyBack, QWebPage::Back);
+ m_tabWidget->addWebAction(m_historyBack, QWebEnginePage::Back);
m_historyBack->setShortcuts(QKeySequence::Back);
m_historyBack->setIconVisibleInMenu(false);
m_historyForward = new QAction(tr("Forward"), this);
- m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward);
+ m_tabWidget->addWebAction(m_historyForward, QWebEnginePage::Forward);
m_historyForward->setShortcuts(QKeySequence::Forward);
m_historyForward->setIconVisibleInMenu(false);
@@ -647,8 +646,9 @@ void BrowserMainWindow::slotFilePrint()
printRequested(currentTab()->page()->mainFrame());
}
-void BrowserMainWindow::printRequested(QWebFrame *frame)
+void BrowserMainWindow::printRequested(QWebEngineFrame *frame)
{
+#if defined(QTWEBENGINE_FEATURE_PRINT)
#ifndef QT_NO_PRINTDIALOG
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
@@ -657,12 +657,13 @@ void BrowserMainWindow::printRequested(QWebFrame *frame)
return;
frame->print(&printer);
#endif
+#endif
}
void BrowserMainWindow::slotPrivateBrowsing()
{
- QWebSettings *settings = QWebSettings::globalSettings();
- bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled);
+ QWebEngineSettings *settings = QWebEngineSettings::globalSettings();
+ bool pb = settings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled);
if (!pb) {
QString title = tr("Are you sure you want to turn on private browsing?");
QString text = tr("<b>%1</b><br><br>When private browsing in turned on,"
@@ -678,10 +679,10 @@ void BrowserMainWindow::slotPrivateBrowsing()
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
if (button == QMessageBox::Ok) {
- settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
+ settings->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, true);
}
} else {
- settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
+ settings->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, false);
QList<BrowserMainWindow*> windows = BrowserApplication::instance()->mainWindows();
for (int i = 0; i < windows.count(); ++i) {
@@ -735,7 +736,7 @@ void BrowserMainWindow::slotEditFindPrevious()
{
if (!currentTab() && !m_lastSearch.isEmpty())
return;
- currentTab()->findText(m_lastSearch, QWebPage::FindBackward);
+ currentTab()->findText(m_lastSearch, QWebEnginePage::FindBackward);
}
void BrowserMainWindow::slotViewZoomIn()
@@ -763,7 +764,7 @@ void BrowserMainWindow::slotViewZoomTextOnly(bool enable)
{
if (!currentTab())
return;
- currentTab()->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, enable);
+ currentTab()->page()->settings()->setAttribute(QWebEngineSettings::ZoomTextOnly, enable);
}
void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen)
@@ -784,7 +785,7 @@ void BrowserMainWindow::slotViewPageSource()
if (!currentTab())
return;
- QString markup = currentTab()->page()->mainFrame()->toHtml();
+ QString markup = currentTab()->page()->toHtml();
QPlainTextEdit *view = new QPlainTextEdit(markup);
view->setWindowTitle(tr("Page Source of %1").arg(currentTab()->title()));
view->setMinimumWidth(640);
@@ -808,7 +809,7 @@ void BrowserMainWindow::slotWebSearch()
void BrowserMainWindow::slotToggleInspector(bool enable)
{
- QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable);
+ QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, enable);
if (enable) {
int result = QMessageBox::question(this, tr("Web Inspector"),
tr("The web inspector will only work correctly for pages that were loaded after enabling.\n"
@@ -868,10 +869,10 @@ void BrowserMainWindow::slotAboutToShowBackMenu()
m_historyBackMenu->clear();
if (!currentTab())
return;
- QWebHistory *history = currentTab()->history();
+ QWebEngineHistory *history = currentTab()->history();
int historyCount = history->count();
for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) {
- QWebHistoryItem item = history->backItems(history->count()).at(i);
+ QWebEngineHistoryItem item = history->backItems(history->count()).at(i);
QAction *action = new QAction(this);
action->setData(-1*(historyCount-i-1));
QIcon icon = BrowserApplication::instance()->icon(item.url());
@@ -886,10 +887,10 @@ void BrowserMainWindow::slotAboutToShowForwardMenu()
m_historyForwardMenu->clear();
if (!currentTab())
return;
- QWebHistory *history = currentTab()->history();
+ QWebEngineHistory *history = currentTab()->history();
int historyCount = history->count();
for (int i = 0; i < history->forwardItems(history->count()).count(); ++i) {
- QWebHistoryItem item = history->forwardItems(historyCount).at(i);
+ QWebEngineHistoryItem item = history->forwardItems(historyCount).at(i);
QAction *action = new QAction(this);
action->setData(historyCount-i);
QIcon icon = BrowserApplication::instance()->icon(item.url());
@@ -935,7 +936,7 @@ void BrowserMainWindow::slotShowWindow()
void BrowserMainWindow::slotOpenActionUrl(QAction *action)
{
int offset = action->data().toInt();
- QWebHistory *history = currentTab()->history();
+ QWebEngineHistory *history = currentTab()->history();
if (offset < 0)
history->goToItem(history->backItems(-1*offset).first()); // back
else if (offset > 0)
diff --git a/examples/widgets/browser/browsermainwindow.h b/examples/widgets/browser/browsermainwindow.h
index a6905e0bc..2e59a73c8 100644
--- a/examples/widgets/browser/browsermainwindow.h
+++ b/examples/widgets/browser/browsermainwindow.h
@@ -49,7 +49,7 @@
class AutoSaver;
class BookmarksToolBar;
class ChaseWidget;
-class QWebFrame;
+class QWebEngineFrame;
class TabWidget;
class ToolbarSearch;
class WebView;
@@ -124,7 +124,7 @@ private slots:
void slotShowWindow();
void slotSwapFocus();
- void printRequested(QWebFrame *frame);
+ void printRequested(QWebEngineFrame *frame);
void geometryChangeRequested(const QRect &geometry);
void updateToolbarActionText(bool visible);
void updateBookmarksToolbarActionText(bool visible);
diff --git a/examples/widgets/browser/cookiejar.cpp b/examples/widgets/browser/cookiejar.cpp
index 28eae7c89..0b94d9903 100644
--- a/examples/widgets/browser/cookiejar.cpp
+++ b/examples/widgets/browser/cookiejar.cpp
@@ -59,7 +59,7 @@
#include <QtCore/QSortFilterProxyModel>
#include <QtNetwork/QNetworkCookie>
-#include <QWebSettings>
+#include <QWebEngineSettings>
#include <QtCore/QDebug>
@@ -226,8 +226,8 @@ QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl &url) const
if (!m_loaded)
that->load();
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
+ if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) {
QList<QNetworkCookie> noCookies;
return noCookies;
}
@@ -240,8 +240,8 @@ bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const
if (!m_loaded)
load();
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
+ if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
return false;
QString host = url.host();
diff --git a/examples/widgets/browser/downloadmanager.cpp b/examples/widgets/browser/downloadmanager.cpp
index 04889d9e3..828e325b9 100644
--- a/examples/widgets/browser/downloadmanager.cpp
+++ b/examples/widgets/browser/downloadmanager.cpp
@@ -57,7 +57,7 @@
#include <QtCore/QDebug>
-#include <QWebSettings>
+#include <QWebEngineSettings>
/*!
DownloadItem is a widget that is displayed in the download manager list.
@@ -429,9 +429,9 @@ void DownloadManager::updateRow()
downloadsView->setRowHeight(row, item->minimumSizeHint().height());
bool remove = false;
- QWebSettings *globalSettings = QWebSettings::globalSettings();
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
if (!item->downloading()
- && globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ && globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
remove = true;
if (item->downloadedSuccessfully()
diff --git a/examples/widgets/browser/history.cpp b/examples/widgets/browser/history.cpp
index d5b245e34..5a355707e 100644
--- a/examples/widgets/browser/history.cpp
+++ b/examples/widgets/browser/history.cpp
@@ -59,15 +59,15 @@
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QStyle>
-#include <QWebHistoryInterface>
-#include <QWebSettings>
+#include <QWebEngineHistoryInterface>
+#include <QWebEngineSettings>
#include <QtCore/QDebug>
static const unsigned int HISTORY_VERSION = 23;
HistoryManager::HistoryManager(QObject *parent)
- : QWebHistoryInterface(parent)
+ : QWebEngineHistoryInterface(parent)
, m_saveTimer(new AutoSaver(this))
, m_historyLimit(30)
, m_historyModel(0)
@@ -87,8 +87,8 @@ HistoryManager::HistoryManager(QObject *parent)
m_historyFilterModel = new HistoryFilterModel(m_historyModel, this);
m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this);
- // QWebHistoryInterface will delete the history manager
- QWebHistoryInterface::setDefaultInterface(this);
+ // QWebEngineHistoryInterface will delete the history manager
+ QWebEngineHistoryInterface::setDefaultInterface(this);
}
HistoryManager::~HistoryManager()
@@ -180,8 +180,8 @@ void HistoryManager::checkForExpired()
void HistoryManager::addHistoryItem(const HistoryItem &item)
{
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
+ if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
return;
m_history.prepend(item);
diff --git a/examples/widgets/browser/history.h b/examples/widgets/browser/history.h
index e8764f2ff..201863f4c 100644
--- a/examples/widgets/browser/history.h
+++ b/examples/widgets/browser/history.h
@@ -52,7 +52,7 @@
#include <QtCore/QSortFilterProxyModel>
-#include <QWebHistoryInterface>
+#include <QWebEngineHistoryInterface>
class HistoryItem
{
@@ -79,7 +79,7 @@ class AutoSaver;
class HistoryModel;
class HistoryFilterModel;
class HistoryTreeModel;
-class HistoryManager : public QWebHistoryInterface
+class HistoryManager : public QWebEngineHistoryInterface
{
Q_OBJECT
Q_PROPERTY(int historyLimit READ historyLimit WRITE setHistoryLimit)
diff --git a/examples/widgets/browser/settings.cpp b/examples/widgets/browser/settings.cpp
index 3521ce977..cdd6f04c8 100644
--- a/examples/widgets/browser/settings.cpp
+++ b/examples/widgets/browser/settings.cpp
@@ -50,7 +50,7 @@
#include <QtCore/QSettings>
#include <QtWidgets/QtWidgets>
-#include <QtWebKitWidgets>
+#include <QtWebEngineWidgets/QtWebEngineWidgets>
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent)
@@ -68,21 +68,21 @@ SettingsDialog::SettingsDialog(QWidget *parent)
void SettingsDialog::loadDefaults()
{
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
- QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
- int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
+ 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(QWebSettings::FixedFont);
- int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
+ 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(QWebSettings::JavascriptEnabled));
- enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled));
+ enableJavascript->setChecked(defaultSettings->testAttribute(QWebEngineSettings::JavascriptEnabled));
+ enablePlugins->setChecked(defaultSettings->testAttribute(QWebEngineSettings::PluginsEnabled));
}
void SettingsDialog::loadFromSettings()
diff --git a/examples/widgets/browser/tabwidget.cpp b/examples/widgets/browser/tabwidget.cpp
index e451b39d5..2a21cf33b 100644
--- a/examples/widgets/browser/tabwidget.cpp
+++ b/examples/widgets/browser/tabwidget.cpp
@@ -289,7 +289,7 @@ void TabWidget::moveTab(int fromIndex, int toIndex)
m_lineEdits->insertWidget(toIndex, lineEdit);
}
-void TabWidget::addWebAction(QAction *action, QWebPage::WebAction webAction)
+void TabWidget::addWebAction(QAction *action, QWebEnginePage::WebAction webAction)
{
if (!action)
return;
@@ -460,8 +460,8 @@ WebView *TabWidget::newTab(bool makeCurrent)
this, SLOT(windowCloseRequested()));
connect(webView->page(), SIGNAL(geometryChangeRequested(QRect)),
this, SIGNAL(geometryChangeRequested(QRect)));
- connect(webView->page(), SIGNAL(printRequested(QWebFrame*)),
- this, SIGNAL(printRequested(QWebFrame*)));
+ connect(webView->page(), SIGNAL(printRequested(QWebEngineFrame*)),
+ this, SIGNAL(printRequested(QWebEngineFrame*)));
connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)),
this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)),
@@ -562,8 +562,8 @@ void TabWidget::closeTab(int index)
}
hasFocus = tab->hasFocus();
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
+ if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) {
m_recentlyClosedTabsAction->setEnabled(true);
m_recentlyClosedTabs.prepend(tab->url());
if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize)
@@ -757,7 +757,7 @@ bool TabWidget::restoreState(const QByteArray &state)
return true;
}
-WebActionMapper::WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent)
+WebActionMapper::WebActionMapper(QAction *root, QWebEnginePage::WebAction webAction, QObject *parent)
: QObject(parent)
, m_currentParent(0)
, m_root(root)
@@ -787,7 +787,7 @@ void WebActionMapper::addChild(QAction *action)
connect(action, SIGNAL(changed()), this, SLOT(childChanged()));
}
-QWebPage::WebAction WebActionMapper::webAction() const
+QWebEnginePage::WebAction WebActionMapper::webAction() const
{
return m_webAction;
}
@@ -812,7 +812,7 @@ void WebActionMapper::childChanged()
}
}
-void WebActionMapper::updateCurrent(QWebPage *currentParent)
+void WebActionMapper::updateCurrent(QWebEnginePage *currentParent)
{
if (m_currentParent)
disconnect(m_currentParent, SIGNAL(destroyed(QObject*)),
diff --git a/examples/widgets/browser/tabwidget.h b/examples/widgets/browser/tabwidget.h
index 9a8f10ff1..e5e1cb606 100644
--- a/examples/widgets/browser/tabwidget.h
+++ b/examples/widgets/browser/tabwidget.h
@@ -84,7 +84,7 @@ private:
int m_dragCurrentIndex;
};
-#include <QWebPage>
+#include <QWebEnginePage>
QT_BEGIN_NAMESPACE
class QAction;
@@ -102,10 +102,10 @@ class WebActionMapper : public QObject
Q_OBJECT
public:
- WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent);
- QWebPage::WebAction webAction() const;
+ WebActionMapper(QAction *root, QWebEnginePage::WebAction webAction, QObject *parent);
+ QWebEnginePage::WebAction webAction() const;
void addChild(QAction *action);
- void updateCurrent(QWebPage *currentParent);
+ void updateCurrent(QWebEnginePage *currentParent);
private slots:
void rootTriggered();
@@ -114,9 +114,9 @@ private slots:
void currentDestroyed();
private:
- QWebPage *m_currentParent;
+ QWebEnginePage *m_currentParent;
QAction *m_root;
- QWebPage::WebAction m_webAction;
+ QWebEnginePage::WebAction m_webAction;
};
#include <QtCore/QUrl>
@@ -152,12 +152,12 @@ signals:
void menuBarVisibilityChangeRequested(bool visible);
void statusBarVisibilityChangeRequested(bool visible);
void toolBarVisibilityChangeRequested(bool visible);
- void printRequested(QWebFrame *frame);
+ void printRequested(QWebEngineFrame *frame);
public:
TabWidget(QWidget *parent = 0);
void clear();
- void addWebAction(QAction *action, QWebPage::WebAction webAction);
+ void addWebAction(QAction *action, QWebEnginePage::WebAction webAction);
QAction *newTabAction() const;
QAction *closeTabAction() const;
diff --git a/examples/widgets/browser/toolbarsearch.cpp b/examples/widgets/browser/toolbarsearch.cpp
index 415be66c4..27ad14a11 100644
--- a/examples/widgets/browser/toolbarsearch.cpp
+++ b/examples/widgets/browser/toolbarsearch.cpp
@@ -50,7 +50,7 @@
#include <QtWidgets/QMenu>
#include <QtCore/QStringListModel>
-#include <QWebSettings>
+#include <QWebEngineSettings>
/*
ToolbarSearch is a very basic search widget that also contains a small history.
@@ -109,8 +109,8 @@ void ToolbarSearch::searchNow()
if (newList.size() >= m_maxSavedSearches)
newList.removeLast();
- QWebSettings *globalSettings = QWebSettings::globalSettings();
- if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
+ QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
+ if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) {
m_stringListModel->setStringList(newList);
m_autosaver->changeOccurred();
}
diff --git a/examples/widgets/browser/webview.cpp b/examples/widgets/browser/webview.cpp
index be6f7de53..11a06cd89 100644
--- a/examples/widgets/browser/webview.cpp
+++ b/examples/widgets/browser/webview.cpp
@@ -52,7 +52,7 @@
#include <QtWidgets/QMessageBox>
#include <QtGui/QMouseEvent>
-#include <QWebHitTestResult>
+#include <QWebEngineHitTestResult>
#ifndef QT_NO_UITOOLS
#include <QtUiTools/QUiLoader>
@@ -62,7 +62,7 @@
#include <QtCore/QBuffer>
WebPage::WebPage(QObject *parent)
- : QWebPage(parent)
+ : QWebEnginePage(parent)
, m_keyboardModifiers(Qt::NoModifier)
, m_pressedButtons(Qt::NoButton)
, m_openInNewTab(false)
@@ -83,12 +83,12 @@ BrowserMainWindow *WebPage::mainWindow()
return BrowserApplication::instance()->mainWindow();
}
-bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
+bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type)
{
// ctrl open in new tab
// ctrl-shift open in new tab and select
// ctrl-alt open in new window
- if (type == QWebPage::NavigationTypeLinkClicked
+ if (type == QWebEnginePage::NavigationTypeLinkClicked
&& (m_keyboardModifiers & Qt::ControlModifier
|| m_pressedButtons == Qt::MidButton)) {
bool newWindow = (m_keyboardModifiers & Qt::AltModifier);
@@ -109,14 +109,12 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
m_pressedButtons = Qt::NoButton;
return false;
}
- if (frame == mainFrame()) {
- m_loadingUrl = request.url();
- emit loadingUrl(m_loadingUrl);
- }
- return QWebPage::acceptNavigationRequest(frame, request, type);
+ m_loadingUrl = request.url();
+ emit loadingUrl(m_loadingUrl);
+ return QWebEnginePage::acceptNavigationRequest(frame, request, type);
}
-QWebPage *WebPage::createWindow(QWebPage::WebWindowType type)
+QWebEnginePage *WebPage::createWindow(QWebEnginePage::WebWindowType type)
{
Q_UNUSED(type);
if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)
@@ -143,6 +141,7 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
+#if defined(QTWEBENGINE_FEATURE_DOWNLOADS)
QString errorString = reply->errorString();
if (m_loadingUrl != reply->url()) {
@@ -176,26 +175,27 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
QString(QLatin1String(imageBuffer.buffer().toBase64())));
}
- QList<QWebFrame*> frames;
+ QList<QWebEngineFrame*> frames;
frames.append(mainFrame());
while (!frames.isEmpty()) {
- QWebFrame *frame = frames.takeFirst();
+ QWebEngineFrame *frame = frames.takeFirst();
if (frame->url() == reply->url()) {
frame->setHtml(html, reply->url());
return;
}
- QList<QWebFrame *> children = frame->childFrames();
- foreach (QWebFrame *frame, children)
+ QList<QWebEngineFrame *> children = frame->childFrames();
+ foreach (QWebEngineFrame *frame, children)
frames.append(frame);
}
if (m_loadingUrl == reply->url()) {
mainFrame()->setHtml(html, reply->url());
}
+#endif
}
WebView::WebView(QWidget* parent)
- : QWebView(parent)
+ : QWebEngineView(parent)
, m_progress(0)
, m_page(new WebPage(this))
{
@@ -216,22 +216,22 @@ WebView::WebView(QWidget* parent)
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
- QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
+ QWebEngineHitTestResult r = page()->hitTestContent(event->pos());
if (!r.linkUrl().isEmpty()) {
QMenu menu(this);
- menu.addAction(pageAction(QWebPage::OpenLinkInNewWindow));
+ menu.addAction(pageAction(QWebEnginePage::OpenLinkInNewWindow));
menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
menu.addSeparator();
- menu.addAction(pageAction(QWebPage::DownloadLinkToDisk));
+ menu.addAction(pageAction(QWebEnginePage::DownloadLinkToDisk));
// Add link to bookmarks...
menu.addSeparator();
- menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
- if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
- menu.addAction(pageAction(QWebPage::InspectElement));
+ menu.addAction(pageAction(QWebEnginePage::CopyLinkToClipboard));
+ if (page()->settings()->testAttribute(QWebEngineSettings::DeveloperExtrasEnabled))
+ menu.addAction(pageAction(QWebEnginePage::InspectElement));
menu.exec(mapToGlobal(event->pos()));
return;
}
- QWebView::contextMenuEvent(event);
+ QWebEngineView::contextMenuEvent(event);
}
void WebView::wheelEvent(QWheelEvent *event)
@@ -243,13 +243,13 @@ void WebView::wheelEvent(QWheelEvent *event)
event->accept();
return;
}
- QWebView::wheelEvent(event);
+ QWebEngineView::wheelEvent(event);
}
void WebView::openLinkInNewTab()
{
m_page->m_openInNewTab = true;
- pageAction(QWebPage::OpenLinkInNewWindow)->trigger();
+ pageAction(QWebEnginePage::OpenLinkInNewWindow)->trigger();
}
void WebView::setProgress(int progress)
@@ -279,7 +279,7 @@ QString WebView::lastStatusBarText() const
QUrl WebView::url() const
{
- QUrl url = QWebView::url();
+ QUrl url = QWebEngineView::url();
if (!url.isEmpty())
return url;
@@ -290,12 +290,12 @@ void WebView::mousePressEvent(QMouseEvent *event)
{
m_page->m_pressedButtons = event->buttons();
m_page->m_keyboardModifiers = event->modifiers();
- QWebView::mousePressEvent(event);
+ QWebEngineView::mousePressEvent(event);
}
void WebView::mouseReleaseEvent(QMouseEvent *event)
{
- QWebView::mouseReleaseEvent(event);
+ QWebEngineView::mouseReleaseEvent(event);
if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) {
QUrl url(QApplication::clipboard()->text(QClipboard::Selection));
if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
diff --git a/examples/widgets/browser/webview.h b/examples/widgets/browser/webview.h
index 4fd04aca9..0dce3e029 100644
--- a/examples/widgets/browser/webview.h
+++ b/examples/widgets/browser/webview.h
@@ -42,7 +42,7 @@
#ifndef WEBVIEW_H
#define WEBVIEW_H
-#include <QWebView>
+#include <QWebEngineView>
QT_BEGIN_NAMESPACE
class QAuthenticator;
@@ -53,7 +53,7 @@ class QSslError;
QT_END_NAMESPACE
class BrowserMainWindow;
-class WebPage : public QWebPage {
+class WebPage : public QWebEnginePage {
Q_OBJECT
signals:
@@ -64,8 +64,8 @@ public:
BrowserMainWindow *mainWindow();
protected:
- bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
- QWebPage *createWindow(QWebPage::WebWindowType type);
+ bool acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type);
+ QWebEnginePage *createWindow(QWebEnginePage::WebWindowType type);
#if !defined(QT_NO_UITOOLS)
QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
#endif
@@ -83,7 +83,7 @@ private:
QUrl m_loadingUrl;
};
-class WebView : public QWebView {
+class WebView : public QWebEngineView {
Q_OBJECT
public: