summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-08-06 19:04:58 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-08-20 18:15:27 +0200
commit63c45a18d37350e5455cf2869832e8b1743712a2 (patch)
tree76f775cd4f87dac796e79eece760d8b2c4ea7b9b /examples
parent68f3331b98d4d9996732117549cbdf4ea80cac70 (diff)
demo browser: Make it link.
The ifdefs should later be removed along with the feature implementations. Change-Id: If73f4c4c02c00e90d6cf54c6a08bb37f43fa95bc Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro6
-rw-r--r--examples/widgets/browser/browser.pro11
-rw-r--r--examples/widgets/browser/browserapplication.cpp20
-rw-r--r--examples/widgets/browser/browsermainwindow.cpp33
-rw-r--r--examples/widgets/browser/downloadmanager.cpp2
-rw-r--r--examples/widgets/browser/history.cpp11
-rw-r--r--examples/widgets/browser/history.h7
-rw-r--r--examples/widgets/browser/settings.cpp10
-rw-r--r--examples/widgets/browser/tabwidget.cpp13
-rw-r--r--examples/widgets/browser/toolbarsearch.cpp5
-rw-r--r--examples/widgets/browser/webview.cpp14
11 files changed, 116 insertions, 16 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index 970c58c69..cc3bcc8ff 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,4 +1,8 @@
TEMPLATE=subdirs
SUBDIRS += quick/quicknanobrowser
-qtHaveModule(widgets): SUBDIRS += widgets/widgetsnanobrowser
+qtHaveModule(widgets) {
+ SUBDIRS += \
+ widgets/browser \
+ widgets/widgetsnanobrowser
+}
diff --git a/examples/widgets/browser/browser.pro b/examples/widgets/browser/browser.pro
index 8de546daf..e19efafb1 100644
--- a/examples/widgets/browser/browser.pro
+++ b/examples/widgets/browser/browser.pro
@@ -2,6 +2,8 @@ TEMPLATE = app
TARGET = browser
QT += webenginewidgets network widgets printsupport
+include($$QTWEBENGINE_ROOT/common.pri)
+
qtHaveModule(uitools):!embedded: QT += uitools
else: DEFINES += QT_NO_UITOOLS
@@ -23,13 +25,11 @@ HEADERS += \
browserapplication.h \
browsermainwindow.h \
chasewidget.h \
- cookiejar.h \
downloadmanager.h \
edittableview.h \
edittreeview.h \
history.h \
modelmenu.h \
- networkaccessmanager.h \
searchlineedit.h \
settings.h \
squeezelabel.h \
@@ -45,13 +45,11 @@ SOURCES += \
browserapplication.cpp \
browsermainwindow.cpp \
chasewidget.cpp \
- cookiejar.cpp \
downloadmanager.cpp \
edittableview.cpp \
edittreeview.cpp \
history.cpp \
modelmenu.cpp \
- networkaccessmanager.cpp \
searchlineedit.cpp \
settings.cpp \
squeezelabel.cpp \
@@ -64,6 +62,11 @@ SOURCES += \
RESOURCES += data/data.qrc htmls/htmls.qrc
+contains(DEFINES, QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) {
+ HEADERS += cookiejar.h networkaccessmanager.h
+ SOURCES += cookiejar.cpp networkaccessmanager.cpp
+}
+
build_all:!build_pass {
CONFIG -= build_all
CONFIG += release
diff --git a/examples/widgets/browser/browserapplication.cpp b/examples/widgets/browser/browserapplication.cpp
index 18b1d0d75..da96b65b9 100644
--- a/examples/widgets/browser/browserapplication.cpp
+++ b/examples/widgets/browser/browserapplication.cpp
@@ -201,11 +201,13 @@ void BrowserApplication::quitBrowser()
*/
void BrowserApplication::postLaunch()
{
+#if defined(QWEBENGINESETTINGS)
QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
if (directory.isEmpty())
directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName();
QWebEngineSettings::setIconDatabasePath(directory);
QWebEngineSettings::setOfflineStoragePath(directory);
+#endif
setWindowIcon(QIcon(QLatin1String(":browser.svg")));
@@ -224,6 +226,7 @@ void BrowserApplication::postLaunch()
void BrowserApplication::loadSettings()
{
+#if defined(QWEBENGINESETTINGS)
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
@@ -251,6 +254,7 @@ void BrowserApplication::loadSettings()
defaultSettings->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
settings.endGroup();
+#endif
}
QList<BrowserMainWindow*> BrowserApplication::mainWindows()
@@ -272,9 +276,11 @@ void BrowserApplication::clean()
void BrowserApplication::saveSession()
{
+#if defined(QWEBENGINESETTINGS)
QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
return;
+#endif
clean();
@@ -410,7 +416,11 @@ void BrowserApplication::newLocalSocketConnection()
CookieJar *BrowserApplication::cookieJar()
{
+#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
return (CookieJar*)networkAccessManager()->cookieJar();
+#else
+ return 0;
+#endif
}
DownloadManager *BrowserApplication::downloadManager()
@@ -423,19 +433,21 @@ DownloadManager *BrowserApplication::downloadManager()
NetworkAccessManager *BrowserApplication::networkAccessManager()
{
+#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
if (!s_networkAccessManager) {
s_networkAccessManager = new NetworkAccessManager();
s_networkAccessManager->setCookieJar(new CookieJar);
}
return s_networkAccessManager;
+#else
+ return 0;
+#endif
}
HistoryManager *BrowserApplication::historyManager()
{
- if (!s_historyManager) {
+ if (!s_historyManager)
s_historyManager = new HistoryManager();
- QWebEngineHistoryInterface::setDefaultInterface(s_historyManager);
- }
return s_historyManager;
}
@@ -449,9 +461,11 @@ BookmarksManager *BrowserApplication::bookmarksManager()
QIcon BrowserApplication::icon(const QUrl &url) const
{
+#if defined(QWEBENGINESETTINGS)
QIcon icon = QWebEngineSettings::iconForUrl(url);
if (!icon.isNull())
return icon.pixmap(16, 16);
+#endif
if (m_defaultIcon.isNull())
m_defaultIcon = QIcon(QLatin1String(":defaulticon.png"));
return m_defaultIcon.pixmap(16, 16);
diff --git a/examples/widgets/browser/browsermainwindow.cpp b/examples/widgets/browser/browsermainwindow.cpp
index 7bddbb2b7..c7679fbe1 100644
--- a/examples/widgets/browser/browsermainwindow.cpp
+++ b/examples/widgets/browser/browsermainwindow.cpp
@@ -641,14 +641,16 @@ void BrowserMainWindow::slotFilePrintPreview()
void BrowserMainWindow::slotFilePrint()
{
+#if defined(QWEBENGINEPAGE_PRINT)
if (!currentTab())
return;
printRequested(currentTab()->page()->mainFrame());
+#endif
}
void BrowserMainWindow::printRequested(QWebEngineFrame *frame)
{
-#if defined(QTWEBENGINE_FEATURE_PRINT)
+#if defined(QWEBENGINEPAGE_PRINT)
#ifndef QT_NO_PRINTDIALOG
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
@@ -662,6 +664,7 @@ void BrowserMainWindow::printRequested(QWebEngineFrame *frame)
void BrowserMainWindow::slotPrivateBrowsing()
{
+#if defined(QWEBENGINESETTINGS)
QWebEngineSettings *settings = QWebEngineSettings::globalSettings();
bool pb = settings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled);
if (!pb) {
@@ -691,6 +694,7 @@ void BrowserMainWindow::slotPrivateBrowsing()
window->tabWidget()->clear();
}
}
+#endif
}
void BrowserMainWindow::closeEvent(QCloseEvent *event)
@@ -712,6 +716,7 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event)
void BrowserMainWindow::slotEditFind()
{
+#if defined(QWEBENGINEPAGE_FINDTEXT)
if (!currentTab())
return;
bool ok;
@@ -723,48 +728,61 @@ void BrowserMainWindow::slotEditFind()
if (!currentTab()->findText(m_lastSearch))
slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch));
}
+#endif
}
void BrowserMainWindow::slotEditFindNext()
{
+#if defined(QWEBENGINEPAGE_FINDTEXT)
if (!currentTab() && !m_lastSearch.isEmpty())
return;
currentTab()->findText(m_lastSearch);
+#endif
}
void BrowserMainWindow::slotEditFindPrevious()
{
+#if defined(QWEBENGINEPAGE_FINDTEXT)
if (!currentTab() && !m_lastSearch.isEmpty())
return;
currentTab()->findText(m_lastSearch, QWebEnginePage::FindBackward);
+#endif
}
void BrowserMainWindow::slotViewZoomIn()
{
+#if defined(QWEBENGINEPAGE_SETZOOMFACTOR)
if (!currentTab())
return;
currentTab()->setZoomFactor(currentTab()->zoomFactor() + 0.1);
+#endif
}
void BrowserMainWindow::slotViewZoomOut()
{
+#if defined(QWEBENGINEPAGE_SETZOOMFACTOR)
if (!currentTab())
return;
currentTab()->setZoomFactor(currentTab()->zoomFactor() - 0.1);
+#endif
}
void BrowserMainWindow::slotViewResetZoom()
{
+#if defined(QWEBENGINEPAGE_SETZOOMFACTOR)
if (!currentTab())
return;
currentTab()->setZoomFactor(1.0);
+#endif
}
void BrowserMainWindow::slotViewZoomTextOnly(bool enable)
{
+#if defined(QWEBENGINESETTINGS)
if (!currentTab())
return;
currentTab()->page()->settings()->setAttribute(QWebEngineSettings::ZoomTextOnly, enable);
+#endif
}
void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen)
@@ -782,6 +800,7 @@ void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen)
void BrowserMainWindow::slotViewPageSource()
{
+#if defined(QWEBENGINEPAGE_TOHTML)
if (!currentTab())
return;
@@ -791,6 +810,7 @@ void BrowserMainWindow::slotViewPageSource()
view->setMinimumWidth(640);
view->setAttribute(Qt::WA_DeleteOnClose);
view->show();
+#endif
}
void BrowserMainWindow::slotHome()
@@ -809,6 +829,7 @@ void BrowserMainWindow::slotWebSearch()
void BrowserMainWindow::slotToggleInspector(bool enable)
{
+#if defined(QWEBENGINEINSPECTOR)
QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, enable);
if (enable) {
int result = QMessageBox::question(this, tr("Web Inspector"),
@@ -819,6 +840,7 @@ void BrowserMainWindow::slotToggleInspector(bool enable)
m_tabWidget->reloadAllTabs();
}
}
+#endif
}
void BrowserMainWindow::slotSwapFocus()
@@ -869,6 +891,7 @@ void BrowserMainWindow::slotAboutToShowBackMenu()
m_historyBackMenu->clear();
if (!currentTab())
return;
+#if defined(QWEBENGINEHISTORY)
QWebEngineHistory *history = currentTab()->history();
int historyCount = history->count();
for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) {
@@ -880,6 +903,7 @@ void BrowserMainWindow::slotAboutToShowBackMenu()
action->setText(item.title());
m_historyBackMenu->addAction(action);
}
+#endif
}
void BrowserMainWindow::slotAboutToShowForwardMenu()
@@ -887,6 +911,7 @@ void BrowserMainWindow::slotAboutToShowForwardMenu()
m_historyForwardMenu->clear();
if (!currentTab())
return;
+#if defined(QWEBENGINEHISTORY)
QWebEngineHistory *history = currentTab()->history();
int historyCount = history->count();
for (int i = 0; i < history->forwardItems(history->count()).count(); ++i) {
@@ -898,6 +923,7 @@ void BrowserMainWindow::slotAboutToShowForwardMenu()
action->setText(item.title());
m_historyForwardMenu->addAction(action);
}
+#endif
}
void BrowserMainWindow::slotAboutToShowWindowMenu()
@@ -935,13 +961,16 @@ void BrowserMainWindow::slotShowWindow()
void BrowserMainWindow::slotOpenActionUrl(QAction *action)
{
+#if defined(QWEBENGINEHISTORY)
+
int offset = action->data().toInt();
QWebEngineHistory *history = currentTab()->history();
if (offset < 0)
history->goToItem(history->backItems(-1*offset).first()); // back
else if (offset > 0)
history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward
- }
+#endif
+}
void BrowserMainWindow::geometryChangeRequested(const QRect &geometry)
{
diff --git a/examples/widgets/browser/downloadmanager.cpp b/examples/widgets/browser/downloadmanager.cpp
index 828e325b9..6f4c6c8ad 100644
--- a/examples/widgets/browser/downloadmanager.cpp
+++ b/examples/widgets/browser/downloadmanager.cpp
@@ -429,10 +429,12 @@ void DownloadManager::updateRow()
downloadsView->setRowHeight(row, item->minimumSizeHint().height());
bool remove = false;
+#if defined(QWEBENGINESETTINGS)
QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
if (!item->downloading()
&& globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
remove = true;
+#endif
if (item->downloadedSuccessfully()
&& removePolicy() == DownloadManager::SuccessFullDownload) {
diff --git a/examples/widgets/browser/history.cpp b/examples/widgets/browser/history.cpp
index 5a355707e..9d599f876 100644
--- a/examples/widgets/browser/history.cpp
+++ b/examples/widgets/browser/history.cpp
@@ -67,8 +67,11 @@
static const unsigned int HISTORY_VERSION = 23;
HistoryManager::HistoryManager(QObject *parent)
- : QWebEngineHistoryInterface(parent)
- , m_saveTimer(new AutoSaver(this))
+ :
+#if defined(QWEBENGINEHISTORYINTERFACE)
+ QWebEngineHistoryInterface(parent),
+#endif
+ m_saveTimer(new AutoSaver(this))
, m_historyLimit(30)
, m_historyModel(0)
, m_historyFilterModel(0)
@@ -87,8 +90,10 @@ HistoryManager::HistoryManager(QObject *parent)
m_historyFilterModel = new HistoryFilterModel(m_historyModel, this);
m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this);
+#if defined(QWEBENGINEHISTORYINTERFACE)
// QWebEngineHistoryInterface will delete the history manager
QWebEngineHistoryInterface::setDefaultInterface(this);
+#endif
}
HistoryManager::~HistoryManager()
@@ -180,9 +185,11 @@ void HistoryManager::checkForExpired()
void HistoryManager::addHistoryItem(const HistoryItem &item)
{
+#if defined(QWEBENGINESETTINGS)
QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
return;
+#endif
m_history.prepend(item);
emit entryAdded(item);
diff --git a/examples/widgets/browser/history.h b/examples/widgets/browser/history.h
index 201863f4c..4006f3415 100644
--- a/examples/widgets/browser/history.h
+++ b/examples/widgets/browser/history.h
@@ -79,7 +79,12 @@ class AutoSaver;
class HistoryModel;
class HistoryFilterModel;
class HistoryTreeModel;
-class HistoryManager : public QWebEngineHistoryInterface
+class HistoryManager
+#if defined(QWEBENGINEHISTORYINTERFACE)
+ : public QWebEngineHistoryInterface
+#else
+ : public QObject
+#endif
{
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 cdd6f04c8..6838c19aa 100644
--- a/examples/widgets/browser/settings.cpp
+++ b/examples/widgets/browser/settings.cpp
@@ -68,6 +68,7 @@ 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,10 +84,12 @@ void SettingsDialog::loadDefaults()
enableJavascript->setChecked(defaultSettings->testAttribute(QWebEngineSettings::JavascriptEnabled));
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/");
@@ -180,10 +183,12 @@ 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());
@@ -272,6 +277,7 @@ void SettingsDialog::saveToSettings()
BrowserApplication::networkAccessManager()->loadSettings();
BrowserApplication::cookieJar()->loadSettings();
BrowserApplication::historyManager()->loadSettings();
+#endif
}
void SettingsDialog::accept()
@@ -282,14 +288,18 @@ void SettingsDialog::accept()
void SettingsDialog::showCookies()
{
+#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
CookiesDialog *dialog = new CookiesDialog(BrowserApplication::cookieJar(), this);
dialog->exec();
+#endif
}
void SettingsDialog::showExceptions()
{
+#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(BrowserApplication::cookieJar(), this);
dialog->exec();
+#endif
}
void SettingsDialog::chooseFont()
diff --git a/examples/widgets/browser/tabwidget.cpp b/examples/widgets/browser/tabwidget.cpp
index 2a21cf33b..47bcc2261 100644
--- a/examples/widgets/browser/tabwidget.cpp
+++ b/examples/widgets/browser/tabwidget.cpp
@@ -473,10 +473,12 @@ WebView *TabWidget::newTab(bool makeCurrent)
setCurrentWidget(webView);
// webview actions
+#if defined(QWEBENGINEPAGE_ACTION)
for (int i = 0; i < m_actions.count(); ++i) {
WebActionMapper *mapper = m_actions[i];
mapper->addChild(webView->page()->action(mapper->webAction()));
}
+#endif
if (count() == 1)
currentChanged(currentIndex());
@@ -547,6 +549,7 @@ void TabWidget::closeTab(int index)
bool hasFocus = false;
if (WebView *tab = webView(index)) {
+#if defined(QWEBENGINEPAGE_ISMODIFIED)
if (tab->isModified()) {
QMessageBox closeConfirmation(tab);
closeConfirmation.setWindowFlags(Qt::Sheet);
@@ -560,10 +563,14 @@ void TabWidget::closeTab(int index)
if (closeConfirmation.exec() == QMessageBox::No)
return;
}
+#endif
hasFocus = tab->hasFocus();
+#if defined(QWEBENGINESETTINGS)
QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) {
+ if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
+#endif
+ {
m_recentlyClosedTabsAction->setEnabled(true);
m_recentlyClosedTabs.prepend(tab->url());
if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize)
@@ -794,10 +801,12 @@ QWebEnginePage::WebAction WebActionMapper::webAction() const
void WebActionMapper::rootTriggered()
{
+#if defined(QWEBENGINEPAGE_ACTION)
if (m_currentParent) {
QAction *gotoAction = m_currentParent->action(m_webAction);
gotoAction->trigger();
}
+#endif
}
void WebActionMapper::childChanged()
@@ -826,9 +835,11 @@ void WebActionMapper::updateCurrent(QWebEnginePage *currentParent)
m_root->setChecked(false);
return;
}
+#if defined(QWEBENGINEPAGE_ACTION)
QAction *source = m_currentParent->action(m_webAction);
m_root->setChecked(source->isChecked());
m_root->setEnabled(source->isEnabled());
+#endif
connect(m_currentParent, SIGNAL(destroyed(QObject*)),
this, SLOT(currentDestroyed()));
}
diff --git a/examples/widgets/browser/toolbarsearch.cpp b/examples/widgets/browser/toolbarsearch.cpp
index 27ad14a11..d6d1ec1da 100644
--- a/examples/widgets/browser/toolbarsearch.cpp
+++ b/examples/widgets/browser/toolbarsearch.cpp
@@ -109,8 +109,11 @@ void ToolbarSearch::searchNow()
if (newList.size() >= m_maxSavedSearches)
newList.removeLast();
+#if defined(QWEBENGINESETTINGS)
QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled)) {
+ if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
+#endif
+ {
m_stringListModel->setStringList(newList);
m_autosaver->changeOccurred();
}
diff --git a/examples/widgets/browser/webview.cpp b/examples/widgets/browser/webview.cpp
index 11a06cd89..c7069f89c 100644
--- a/examples/widgets/browser/webview.cpp
+++ b/examples/widgets/browser/webview.cpp
@@ -67,7 +67,9 @@ WebPage::WebPage(QObject *parent)
, m_pressedButtons(Qt::NoButton)
, m_openInNewTab(false)
{
+#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
setNetworkAccessManager(BrowserApplication::networkAccessManager());
+#endif
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)),
this, SLOT(handleUnsupportedContent(QNetworkReply*)));
}
@@ -85,6 +87,7 @@ BrowserMainWindow *WebPage::mainWindow()
bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type)
{
+#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
// ctrl open in new tab
// ctrl-shift open in new tab and select
// ctrl-alt open in new window
@@ -111,6 +114,7 @@ bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequ
}
m_loadingUrl = request.url();
emit loadingUrl(m_loadingUrl);
+#endif
return QWebEnginePage::acceptNavigationRequest(frame, request, type);
}
@@ -141,7 +145,7 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
-#if defined(QTWEBENGINE_FEATURE_DOWNLOADS)
+#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
QString errorString = reply->errorString();
if (m_loadingUrl != reply->url()) {
@@ -210,12 +214,15 @@ WebView::WebView(QWidget* parent)
this, SIGNAL(urlChanged(QUrl)));
connect(page(), SIGNAL(downloadRequested(QNetworkRequest)),
this, SLOT(downloadRequested(QNetworkRequest)));
+#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
page()->setForwardUnsupportedContent(true);
+#endif
}
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
+#if defined(QWEBENGINEPAGE_HITTESTCONTENT)
QWebEngineHitTestResult r = page()->hitTestContent(event->pos());
if (!r.linkUrl().isEmpty()) {
QMenu menu(this);
@@ -231,11 +238,13 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.exec(mapToGlobal(event->pos()));
return;
}
+#endif
QWebEngineView::contextMenuEvent(event);
}
void WebView::wheelEvent(QWheelEvent *event)
{
+#if defined(QWEBENGINEPAGE_SETTEXTSIZEMULTIPLIER)
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
int numDegrees = event->delta() / 8;
int numSteps = numDegrees / 15;
@@ -243,13 +252,16 @@ void WebView::wheelEvent(QWheelEvent *event)
event->accept();
return;
}
+#endif
QWebEngineView::wheelEvent(event);
}
void WebView::openLinkInNewTab()
{
+#if defined(QWEBENGINEPAGE_ACTION)
m_page->m_openInNewTab = true;
pageAction(QWebEnginePage::OpenLinkInNewWindow)->trigger();
+#endif
}
void WebView::setProgress(int progress)