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.
This commit is contained in:
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
import markdown
|
import markdown
|
||||||
import requests
|
import requests
|
||||||
from packaging import version
|
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.QtGui import QIcon
|
||||||
from PySide6.QtMultimedia import QAudioOutput, QMediaPlayer
|
from PySide6.QtMultimedia import QAudioOutput, QMediaPlayer
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
@@ -465,6 +465,11 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin, AnalysisMixin):
|
|||||||
self.progress_bar.setStyleSheet(StyleSheet.PROGRESS_BAR)
|
self.progress_bar.setStyleSheet(StyleSheet.PROGRESS_BAR)
|
||||||
progress_layout.addWidget(self.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
|
# Add download details label with improved styling
|
||||||
self.download_details_label = QLabel()
|
self.download_details_label = QLabel()
|
||||||
self.download_details_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
self.download_details_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
@@ -828,6 +833,18 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin, AnalysisMixin):
|
|||||||
try:
|
try:
|
||||||
# Scale float percentage (0-100) to progress bar range (0-10000) for precision
|
# Scale float percentage (0-100) to progress bar range (0-10000) for precision
|
||||||
scaled_value = int(float(value) * 100)
|
scaled_value = int(float(value) * 100)
|
||||||
|
|
||||||
|
# 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)
|
self.progress_bar.setValue(scaled_value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Progress bar update error: {e}")
|
logger.exception(f"Progress bar update error: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user