add downloading items to download tab

This commit is contained in:
2025-10-12 00:50:40 +02:00
parent f358d5462f
commit 962ce8984c
3 changed files with 15 additions and 3 deletions
+9
View File
@@ -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.timeout.connect(lambda: run_thread(threading.Thread(target=self.update_progress)))
self.progress_timer.start(1000) 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): def closeEvent(self, event: QCloseEvent):
closehelper() closehelper()
event.accept() event.accept()
+4 -2
View File
@@ -38,7 +38,8 @@ def aria2server():
def dlprogress(): def dlprogress():
try: try:
downloads = state.aria2.get_downloads() state.downloads = state.aria2.get_downloads()
downloads = state.downloads
if downloads: if downloads:
for download in downloads: for download in downloads:
progress = download.progress_string(0) progress = download.progress_string(0)
@@ -48,10 +49,11 @@ def dlprogress():
except: except:
return 0 return 0
def send_notification(shutdown_event): def send_notification(shutdown_event):
while not shutdown_event.is_set(): while not shutdown_event.is_set():
try: try:
for download in state.aria2.get_downloads(): for download in state.downloads:
if dlprogress() == 100: if dlprogress() == 100:
notification.notify( notification.notify(
title = "Download finished", title = "Download finished",
+2 -1
View File
@@ -8,6 +8,7 @@ class AppState:
post_titles: List[str] post_titles: List[str]
post_urls: List[str] post_urls: List[str]
post_author: List[str] post_author: List[str]
downloads: List[str]
debug: bool = False debug: bool = False
tracker: str = "rutracker" tracker: str = "rutracker"
api_url: str = "https://api.michijackson.xyz" api_url: str = "https://api.michijackson.xyz"
@@ -18,4 +19,4 @@ class AppState:
aria2p: Any = None aria2p: Any = None
aria2_threads: int = 4 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="")