From f3379174b036c405dcc54752794cdd1307385b45 Mon Sep 17 00:00:00 2001 From: KeksNino Date: Fri, 30 Jan 2026 21:59:31 +0100 Subject: [PATCH] feat: improve pause/resume/open folder button in downloads tab --- core/interface/gui.py | 46 +++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/core/interface/gui.py b/core/interface/gui.py index c596253..f58a182 100644 --- a/core/interface/gui.py +++ b/core/interface/gui.py @@ -252,27 +252,35 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): class PauseResumeDelegate(QStyledItemDelegate): clicked = Signal(int) - def paint(self, painter, option, index): - if index.column() != 0: - super().paint(painter, option, index) - return + def setEditorData(self, editor, index): + download = state.downloads[index.row()] + button = editor.findChild(QtWidgets.QPushButton) - paused = index.data(Qt.UserRole) + if button: + if download.progress == 100: + button.setText("📁") + else: + button.setText("▶︎" if download.is_paused else "⏸︎") + + + def createEditor(self, parent, option, index): download = state.downloads[index.row()] - button = QStyleOptionButton() - button.rect = option.rect - + widget = QWidget(parent) + widget.setStyleSheet("border: none;") + layout = QHBoxLayout(widget) + layout.setContentsMargins(0, 0, 0, 0) if download.progress == 100: - button.text = "📁" + btnPause = QtWidgets.QPushButton("📁") else: - button.text = "▶︎" if paused else "⏸︎" - - button.state = QStyle.State_Enabled - - QApplication.style().drawControl( - QStyle.CE_PushButton, button, painter - ) + btnPause = QtWidgets.QPushButton("▶︎" if download.is_paused else "⏸︎") + btnPause.setFixedSize(40, 30) + btnPause.clicked.connect(lambda: self.clicked.emit(index.row())) + layout.addStretch() + layout.addWidget(btnPause) + layout.addStretch() + widget.setLayout(layout) + return widget def editorEvent(self, event, model, option, index): if index.column() == 0 and event.type() == QEvent.Type.MouseButtonPress: @@ -364,7 +372,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): 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.timeout.connect(self.download_list_update) self.download_timer.start(500) self.active_timer = QTimer() @@ -393,6 +401,10 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): if self.download_model: self.download_model.layoutAboutToBeChanged.emit() self.download_model.layoutChanged.emit() + for row in range(self.download_model.rowCount()): + idx = self.download_model.index(row, 0) + self.downloadList.closePersistentEditor(idx) + self.downloadList.openPersistentEditor(idx) def closeEvent(self, event: QCloseEvent):