summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/gui/progress.py
diff options
context:
space:
mode:
Diffstat (limited to 'tidal_dl_ng/gui/progress.py')
-rw-r--r--tidal_dl_ng/gui/progress.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tidal_dl_ng/gui/progress.py b/tidal_dl_ng/gui/progress.py
new file mode 100644
index 0000000..d46ea3d
--- /dev/null
+++ b/tidal_dl_ng/gui/progress.py
@@ -0,0 +1,31 @@
+"""Progress bars mixin for MainWindow.
+
+Handles progress bar updates and formatting.
+"""
+
+import math
+
+
+class ProgressMixin:
+ """Mixin containing progress bar management methods."""
+
+ def on_progress_reset(self):
+ """Reset progress bars to zero."""
+ self.pb_list.setValue(0)
+ self.pb_item.setValue(0)
+
+ def on_progress_list(self, value: float) -> None:
+ """Update the progress of the list progress bar."""
+ self.pb_list.setValue(int(math.ceil(value)))
+
+ def on_progress_item(self, value: float) -> None:
+ """Update the progress of the item progress bar."""
+ self.pb_item.setValue(int(math.ceil(value)))
+
+ def on_progress_item_name(self, value: str) -> None:
+ """Set the format of the item progress bar."""
+ self.pb_item.setFormat(f"%p% {value}")
+
+ def on_progress_list_name(self, value: str) -> None:
+ """Set the format of the list progress bar."""
+ self.pb_list.setFormat(f"%p% {value}")