Merge branch 'Kingdread-confirm-quit-downloads'

This commit is contained in:
Florian Bruhin 2016-05-09 07:07:59 +02:00
commit e132c1cc1e
4 changed files with 23 additions and 3 deletions

View File

@ -53,6 +53,7 @@ Fixed
- Close file handles correctly when a download failed
- Fixed crash when using `;Y` (`:hint links yank-primary`) on a system without
primary selection
- Don't display quit confirmation with finished downloads
v0.6.2
------

View File

@ -897,8 +897,8 @@ class DownloadManager(QAbstractListModel):
download.redirected.connect(
functools.partial(self.on_redirect, download))
download.basename = suggested_filename
idx = len(self.downloads) + 1
download.index = idx
idx = len(self.downloads)
download.index = idx + 1 # "Human readable" index
self.beginInsertRows(QModelIndex(), idx, idx)
self.downloads.append(download)
self.endInsertRows()
@ -1238,3 +1238,11 @@ class DownloadManager(QAbstractListModel):
# We don't have children
return 0
return len(self.downloads)
def running_downloads(self):
"""Return the amount of still running downloads.
Return:
The number of unfinished downloads.
"""
return sum(1 for download in self.downloads if not download.done)

View File

@ -413,7 +413,7 @@ class MainWindow(QWidget):
tab_count = self.tabbed_browser.count()
download_manager = objreg.get('download-manager', scope='window',
window=self.win_id)
download_count = download_manager.rowCount()
download_count = download_manager.running_downloads()
quit_texts = []
# Ask if multiple-tabs are open
if 'multiple-tabs' in confirm_quit and tab_count > 1:

View File

@ -200,3 +200,14 @@ Feature: Downloading things from a website.
And I run :close
And I wait 0.5s
Then no crash should happen
## https://github.com/The-Compiler/qutebrowser/issues/846
Scenario: Quitting with finished downloads and confirm-quit=downloads
Given I have a fresh instance
When I set storage -> prompt-download-directory to false
And I set ui -> confirm-quit to downloads
And I open data/downloads/download.bin
And I wait until the download is finished
And I run :close
Then qutebrowser should quit