Add DownloadItem class
This commit is contained in:
parent
7dd5b1b94e
commit
80e2259df3
@ -24,6 +24,30 @@ from PyQt5.QtCore import pyqtSlot, QObject
|
|||||||
from qutebrowser.utils.log import downloads as logger
|
from qutebrowser.utils.log import downloads as logger
|
||||||
|
|
||||||
|
|
||||||
|
class DownloadItem(QObject):
|
||||||
|
|
||||||
|
"""A single download currently running.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
reply: The QNetworkReply associated with this download.
|
||||||
|
percentage: How many percent were downloaded successfully.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, reply, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.reply = reply
|
||||||
|
self.percentage = None
|
||||||
|
|
||||||
|
@pyqtSlot(int, int)
|
||||||
|
def on_download_progress(self, done, total):
|
||||||
|
if total == -1:
|
||||||
|
perc = -1
|
||||||
|
else:
|
||||||
|
perc = 100 * done / total
|
||||||
|
logger.debug("{}% done".format(perc))
|
||||||
|
self.percentage = perc
|
||||||
|
|
||||||
|
|
||||||
class DownloadManager(QObject):
|
class DownloadManager(QObject):
|
||||||
|
|
||||||
"""Manager for running downloads."""
|
"""Manager for running downloads."""
|
||||||
|
Loading…
Reference in New Issue
Block a user