diff options
| author | Warry <FunWarry@users.noreply.github.com> | 2025-12-03 11:41:18 +0100 |
|---|---|---|
| committer | Warry <FunWarry@users.noreply.github.com> | 2025-12-03 11:41:18 +0100 |
| commit | c1d40619aa2aa44f5d967af9b5f47d040d6dc7dd (patch) | |
| tree | ad05969f0bae4cfe68e3e5baf9ea6a8954fa626a /tidal_dl_ng/gui_queue.py | |
| parent | 85f7e33b28985afd62a99d64b3e7a6883d62b072 (diff) | |
| parent | e89be804fd8fdbee1638f0cdc055eb095206ef8c (diff) | |
| download | tidal-dl-ng-c1d40619aa2aa44f5d967af9b5f47d040d6dc7dd.tar.gz | |
Merge branch 'feature/json-downloaded' into fusion-refac-&-info
# Conflicts:
# .gitignore
# README.md
# tidal_dl_ng/gui.py
Diffstat (limited to 'tidal_dl_ng/gui_queue.py')
| -rw-r--r-- | tidal_dl_ng/gui_queue.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/tidal_dl_ng/gui_queue.py b/tidal_dl_ng/gui_queue.py index 3abd3f0..d716a08 100644 --- a/tidal_dl_ng/gui_queue.py +++ b/tidal_dl_ng/gui_queue.py @@ -82,18 +82,23 @@ class GuiQueueManager: def on_queue_download_clear_all(self) -> None: """Clear all items from the download queue.""" self.on_clear_queue_download( - f"({QueueDownloadStatus.Waiting}|{QueueDownloadStatus.Finished}|{QueueDownloadStatus.Failed}|{QueueDownloadStatus.Skipped})" + f"({QueueDownloadStatus.Waiting}|{QueueDownloadStatus.Finished}|{QueueDownloadStatus.Failed})" ) def on_queue_download_clear_finished(self) -> None: """Clear finished items from the download queue.""" - self.on_clear_queue_download(f"({QueueDownloadStatus.Finished}|{QueueDownloadStatus.Skipped})") + self.on_clear_queue_download(f"[{QueueDownloadStatus.Finished}]") def on_clear_queue_download(self, regex: str) -> None: - """Clear items from the download queue matching the given regex.""" - items = self.main_window.tr_queue_download.findItems( + """Clear items from the download queue matching the given regex. + + Args: + regex (str): Regular expression to match items. + """ + items: list[QtWidgets.QTreeWidgetItem | None] = self.main_window.tr_queue_download.findItems( regex, QtCore.Qt.MatchFlag.MatchRegularExpression, column=0 ) + for item in items: self.main_window.tr_queue_download.takeTopLevelItem( self.main_window.tr_queue_download.indexOfTopLevelItem(item) @@ -101,12 +106,14 @@ class GuiQueueManager: def on_queue_download_remove(self) -> None: """Remove selected items from the download queue.""" - items = self.main_window.tr_queue_download.selectedItems() - if not items: + items: list[QtWidgets.QTreeWidgetItem | None] = self.main_window.tr_queue_download.selectedItems() + + if len(items) == 0: logger_gui.error("Please select an item from the queue first.") else: for item in items: status: str = item.text(0) + if status != QueueDownloadStatus.Downloading: self.main_window.tr_queue_download.takeTopLevelItem( self.main_window.tr_queue_download.indexOfTopLevelItem(item) @@ -115,8 +122,12 @@ class GuiQueueManager: logger_gui.info("Cannot remove a currently downloading item from queue.") def on_pb_queue_download_toggle(self) -> None: - """Toggle download status (pause / resume) accordingly.""" + """Toggle download status (pause / resume) accordingly. + + :return: None + """ handling_app: HandlingApp = HandlingApp() + if handling_app.event_run.is_set(): self.pb_queue_download_pause() else: @@ -125,7 +136,9 @@ class GuiQueueManager: def pb_queue_download_run(self) -> None: """Start the download queue and update the button state.""" handling_app: HandlingApp = HandlingApp() + handling_app.event_run.set() + icon = QtGui.QIcon(QtGui.QIcon.fromTheme(QtGui.QIcon.ThemeIcon.MediaPlaybackPause)) self.main_window.pb_queue_download_toggle.setIcon(icon) self.main_window.pb_queue_download_toggle.setStyleSheet("background-color: #e0a800; color: #212529") @@ -133,7 +146,9 @@ class GuiQueueManager: def pb_queue_download_pause(self) -> None: """Pause the download queue and update the button state.""" handling_app: HandlingApp = HandlingApp() + handling_app.event_run.clear() + icon = QtGui.QIcon(QtGui.QIcon.fromTheme(QtGui.QIcon.ThemeIcon.MediaPlaybackStart)) self.main_window.pb_queue_download_toggle.setIcon(icon) self.main_window.pb_queue_download_toggle.setStyleSheet("background-color: #218838; color: #fff") |
