Don't ask the user twice for a filename
Fixes a bug where the user would be asked twice for a filename when using :download without a dest-argument. The problem was that we unconditionally overwrote filename, even if one was given, thus discarding any "filename-finding-process" that we had and asking the user again.
This commit is contained in:
parent
86eda2843d
commit
89c9b5959e
@ -776,7 +776,8 @@ class DownloadManager(QAbstractListModel):
|
|||||||
QNetworkRequest.AlwaysNetwork)
|
QNetworkRequest.AlwaysNetwork)
|
||||||
suggested_fn = urlutils.filename_from_url(request.url())
|
suggested_fn = urlutils.filename_from_url(request.url())
|
||||||
|
|
||||||
if fileobj is None:
|
# We won't need a question if a filename or fileobj is already given
|
||||||
|
if fileobj is None and filename is None:
|
||||||
filename, q = ask_for_filename(
|
filename, q = ask_for_filename(
|
||||||
suggested_fn, self._win_id, parent=self,
|
suggested_fn, self._win_id, parent=self,
|
||||||
prompt_download_directory=prompt_download_directory
|
prompt_download_directory=prompt_download_directory
|
||||||
@ -873,14 +874,22 @@ class DownloadManager(QAbstractListModel):
|
|||||||
download.autoclose = False
|
download.autoclose = False
|
||||||
return download
|
return download
|
||||||
|
|
||||||
filename, q = ask_for_filename(
|
|
||||||
suggested_filename, self._win_id, parent=self,
|
|
||||||
prompt_download_directory=prompt_download_directory,
|
|
||||||
)
|
|
||||||
if filename is not None:
|
if filename is not None:
|
||||||
download.set_filename(filename)
|
download.set_filename(filename)
|
||||||
return download
|
return download
|
||||||
|
|
||||||
|
# Neither filename nor fileobj were given, prepare a question
|
||||||
|
filename, q = ask_for_filename(
|
||||||
|
suggested_filename, self._win_id, parent=self,
|
||||||
|
prompt_download_directory=prompt_download_directory,
|
||||||
|
)
|
||||||
|
|
||||||
|
# User doesn't want to be asked, so just use the download_dir
|
||||||
|
if filename is not None:
|
||||||
|
download.set_filename(filename)
|
||||||
|
return download
|
||||||
|
|
||||||
|
# Ask the user for a filename
|
||||||
self._postprocess_question(q)
|
self._postprocess_question(q)
|
||||||
q.answered.connect(download.set_filename)
|
q.answered.connect(download.set_filename)
|
||||||
q.cancelled.connect(download.cancel)
|
q.cancelled.connect(download.cancel)
|
||||||
|
Loading…
Reference in New Issue
Block a user