This commit is contained in:
Vxrtrauter
2025-10-12 20:27:03 +02:00
3 changed files with 54 additions and 10 deletions
+52 -8
View File
@@ -1,7 +1,9 @@
from PySide6 import QtWidgets 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 ( from PySide6.QtWidgets import (
QLineEdit, QLineEdit,
QTableView,
QWidget, QWidget,
QVBoxLayout, QVBoxLayout,
QListWidget, QListWidget,
@@ -11,6 +13,7 @@ from PySide6.QtWidgets import (
QComboBox, QComboBox,
QTabWidget, QTabWidget,
QProgressBar, QProgressBar,
QHeaderView,
) )
from PySide6.QtGui import QIcon, QAction, QCloseEvent from PySide6.QtGui import QIcon, QAction, QCloseEvent
import darkdetect import darkdetect
@@ -48,7 +51,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.softwareList = QListWidget() self.softwareList = QListWidget()
self.post_author_list = QListWidget() self.post_author_list = QListWidget()
self.libraryList = QListWidget() self.libraryList = QListWidget()
self.downloadList = QListWidget() self.download_model = None
self.downloadList = QTableView()
self.emptyLibrary = QLabel("No items in library.") self.emptyLibrary = QLabel("No items in library.")
self.emptyDownload = QLabel("No items in downloads.") self.emptyDownload = QLabel("No items in downloads.")
self.progressbar = QProgressBar() self.progressbar = QProgressBar()
@@ -61,6 +65,47 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
containerLayout.addWidget(self.post_author_list) containerLayout.addWidget(self.post_author_list)
self.softwareList.addItems(searchresults) 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 # download button triggers
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(self.softwareList.currentItem(), state.posts, state.post_titles)))) 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 = QTimer()
self.download_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.download_list_update))) 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): def download_list_update(self):
self.downloadList.clear() if self.download_model:
for download in state.downloads: self.download_model.layoutAboutToBeChanged.emit()
self.downloadList.addItem(download.name) self.download_model.layoutChanged.emit()
def closeEvent(self, event: QCloseEvent): def closeEvent(self, event: QCloseEvent):
closehelper() closehelper()
@@ -125,7 +170,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
def set_tracker(self, _): def set_tracker(self, _):
state.tracker = self.tracker_list.currentText() state.tracker = self.tracker_list.currentText()
def update_progress(self): def update_progress(self):
progress = dlprogress() progress = dlprogress()
self.progressbar.setValue(progress) self.progressbar.setValue(progress)
+1 -1
View File
@@ -14,4 +14,4 @@ def create_tab(title, searchbar, software_list, tabs, dlbutton, layout2):
layout.addWidget(dlbutton) layout.addWidget(dlbutton)
tab.setLayout(layout) tab.setLayout(layout)
tabs.addTab(tab, title) tabs.addTab(tab, title)
return tab return tab
+1 -1
View File
@@ -44,7 +44,7 @@ def aria2server():
def dlprogress(): def dlprogress():
try: 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 downloads = state.downloads
if downloads: if downloads:
for download in downloads: for download in downloads: