summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/browser/tabwidget.cpp
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@theqtcompany.com>2015-02-02 17:11:51 +0100
committerAndras Becsi <andras.becsi@theqtcompany.com>2015-02-05 16:13:05 +0000
commit0cf3235924e7ea95c5804c807a9ef0e91678c49d (patch)
treee43d0e34366ce6605109af7ab967e3abe6def940 /examples/webenginewidgets/browser/tabwidget.cpp
parent4ef5831a398280cc26cbf359dcbb9878e77ab7fb (diff)
Revive the widget Browser's DownloadManager
This reenables the widget example Browser's download code by porting it from the QNAM-based QtWebKit API to the new download API of QtWebEngine. Change-Id: I0630c76902fb30c355c774664f0a2005fe29023c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'examples/webenginewidgets/browser/tabwidget.cpp')
-rw-r--r--examples/webenginewidgets/browser/tabwidget.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/webenginewidgets/browser/tabwidget.cpp b/examples/webenginewidgets/browser/tabwidget.cpp
index 74fb05b46..6f27b9391 100644
--- a/examples/webenginewidgets/browser/tabwidget.cpp
+++ b/examples/webenginewidgets/browser/tabwidget.cpp
@@ -43,12 +43,15 @@
#include "browserapplication.h"
#include "browsermainwindow.h"
+#include "downloadmanager.h"
#include "history.h"
#include "urllineedit.h"
#include "webview.h"
#include <QtCore/QMimeData>
#include <QtGui/QClipboard>
+#include <QtWebEngineWidgets/QWebEngineDownloadItem>
+#include <QtWebEngineWidgets/QWebEngineProfile>
#include <QtWidgets/QCompleter>
#include <QtWidgets/QListView>
#include <QtWidgets/QMenu>
@@ -314,6 +317,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(linkHovered(const QString&)));
disconnect(oldWebView, SIGNAL(loadProgress(int)),
this, SIGNAL(loadProgress(int)));
+ disconnect(oldWebView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
+ this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
}
#if defined(QWEBENGINEVIEW_STATUSBARMESSAGE)
@@ -324,6 +329,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(linkHovered(const QString&)));
connect(webView, SIGNAL(loadProgress(int)),
this, SIGNAL(loadProgress(int)));
+ connect(webView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
+ this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
for (int i = 0; i < m_actions.count(); ++i) {
WebActionMapper *mapper = m_actions[i];
@@ -772,6 +779,12 @@ bool TabWidget::restoreState(const QByteArray &state)
return true;
}
+void TabWidget::downloadRequested(QWebEngineDownloadItem *download)
+{
+ BrowserApplication::downloadManager()->download(download);
+ download->accept();
+}
+
WebActionMapper::WebActionMapper(QAction *root, QWebEnginePage::WebAction webAction, QObject *parent)
: QObject(parent)
, m_currentParent(0)