diff options
Diffstat (limited to 'src/webenginewidgets/api/qwebenginedownloaditem.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index e1bfc506f..7366dbf59 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -170,6 +170,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr , interruptReason(QWebEngineDownloadItem::NoReason) , downloadUrl(url) , downloadPaused(false) + , isCustomFileName(false) , totalBytes(-1) , receivedBytes(0) , page(0) @@ -588,20 +589,21 @@ QString QWebEngineDownloadItem::downloadDirectory() const download item's state. */ -void QWebEngineDownloadItem::setDownloadDirectory(QString directory) +void QWebEngineDownloadItem::setDownloadDirectory(const QString &directory) { Q_D(QWebEngineDownloadItem); if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) { qWarning("Setting the download directory is not allowed after the download has been accepted."); return; - } + } if (!directory.isEmpty() && d->downloadDirectory != directory) d->downloadDirectory = directory; - d->downloadFileName = QFileInfo(d->profile->profileAdapter()->updateDownloadPath(d->downloadId, - d->downloadDirectory, - d->suggestedFileName)).fileName(); + if (!d->isCustomFileName) + d->downloadFileName = QFileInfo(d->profile->profileAdapter()->determineDownloadPath(d->downloadDirectory, + d->suggestedFileName, + d->startTime)).fileName(); } /*! @@ -626,7 +628,7 @@ QString QWebEngineDownloadItem::downloadFileName() const download item's state. */ -void QWebEngineDownloadItem::setDownloadFileName(QString fileName) +void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName) { Q_D(QWebEngineDownloadItem); if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) { @@ -634,8 +636,10 @@ void QWebEngineDownloadItem::setDownloadFileName(QString fileName) return; } - if (!fileName.isEmpty()) + if (!fileName.isEmpty()) { d->downloadFileName = fileName; + d->isCustomFileName = true; + } } /*! |