From 65a5b8cdbfdf2a9ae1e1aff118d42b10537ea212 Mon Sep 17 00:00:00 2001 From: KeksNino Date: Sun, 12 Oct 2025 17:06:00 +0200 Subject: [PATCH 1/3] hide aria2 metadata in state.downloads --- core/interface/utils/tabhelper.py | 2 +- core/network/aria2_integration.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/interface/utils/tabhelper.py b/core/interface/utils/tabhelper.py index 0540517..e424b3f 100644 --- a/core/interface/utils/tabhelper.py +++ b/core/interface/utils/tabhelper.py @@ -14,4 +14,4 @@ def create_tab(title, searchbar, software_list, tabs, dlbutton, layout2): layout.addWidget(dlbutton) tab.setLayout(layout) tabs.addTab(tab, title) - return tab \ No newline at end of file + return tab diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index 49cd7e5..1850654 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -44,7 +44,7 @@ def aria2server(): def dlprogress(): try: - state.downloads = state.aria2.get_downloads() + state.downloads = [download for download in state.aria2.get_downloads() if not download.is_metadata] downloads = state.downloads if downloads: for download in downloads: From 6e2860cb676d8760566a728a325558420917f7eb Mon Sep 17 00:00:00 2001 From: KeksNino Date: Sun, 12 Oct 2025 20:08:35 +0200 Subject: [PATCH 2/3] add downloads tab functionality --- core/interface/gui.py | 60 ++++++++++++++++++++++++++----- core/network/aria2_integration.py | 11 ++++++ core/utils/data/state.py | 1 + 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/core/interface/gui.py b/core/interface/gui.py index b057757..0735108 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -1,7 +1,9 @@ from PySide6 import QtWidgets -from PySide6.QtCore import Qt, QTimer +from PySide6 import QtCore +from PySide6.QtCore import Qt, QTimer, QModelIndex, QAbstractTableModel from PySide6.QtWidgets import ( - QLineEdit, + QLineEdit, + QTableView, QWidget, QVBoxLayout, QListWidget, @@ -11,6 +13,7 @@ from PySide6.QtWidgets import ( QComboBox, QTabWidget, QProgressBar, + QHeaderView, ) from PySide6.QtGui import QIcon, QAction, QCloseEvent import darkdetect @@ -48,7 +51,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.softwareList = QListWidget() self.post_author_list = QListWidget() self.libraryList = QListWidget() - self.downloadList = QListWidget() + self.download_model = None + self.downloadList = QTableView() self.emptyLibrary = QLabel("No items in library.") self.emptyDownload = QLabel("No items in downloads.") self.progressbar = QProgressBar() @@ -61,6 +65,47 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): containerLayout.addWidget(self.post_author_list) self.softwareList.addItems(searchresults) + class DownloadModel(QAbstractTableModel): + def __init__(self): + super().__init__() + self.headers = ["Name", "Status", "Progress", "Speed", "Size", "Total Size"] + + def rowCount(self, parent=QModelIndex()): + return len(state.downloads) + + def columnCount(self, parent=QModelIndex()): + return len(self.headers) + + def headerData(self, section, orientation, role=Qt.DisplayRole): + if role == Qt.DisplayRole and orientation == Qt.Horizontal: + return self.headers[section] + return None + + def data(self, index, role=Qt.DisplayRole): + if role == Qt.DisplayRole: + download = state.downloads[index.row()] + col = index.column() + + if col == 0: + return download.name + elif col == 1: + return getattr(download, 'status', 'Downloading') + elif col == 2: + return f"{int(download.progress)}%" + elif col == 3: + return f"{download.download_speed_string()}" + elif col == 4: + pass + elif col == 5: + return f"{download.total_length_string()}" + return None + + self.download_model = DownloadModel() + self.downloadList.setModel(self.download_model) + self.downloadList.horizontalHeader().setStretchLastSection(False) + self.downloadList.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) + self.downloadList.setSelectionBehavior(QTableView.SelectRows) + # download button triggers self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(self.softwareList.currentItem(), state.posts, state.post_titles)))) @@ -111,12 +156,12 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.download_timer = QTimer() self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update))) - self.download_timer.start(5000) + self.download_timer.start(500) def download_list_update(self): - self.downloadList.clear() - for download in state.downloads: - self.downloadList.addItem(download.name) + if self.download_model: + self.download_model.layoutAboutToBeChanged.emit() + self.download_model.layoutChanged.emit() def closeEvent(self, event: QCloseEvent): closehelper() @@ -125,7 +170,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): def set_tracker(self, _): state.tracker = self.tracker_list.currentText() - def update_progress(self): progress = dlprogress() self.progressbar.setValue(progress) diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index 1850654..2830cac 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -55,6 +55,17 @@ def dlprogress(): except: return 0 +# def dlspeed(): +# try: +# state.downloads = [download for download in state.aria2.get_downloads() if not download.is_metadata] +# downloads = state.downloads +# if downloads: +# for download in downloads: +# speed = download.download_speed() +# return speed +# return "0 B/s" +# except: +# return "0 B/s" def send_notification(shutdown_event): while not shutdown_event.is_set(): diff --git a/core/utils/data/state.py b/core/utils/data/state.py index 633415e..912bfd8 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -9,6 +9,7 @@ class AppState: post_urls: List[str] post_author: List[str] downloads: List[str] + # dl_speed: str = "0 B/s" debug: bool = False tracker: str = "rutracker" api_url: str = "https://api.michijackson.xyz" From de2fc1ca420668668167867bbdb37b4bc69e0d89 Mon Sep 17 00:00:00 2001 From: KeksNino Date: Sun, 12 Oct 2025 20:09:38 +0200 Subject: [PATCH 3/3] remove unnecessary comments --- core/network/aria2_integration.py | 12 ------------ core/utils/data/state.py | 1 - 2 files changed, 13 deletions(-) diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index 2830cac..9b14bb5 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -55,18 +55,6 @@ def dlprogress(): except: return 0 -# def dlspeed(): -# try: -# state.downloads = [download for download in state.aria2.get_downloads() if not download.is_metadata] -# downloads = state.downloads -# if downloads: -# for download in downloads: -# speed = download.download_speed() -# return speed -# return "0 B/s" -# except: -# return "0 B/s" - def send_notification(shutdown_event): while not shutdown_event.is_set(): try: diff --git a/core/utils/data/state.py b/core/utils/data/state.py index 912bfd8..633415e 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -9,7 +9,6 @@ class AppState: post_urls: List[str] post_author: List[str] downloads: List[str] - # dl_speed: str = "0 B/s" debug: bool = False tracker: str = "rutracker" api_url: str = "https://api.michijackson.xyz"