summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-08-07 08:27:00 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-08-17 16:05:43 +0200
commitcc31847a8a7fc36e970a5048de4a91f9e9f8f573 (patch)
tree80bc467190146a28f1eb7c2f1d37136bc6ad2385
parentcf830e3122c94e429321f43ddc81b860bd223a72 (diff)
Move QWebEngineDownloadItem to QtWebEngineCore
Use QWebEngineDownloadItem class in qml instead of QQuickWebEngineDonloadItem. Change-Id: I0fc9595f8675c9b082be873adead6de3df1e669d Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
-rw-r--r--src/core/api/core_api.pro7
-rw-r--r--src/core/api/qwebenginedownloaditem.cpp (renamed from src/webenginewidgets/api/qwebenginedownloaditem.cpp)105
-rw-r--r--src/core/api/qwebenginedownloaditem.h (renamed from src/webengine/api/qquickwebenginedownloaditem_p.h)126
-rw-r--r--src/core/api/qwebenginedownloaditem_p.h (renamed from src/webenginewidgets/api/qwebenginedownloaditem_p.h)31
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp789
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h99
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp40
-rw-r--r--src/webengine/api/qquickwebengineprofile.h8
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h4
-rw-r--r--src/webengine/doc/src/webengine_download_item.qdoc360
-rw-r--r--src/webengine/module.pro3
-rw-r--r--src/webengine/plugin/plugin.cpp20
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h174
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp2
-rw-r--r--src/webenginewidgets/webenginewidgets.pro3
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp149
-rw-r--r--tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp24
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp2
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp2
20 files changed, 619 insertions, 1331 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index aca83c7bb..533ebf03f 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -52,7 +52,9 @@ HEADERS = \
qwebengineurlscheme.h \
qwebengineurlschemehandler.h \
qwebenginecontextmenurequest.h \
- qwebenginecontextmenurequest_p.h
+ qwebenginecontextmenurequest_p.h \
+ qwebenginedownloaditem.h \
+ qwebenginedownloaditem_p.h
SOURCES = \
qtwebenginecoreglobal.cpp \
@@ -69,7 +71,8 @@ SOURCES = \
qwebengineurlrequestjob.cpp \
qwebengineurlscheme.cpp \
qwebengineurlschemehandler.cpp \
- qwebenginecontextmenurequest.cpp
+ qwebenginecontextmenurequest.cpp \
+ qwebenginedownloaditem.cpp
# Chromium headers included are not remotely clean
CONFIG -= warning_clean
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/core/api/qwebenginedownloaditem.cpp
index 7366dbf59..f7ddf024b 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/core/api/qwebenginedownloaditem.cpp
@@ -41,7 +41,6 @@
#include "qwebenginedownloaditem_p.h"
#include "profile_adapter.h"
-#include "qwebengineprofile_p.h"
#include <QDir>
#include "QFileInfo"
@@ -104,9 +103,7 @@ static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterrup
\class QWebEngineDownloadItem
\brief The QWebEngineDownloadItem class provides information about a download.
- \since 5.5
-
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
QWebEngineDownloadItem models a download throughout its life cycle, starting
with a pending download request and finishing with a completed download. It
@@ -160,8 +157,8 @@ static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterrup
QWebEnginePage::download, QWebEnginePage::save
*/
-QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url)
- : profile(p)
+QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QtWebEngineCore::ProfileAdapter *adapter, const QUrl &url)
+ : m_profileAdapter(adapter)
, downloadFinished(false)
, downloadId(-1)
, downloadState(QWebEngineDownloadItem::DownloadCancelled)
@@ -173,7 +170,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr
, isCustomFileName(false)
, totalBytes(-1)
, receivedBytes(0)
- , page(0)
+ , page(nullptr)
{
}
@@ -187,18 +184,26 @@ void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadI
Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested);
- if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason)
+ if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
-
+ Q_EMIT q->interruptReasonChanged();
+ }
if (toDownloadState(info.state) != downloadState) {
downloadState = toDownloadState(info.state);
Q_EMIT q->stateChanged(downloadState);
}
if (info.receivedBytes != receivedBytes || info.totalBytes != totalBytes) {
- receivedBytes = info.receivedBytes;
- totalBytes = info.totalBytes;
- Q_EMIT q->downloadProgress(receivedBytes, totalBytes);
+
+ if (info.receivedBytes != receivedBytes) {
+ receivedBytes = info.receivedBytes;
+ Q_EMIT q->receivedBytesChanged();
+ }
+ if (info.totalBytes != totalBytes) {
+ totalBytes = info.totalBytes;
+ Q_EMIT q->totalBytesChanged();
+ }
+ Q_EMIT q->downloadProgress(receivedBytes, totalBytes);
}
if (info.done)
@@ -206,7 +211,7 @@ void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadI
if (downloadPaused != info.paused) {
downloadPaused = info.paused;
- Q_EMIT q->isPausedChanged(downloadPaused);
+ Q_EMIT q->isPausedChanged();
}
}
@@ -216,7 +221,7 @@ void QWebEngineDownloadItemPrivate::setFinished()
return;
downloadFinished = true;
- Q_EMIT q_ptr->finished();
+ Q_EMIT q_ptr->isFinishedChanged();
}
/*!
@@ -267,8 +272,8 @@ void QWebEngineDownloadItem::cancel()
// We directly cancel the download request if the user cancels
// before it even started, so no need to notify the profile here.
if (state == QWebEngineDownloadItem::DownloadInProgress) {
- if (auto profileAdapter = d->profile->profileAdapter())
- profileAdapter->cancelDownload(d->downloadId);
+ if (d->m_profileAdapter)
+ d->m_profileAdapter->cancelDownload(d->downloadId);
} else {
d->downloadState = QWebEngineDownloadItem::DownloadCancelled;
Q_EMIT stateChanged(d->downloadState);
@@ -277,7 +282,6 @@ void QWebEngineDownloadItem::cancel()
}
/*!
- \since 5.10
Pauses the download.
Has no effect if the state is not \l DownloadInProgress. Does not change the
@@ -295,11 +299,11 @@ void QWebEngineDownloadItem::pause()
if (state != QWebEngineDownloadItem::DownloadInProgress)
return;
- d->profile->profileAdapter()->pauseDownload(d->downloadId);
+ if (d->m_profileAdapter)
+ d->m_profileAdapter->pauseDownload(d->downloadId);
}
/*!
- \since 5.10
Resumes the current download if it was paused or interrupted.
Has no effect if the state is not \l DownloadInProgress or \l
@@ -315,7 +319,8 @@ void QWebEngineDownloadItem::resume()
if (d->downloadFinished || (state != QWebEngineDownloadItem::DownloadInProgress && state != QWebEngineDownloadItem::DownloadInterrupted))
return;
- d->profile->profileAdapter()->resumeDownload(d->downloadId);
+ if (d->m_profileAdapter)
+ d->m_profileAdapter->resumeDownload(d->downloadId);
}
/*!
@@ -338,7 +343,6 @@ quint32 QWebEngineDownloadItem::id() const
/*!
\fn void QWebEngineDownloadItem::isPausedChanged(bool isPaused)
- \since 5.10
This signal is emitted whenever \a isPaused changes.
@@ -381,7 +385,6 @@ quint32 QWebEngineDownloadItem::id() const
/*!
\enum QWebEngineDownloadItem::SavePageFormat
- \since 5.7
This enum describes the format that is used to save a web page.
@@ -395,7 +398,6 @@ quint32 QWebEngineDownloadItem::id() const
/*!
\enum QWebEngineDownloadItem::DownloadType
- \since 5.8
\obsolete
Describes the requested download's type.
@@ -415,7 +417,6 @@ quint32 QWebEngineDownloadItem::id() const
/*!
\enum QWebEngineDownloadItem::DownloadInterruptReason
- \since 5.9
Describes the reason why a download was interrupted:
@@ -499,8 +500,6 @@ QUrl QWebEngineDownloadItem::url() const
}
/*!
- \since 5.6
-
Returns the MIME type of the download.
*/
@@ -557,19 +556,32 @@ void QWebEngineDownloadItem::setPath(QString path)
return;
}
+ QString newDirectory;
+ QString newFileName;
+
if (QFileInfo(path).fileName() == path) {
- d->downloadDirectory = QStringLiteral("");
- d->downloadFileName = path;
+ newDirectory = QStringLiteral("");
+ newFileName = path;
} else {
- d->downloadDirectory = QFileInfo(path).path();
- d->downloadFileName = QFileInfo(path).fileName();
+ newDirectory = QFileInfo(path).path();
+ newFileName = QFileInfo(path).fileName();
+ }
+
+ if (d->downloadDirectory != newDirectory) {
+ d->downloadDirectory = newDirectory;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadDirectoryChanged();
+ }
+
+ if (d->downloadFileName != newFileName) {
+ d->downloadFileName = newFileName;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
}
}
}
/*!
- \since 5.14
-
Returns the download directory path.
*/
@@ -580,8 +592,6 @@ QString QWebEngineDownloadItem::downloadDirectory() const
}
/*!
- \since 5.14
-
Sets \a directory as the directory path to download the file to.
The download directory path can only be set in response to the QWebEngineProfile::downloadRequested()
@@ -600,15 +610,13 @@ void QWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
if (!directory.isEmpty() && d->downloadDirectory != directory)
d->downloadDirectory = directory;
- if (!d->isCustomFileName)
- d->downloadFileName = QFileInfo(d->profile->profileAdapter()->determineDownloadPath(d->downloadDirectory,
+ if (!d->isCustomFileName && d->m_profileAdapter)
+ d->downloadFileName = QFileInfo(d->m_profileAdapter->determineDownloadPath(d->downloadDirectory,
d->suggestedFileName,
d->startTime)).fileName();
}
/*!
- \since 5.14
-
Returns the file name to download the file to.
*/
@@ -619,8 +627,6 @@ QString QWebEngineDownloadItem::downloadFileName() const
}
/*!
- \since 5.14
-
Sets \a fileName as the file name to download the file to.
The download file name can only be set in response to the QWebEngineProfile::downloadRequested()
@@ -643,8 +649,6 @@ void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
}
/*!
- \since 5.14
-
Returns the suggested file name.
*/
@@ -680,8 +684,6 @@ bool QWebEngineDownloadItem::isPaused() const
/*!
Returns the format the web page will be saved in if this is a download request for a web page.
- \since 5.7
-
\sa setSavePageFormat(), isSavePageDownload()
*/
QWebEngineDownloadItem::SavePageFormat QWebEngineDownloadItem::savePageFormat() const
@@ -692,19 +694,20 @@ QWebEngineDownloadItem::SavePageFormat QWebEngineDownloadItem::savePageFormat()
/*!
Sets the \a format the web page will be saved in if this is a download request for a web page.
- \since 5.7
\sa savePageFormat(), isSavePageDownload()
*/
void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageFormat format)
{
- Q_D(QWebEngineDownloadItem);
- d->savePageFormat = format;
+ Q_D(QWebEngineDownloadItem);
+ if (d->savePageFormat != format) {
+ d->savePageFormat = format;
+ Q_EMIT savePageFormatChanged();
+ }
}
/*!
Returns the requested download's type.
- \since 5.8
\obsolete
\note This property works unreliably, except for \c SavePage
@@ -719,7 +722,6 @@ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
/*!
Returns \c true if this is a download request for saving a web page.
- \since 5.11
\sa savePageFormat(), setSavePageFormat()
*/
@@ -731,7 +733,6 @@ bool QWebEngineDownloadItem::isSavePageDownload() const
/*!
Returns the reason why the download was interrupted.
- \since 5.9
\sa interruptReasonString()
*/
@@ -744,7 +745,6 @@ QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interrup
/*!
Returns a human-readable description of the reason for interrupting the download.
- \since 5.9
\sa interruptReason()
*/
@@ -756,11 +756,10 @@ QString QWebEngineDownloadItem::interruptReasonString() const
}
/*!
- \since 5.12
Returns the page the download was requested on. If the download was not triggered by content in a page,
\c nullptr is returned.
*/
-QWebEnginePage *QWebEngineDownloadItem::page() const
+QObject *QWebEngineDownloadItem::page() const
{
Q_D(const QWebEngineDownloadItem);
return d->page;
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/core/api/qwebenginedownloaditem.h
index 38293cd30..9310d95db 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/core/api/qwebenginedownloaditem.h
@@ -37,38 +37,45 @@
**
****************************************************************************/
-#ifndef QQUICKWEBENGINEDOWNLOADITEM_P_H
-#define QQUICKWEBENGINEDOWNLOADITEM_P_H
+#ifndef QWEBENGINEDOWNLOADITEM_H
+#define QWEBENGINEDOWNLOADITEM_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
-#include <QtWebEngine/private/qtwebengineglobal_p.h>
-
-#include <QObject>
-#include <QScopedPointer>
-#include <QString>
-#include <QUrl>
-
-#include "qquickwebengineview_p.h"
+#include <QtCore/qobject.h>
+#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItemPrivate;
-class QQuickWebEngineProfilePrivate;
+//TODO: class QWebEnginePage;
+class QWebEngineDownloadItemPrivate;
+class QWebEngineProfilePrivate;
-class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineDownloadItem: public QObject {
+class Q_WEBENGINECORE_EXPORT QWebEngineDownloadItem : public QObject
+{
Q_OBJECT
public:
- ~QQuickWebEngineDownloadItem();
+ Q_PROPERTY(quint32 id READ id CONSTANT FINAL)
+ Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged FINAL)
+ Q_PROPERTY(SavePageFormat savePageFormat READ savePageFormat WRITE setSavePageFormat NOTIFY savePageFormatChanged REVISION 2 FINAL)
+ Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged FINAL)
+ Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged FINAL)
+ Q_PROPERTY(QString mimeType READ mimeType REVISION 1 FINAL)
+ Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged FINAL)
+ Q_PROPERTY(DownloadType type READ type REVISION 3 FINAL)
+ Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged REVISION 4 FINAL)
+ Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged REVISION 4 FINAL)
+ Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged REVISION 5 FINAL)
+ Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL)
+ Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL)
+ //TODO: Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL)
+ Q_PROPERTY(QUrl url READ url CONSTANT REVISION 10 FINAL)
+ Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 10 FINAL)
+ Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 10 FINAL)
+ Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 10 FINAL)
+
+ ~QWebEngineDownloadItem();
+
enum DownloadState {
DownloadRequested,
DownloadInProgress,
@@ -125,62 +132,56 @@ public:
};
Q_ENUM(DownloadType)
- Q_PROPERTY(quint32 id READ id CONSTANT FINAL)
- Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged FINAL)
- Q_PROPERTY(SavePageFormat savePageFormat READ savePageFormat WRITE setSavePageFormat NOTIFY savePageFormatChanged REVISION 2 FINAL)
- Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged FINAL)
- Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged FINAL)
- Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged REVISION 1 FINAL)
- Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged FINAL)
- Q_PROPERTY(DownloadType type READ type NOTIFY typeChanged REVISION 3 FINAL)
- Q_PROPERTY(DownloadInterruptReason interruptReason READ interruptReason NOTIFY interruptReasonChanged REVISION 4 FINAL)
- Q_PROPERTY(QString interruptReasonString READ interruptReasonString NOTIFY interruptReasonChanged REVISION 4 FINAL)
- Q_PROPERTY(bool isFinished READ isFinished NOTIFY isFinishedChanged REVISION 5 FINAL)
- 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 10 FINAL)
- Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 10 FINAL)
- Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 10 FINAL)
- Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 10 FINAL)
-
- Q_INVOKABLE void accept();
- Q_INVOKABLE void cancel();
- Q_INVOKABLE void pause();
- Q_INVOKABLE void resume();
-
quint32 id() const;
DownloadState state() const;
qint64 totalBytes() const;
qint64 receivedBytes() const;
+ QUrl url() const;
QString mimeType() const;
+#if QT_DEPRECATED_SINCE(5, 14)
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead")
+ QString path() const;
+ QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead")
+ void setPath(QString path);
+#else
+ QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead")
QString path() const;
+ QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead")
void setPath(QString path);
+#endif
+#endif
+ bool isFinished() const;
+ bool isPaused() const;
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
DownloadType Q_DECL_DEPRECATED type() const;
DownloadInterruptReason interruptReason() const;
QString interruptReasonString() const;
- bool isFinished() const;
- bool isPaused() const;
bool isSavePageDownload() const;
- QQuickWebEngineView *view() const;
- QUrl url() const;
QString suggestedFileName() const;
QString downloadDirectory() const;
void setDownloadDirectory(const QString &directory);
QString downloadFileName() const;
void setDownloadFileName(const QString &fileName);
- bool isCustomFileName;
+
+ //TODO:
+ QObject *page() const;
+
+public Q_SLOTS:
+ void accept();
+ void cancel();
+ void pause();
+ void resume();
Q_SIGNALS:
- void stateChanged();
+ void stateChanged(QWebEngineDownloadItem::DownloadState state);
+ //TODO: fix it for qml
+ void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
Q_REVISION(2) void savePageFormatChanged();
void receivedBytesChanged();
void totalBytesChanged();
- Q_REVISION(1) void mimeTypeChanged();
void pathChanged();
- Q_REVISION(3) void typeChanged();
Q_REVISION(4) void interruptReasonChanged();
Q_REVISION(5) void isFinishedChanged();
Q_REVISION(5) void isPausedChanged();
@@ -188,14 +189,15 @@ Q_SIGNALS:
Q_REVISION(10) void downloadFileNameChanged();
private:
- QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
- Q_DISABLE_COPY(QQuickWebEngineDownloadItem)
- Q_DECLARE_PRIVATE(QQuickWebEngineDownloadItem)
- friend class QQuickWebEngineProfilePrivate;
+ Q_DISABLE_COPY(QWebEngineDownloadItem)
+ Q_DECLARE_PRIVATE(QWebEngineDownloadItem)
- QScopedPointer<QQuickWebEngineDownloadItemPrivate> d_ptr;
+ friend class QWebEngineProfilePrivate;
+ friend class QQuickWebEngineProfilePrivate;
+ QWebEngineDownloadItem(QWebEngineDownloadItemPrivate*, QObject *parent = Q_NULLPTR);
+ QScopedPointer<QWebEngineDownloadItemPrivate> d_ptr;
};
QT_END_NAMESPACE
-#endif // QQUICKWEBENGINEDOWNLOADITEM_P_H
+#endif // QWEBENGINEDOWNLOADITEM_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/core/api/qwebenginedownloaditem_p.h
index 04c6fadcc..b40a21250 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ b/src/core/api/qwebenginedownloaditem_p.h
@@ -51,23 +51,26 @@
// We mean it.
//
-#include "qtwebenginewidgetsglobal.h"
-
+#include "qtwebenginecoreglobal.h"
#include "qwebenginedownloaditem.h"
-#include "qwebengineprofile_p.h"
+#include "profile_adapter_client.h"
#include <QString>
+#include <QPointer>
+
+namespace QtWebEngineCore {
+class ProfileAdapter;
+}
QT_BEGIN_NAMESPACE
-class QWebEngineDownloadItemPrivate {
- QWebEngineDownloadItem *q_ptr;
- QWebEngineProfilePrivate* profile;
- friend class QWebEngineProfilePrivate;
+class Q_WEBENGINECORE_PRIVATE_EXPORT QWebEngineDownloadItemPrivate {
public:
- Q_DECLARE_PUBLIC(QWebEngineDownloadItem)
- QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url);
+ QWebEngineDownloadItemPrivate(QtWebEngineCore::ProfileAdapter *adapter, const QUrl &url);
~QWebEngineDownloadItemPrivate();
+ void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
+ void setFinished();
+
bool downloadFinished;
quint32 downloadId;
qint64 startTime;
@@ -83,14 +86,12 @@ public:
QString downloadDirectory;
QString downloadFileName;
bool isCustomFileName;
-
qint64 totalBytes;
qint64 receivedBytes;
- QWebEnginePage *page;
-
- void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
-
- void setFinished();
+ QWebEngineDownloadItem *q_ptr;
+ QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
+ QObject *page;
+ Q_DECLARE_PUBLIC(QWebEngineDownloadItem)
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
deleted file mode 100644
index 767ada58f..000000000
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ /dev/null
@@ -1,789 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickwebenginedownloaditem_p.h"
-#include "qquickwebenginedownloaditem_p_p.h"
-
-#include "profile_adapter.h"
-#include "qquickwebengineprofile_p.h"
-
-#include <QDir>
-#include "QFileInfo"
-
-using QtWebEngineCore::ProfileAdapterClient;
-
-QT_BEGIN_NAMESPACE
-
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QQuickWebEngineDownloadItem::NoReason)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QQuickWebEngineDownloadItem::FileFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QQuickWebEngineDownloadItem::FileAccessDenied)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QQuickWebEngineDownloadItem::FileNoSpace)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QQuickWebEngineDownloadItem::FileNameTooLong)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QQuickWebEngineDownloadItem::FileTooLarge)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QQuickWebEngineDownloadItem::FileVirusInfected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QQuickWebEngineDownloadItem::FileTransientError)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QQuickWebEngineDownloadItem::FileBlocked)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QQuickWebEngineDownloadItem::FileSecurityCheckFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QQuickWebEngineDownloadItem::FileTooShort)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QQuickWebEngineDownloadItem::FileHashMismatch)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QQuickWebEngineDownloadItem::NetworkFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QQuickWebEngineDownloadItem::NetworkTimeout)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QQuickWebEngineDownloadItem::NetworkDisconnected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QQuickWebEngineDownloadItem::NetworkServerDown)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QQuickWebEngineDownloadItem::NetworkInvalidRequest)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QQuickWebEngineDownloadItem::ServerFailed)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QQuickWebEngineDownloadItem::ServerNoRange)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QQuickWebEngineDownloadItem::ServerBadContent)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QQuickWebEngineDownloadItem::ServerUnauthorized)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QQuickWebEngineDownloadItem::ServerCertProblem)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QQuickWebEngineDownloadItem::ServerForbidden)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QQuickWebEngineDownloadItem::ServerUnreachable)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QQuickWebEngineDownloadItem::UserCanceled)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QQuickWebEngineDownloadItem::UserShutdown)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QQuickWebEngineDownloadItem::Crash)
-
-static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int state) {
- switch (state) {
- case ProfileAdapterClient::DownloadInProgress:
- return QQuickWebEngineDownloadItem::DownloadInProgress;
- case ProfileAdapterClient::DownloadCompleted:
- return QQuickWebEngineDownloadItem::DownloadCompleted;
- case ProfileAdapterClient::DownloadCancelled:
- return QQuickWebEngineDownloadItem::DownloadCancelled;
- case ProfileAdapterClient::DownloadInterrupted:
- return QQuickWebEngineDownloadItem::DownloadInterrupted;
- default:
- Q_UNREACHABLE();
- return QQuickWebEngineDownloadItem::DownloadCancelled;
- }
-}
-
-static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
-{
- return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason);
-}
-
-QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url)
- : profile(p)
- , downloadId(-1)
- , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
- , savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat)
- , type(QQuickWebEngineDownloadItem::Attachment)
- , interruptReason(QQuickWebEngineDownloadItem::NoReason)
- , totalBytes(-1)
- , receivedBytes(0)
- , downloadFinished(false)
- , downloadPaused(false)
- , view(nullptr)
- , downloadUrl(url)
- , isCustomFileName(false)
-{
-}
-
-QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate()
-{
- if (profile)
- profile->d_ptr->downloadDestroyed(downloadId);
-}
-
-/*!
- \qmltype WebEngineDownloadItem
- \instantiates QQuickWebEngineDownloadItem
- \inqmlmodule QtWebEngine
- \since QtWebEngine 1.1
- \brief Provides information about a download.
-
- WebEngineDownloadItem models a download throughout its life cycle, starting
- with a pending download request and finishing with a completed download. It
- can be used, for example, to get information about new downloads, to monitor
- progress, and to pause, resume, and cancel downloads.
-
- Downloads are usually triggered by user interaction on a web page. It is the
- WebEngineProfile's responsibility to notify the application of new download
- requests, which it does by emitting the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} signal together
- with a newly created WebEngineDownloadItem. The application can then examine
- this item and decide whether to accept it or not. A signal handler must
- explicitly call accept() on the item for \QWE to actually start
- downloading and writing data to disk. If no signal handler calls accept(),
- then the download request will be automatically rejected and nothing will be
- written to disk.
-
- \note Some properties, like the \l path under which the file will be saved,
- can only be changed before calling accept().
-
- \section2 Object Life Cycle
-
- All items are guaranteed to be valid during the emission of the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} signal. If
- accept() is \e not called by any signal handler, then the item will be
- deleted \e immediately after signal emission. This means that the
- application \b{must not} keep references to rejected download items.
-
- \section2 Web Page Downloads
-
- In addition to normal file downloads, which consist simply of retrieving
- some raw bytes from the network and writing them to disk, \QWE also
- supports saving complete web pages, which involves parsing the page's HTML,
- downloading any dependent resources, and potentially packaging everything
- into a special file format (\l savePageFormat). To check if a download is
- for a file or a web page, use \l isSavePageDownload.
-
- \sa WebEngineProfile, WebEngineProfile::downloadRequested,
- WebEngineProfile::downloadFinished
-*/
-
-void QQuickWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info)
-{
- Q_Q(QQuickWebEngineDownloadItem);
-
- updateState(toDownloadState(info.state));
-
- if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
- interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
- Q_EMIT q->interruptReasonChanged();
- }
-
- if (info.receivedBytes != receivedBytes) {
- receivedBytes = info.receivedBytes;
- Q_EMIT q->receivedBytesChanged();
- }
-
- if (info.totalBytes != totalBytes) {
- totalBytes = info.totalBytes;
- Q_EMIT q->totalBytesChanged();
- }
-
- if (info.done)
- setFinished();
-
- if (info.paused != downloadPaused) {
- downloadPaused = info.paused;
- Q_EMIT q->isPausedChanged();
- }
-}
-
-void QQuickWebEngineDownloadItemPrivate::updateState(QQuickWebEngineDownloadItem::DownloadState newState)
-{
- Q_Q(QQuickWebEngineDownloadItem);
-
- if (downloadState != newState) {
- downloadState = newState;
- Q_EMIT q->stateChanged();
- }
-}
-
-void QQuickWebEngineDownloadItemPrivate::setFinished()
-{
- Q_Q(QQuickWebEngineDownloadItem);
-
- if (downloadFinished)
- return;
-
- downloadFinished = true;
- Q_EMIT q->isFinishedChanged();
-}
-
-/*!
- \qmlmethod void WebEngineDownloadItem::accept()
-
- Accepts the download request, which will start the download.
-
- If the item is in the \c DownloadRequested state, then it will transition
- into the \c DownloadInProgress state and the downloading will begin. If the
- item is in any other state, then nothing will happen.
-
- \sa state
-*/
-
-void QQuickWebEngineDownloadItem::accept()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested)
- return;
-
- d->updateState(QQuickWebEngineDownloadItem::DownloadInProgress);
-}
-
-/*!
- \qmlmethod void WebEngineDownloadItem::cancel()
-
- Cancels the download.
-
- If the item is in the \c DownloadInProgress state, then it will transition
- into the \c DownloadCancelled state, the downloading will stop, and
- partially downloaded files will be deleted from disk.
-
- If the item is in the \c DownloadCompleted state, then nothing will happen.
- If the item is in any other state, then it will transition into the \c
- DownloadCancelled state without further effect.
-
- \sa state
-*/
-
-void QQuickWebEngineDownloadItem::cancel()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state == QQuickWebEngineDownloadItem::DownloadCompleted
- || state == QQuickWebEngineDownloadItem::DownloadCancelled)
- return;
-
- d->updateState(QQuickWebEngineDownloadItem::DownloadCancelled);
- d->setFinished();
-
- // We directly cancel the download if the user cancels before
- // it even started, so no need to notify the profile here.
- if (state == QQuickWebEngineDownloadItem::DownloadInProgress) {
- if (d->profile)
- d->profile->d_ptr->cancelDownload(d->downloadId);
- }
-}
-
-
-/*!
- \qmlmethod void WebEngineDownloadItem::pause()
- \since QtWebEngine 1.6
-
- Pauses the download.
-
- Has no effect if the state is not \c DownloadInProgress. Does not change the
- state.
-
- \sa resume, isPaused
-*/
-
-void QQuickWebEngineDownloadItem::pause()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state != QQuickWebEngineDownloadItem::DownloadInProgress)
- return;
-
- if (d->profile)
- d->profile->d_ptr->profileAdapter()->pauseDownload(d->downloadId);
-}
-
-/*!
- \qmlmethod void WebEngineDownloadItem::resume()
- \since QtWebEngine 1.6
-
- Resumes the download if it was paused or interrupted.
-
- Has no effect if the state is not \c DownloadInProgress or \c
- DownloadInterrupted. Does not change the state.
-
- \sa pause, isPaused
-*/
-void QQuickWebEngineDownloadItem::resume()
-{
- Q_D(QQuickWebEngineDownloadItem);
-
- QQuickWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (d->downloadFinished || (state != QQuickWebEngineDownloadItem::DownloadInProgress && state != QQuickWebEngineDownloadItem::DownloadInterrupted))
- return;
-
- if (d->profile)
- d->profile->d_ptr->profileAdapter()->resumeDownload(d->downloadId);
-}
-
-/*!
- \qmlproperty int WebEngineDownloadItem::id
-
- Holds the download item's ID.
-*/
-
-quint32 QQuickWebEngineDownloadItem::id() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadId;
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::state
-
- Describes the state of the download:
-
- \value WebEngineDownloadItem.DownloadRequested
- Download has been requested, but it has not been accepted yet.
- \value WebEngineDownloadItem.DownloadInProgress
- Download is in progress.
- \value WebEngineDownloadItem.DownloadCompleted
- Download completed successfully.
- \value WebEngineDownloadItem.DownloadCancelled
- Download was cancelled by the user.
- \value WebEngineDownloadItem.DownloadInterrupted
- Download has been interrupted (by the server or because of lost connectivity).
-*/
-
-QQuickWebEngineDownloadItem::DownloadState QQuickWebEngineDownloadItem::state() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadState;
-}
-
-/*!
- \qmlproperty int WebEngineDownloadItem::totalBytes
-
- Holds the total amount of data to download in bytes.
-
- \c -1 means the total size is unknown.
-*/
-
-qint64 QQuickWebEngineDownloadItem::totalBytes() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->totalBytes;
-}
-
-/*!
- \qmlproperty int WebEngineDownloadItem::receivedBytes
-
- Holds the amount of data in bytes that has been downloaded so far.
-*/
-
-qint64 QQuickWebEngineDownloadItem::receivedBytes() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->receivedBytes;
-}
-
-/*!
- \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
-
- Holds the MIME type of the download.
-*/
-
-QString QQuickWebEngineDownloadItem::mimeType() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->mimeType;
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::path
- \obsolete
-
- Use \l suggestedFileName, \l downloadDirectory, and
- \l downloadFileName instead.
-
- Holds the full target path where data is being downloaded to.
-
- The path includes the file name. The default suggested path is the standard
- download location and file name is deduced not to overwrite already existing files.
-
- The download path can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-QString QQuickWebEngineDownloadItem::path() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
-}
-
-void QQuickWebEngineDownloadItem::setPath(QString path)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download path is not allowed after the download has been accepted.");
- return;
- }
- if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
- if (QFileInfo(path).fileName().isEmpty()) {
- qWarning("The download path does not include file name.");
- return;
- }
-
- if (QFileInfo(path).isDir()) {
- qWarning("The download path matches with an already existing directory path.");
- return;
- }
-
- QString newDirectory;
- QString newFileName;
-
- if (QFileInfo(path).fileName() == path) {
- newDirectory = QStringLiteral("");
- newFileName = path;
- } else {
- newDirectory = QFileInfo(path).path();
- newFileName = QFileInfo(path).fileName();
- }
-
- if (d->downloadDirectory != newDirectory) {
- d->downloadDirectory = newDirectory;
- Q_EMIT pathChanged();
- Q_EMIT downloadDirectoryChanged();
- }
-
- if (d->downloadFileName != newFileName) {
- d->downloadFileName = newFileName;
- Q_EMIT pathChanged();
- Q_EMIT downloadFileNameChanged();
- }
- }
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::downloadDirectory
- \since QtWebEngine 1.10
-
- Holds the full target path without file name where data is being downloaded to.
-
- The download directory can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-QString QQuickWebEngineDownloadItem::downloadDirectory() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadDirectory;
-}
-
-void QQuickWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download directory is not allowed after the download has been accepted.");
- return;
- }
-
- bool isPathChanged = false;
- QString changeDirectory = d->downloadDirectory;
- if (!directory.isEmpty() && changeDirectory != directory) {
- changeDirectory = directory;
-
- if (d->downloadDirectory != changeDirectory) {
- d->downloadDirectory = changeDirectory;
- Q_EMIT downloadDirectoryChanged();
- isPathChanged = true;
- }
-
- if (!d->isCustomFileName) {
- QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->determineDownloadPath(d->downloadDirectory,
- d->suggestedFileName,
- d->startTime)).fileName();
- if (d->downloadFileName != newFileName) {
- d->downloadFileName = newFileName;
- Q_EMIT downloadFileNameChanged();
- isPathChanged = true;
- }
- }
- }
-
- if (isPathChanged)
- Q_EMIT pathChanged();
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::downloadFileName
- \since QtWebEngine 1.10
-
- Holds the name of the file to which data is being downloaded.
-
- The download file name can only be set in the
- \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
- the download is accepted.
-
- \sa WebEngineProfile::downloadRequested(), accept()
-*/
-
-QString QQuickWebEngineDownloadItem::downloadFileName() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadFileName;
-}
-
-void QQuickWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download file name is not allowed after the download has been accepted.");
- return;
- }
-
- if (d->downloadFileName != fileName && !fileName.isEmpty()) {
- d->downloadFileName = fileName;
- d->isCustomFileName = true;
- Q_EMIT downloadFileNameChanged();
- Q_EMIT pathChanged();
- }
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::suggestedFileName
- \since QtWebEngine 1.10
-
- Returns the suggested file name.
-*/
-
-QString QQuickWebEngineDownloadItem::suggestedFileName() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->suggestedFileName;
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::savePageFormat
- \since QtWebEngine 1.3
-
- Describes the format that is used to save a web page.
-
- \value WebEngineDownloadItem.UnknownSaveFormat
- This is not a request for downloading a complete web page.
- \value WebEngineDownloadItem.SingleHtmlSaveFormat
- The page is saved as a single HTML page. Resources such as images
- are not saved.
- \value WebEngineDownloadItem.CompleteHtmlSaveFormat
- The page is saved as a complete HTML page, for example a directory
- containing the single HTML page and the resources.
- \value WebEngineDownloadItem.MimeHtmlSaveFormat
- The page is saved as a complete web page in the MIME HTML format.
-*/
-
-QQuickWebEngineDownloadItem::SavePageFormat QQuickWebEngineDownloadItem::savePageFormat() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->savePageFormat;
-}
-
-void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem::SavePageFormat format)
-{
- Q_D(QQuickWebEngineDownloadItem);
- if (d->savePageFormat != format) {
- d->savePageFormat = format;
- Q_EMIT savePageFormatChanged();
- }
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::type
- \readonly
- \since QtWebEngine 1.4
- \obsolete
-
- Describes the requested download's type.
-
- \note This property works unreliably, except for \c SavePage
- downloads. Use \l isSavePageDownload instead.
-
- \value WebEngineDownloadItem.Attachment The web server's response includes a
- \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition
- is present in the reply, the web server is indicating that the client should prompt the
- user to save the content regardless of the content type.
- See \l {RFC 2616 section 19.5.1} for details.
- \value WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download
- attribute.
- \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by
- selecting a web action.
- \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by
- the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action).
-
-*/
-
-QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->type;
-}
-
-/*!
- \qmlproperty bool WebEngineDownloadItem::isSavePageDownload
- \readonly
- \since QtWebEngine 1.7
-
- Whether this is a download request for saving a web page or a file.
-
- \sa savePageFormat
-*/
-bool QQuickWebEngineDownloadItem::isSavePageDownload() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->type == QQuickWebEngineDownloadItem::SavePage;
-}
-
-/*!
- \qmlproperty enumeration WebEngineDownloadItem::interruptReason
- \readonly
- \since QtWebEngine 1.5
-
- Returns the reason why the download was interrupted:
-
- \value WebEngineDownloadItem.NoReason Unknown reason or not interrupted.
- \value WebEngineDownloadItem.FileFailed General file operation failure.
- \value WebEngineDownloadItem.FileAccessDenied The file cannot be written locally, due to access restrictions.
- \value WebEngineDownloadItem.FileNoSpace Insufficient space on the target drive.
- \value WebEngineDownloadItem.FileNameTooLong The directory or file name is too long.
- \value WebEngineDownloadItem.FileTooLarge The file size exceeds the file system limitation.
- \value WebEngineDownloadItem.FileVirusInfected The file is infected with a virus.
- \value WebEngineDownloadItem.FileTransientError Temporary problem (for example the file is in use,
- out of memory, or too many files are opened at once).
- \value WebEngineDownloadItem.FileBlocked The file was blocked due to local policy.
- \value WebEngineDownloadItem.FileSecurityCheckFailed An attempt to check the safety of the download
- failed due to unexpected reasons.
- \value WebEngineDownloadItem.FileTooShort An attempt was made to seek past the end of a file when
- opening a file (as part of resuming a previously interrupted download).
- \value WebEngineDownloadItem.FileHashMismatch The partial file did not match the expected hash.
-
- \value WebEngineDownloadItem.NetworkFailed General network failure.
- \value WebEngineDownloadItem.NetworkTimeout The network operation has timed out.
- \value WebEngineDownloadItem.NetworkDisconnected The network connection has been terminated.
- \value WebEngineDownloadItem.NetworkServerDown The server has gone down.
- \value WebEngineDownloadItem.NetworkInvalidRequest The network request was invalid (for example, the
- original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
-
- \value WebEngineDownloadItem.ServerFailed General server failure.
- \value WebEngineDownloadItem.ServerBadContent The server does not have the requested data.
- \value WebEngineDownloadItem.ServerUnauthorized The server did not authorize access to the resource.
- \value WebEngineDownloadItem.ServerCertProblem A problem with the server certificate occurred.
- \value WebEngineDownloadItem.ServerForbidden Access forbidden by the server.
- \value WebEngineDownloadItem.ServerUnreachable Unexpected server response (might indicate that
- the responding server may not be the intended server).
- \value WebEngineDownloadItem.UserCanceled The user canceled the download.
-
- \sa interruptReasonString
-*/
-
-QQuickWebEngineDownloadItem::DownloadInterruptReason QQuickWebEngineDownloadItem::interruptReason() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->interruptReason;
-}
-
-/*!
- \qmlproperty string WebEngineDownloadItem::interruptReasonString
- Returns a human-readable description of the reason for interrupting the download.
- \since QtWebEngine 1.5
-
- \sa interruptReason
-*/
-QString QQuickWebEngineDownloadItem::interruptReasonString() const
-{
- return ProfileAdapterClient::downloadInterruptReasonToString(
- static_cast<ProfileAdapterClient::DownloadInterruptReason>(interruptReason()));
-}
-
-/*!
- \qmlproperty bool WebEngineDownloadItem::isFinished
- \readonly
- \since QtWebEngine 1.6
-
- Whether this download is finished (completed, cancelled, or non-resumable interrupted state).
- */
-
-bool QQuickWebEngineDownloadItem::isFinished() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadFinished;
-}
-
-/*!
- \qmlproperty bool WebEngineDownloadItem::isPaused
- \readonly
- \since QtWebEngine 1.6
-
- Whether this download is paused.
-
- \sa pause, resume
- */
-
-bool QQuickWebEngineDownloadItem::isPaused() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadPaused;
-}
-
-/*!
- \qmlproperty WebEngineView WebEngineDownloadItem::view
- \readonly
- \since QtWebEngine 1.8
-
- Returns the view the download was requested on. If the download was not triggered by content in a view,
- \c nullptr is returned.
-
- \sa WebEngineView
-*/
-QQuickWebEngineView *QQuickWebEngineDownloadItem::view() const
-{
- Q_D(const QQuickWebEngineDownloadItem);
- return d->view;
-}
-
-QQuickWebEngineDownloadItem::QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate *p, QObject *parent)
- : QObject(parent)
- , d_ptr(p)
-{
- p->q_ptr = this;
-}
-
-QQuickWebEngineDownloadItem::~QQuickWebEngineDownloadItem()
-{
- if (!isFinished())
- cancel();
-}
-
-QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
deleted file mode 100644
index acd7fe806..000000000
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKWEBENGINEDOWNLOADITEM_P_P_H
-#define QQUICKWEBENGINEDOWNLOADITEM_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "profile_adapter_client.h"
-#include "qquickwebenginedownloaditem_p.h"
-#include "qquickwebengineprofile.h"
-#include <QString>
-#include <QPointer>
-
-QT_BEGIN_NAMESPACE
-class QQuickWebEngineProfilePrivate;
-class QQuickWebEngineView;
-
-class QQuickWebEngineDownloadItemPrivate {
- QQuickWebEngineDownloadItem *q_ptr;
- QPointer<QQuickWebEngineProfile> profile;
- friend class QQuickWebEngineProfilePrivate;
-public:
- Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
- QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url);
- ~QQuickWebEngineDownloadItemPrivate();
-
- quint32 downloadId;
- qint64 startTime;
- QQuickWebEngineDownloadItem::DownloadState downloadState;
- QQuickWebEngineDownloadItem::SavePageFormat savePageFormat;
- QQuickWebEngineDownloadItem::DownloadType type;
- QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason;
- qint64 totalBytes;
- qint64 receivedBytes;
- QString mimeType;
- QString downloadPath;
- bool downloadFinished;
- bool downloadPaused;
- QQuickWebEngineView *view;
- QUrl downloadUrl;
- QString suggestedFileName;
- QString downloadDirectory;
- QString downloadFileName;
- bool isCustomFileName;
-
- void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
- void updateState(QQuickWebEngineDownloadItem::DownloadState newState);
- void setFinished();
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKWEBENGINEDOWNLOADITEM_P_P_H
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 834bb6a05..479fa820d 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -39,8 +39,6 @@
#include "qquickwebengineprofile.h"
-#include "qquickwebenginedownloaditem_p.h"
-#include "qquickwebenginedownloaditem_p_p.h"
#include "qquickwebengineprofile_p.h"
#include "qquickwebenginescript_p.h"
#include "qquickwebenginesettings_p.h"
@@ -56,17 +54,13 @@
#include "renderer_host/user_resource_controller_host.h"
#include "web_engine_settings.h"
+#include <QtWebEngineCore/private/qwebenginedownloaditem_p.h>
#include <QtWebEngineCore/qwebengineurlscheme.h>
using QtWebEngineCore::ProfileAdapter;
QT_BEGIN_NAMESPACE
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat)
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat)
-
/*!
\class QQuickWebEngineProfile
\brief The QQuickWebEngineProfile class provides a web engine profile shared by multiple pages.
@@ -133,12 +127,12 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
*/
/*!
- \fn QQuickWebEngineProfile::downloadRequested(QQuickWebEngineDownloadItem *download)
+ \fn QQuickWebEngineProfile::downloadRequested(QWebEngineDownloadItem *download)
This signal is emitted whenever a download has been triggered.
The \a download argument holds the state of the download.
The download has to be explicitly accepted with
- \c{QQuickWebEngineDownloadItem::accept()} or it will be
+ \c{QWebEngineDownloadItem::accept()} or it will be
cancelled by default.
The download item is parented by the profile. If it is not accepted, it
will be deleted immediately after the signal emission.
@@ -146,7 +140,7 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC
*/
/*!
- \fn QQuickWebEngineProfile::downloadFinished(QQuickWebEngineDownloadItem *download)
+ \fn QQuickWebEngineProfile::downloadFinished(QWebEngineDownloadItem *download)
This signal is emitted whenever downloading stops, because it finished successfully, was
cancelled, or was interrupted (for example, because connectivity was lost).
@@ -242,38 +236,38 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QQuickWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url);
+ QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(m_profileAdapter, info.url);
itemPrivate->downloadId = info.id;
- itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
+ itemPrivate->downloadState = QWebEngineDownloadItem::DownloadRequested;
itemPrivate->startTime = info.startTime;
itemPrivate->totalBytes = info.totalBytes;
itemPrivate->mimeType = info.mimeType;
itemPrivate->downloadDirectory = QFileInfo(info.path).path();
itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
itemPrivate->suggestedFileName = info.suggestedFileName;
- itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>(
+ itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(
info.savePageFormat);
- itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType);
+ itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::QmlClient)
- itemPrivate->view = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr;
+ itemPrivate->page = static_cast<QQuickWebEngineViewPrivate *>(info.page)->q_ptr;
else
- itemPrivate->view = nullptr;
+ itemPrivate->page = nullptr;
- QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q);
+ QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q);
m_ongoingDownloads.insert(info.id, download);
- QObject::connect(download, &QQuickWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
+ QObject::connect(download, &QWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
QQmlEngine::setObjectOwnership(download, QQmlEngine::JavaScriptOwnership);
Q_EMIT q->downloadRequested(download);
- QQuickWebEngineDownloadItem::DownloadState state = download->state();
+ QWebEngineDownloadItem::DownloadState state = download->state();
info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = itemPrivate->savePageFormat;
- info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled
- && state != QQuickWebEngineDownloadItem::DownloadRequested;
+ info.accepted = state != QWebEngineDownloadItem::DownloadCancelled
+ && state != QWebEngineDownloadItem::DownloadRequested;
- if (state == QQuickWebEngineDownloadItem::DownloadRequested) {
+ if (state == QWebEngineDownloadItem::DownloadRequested) {
// Delete unaccepted downloads.
info.accepted = false;
delete download;
@@ -287,7 +281,7 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info
Q_Q(QQuickWebEngineProfile);
- QQuickWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
+ QWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
if (!download) {
downloadDestroyed(info.id);
diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h
index e5f7ff713..b5fae2271 100644
--- a/src/webengine/api/qquickwebengineprofile.h
+++ b/src/webengine/api/qquickwebengineprofile.h
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItem;
+class QWebEngineDownloadItem;
class QQuickWebEngineProfilePrivate;
class QQuickWebEngineScript;
class QQuickWebEngineSettings;
@@ -173,8 +173,8 @@ Q_SIGNALS:
Q_REVISION(5) void useForGlobalCertificateVerificationChanged();
Q_REVISION(5) void downloadPathChanged();
- void downloadRequested(QQuickWebEngineDownloadItem *download);
- void downloadFinished(QQuickWebEngineDownloadItem *download);
+ void downloadRequested(QWebEngineDownloadItem *download);
+ void downloadFinished(QWebEngineDownloadItem *download);
Q_REVISION(5) void presentNotification(QWebEngineNotification *notification);
@@ -186,8 +186,6 @@ private:
friend class QQuickWebEngineSettings;
friend class QQuickWebEngineSingleton;
friend class QQuickWebEngineViewPrivate;
- friend class QQuickWebEngineDownloadItem;
- friend class QQuickWebEngineDownloadItemPrivate;
friend class QQuickWebEngineView;
QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr;
};
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index c6d412ab3..06754c8b3 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -62,7 +62,7 @@
QT_BEGIN_NAMESPACE
-class QQuickWebEngineDownloadItem;
+class QWebEngineDownloadItem;
class QQuickWebEngineSettings;
class QQuickWebEngineViewPrivate;
@@ -100,7 +100,7 @@ private:
QQuickWebEngineProfile *q_ptr;
QScopedPointer<QQuickWebEngineSettings> m_settings;
QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
- QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads;
+ QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
QList<QQuickWebEngineScript *> m_userScripts;
};
diff --git a/src/webengine/doc/src/webengine_download_item.qdoc b/src/webengine/doc/src/webengine_download_item.qdoc
new file mode 100644
index 000000000..5695a2967
--- /dev/null
+++ b/src/webengine/doc/src/webengine_download_item.qdoc
@@ -0,0 +1,360 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype WebEngineDownloadItem
+ \instantiates QWebEngineDownloadItem
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.1
+ \brief Provides information about a download.
+
+ WebEngineDownloadItem models a download throughout its life cycle, starting
+ with a pending download request and finishing with a completed download. It
+ can be used, for example, to get information about new downloads, to monitor
+ progress, and to pause, resume, and cancel downloads.
+
+ Downloads are usually triggered by user interaction on a web page. It is the
+ WebEngineProfile's responsibility to notify the application of new download
+ requests, which it does by emitting the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} signal together
+ with a newly created WebEngineDownloadItem. The application can then examine
+ this item and decide whether to accept it or not. A signal handler must
+ explicitly call accept() on the item for \QWE to actually start
+ downloading and writing data to disk. If no signal handler calls accept(),
+ then the download request will be automatically rejected and nothing will be
+ written to disk.
+
+ \note Some properties, like the \l path under which the file will be saved,
+ can only be changed before calling accept().
+
+ \section2 Object Life Cycle
+
+ All items are guaranteed to be valid during the emission of the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} signal. If
+ accept() is \e not called by any signal handler, then the item will be
+ deleted \e immediately after signal emission. This means that the
+ application \b{must not} keep references to rejected download items.
+
+ \section2 Web Page Downloads
+
+ In addition to normal file downloads, which consist simply of retrieving
+ some raw bytes from the network and writing them to disk, \QWE also
+ supports saving complete web pages, which involves parsing the page's HTML,
+ downloading any dependent resources, and potentially packaging everything
+ into a special file format (\l savePageFormat). To check if a download is
+ for a file or a web page, use \l isSavePageDownload.
+
+ \sa WebEngineProfile, WebEngineProfile::downloadRequested,
+ WebEngineProfile::downloadFinished
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadItem::accept()
+
+ Accepts the download request, which will start the download.
+
+ If the item is in the \c DownloadRequested state, then it will transition
+ into the \c DownloadInProgress state and the downloading will begin. If the
+ item is in any other state, then nothing will happen.
+
+ \sa state
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadItem::cancel()
+
+ Cancels the download.
+
+ If the item is in the \c DownloadInProgress state, then it will transition
+ into the \c DownloadCancelled state, the downloading will stop, and
+ partially downloaded files will be deleted from disk.
+
+ If the item is in the \c DownloadCompleted state, then nothing will happen.
+ If the item is in any other state, then it will transition into the \c
+ DownloadCancelled state without further effect.
+
+ \sa state
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadItem::pause()
+ \since QtWebEngine 1.6
+
+ Pauses the download.
+
+ Has no effect if the state is not \c DownloadInProgress. Does not change the
+ state.
+
+ \sa resume, isPaused
+*/
+
+/*!
+ \qmlmethod void WebEngineDownloadItem::resume()
+ \since QtWebEngine 1.6
+
+ Resumes the download if it was paused or interrupted.
+
+ Has no effect if the state is not \c DownloadInProgress or \c
+ DownloadInterrupted. Does not change the state.
+
+ \sa pause, isPaused
+*/
+
+/*!
+ \qmlproperty int WebEngineDownloadItem::id
+
+ Holds the download item's ID.
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::state
+
+ Describes the state of the download:
+
+ \value WebEngineDownloadItem.DownloadRequested
+ Download has been requested, but it has not been accepted yet.
+ \value WebEngineDownloadItem.DownloadInProgress
+ Download is in progress.
+ \value WebEngineDownloadItem.DownloadCompleted
+ Download completed successfully.
+ \value WebEngineDownloadItem.DownloadCancelled
+ Download was cancelled by the user.
+ \value WebEngineDownloadItem.DownloadInterrupted
+ Download has been interrupted (by the server or because of lost connectivity).
+*/
+
+/*!
+ \qmlproperty int WebEngineDownloadItem::totalBytes
+
+ Holds the total amount of data to download in bytes.
+
+ \c -1 means the total size is unknown.
+*/
+
+/*!
+ \qmlproperty int WebEngineDownloadItem::receivedBytes
+
+ Holds the amount of data in bytes that has been downloaded so far.
+*/
+
+/*!
+ \qmlproperty url WebEngineDownloadItem::url
+ \readonly
+ \since QtWebEngine 1.10
+
+ Returns the download's origin URL.
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::mimeType
+ \since QtWebEngine 1.2
+
+ Holds the MIME type of the download.
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::path
+ \obsolete
+
+ Use \l suggestedFileName, \l downloadDirectory, and
+ \l downloadFileName instead.
+
+ Holds the full target path where data is being downloaded to.
+
+ The path includes the file name. The default suggested path is the standard
+ download location and file name is deduced not to overwrite already existing files.
+
+ The download path can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::downloadDirectory
+ \since QtWebEngine 1.10
+
+ Holds the full target path without file name where data is being downloaded to.
+
+ The download directory can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::downloadFileName
+ \since QtWebEngine 1.10
+
+ Holds the name of the file to which data is being downloaded.
+
+ The download file name can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::suggestedFileName
+ \since QtWebEngine 1.10
+
+ Returns the suggested file name.
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::savePageFormat
+ \since QtWebEngine 1.3
+
+ Describes the format that is used to save a web page.
+
+ \value WebEngineDownloadItem.UnknownSaveFormat
+ This is not a request for downloading a complete web page.
+ \value WebEngineDownloadItem.SingleHtmlSaveFormat
+ The page is saved as a single HTML page. Resources such as images
+ are not saved.
+ \value WebEngineDownloadItem.CompleteHtmlSaveFormat
+ The page is saved as a complete HTML page, for example a directory
+ containing the single HTML page and the resources.
+ \value WebEngineDownloadItem.MimeHtmlSaveFormat
+ The page is saved as a complete web page in the MIME HTML format.
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::type
+ \readonly
+ \since QtWebEngine 1.4
+ \obsolete
+
+ Describes the requested download's type.
+
+ \note This property works unreliably, except for \c SavePage
+ downloads. Use \l isSavePageDownload instead.
+
+ \value WebEngineDownloadItem.Attachment The web server's response includes a
+ \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition
+ is present in the reply, the web server is indicating that the client should prompt the
+ user to save the content regardless of the content type.
+ See \l {RFC 2616 section 19.5.1} for details.
+ \value WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download
+ attribute.
+ \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by
+ selecting a web action.
+ \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by
+ the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action).
+*/
+
+/*!
+ \qmlproperty bool WebEngineDownloadItem::isSavePageDownload
+ \readonly
+ \since QtWebEngine 1.7
+
+ Whether this is a download request for saving a web page or a file.
+
+ \sa savePageFormat
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineDownloadItem::interruptReason
+ \readonly
+ \since QtWebEngine 1.5
+
+ Returns the reason why the download was interrupted:
+
+ \value WebEngineDownloadItem.NoReason Unknown reason or not interrupted.
+ \value WebEngineDownloadItem.FileFailed General file operation failure.
+ \value WebEngineDownloadItem.FileAccessDenied The file cannot be written locally, due to access restrictions.
+ \value WebEngineDownloadItem.FileNoSpace Insufficient space on the target drive.
+ \value WebEngineDownloadItem.FileNameTooLong The directory or file name is too long.
+ \value WebEngineDownloadItem.FileTooLarge The file size exceeds the file system limitation.
+ \value WebEngineDownloadItem.FileVirusInfected The file is infected with a virus.
+ \value WebEngineDownloadItem.FileTransientError Temporary problem (for example the file is in use,
+ out of memory, or too many files are opened at once).
+ \value WebEngineDownloadItem.FileBlocked The file was blocked due to local policy.
+ \value WebEngineDownloadItem.FileSecurityCheckFailed An attempt to check the safety of the download
+ failed due to unexpected reasons.
+ \value WebEngineDownloadItem.FileTooShort An attempt was made to seek past the end of a file when
+ opening a file (as part of resuming a previously interrupted download).
+ \value WebEngineDownloadItem.FileHashMismatch The partial file did not match the expected hash.
+
+ \value WebEngineDownloadItem.NetworkFailed General network failure.
+ \value WebEngineDownloadItem.NetworkTimeout The network operation has timed out.
+ \value WebEngineDownloadItem.NetworkDisconnected The network connection has been terminated.
+ \value WebEngineDownloadItem.NetworkServerDown The server has gone down.
+ \value WebEngineDownloadItem.NetworkInvalidRequest The network request was invalid (for example, the
+ original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
+
+ \value WebEngineDownloadItem.ServerFailed General server failure.
+ \value WebEngineDownloadItem.ServerBadContent The server does not have the requested data.
+ \value WebEngineDownloadItem.ServerUnauthorized The server did not authorize access to the resource.
+ \value WebEngineDownloadItem.ServerCertProblem A problem with the server certificate occurred.
+ \value WebEngineDownloadItem.ServerForbidden Access forbidden by the server.
+ \value WebEngineDownloadItem.ServerUnreachable Unexpected server response (might indicate that
+ the responding server may not be the intended server).
+ \value WebEngineDownloadItem.UserCanceled The user canceled the download.
+
+ \sa interruptReasonString
+*/
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::interruptReasonString
+ Returns a human-readable description of the reason for interrupting the download.
+ \since QtWebEngine 1.5
+
+ \sa interruptReason
+*/
+
+/*!
+ \qmlproperty bool WebEngineDownloadItem::isFinished
+ \readonly
+ \since QtWebEngine 1.6
+
+ Whether this download is finished (completed, cancelled, or non-resumable interrupted state).
+ */
+
+/*!
+ \qmlproperty bool WebEngineDownloadItem::isPaused
+ \readonly
+ \since QtWebEngine 1.6
+
+ Whether this download is paused.
+
+ \sa pause, resume
+ */
+
+/*!
+ \qmlproperty WebEngineView WebEngineDownloadItem::view
+ \readonly
+ \since QtWebEngine 1.8
+
+ Returns the view the download was requested on. If the download was not triggered by content in a view,
+ \c nullptr is returned.
+
+ \sa WebEngineView
+*/
diff --git a/src/webengine/module.pro b/src/webengine/module.pro
index 40c0f57b8..8b1cab596 100644
--- a/src/webengine/module.pro
+++ b/src/webengine/module.pro
@@ -18,7 +18,6 @@ SOURCES = \
api/qquickwebengineaction.cpp \
api/qquickwebengineclientcertificateselection.cpp \
api/qquickwebenginedialogrequests.cpp \
- api/qquickwebenginedownloaditem.cpp \
api/qquickwebenginehistory.cpp \
api/qquickwebenginefaviconprovider.cpp \
api/qquickwebengineloadrequest.cpp \
@@ -42,8 +41,6 @@ HEADERS = \
api/qquickwebengineaction_p_p.h \
api/qquickwebengineclientcertificateselection_p.h \
api/qquickwebenginedialogrequests_p.h \
- api/qquickwebenginedownloaditem_p.h \
- api/qquickwebenginedownloaditem_p_p.h \
api/qquickwebenginehistory_p.h \
api/qquickwebenginefaviconprovider_p_p.h \
api/qquickwebengineloadrequest_p.h \
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 25cb375ad..031db6b31 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -42,7 +42,6 @@
#include <QtWebEngine/private/qquickwebengineclientcertificateselection_p.h>
#include <QtWebEngine/private/qquickwebenginedialogrequests_p.h>
-#include <QtWebEngine/private/qquickwebenginedownloaditem_p.h>
#include <QtWebEngine/private/qquickwebenginehistory_p.h>
#include <QtWebEngine/private/qquickwebenginefaviconprovider_p_p.h>
#include <QtWebEngine/private/qquickwebengineloadrequest_p.h>
@@ -59,6 +58,7 @@
#include <QtWebEngineCore/qwebenginequotarequest.h>
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
+#include <QtWebEngineCore/qwebenginedownloaditem.h>
QT_BEGIN_NAMESPACE
@@ -107,23 +107,23 @@ public:
qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript");
qRegisterMetaType<QWebEngineCertificateError>();
qmlRegisterUncreatableType<QWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", msgUncreatableType("WebEngineCertificateError"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 1>(uri, 1, 2, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 1>(uri, 1, 2, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 2>(uri, 1, 3, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 2>(uri, 1, 3, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 4>(uri, 1, 5, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 4>(uri, 1, 5, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 5>(uri, 1, 6, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 5>(uri, 1, 6, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 6>(uri, 1, 7, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 6>(uri, 1, 7, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem",
msgUncreatableType("WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 10>(uri, 1, 10, "WebEngineDownloadItem",
+ qmlRegisterUncreatableType<QWebEngineDownloadItem, 10>(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"));
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
deleted file mode 100644
index 094054079..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINEDOWNLOADITEM_H
-#define QWEBENGINEDOWNLOADITEM_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEnginePage;
-class QWebEngineDownloadItemPrivate;
-class QWebEngineProfilePrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineDownloadItem : public QObject
-{
- Q_OBJECT
-public:
- ~QWebEngineDownloadItem();
-
- enum DownloadState {
- DownloadRequested,
- DownloadInProgress,
- DownloadCompleted,
- DownloadCancelled,
- DownloadInterrupted
- };
- Q_ENUM(DownloadState)
-
- enum SavePageFormat {
- UnknownSaveFormat = -1,
- SingleHtmlSaveFormat,
- CompleteHtmlSaveFormat,
- MimeHtmlSaveFormat
- };
- Q_ENUM(SavePageFormat)
-
- enum DownloadInterruptReason {
- NoReason = 0,
- FileFailed = 1,
- FileAccessDenied = 2,
- FileNoSpace = 3,
- FileNameTooLong = 5,
- FileTooLarge = 6,
- FileVirusInfected = 7,
- FileTransientError = 10,
- FileBlocked = 11,
- FileSecurityCheckFailed = 12,
- FileTooShort = 13,
- FileHashMismatch = 14,
- NetworkFailed = 20,
- NetworkTimeout = 21,
- NetworkDisconnected = 22,
- NetworkServerDown = 23,
- NetworkInvalidRequest = 24,
- ServerFailed = 30,
- //ServerNoRange = 31,
- ServerBadContent = 33,
- ServerUnauthorized = 34,
- ServerCertProblem = 35,
- ServerForbidden = 36,
- ServerUnreachable = 37,
- UserCanceled = 40,
- //UserShutdown = 41,
- //Crash = 50
- };
- Q_ENUM(DownloadInterruptReason)
-
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
- Q_ENUM(DownloadType)
-
- quint32 id() const;
- DownloadState state() const;
- qint64 totalBytes() const;
- qint64 receivedBytes() const;
- QUrl url() const;
- QString mimeType() const;
-#if QT_DEPRECATED_SINCE(5, 14)
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#else
- QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#endif
-#endif
- bool isFinished() const;
- bool isPaused() const;
- SavePageFormat savePageFormat() const;
- void setSavePageFormat(SavePageFormat format);
- DownloadType Q_DECL_DEPRECATED type() const;
- DownloadInterruptReason interruptReason() const;
- QString interruptReasonString() const;
- bool isSavePageDownload() const;
- QString suggestedFileName() const;
- QString downloadDirectory() const;
- void setDownloadDirectory(const QString &directory);
- QString downloadFileName() const;
- void setDownloadFileName(const QString &fileName);
-
- QWebEnginePage *page() const;
-
-public Q_SLOTS:
- void accept();
- void cancel();
- void pause();
- void resume();
-
-Q_SIGNALS:
- void finished();
- void stateChanged(QWebEngineDownloadItem::DownloadState state);
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void isPausedChanged(bool isPaused);
-
-private:
- Q_DISABLE_COPY(QWebEngineDownloadItem)
- Q_DECLARE_PRIVATE(QWebEngineDownloadItem)
-
- friend class QWebEngineProfilePrivate;
-
- QWebEngineDownloadItem(QWebEngineDownloadItemPrivate*, QObject *parent = Q_NULLPTR);
- QScopedPointer<QWebEngineDownloadItemPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEDOWNLOADITEM_H
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index c1fff2ac2..ffb9425f0 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -42,7 +42,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebengineclientcertificateselection.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <QtWebEngineCore/qwebenginedownloaditem.h>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 4c49be709..8dd007d16 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -223,7 +223,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(this, info.url);
+ QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(m_profileAdapter, info.url);
itemPrivate->downloadId = info.id;
itemPrivate->downloadState = info.accepted ? QWebEngineDownloadItem::DownloadInProgress
: QWebEngineDownloadItem::DownloadRequested;
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 088b152a8..697f97493 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -14,7 +14,6 @@ INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
api/qwebengineclientcertificateselection.cpp \
- api/qwebenginedownloaditem.cpp \
api/qwebenginefullscreenrequest.cpp \
api/qwebenginehistory.cpp \
api/qwebenginenotificationpresenter.cpp \
@@ -29,8 +28,6 @@ SOURCES = \
HEADERS = \
api/qtwebenginewidgetsglobal.h \
api/qwebengineclientcertificateselection.h \
- api/qwebenginedownloaditem.h \
- api/qwebenginedownloaditem_p.h \
api/qwebenginefullscreenrequest.h \
api/qwebenginehistory.h \
api/qwebenginenotificationpresenter_p.h \
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 47ba7b2de..3e24632e0 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -41,11 +41,11 @@
#include <QtWebEngineCore/QWebEngineQuotaRequest>
#include <QtWebEngineCore/QWebEngineRegisterProtocolHandlerRequest>
#include <QtWebEngineCore/QWebEngineContextMenuRequest>
+#include <QtWebEngineCore/QWebEngineDownloadItem>
#include <private/qquickwebengineview_p.h>
#include <private/qquickwebengineaction_p.h>
#include <private/qquickwebengineclientcertificateselection_p.h>
#include <private/qquickwebenginedialogrequests_p.h>
-#include <private/qquickwebenginedownloaditem_p.h>
#include <private/qquickwebenginehistory_p.h>
#include <private/qquickwebengineloadrequest_p.h>
#include <private/qquickwebenginenavigationrequest_p.h>
@@ -64,7 +64,7 @@ static const QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *
<< &QQuickWebEngineAction::staticMetaObject
<< &QQuickWebEngineClientCertificateOption::staticMetaObject
<< &QQuickWebEngineClientCertificateSelection::staticMetaObject
- << &QQuickWebEngineDownloadItem::staticMetaObject
+ << &QWebEngineDownloadItem::staticMetaObject
<< &QQuickWebEngineHistory::staticMetaObject
<< &QQuickWebEngineHistoryListModel::staticMetaObject
<< &QQuickWebEngineLoadRequest::staticMetaObject
@@ -199,77 +199,76 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineContextMenuRequest.selectedText --> QString"
<< "QWebEngineContextMenuRequest.spellCheckerSuggestions --> QStringList"
<< "QWebEngineContextMenuRequest.position --> QPoint"
- << "QQuickWebEngineDownloadItem.Attachment --> DownloadType"
- << "QQuickWebEngineDownloadItem.CompleteHtmlSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.DownloadAttribute --> DownloadType"
- << "QQuickWebEngineDownloadItem.DownloadCancelled --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadCompleted --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadInProgress --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadInterrupted --> DownloadState"
- << "QQuickWebEngineDownloadItem.DownloadRequested --> DownloadState"
- << "QQuickWebEngineDownloadItem.FileAccessDenied --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileBlocked --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileHashMismatch --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileNameTooLong --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileNoSpace --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileSecurityCheckFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileTooLarge --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileTooShort --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileTransientError --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.FileVirusInfected --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.MimeHtmlSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.NetworkDisconnected --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkInvalidRequest --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkServerDown --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NetworkTimeout --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.NoReason --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.SavePage --> DownloadType"
- << "QQuickWebEngineDownloadItem.ServerBadContent --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerCertProblem --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerFailed --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerForbidden --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerUnauthorized --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.ServerUnreachable --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.SingleHtmlSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.UnknownSaveFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.UserCanceled --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.UserRequested --> DownloadType"
- << "QQuickWebEngineDownloadItem.accept() --> void"
- << "QQuickWebEngineDownloadItem.cancel() --> void"
- << "QQuickWebEngineDownloadItem.id --> uint"
- << "QQuickWebEngineDownloadItem.interruptReason --> DownloadInterruptReason"
- << "QQuickWebEngineDownloadItem.interruptReasonChanged() --> void"
- << "QQuickWebEngineDownloadItem.interruptReasonString --> QString"
- << "QQuickWebEngineDownloadItem.isFinished --> bool"
- << "QQuickWebEngineDownloadItem.isFinishedChanged() --> void"
- << "QQuickWebEngineDownloadItem.isPaused --> bool"
- << "QQuickWebEngineDownloadItem.isPausedChanged() --> void"
- << "QQuickWebEngineDownloadItem.isSavePageDownload --> bool"
- << "QQuickWebEngineDownloadItem.mimeType --> QString"
- << "QQuickWebEngineDownloadItem.mimeTypeChanged() --> void"
- << "QQuickWebEngineDownloadItem.path --> QString"
- << "QQuickWebEngineDownloadItem.pathChanged() --> void"
- << "QQuickWebEngineDownloadItem.pause() --> void"
- << "QQuickWebEngineDownloadItem.receivedBytes --> qlonglong"
- << "QQuickWebEngineDownloadItem.receivedBytesChanged() --> void"
- << "QQuickWebEngineDownloadItem.resume() --> void"
- << "QQuickWebEngineDownloadItem.savePageFormat --> SavePageFormat"
- << "QQuickWebEngineDownloadItem.savePageFormatChanged() --> void"
- << "QQuickWebEngineDownloadItem.state --> DownloadState"
- << "QQuickWebEngineDownloadItem.stateChanged() --> void"
- << "QQuickWebEngineDownloadItem.totalBytes --> qlonglong"
- << "QQuickWebEngineDownloadItem.totalBytesChanged() --> void"
- << "QQuickWebEngineDownloadItem.type --> DownloadType"
- << "QQuickWebEngineDownloadItem.typeChanged() --> void"
- << "QQuickWebEngineDownloadItem.view --> QQuickWebEngineView*"
- << "QQuickWebEngineDownloadItem.url --> QUrl"
- << "QQuickWebEngineDownloadItem.suggestedFileName --> QString"
- << "QQuickWebEngineDownloadItem.downloadDirectory --> QString"
- << "QQuickWebEngineDownloadItem.downloadDirectoryChanged() --> void"
- << "QQuickWebEngineDownloadItem.downloadFileName --> QString"
- << "QQuickWebEngineDownloadItem.downloadFileNameChanged() --> void"
+ << "QWebEngineDownloadItem.Attachment --> DownloadType"
+ << "QWebEngineDownloadItem.CompleteHtmlSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadItem.DownloadAttribute --> DownloadType"
+ << "QWebEngineDownloadItem.DownloadCancelled --> DownloadState"
+ << "QWebEngineDownloadItem.DownloadCompleted --> DownloadState"
+ << "QWebEngineDownloadItem.DownloadInProgress --> DownloadState"
+ << "QWebEngineDownloadItem.DownloadInterrupted --> DownloadState"
+ << "QWebEngineDownloadItem.DownloadRequested --> DownloadState"
+ << "QWebEngineDownloadItem.FileAccessDenied --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileBlocked --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileHashMismatch --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileNameTooLong --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileNoSpace --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileSecurityCheckFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileTooLarge --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileTooShort --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileTransientError --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.FileVirusInfected --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.MimeHtmlSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadItem.NetworkDisconnected --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.NetworkFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.NetworkInvalidRequest --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.NetworkServerDown --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.NetworkTimeout --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.NoReason --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.SavePage --> DownloadType"
+ << "QWebEngineDownloadItem.ServerBadContent --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.ServerCertProblem --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.ServerFailed --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.ServerForbidden --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.ServerUnauthorized --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.ServerUnreachable --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.SingleHtmlSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadItem.UnknownSaveFormat --> SavePageFormat"
+ << "QWebEngineDownloadItem.UserCanceled --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.UserRequested --> DownloadType"
+ << "QWebEngineDownloadItem.accept() --> void"
+ << "QWebEngineDownloadItem.cancel() --> void"
+ << "QWebEngineDownloadItem.id --> uint"
+ << "QWebEngineDownloadItem.interruptReason --> DownloadInterruptReason"
+ << "QWebEngineDownloadItem.interruptReasonChanged() --> void"
+ << "QWebEngineDownloadItem.interruptReasonString --> QString"
+ << "QWebEngineDownloadItem.isFinished --> bool"
+ << "QWebEngineDownloadItem.isFinishedChanged() --> void"
+ << "QWebEngineDownloadItem.isPaused --> bool"
+ << "QWebEngineDownloadItem.isPausedChanged() --> void"
+ << "QWebEngineDownloadItem.isSavePageDownload --> bool"
+ << "QWebEngineDownloadItem.mimeType --> QString"
+ << "QWebEngineDownloadItem.path --> QString"
+ << "QWebEngineDownloadItem.pathChanged() --> void"
+ << "QWebEngineDownloadItem.pause() --> void"
+ << "QWebEngineDownloadItem.receivedBytes --> qlonglong"
+ << "QWebEngineDownloadItem.receivedBytesChanged() --> void"
+ << "QWebEngineDownloadItem.resume() --> void"
+ << "QWebEngineDownloadItem.savePageFormat --> SavePageFormat"
+ << "QWebEngineDownloadItem.savePageFormatChanged() --> void"
+ << "QWebEngineDownloadItem.state --> DownloadState"
+ << "QWebEngineDownloadItem.stateChanged(QWebEngineDownloadItem::DownloadState) --> void"
+ << "QWebEngineDownloadItem.totalBytes --> qlonglong"
+ << "QWebEngineDownloadItem.totalBytesChanged() --> void"
+ << "QWebEngineDownloadItem.type --> DownloadType"
+ // FIXME << "QWebEngineDownloadItem.view --> QQuickWebEngineView*"
+ << "QWebEngineDownloadItem.url --> QUrl"
+ << "QWebEngineDownloadItem.suggestedFileName --> QString"
+ << "QWebEngineDownloadItem.downloadDirectory --> QString"
+ << "QWebEngineDownloadItem.downloadDirectoryChanged() --> void"
+ << "QWebEngineDownloadItem.downloadFileName --> QString"
+ << "QWebEngineDownloadItem.downloadFileNameChanged() --> void"
+ << "QWebEngineDownloadItem.downloadProgress(qlonglong,qlonglong) --> void" // FIXME
<< "QQuickWebEngineFileDialogRequest.FileModeOpen --> FileMode"
<< "QQuickWebEngineFileDialogRequest.FileModeOpenMultiple --> FileMode"
<< "QQuickWebEngineFileDialogRequest.FileModeSave --> FileMode"
@@ -341,8 +340,8 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineProfile.cachePath --> QString"
<< "QQuickWebEngineProfile.cachePathChanged() --> void"
<< "QQuickWebEngineProfile.clearHttpCache() --> void"
- << "QQuickWebEngineProfile.downloadFinished(QQuickWebEngineDownloadItem*) --> void"
- << "QQuickWebEngineProfile.downloadRequested(QQuickWebEngineDownloadItem*) --> void"
+ << "QQuickWebEngineProfile.downloadFinished(QWebEngineDownloadItem*) --> void"
+ << "QQuickWebEngineProfile.downloadRequested(QWebEngineDownloadItem*) --> void"
<< "QQuickWebEngineProfile.downloadPath --> QString"
<< "QQuickWebEngineProfile.downloadPathChanged() --> void"
<< "QQuickWebEngineProfile.presentNotification(QWebEngineNotification*) --> void"
diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
index 1af6dd49f..46de44d08 100644
--- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
+++ b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
@@ -123,7 +123,7 @@ void tst_QWebEngineDownloadItem::initTestCase()
m_requestedDownloads.remove(item);
m_finishedDownloads.remove(item);
});
- connect(item, &QWebEngineDownloadItem::finished, [this, item](){
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [this, item](){
m_finishedDownloads.insert(item);
});
});
@@ -471,7 +471,7 @@ void tst_QWebEngineDownloadItem::downloadLink()
QCOMPARE(item->url(), downloadUrl);
QCOMPARE(item->page(), m_page);
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), fileContents.size());
@@ -595,7 +595,7 @@ void tst_QWebEngineDownloadItem::downloadTwoLinks()
QFAIL(qPrintable("Unexpected file name: " + filePart));
}
- connect(item, &QWebEngineDownloadItem::finished, [&]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&]() {
finishedCount++;
});
item->setDownloadDirectory(tmpDir.path());
@@ -681,7 +681,7 @@ void tst_QWebEngineDownloadItem::downloadPage()
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
@@ -832,7 +832,7 @@ void tst_QWebEngineDownloadItem::downloadDeleted()
QVERIFY(item);
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadRequested);
downloadItem = item;
- connect(downloadItem, &QWebEngineDownloadItem::finished, [&]() {
+ connect(downloadItem, &QWebEngineDownloadItem::isFinishedChanged, [&]() {
finishedCount++;
});
item->accept();
@@ -858,7 +858,7 @@ void tst_QWebEngineDownloadItem::downloadDeletedByProfile()
bool downloadFinished = false;
QPointer<QWebEngineDownloadItem> downloadItem;
connect(profile, &QWebEngineProfile::downloadRequested, [&] (QWebEngineDownloadItem *item) {
- connect(item, &QWebEngineDownloadItem::finished, [&] () {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&] () {
downloadFinished = true;
});
downloadItem = item;
@@ -918,7 +918,7 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename()
ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
suggestedFileName = item->suggestedFileName();
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
@@ -977,7 +977,7 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilenameWithTimestamp()
ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
suggestedFileName = item->suggestedFileName();
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
@@ -1074,7 +1074,7 @@ void tst_QWebEngineDownloadItem::downloadToNonExistentDir()
ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
suggestedFileName = item->suggestedFileName();
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
@@ -1133,7 +1133,7 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
suggestedFileName = item->suggestedFileName();
downloadItem = item;
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&]() {
downloadFinished = true;
});
downloadAccepted = true;
@@ -1199,7 +1199,7 @@ void tst_QWebEngineDownloadItem::downloadPathValidation()
}
});
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
@@ -1338,7 +1338,7 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(item->path(), QDir(item->downloadDirectory()).filePath(item->downloadFileName()));
item->accept();
- connect(item, &QWebEngineDownloadItem::finished, [&, item]() {
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
QCOMPARE(item->state(), QWebEngineDownloadItem::DownloadCompleted);
QCOMPARE(item->isFinished(), true);
QCOMPARE(item->totalBytes(), item->receivedBytes());
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 550548418..21cbfa2ba 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -1681,7 +1681,7 @@ void tst_QWebEnginePage::savePage()
connect(page->profile(), &QWebEngineProfile::downloadRequested,
[] (QWebEngineDownloadItem *item)
{
- connect(item, &QWebEngineDownloadItem::finished,
+ connect(item, &QWebEngineDownloadItem::isFinishedChanged,
&QTestEventLoop::instance(), &QTestEventLoop::exitLoop, Qt::QueuedConnection);
});
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index fad94259c..34da70005 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -39,7 +39,7 @@
#include <QtWebEngineWidgets/qwebenginepage.h>
#include <QtWebEngineWidgets/qwebenginesettings.h>
#include <QtWebEngineWidgets/qwebengineview.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <QtWebEngineCore/qwebenginedownloaditem.h>
#if QT_CONFIG(webengine_webchannel)
#include <QWebChannel>