diff --git a/core/interface/gui.py b/core/interface/gui.py index efa62dd..b057757 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -109,6 +109,15 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.progress_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.update_progress))) self.progress_timer.start(1000) + self.download_timer = QTimer() + self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update))) + self.download_timer.start(5000) + + def download_list_update(self): + self.downloadList.clear() + for download in state.downloads: + self.downloadList.addItem(download.name) + def closeEvent(self, event: QCloseEvent): closehelper() event.accept() diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index aeb27d8..b9152b2 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -38,7 +38,8 @@ def aria2server(): def dlprogress(): try: - downloads = state.aria2.get_downloads() + state.downloads = state.aria2.get_downloads() + downloads = state.downloads if downloads: for download in downloads: progress = download.progress_string(0) @@ -48,10 +49,11 @@ def dlprogress(): except: return 0 + def send_notification(shutdown_event): while not shutdown_event.is_set(): try: - for download in state.aria2.get_downloads(): + for download in state.downloads: if dlprogress() == 100: notification.notify( title = "Download finished", diff --git a/core/utils/data/state.py b/core/utils/data/state.py index 425d521..633415e 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -8,6 +8,7 @@ class AppState: post_titles: List[str] post_urls: List[str] post_author: List[str] + downloads: List[str] debug: bool = False tracker: str = "rutracker" api_url: str = "https://api.michijackson.xyz" @@ -18,4 +19,4 @@ class AppState: aria2p: Any = None aria2_threads: int = 4 -state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], download_path="") +state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], downloads=[], download_path="")