diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/download_manager_delegate_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/profile_adapter.cpp | 6 | ||||
-rw-r--r-- | src/core/profile_adapter.h | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 41 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.h | 5 | ||||
-rw-r--r-- | src/webengine/plugin/plugin.pro | 2 | ||||
-rw-r--r-- | src/webengine/plugin/plugins.qmltypes | 16 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.cpp | 28 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineprofile.h | 3 |
9 files changed, 100 insertions, 7 deletions
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 948a62047..398bde710 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -164,7 +164,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem* suggestedFilename += QStringLiteral(".") + mimeType.preferredSuffix(); } - QDir defaultDownloadDirectory = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + QDir defaultDownloadDirectory(m_profileAdapter->downloadPath()); QFileInfo suggestedFile(defaultDownloadDirectory.absoluteFilePath(suggestedFilename)); QString suggestedFilePath = suggestedFile.absoluteFilePath(); diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index cee783118..dfe701cc9 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -84,6 +84,7 @@ ProfileAdapter::ProfileAdapter(const QString &storageName): , m_visitedLinksPolicy(TrackVisitedLinksOnDisk) , m_httpCacheMaxSize(0) , m_pageRequestInterceptors(0) + , m_downloadPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)) { WebEngineContext::current()->addProfileAdapter(this); // creation of profile requires webengine context @@ -253,6 +254,11 @@ void ProfileAdapter::setDataPath(const QString &path) } } +void ProfileAdapter::setDownloadPath(const QString &path) +{ + m_downloadPath = path.isEmpty() ? QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) : path; +} + QString ProfileAdapter::cachePath() const { if (m_offTheRecord) diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h index 9849d2788..3b1b9bc91 100644 --- a/src/core/profile_adapter.h +++ b/src/core/profile_adapter.h @@ -113,6 +113,9 @@ public: QString dataPath() const; void setDataPath(const QString &path); + QString downloadPath() const { return m_downloadPath; } + void setDownloadPath(const QString &path); + QString cachePath() const; void setCachePath(const QString &path); @@ -211,6 +214,7 @@ private: QPointer<QWebEngineUrlRequestInterceptor> m_requestInterceptor; QString m_dataPath; + QString m_downloadPath; QString m_cachePath; QString m_httpUserAgent; HttpCacheType m_httpCacheType; diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 1d93c5070..4448d44d1 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -850,6 +850,47 @@ bool QQuickWebEngineProfile::isUsedForGlobalCertificateVerification() const } /*! + \qmlproperty string WebEngineProfile::downloadPath + \since QtWebEngine 1.9 + + The path to the location where the downloaded files are stored. + + Overrides the default path used for download location. + + If set to the null string, the default path is restored. + + \note By default, the download path is QStandardPaths::DownloadLocation. +*/ + +/*! + \property QQuickWebEngineProfile::downloadPath + \since QtWebEngine 1.9 + + The path to the location where the downloaded files are stored. + + Overrides the default path used for download location, setting it to \a path. + + If set to the null string, the default path is restored. + + \note By default, the download path is QStandardPaths::DownloadLocation. +*/ + +void QQuickWebEngineProfile::setDownloadPath(const QString &path) +{ + Q_D(QQuickWebEngineProfile); + if (downloadPath() == path) + return; + d->profileAdapter()->setDownloadPath(path); + emit downloadPathChanged(); +} + +QString QQuickWebEngineProfile::downloadPath() const +{ + const Q_D(QQuickWebEngineProfile); + return d->profileAdapter()->downloadPath(); +} + +/*! Returns the cookie store for this profile. */ diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h index 1a3abe044..1e2e3e030 100644 --- a/src/webengine/api/qquickwebengineprofile.h +++ b/src/webengine/api/qquickwebengineprofile.h @@ -77,6 +77,7 @@ class Q_WEBENGINE_EXPORT QQuickWebEngineProfile : public QObject { WRITE setUseForGlobalCertificateVerification NOTIFY useForGlobalCertificateVerificationChanged FINAL REVISION 5) + Q_PROPERTY(QString downloadPath READ downloadPath WRITE setDownloadPath NOTIFY downloadPathChanged FINAL REVISION 5) public: QQuickWebEngineProfile(QObject *parent = Q_NULLPTR); @@ -145,6 +146,9 @@ public: void setUseForGlobalCertificateVerification(bool b); bool isUsedForGlobalCertificateVerification() const; + QString downloadPath() const; + void setDownloadPath(const QString &path); + static QQuickWebEngineProfile *defaultProfile(); Q_SIGNALS: @@ -160,6 +164,7 @@ Q_SIGNALS: Q_REVISION(3) void spellCheckLanguagesChanged(); Q_REVISION(3) void spellCheckEnabledChanged(); Q_REVISION(5) void useForGlobalCertificateVerificationChanged(); + Q_REVISION(5) void downloadPathChanged(); void downloadRequested(QQuickWebEngineDownloadItem *download); void downloadFinished(QQuickWebEngineDownloadItem *download); diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro index c3702e81d..102f9a9fe 100644 --- a/src/webengine/plugin/plugin.pro +++ b/src/webengine/plugin/plugin.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = qtwebengineplugin TARGETPATH = QtWebEngine -IMPORT_VERSION = 1.8 +IMPORT_VERSION = 1.9 QT += qml quick QT_PRIVATE += core-private webenginecore-private webengine-private diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes index 1f295ac57..435124e30 100644 --- a/src/webengine/plugin/plugins.qmltypes +++ b/src/webengine/plugin/plugins.qmltypes @@ -4,7 +4,7 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -defaultplatform -dependencies dependencies.json -nonrelocatable QtWebEngine 1.8' +// 'qmlplugindump -defaultplatform -dependencies dependencies.json -nonrelocatable QtWebEngine 1.9' Module { dependencies: ["QtQuick 2.8"] @@ -437,9 +437,10 @@ Module { "QtWebEngine/WebEngineProfile 1.2", "QtWebEngine/WebEngineProfile 1.3", "QtWebEngine/WebEngineProfile 1.4", - "QtWebEngine/WebEngineProfile 1.5" + "QtWebEngine/WebEngineProfile 1.5", + "QtWebEngine/WebEngineProfile 1.9" ] - exportMetaObjectRevisions: [0, 1, 2, 3, 4] + exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5] Enum { name: "HttpCacheType" values: { @@ -474,9 +475,13 @@ Module { isList: true isReadonly: true } + Property { name: "useForGlobalCertificateVerification"; revision: 5; type: "bool" } + Property { name: "downloadPath"; revision: 5; type: "string" } Signal { name: "httpAcceptLanguageChanged"; revision: 1 } Signal { name: "spellCheckLanguagesChanged"; revision: 3 } Signal { name: "spellCheckEnabledChanged"; revision: 3 } + Signal { name: "useForGlobalCertificateVerificationChanged"; revision: 5 } + Signal { name: "downloadPathChanged"; revision: 5 } Signal { name: "downloadRequested" Parameter { name: "download"; type: "QQuickWebEngineDownloadItem"; isPointer: true } @@ -664,9 +669,10 @@ Module { "QtWebEngine/WebEngineView 1.5", "QtWebEngine/WebEngineView 1.6", "QtWebEngine/WebEngineView 1.7", - "QtWebEngine/WebEngineView 1.8" + "QtWebEngine/WebEngineView 1.8", + "QtWebEngine/WebEngineView 1.9" ] - exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7, 8] + exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Enum { name: "NavigationRequestAction" values: { diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 7b2f398ba..7e80f9720 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -359,6 +359,34 @@ void QWebEngineProfile::setPersistentStoragePath(const QString &path) } /*! + \since 5.13 + + The path to the location where the downloaded files are stored. + + \note By default, the download path is QStandardPaths::DownloadLocation. + + \sa setDownloadPath(), QStandardPaths::writableLocation() +*/ +QString QWebEngineProfile::downloadPath() const +{ + const Q_D(QWebEngineProfile); + return d->profileAdapter()->downloadPath(); +} + +/*! + Overrides the default path used for download location, setting it to \a path. + + If set to the null string, the default path is restored. + + \sa downloadPath() +*/ +void QWebEngineProfile::setDownloadPath(const QString &path) +{ + Q_D(QWebEngineProfile); + d->profileAdapter()->setDownloadPath(path); +} + +/*! Returns the path used for caches. By default, this is below StandardPaths::CacheLocation in a QtWebengine/StorageName specific diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index 7ec28ac0a..9fc509851 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -131,6 +131,9 @@ public: void setUseForGlobalCertificateVerification(); bool isUsedForGlobalCertificateVerification() const; + QString downloadPath() const; + void setDownloadPath(const QString &path); + static QWebEngineProfile *defaultProfile(); Q_SIGNALS: |