Add donwloaded megabytes and current download speed to the
download window
This commit is contained in:
@@ -3,7 +3,7 @@ from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
from threads import DownloadThread, ThreadStatus
|
||||
from utilities import pop_up, resource_path
|
||||
from constants import Messages
|
||||
from constants import Constants, Messages
|
||||
|
||||
Ui_Download_window, _ = uic.loadUiType(resource_path("download_db_window.ui"))
|
||||
|
||||
@@ -33,8 +33,23 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
||||
|
||||
self.download_thread = DownloadThread()
|
||||
self.download_thread.finished.connect(self.wait_close)
|
||||
self.download_thread.progress.connect(self.__display_progress)
|
||||
self.cancel_btn.clicked.connect(self.terminate_process)
|
||||
|
||||
def __downlaod_format_str(self, n, speed):
|
||||
return f"Downloaded MB: {n}\nSpeed: {speed} MB/s"
|
||||
|
||||
def show(self):
|
||||
self.status_lbl.setText(self.__downlaod_format_str(0, 0))
|
||||
super().show()
|
||||
|
||||
@pyqtSlot(int, float)
|
||||
def __display_progress(self, progress, speed):
|
||||
if progress != Constants.EXTRACTING_CODE:
|
||||
self.status_lbl.setText(self.__downlaod_format_str(progress, speed))
|
||||
elif progress == Constants.EXTRACTING_CODE:
|
||||
self.status_lbl.setText(Constants.EXTRACTING_MSG + '\n')
|
||||
|
||||
@pyqtSlot()
|
||||
def terminate_process(self):
|
||||
if self.download_thread.isRunning():
|
||||
|
||||
Reference in New Issue
Block a user