Allow getting AnimatedIcon frame rate.
This commit is contained in:
parent
1e89c19a03
commit
3749f10e7f
2 changed files with 14 additions and 0 deletions
|
|
@ -41,6 +41,7 @@ public:
|
||||||
[[nodiscard]] bool valid() const;
|
[[nodiscard]] bool valid() const;
|
||||||
[[nodiscard]] QSize size() const;
|
[[nodiscard]] QSize size() const;
|
||||||
[[nodiscard]] int framesCount() const;
|
[[nodiscard]] int framesCount() const;
|
||||||
|
[[nodiscard]] double frameRate() const;
|
||||||
[[nodiscard]] Frame &frame();
|
[[nodiscard]] Frame &frame();
|
||||||
[[nodiscard]] const Frame &frame() const;
|
[[nodiscard]] const Frame &frame() const;
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@ private:
|
||||||
|
|
||||||
base::weak_ptr<AnimatedIcon> _weak;
|
base::weak_ptr<AnimatedIcon> _weak;
|
||||||
int _framesCount = 0;
|
int _framesCount = 0;
|
||||||
|
double _frameRate = 0.;
|
||||||
mutable crl::semaphore _semaphore;
|
mutable crl::semaphore _semaphore;
|
||||||
mutable bool _ready = false;
|
mutable bool _ready = false;
|
||||||
|
|
||||||
|
|
@ -88,6 +90,7 @@ void AnimatedIcon::Impl::prepareFromAsync(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_framesCount = generator->count();
|
_framesCount = generator->count();
|
||||||
|
_frameRate = generator->rate();
|
||||||
_current.generated = generator->renderNext(QImage(), sizeOverride);
|
_current.generated = generator->renderNext(QImage(), sizeOverride);
|
||||||
if (_current.generated.image.isNull()) {
|
if (_current.generated.image.isNull()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -120,6 +123,11 @@ int AnimatedIcon::Impl::framesCount() const {
|
||||||
return _framesCount;
|
return _framesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double AnimatedIcon::Impl::frameRate() const {
|
||||||
|
waitTillPrepared();
|
||||||
|
return _frameRate;
|
||||||
|
}
|
||||||
|
|
||||||
AnimatedIcon::Frame &AnimatedIcon::Impl::frame() {
|
AnimatedIcon::Frame &AnimatedIcon::Impl::frame() {
|
||||||
waitTillPrepared();
|
waitTillPrepared();
|
||||||
return _current;
|
return _current;
|
||||||
|
|
@ -222,6 +230,10 @@ int AnimatedIcon::framesCount() const {
|
||||||
return _impl->framesCount();
|
return _impl->framesCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double AnimatedIcon::frameRate() const {
|
||||||
|
return _impl->frameRate();
|
||||||
|
}
|
||||||
|
|
||||||
QImage AnimatedIcon::frame(const QColor &textColor) const {
|
QImage AnimatedIcon::frame(const QColor &textColor) const {
|
||||||
return frame(textColor, QSize(), nullptr).image;
|
return frame(textColor, QSize(), nullptr).image;
|
||||||
}
|
}
|
||||||
|
|
@ -356,6 +368,7 @@ int AnimatedIcon::wantedFrameIndex(
|
||||||
const auto next = _animationCurrentStart + duration;
|
const auto next = _animationCurrentStart + duration;
|
||||||
if (frame->generated.last) {
|
if (frame->generated.last) {
|
||||||
_animation.stop();
|
_animation.stop();
|
||||||
|
if (_repaint) _repaint();
|
||||||
return _animationCurrentIndex;
|
return _animationCurrentIndex;
|
||||||
} else if (now < next) {
|
} else if (now < next) {
|
||||||
return _animationCurrentIndex;
|
return _animationCurrentIndex;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ public:
|
||||||
[[nodiscard]] bool valid() const;
|
[[nodiscard]] bool valid() const;
|
||||||
[[nodiscard]] int frameIndex() const;
|
[[nodiscard]] int frameIndex() const;
|
||||||
[[nodiscard]] int framesCount() const;
|
[[nodiscard]] int framesCount() const;
|
||||||
|
[[nodiscard]] double frameRate() const;
|
||||||
[[nodiscard]] QImage frame(const QColor &textColor) const;
|
[[nodiscard]] QImage frame(const QColor &textColor) const;
|
||||||
[[nodiscard]] QImage notColorizedFrame() const;
|
[[nodiscard]] QImage notColorizedFrame() const;
|
||||||
[[nodiscard]] int width() const;
|
[[nodiscard]] int width() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue