diff --git a/ui/animated_icon.cpp b/ui/animated_icon.cpp index 64ef391..5e5be7d 100644 --- a/ui/animated_icon.cpp +++ b/ui/animated_icon.cpp @@ -41,6 +41,7 @@ public: [[nodiscard]] bool valid() const; [[nodiscard]] QSize size() const; [[nodiscard]] int framesCount() const; + [[nodiscard]] double frameRate() const; [[nodiscard]] Frame &frame(); [[nodiscard]] const Frame &frame() const; @@ -67,6 +68,7 @@ private: base::weak_ptr _weak; int _framesCount = 0; + double _frameRate = 0.; mutable crl::semaphore _semaphore; mutable bool _ready = false; @@ -88,6 +90,7 @@ void AnimatedIcon::Impl::prepareFromAsync( return; } _framesCount = generator->count(); + _frameRate = generator->rate(); _current.generated = generator->renderNext(QImage(), sizeOverride); if (_current.generated.image.isNull()) { return; @@ -120,6 +123,11 @@ int AnimatedIcon::Impl::framesCount() const { return _framesCount; } +double AnimatedIcon::Impl::frameRate() const { + waitTillPrepared(); + return _frameRate; +} + AnimatedIcon::Frame &AnimatedIcon::Impl::frame() { waitTillPrepared(); return _current; @@ -222,6 +230,10 @@ int AnimatedIcon::framesCount() const { return _impl->framesCount(); } +double AnimatedIcon::frameRate() const { + return _impl->frameRate(); +} + QImage AnimatedIcon::frame(const QColor &textColor) const { return frame(textColor, QSize(), nullptr).image; } @@ -356,6 +368,7 @@ int AnimatedIcon::wantedFrameIndex( const auto next = _animationCurrentStart + duration; if (frame->generated.last) { _animation.stop(); + if (_repaint) _repaint(); return _animationCurrentIndex; } else if (now < next) { return _animationCurrentIndex; diff --git a/ui/animated_icon.h b/ui/animated_icon.h index edec7cd..b6c6b35 100644 --- a/ui/animated_icon.h +++ b/ui/animated_icon.h @@ -36,6 +36,7 @@ public: [[nodiscard]] bool valid() const; [[nodiscard]] int frameIndex() const; [[nodiscard]] int framesCount() const; + [[nodiscard]] double frameRate() const; [[nodiscard]] QImage frame(const QColor &textColor) const; [[nodiscard]] QImage notColorizedFrame() const; [[nodiscard]] int width() const;