diff -r 0a74c1efab70 -r 0daf79d65080 WebBrowser/Download/DownloadItem.py --- a/WebBrowser/Download/DownloadItem.py Mon Apr 02 12:04:56 2018 +0200 +++ b/WebBrowser/Download/DownloadItem.py Tue May 01 12:03:52 2018 +0200 @@ -21,7 +21,7 @@ from .Ui_DownloadItem import Ui_DownloadItem -from .DownloadUtilities import timeString, dataString +from .DownloadUtilities import timeString, dataString, speedString from WebBrowser.WebBrowserWindow import WebBrowserWindow import UI.PixmapCache @@ -35,11 +35,11 @@ Class implementing a widget controlling a download. @signal statusChanged() emitted upon a status change of a download - @signal downloadFinished() emitted when a download finished + @signal downloadFinished(success) emitted when a download finished @signal progress(int, int) emitted to signal the download progress """ statusChanged = pyqtSignal() - downloadFinished = pyqtSignal() + downloadFinished = pyqtSignal(bool) progress = pyqtSignal(int, int) Downloading = 0 @@ -356,7 +356,7 @@ self.__state = DownloadItem.DownloadCancelled self.__downloadItem.cancel() self.__setDateTime() - self.downloadFinished.emit() + self.downloadFinished.emit(False) @pyqtSlot() def on_openButton_clicked(self): @@ -401,6 +401,15 @@ self.progress.emit(currentValue, totalValue) self.__updateInfoLabel() + def downloadProgress(self): + """ + Public method to get the download progress. + + @return current download progress + @rtype int + """ + return self.progressBar.value() + def bytesTotal(self): """ Public method to get the total number of bytes of the download. @@ -471,12 +480,12 @@ if bytesTotal > 0: remaining = timeString(timeRemaining) - info = self.tr("{0} of {1} ({2}/sec)\n{3}")\ + info = self.tr("{0} of {1} ({2}/sec) {3}")\ .format( dataString(self.__bytesReceived), bytesTotal == -1 and self.tr("?") or dataString(bytesTotal), - dataString(int(speed)), + speedString(speed), remaining) else: if self.__bytesReceived == bytesTotal or bytesTotal == -1: @@ -535,7 +544,7 @@ self.__adjustSize() self.statusChanged.emit() - self.downloadFinished.emit() + self.downloadFinished.emit(True) if self.__autoOpen: self.openFile()