eric7/WebBrowser/Download/DownloadItem.py

branch
eric7
changeset 8318
962bce857696
parent 8312
800c432b34c8
child 8356
68ec9c3d4de5
equal deleted inserted replaced
8316:0c7a44af84bc 8318:962bce857696
7 Module implementing a widget controlling a download. 7 Module implementing a widget controlling a download.
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt5.QtCore import ( 12 from PyQt6.QtCore import (
13 pyqtSlot, pyqtSignal, Qt, QTime, QUrl, QStandardPaths, QFileInfo, QDateTime 13 pyqtSlot, pyqtSignal, Qt, QTime, QUrl, QStandardPaths, QFileInfo, QDateTime
14 ) 14 )
15 from PyQt5.QtGui import QPalette, QDesktopServices 15 from PyQt6.QtGui import QPalette, QDesktopServices
16 from PyQt5.QtWidgets import QWidget, QStyle, QDialog 16 from PyQt6.QtWidgets import QWidget, QStyle, QDialog
17 from PyQt5.QtWebEngineWidgets import QWebEngineDownloadItem 17 from PyQt6.QtWebEngineWidgets import QWebEngineDownloadItem
18 18
19 from E5Gui import E5FileDialog 19 from E5Gui import E5FileDialog
20 20
21 from .Ui_DownloadItem import Ui_DownloadItem 21 from .Ui_DownloadItem import Ui_DownloadItem
22 22
107 self.__finishedDownloading = False 107 self.__finishedDownloading = False
108 self.__bytesReceived = 0 108 self.__bytesReceived = 0
109 self.__bytesTotal = -1 109 self.__bytesTotal = -1
110 110
111 # start timer for the download estimation 111 # start timer for the download estimation
112 self.__downloadTime.start() 112 self.__downloadTime = QTime.currentTime()
113 113
114 # attach to the download item object 114 # attach to the download item object
115 self.__url = self.__downloadItem.url() 115 self.__url = self.__downloadItem.url()
116 self.__downloadItem.downloadProgress.connect(self.__downloadProgress) 116 self.__downloadItem.downloadProgress.connect(self.__downloadProgress)
117 self.__downloadItem.finished.connect(self.__finished) 117 self.__downloadItem.finished.connect(self.__finished)
419 @return estimation for the download speed (float) 419 @return estimation for the download speed (float)
420 """ 420 """
421 if not self.downloading(): 421 if not self.downloading():
422 return -1.0 422 return -1.0
423 423
424 return self.__bytesReceived * 1000.0 / self.__downloadTime.elapsed() 424 return (
425 self.__bytesReceived * 1000.0 /
426 self.__downloadTime.msecsTo(QTime.currentTime)
427 )
425 428
426 def __updateInfoLabel(self): 429 def __updateInfoLabel(self):
427 """ 430 """
428 Private method to update the info label. 431 Private method to update the info label.
429 """ 432 """

eric ide

mercurial