From 0c03e3b4ba65f75bc7093d20e4f67ed15bc66695 Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Sat, 24 Jan 2026 17:34:12 +0200 Subject: [PATCH] Add smooth animation to progress bar updates Introduces a QPropertyAnimation for the progress bar to provide a smooth transition effect when updating its value. The animation is triggered for significant changes in progress, improving the user experience with more visually appealing feedback. --- src/gui/ytsage_gui_main.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gui/ytsage_gui_main.py b/src/gui/ytsage_gui_main.py index c47d159..99b2677 100644 --- a/src/gui/ytsage_gui_main.py +++ b/src/gui/ytsage_gui_main.py @@ -7,7 +7,7 @@ from pathlib import Path import markdown import requests from packaging import version -from PySide6.QtCore import Q_ARG, QMetaObject, Qt, QTimer, Slot, QThread, Signal, QUrl +from PySide6.QtCore import Q_ARG, QMetaObject, Qt, QTimer, Slot, QThread, Signal, QUrl, QPropertyAnimation, QEasingCurve from PySide6.QtGui import QIcon from PySide6.QtMultimedia import QAudioOutput, QMediaPlayer from PySide6.QtWidgets import ( @@ -464,6 +464,11 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin, AnalysisMixin): self.progress_bar.setFormat("%p%") # Display as percentage self.progress_bar.setStyleSheet(StyleSheet.PROGRESS_BAR) progress_layout.addWidget(self.progress_bar) + + # Setup smooth animation for progress bar + self._progress_animation = QPropertyAnimation(self.progress_bar, b"value") + self._progress_animation.setDuration(150) # 150ms smooth transition + self._progress_animation.setEasingCurve(QEasingCurve.Type.OutCubic) # Add download details label with improved styling self.download_details_label = QLabel() @@ -828,7 +833,19 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin, AnalysisMixin): try: # Scale float percentage (0-100) to progress bar range (0-10000) for precision scaled_value = int(float(value) * 100) - self.progress_bar.setValue(scaled_value) + + # Use smooth animation for progress updates + if self._progress_animation.state() == QPropertyAnimation.State.Running: + self._progress_animation.stop() + + current_value = self.progress_bar.value() + # Only animate if there's a meaningful change (avoid micro-animations) + if abs(scaled_value - current_value) > 10: # More than 0.1% change + self._progress_animation.setStartValue(current_value) + self._progress_animation.setEndValue(scaled_value) + self._progress_animation.start() + else: + self.progress_bar.setValue(scaled_value) except Exception as e: logger.exception(f"Progress bar update error: {e}")