summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2019-04-15 10:16:02 +0200
committerTamas Zakor <ztamas@inf.u-szeged.hu>2019-04-29 06:18:26 +0000
commit5d6086d1b97461b35c143839a8a6ba1b990bb87c (patch)
tree3f0811a9ce1b99fd20253e1d11d9bea1499db029 /src
parent15ebee1c10a954ea2408e35e53fa8307defc3970 (diff)
Extend the QQuickWebEngineDownloadItem Qml type with url property
Task-number: QTBUG-72996 Change-Id: I8af67d69a9a88ccbc95e37a252615dd3fd3ca0ca Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp17
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h3
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h3
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp2
-rw-r--r--src/webengine/plugin/plugin.cpp2
-rw-r--r--src/webengine/plugin/plugin.pro2
6 files changed, 25 insertions, 4 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index 981d11633..8aff4e625 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -96,7 +96,7 @@ static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInt
return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason);
}
-QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p)
+QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url)
: profile(p)
, downloadId(-1)
, downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
@@ -108,6 +108,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb
, downloadFinished(false)
, downloadPaused(false)
, view(nullptr)
+ , downloadUrl(url)
{
}
@@ -386,6 +387,20 @@ qint64 QQuickWebEngineDownloadItem::receivedBytes() const
}
/*!
+ \qmlproperty url WebEngineDownloadItem::url
+ \readonly
+ \since QtWebEngine 1.10
+
+ Returns the download's origin URL.
+*/
+
+QUrl QQuickWebEngineDownloadItem::url() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadUrl;
+}
+
+/*!
\qmlproperty string WebEngineDownloadItem::mimeType
\since QtWebEngine 1.2
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index d19ca4828..1b17f71aa 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -55,6 +55,7 @@
#include <QObject>
#include <QScopedPointer>
#include <QString>
+#include <QUrl>
QT_BEGIN_NAMESPACE
@@ -136,6 +137,7 @@ public:
Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL)
Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL)
Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL)
+ Q_PROPERTY(QUrl url READ url CONSTANT REVISION 8 FINAL)
Q_INVOKABLE void accept();
Q_INVOKABLE void cancel();
@@ -158,6 +160,7 @@ public:
bool isPaused() const;
bool isSavePageDownload() const;
QQuickWebEngineView *view() const;
+ QUrl url() const;
Q_SIGNALS:
void stateChanged();
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index f444c04a5..955a6fd6a 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -67,7 +67,7 @@ class QQuickWebEngineDownloadItemPrivate {
friend class QQuickWebEngineProfilePrivate;
public:
Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
- QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p);
+ QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url);
~QQuickWebEngineDownloadItemPrivate();
quint32 downloadId;
@@ -82,6 +82,7 @@ public:
bool downloadFinished;
bool downloadPaused;
QQuickWebEngineView *view;
+ QUrl downloadUrl;
void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
void updateState(QQuickWebEngineDownloadItem::DownloadState newState);
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 4832ba303..911e4cbce 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -237,7 +237,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QQuickWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q);
+ QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url);
itemPrivate->downloadId = info.id;
itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
itemPrivate->totalBytes = info.totalBytes;
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index cd2f5e001..bd367dea2 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -120,6 +120,8 @@ public:
msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
+ qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 8>(uri, 1, 10, "WebEngineDownloadItem",
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", msgUncreatableType("WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest, 1>(uri, 1, 5, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", msgUncreatableType("WebEngineSettings"));
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 0c1310de3..3b30bece2 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtwebengineplugin
TARGETPATH = QtWebEngine
-IMPORT_VERSION = 1.9
+IMPORT_VERSION = 1.10
QT += qml quick
QT_PRIVATE += core-private webenginecore-private webengine-private