diff options
author | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2019-05-28 13:54:28 +0200 |
---|---|---|
committer | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2019-07-05 08:57:30 +0200 |
commit | 0884fab3b161b62c1e2bb1bac6bbd74560f06232 (patch) | |
tree | ec07c0b9473c5eb05880cd1783ca11dd5bc09aa0 /examples | |
parent | fbc2700180d97d9c84b079b7c4da9eace19abf23 (diff) |
Add API to change download directory path and file name
Add functions and property to change the download directory and
file name in QWebEngineDownloadItem and QQuickWebEngineDownloadItem
and deprecate the path() and setPath().
Regenerating the uniquifying download filename after
change the download directory.
[ChangeLog][DownloadItem] Add functions and property
to change the download directory and file name in
QWebEngineDownloadItem and QQuickWebEngineDownloadItem
and deprecate the path() and setPath().
Task-number: QTBUG-56978
Change-Id: I6e63da82a187add8bc3206cc80c8bf6865fbdd35
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'examples')
3 files changed, 6 insertions, 4 deletions
diff --git a/examples/webengine/quicknanobrowser/DownloadView.qml b/examples/webengine/quicknanobrowser/DownloadView.qml index f6ebeab4a..e26c770bc 100644 --- a/examples/webengine/quicknanobrowser/DownloadView.qml +++ b/examples/webengine/quicknanobrowser/DownloadView.qml @@ -101,7 +101,7 @@ Rectangle { } Label { id: label - text: path + text: downloadDirectory + "/" + downloadFileName anchors { verticalCenter: cancelButton.verticalCenter left: parent.left diff --git a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp index e0a511475..b6f9e9c13 100644 --- a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp +++ b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp @@ -55,6 +55,7 @@ #include "downloadwidget.h" #include <QFileDialog> +#include <QDir> #include <QWebEngineDownloadItem> DownloadManagerWidget::DownloadManagerWidget(QWidget *parent) @@ -68,11 +69,12 @@ void DownloadManagerWidget::downloadRequested(QWebEngineDownloadItem *download) { Q_ASSERT(download && download->state() == QWebEngineDownloadItem::DownloadRequested); - QString path = QFileDialog::getSaveFileName(this, tr("Save as"), download->path()); + QString path = QFileDialog::getSaveFileName(this, tr("Save as"), QDir(download->downloadDirectory()).filePath(download->downloadFileName())); if (path.isEmpty()) return; - download->setPath(path); + download->setDownloadDirectory(QFileInfo(path).path()); + download->setDownloadFileName(QFileInfo(path).fileName()); download->accept(); add(new DownloadWidget(download)); diff --git a/examples/webenginewidgets/simplebrowser/downloadwidget.cpp b/examples/webenginewidgets/simplebrowser/downloadwidget.cpp index 1d599a19d..835a901c6 100644 --- a/examples/webenginewidgets/simplebrowser/downloadwidget.cpp +++ b/examples/webenginewidgets/simplebrowser/downloadwidget.cpp @@ -60,7 +60,7 @@ DownloadWidget::DownloadWidget(QWebEngineDownloadItem *download, QWidget *parent , m_timeAdded(QTime::currentTime()) { setupUi(this); - m_dstName->setText(QFileInfo(m_download->path()).fileName()); + m_dstName->setText(m_download->downloadFileName()); m_srcUrl->setText(m_download->url().toDisplayString()); connect(m_cancelButton, &QPushButton::clicked, |