diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-18 11:39:36 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-22 03:32:24 +0000 |
commit | 3752a3cbcd0cc0742a5b955e925df18395afdb75 (patch) | |
tree | 453369210f11bd672441d11ef4065e79109ac260 /src/core/api | |
parent | 15e5ba4bfc920adf56df8dd11cb09ca3a9942963 (diff) |
Add page() and view() back to download-item
Restores a QML type but this time derived from the core type.
Change-Id: I09ddb6672f7262ae31e4c57f09d019f71abccd41
Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
(cherry picked from commit b2ecb708e149fe8914d7d0cbfcf9c300e52a029e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/core/api')
-rw-r--r-- | src/core/api/qwebenginedownloadrequest.cpp | 14 | ||||
-rw-r--r-- | src/core/api/qwebenginedownloadrequest.h | 13 | ||||
-rw-r--r-- | src/core/api/qwebenginepage.cpp | 4 | ||||
-rw-r--r-- | src/core/api/qwebenginepage.h | 2 |
4 files changed, 16 insertions, 17 deletions
diff --git a/src/core/api/qwebenginedownloadrequest.cpp b/src/core/api/qwebenginedownloadrequest.cpp index 006fd2e4b..57823a7c9 100644 --- a/src/core/api/qwebenginedownloadrequest.cpp +++ b/src/core/api/qwebenginedownloadrequest.cpp @@ -40,10 +40,13 @@ #include "qwebenginedownloadrequest.h" #include "qwebenginedownloadrequest_p.h" +#include "qwebenginepage.h" + #include "profile_adapter.h" +#include "web_contents_adapter_client.h" #include <QDir> -#include "QFileInfo" +#include <QFileInfo> QT_BEGIN_NAMESPACE @@ -662,14 +665,17 @@ QString QWebEngineDownloadRequest::interruptReasonString() const Returns the page the download was requested on. If the download was not triggered by content in a page, \c nullptr is returned. */ -QObject *QWebEngineDownloadRequest::page() const +QWebEnginePage *QWebEngineDownloadRequest::page() const { Q_D(const QWebEngineDownloadRequest); - //TODO: come back here when page is in core - Q_UNREACHABLE(); + if (d->adapterClient->clientType() == QtWebEngineCore::WebContentsAdapterClient::WidgetsClient) + return const_cast<QWebEnginePage *>(static_cast<const QWebEnginePage *>(d->adapterClient->holdingQObject())); return nullptr; } + +/*! \internal +*/ QWebEngineDownloadRequest::QWebEngineDownloadRequest(QWebEngineDownloadRequestPrivate *p, QObject *parent) : QObject(parent) , d_ptr(p) diff --git a/src/core/api/qwebenginedownloadrequest.h b/src/core/api/qwebenginedownloadrequest.h index 60782390c..f3056a936 100644 --- a/src/core/api/qwebenginedownloadrequest.h +++ b/src/core/api/qwebenginedownloadrequest.h @@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE -//TODO: class QWebEnginePage; class QWebEngineDownloadRequestPrivate; +class QWebEnginePage; class QWebEngineProfilePrivate; class Q_WEBENGINECORE_EXPORT QWebEngineDownloadRequest : public QObject @@ -66,13 +66,12 @@ public: Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged FINAL) Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged FINAL) Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT FINAL) - //TODO: Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION(1,7) FINAL) Q_PROPERTY(QUrl url READ url CONSTANT FINAL) Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT FINAL) Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged FINAL) Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged FINAL) - ~QWebEngineDownloadRequest(); + ~QWebEngineDownloadRequest() override; enum DownloadState { DownloadRequested, @@ -141,8 +140,7 @@ public: QString downloadFileName() const; void setDownloadFileName(const QString &fileName); - //TODO: - QObject *page() const; + QWebEnginePage *page() const; public Q_SLOTS: void accept(); @@ -168,9 +166,10 @@ private: Q_DECLARE_PRIVATE(QWebEngineDownloadRequest) friend class QWebEngineProfilePrivate; - friend class QQuickWebEngineProfilePrivate; friend class QWebEnginePage; - QWebEngineDownloadRequest(QWebEngineDownloadRequestPrivate*, QObject *parent = nullptr); + +protected: + QWebEngineDownloadRequest(QWebEngineDownloadRequestPrivate *, QObject *parent = nullptr); QScopedPointer<QWebEngineDownloadRequestPrivate> d_ptr; }; diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp index 6b66a0d70..3028c38f5 100644 --- a/src/core/api/qwebenginepage.cpp +++ b/src/core/api/qwebenginepage.cpp @@ -2415,10 +2415,6 @@ void QWebEnginePage::setVisible(bool visible) d->adapter->setVisible(visible); } -QWebEnginePage* QWebEnginePage::fromDownloadRequest(QWebEngineDownloadRequest *request) { - return static_cast<QWebEnginePagePrivate *>(request->d_ptr->adapterClient)->q_ptr; -} - QDataStream &operator<<(QDataStream &stream, const QWebEngineHistory &history) { auto adapter = history.d_func()->adapter(); diff --git a/src/core/api/qwebenginepage.h b/src/core/api/qwebenginepage.h index f2ac8eb6c..3eb4147ac 100644 --- a/src/core/api/qwebenginepage.h +++ b/src/core/api/qwebenginepage.h @@ -324,8 +324,6 @@ public: void acceptAsNewWindow(QWebEngineNewWindowRequest &request); - static QWebEnginePage* fromDownloadRequest(QWebEngineDownloadRequest * request); - Q_SIGNALS: void loadStarted(); void loadProgress(int progress); |