You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
/* Общий GUI-таймер анимированных emoji: регистрирует LottieIcon и выдаёт ticked. |
|
* play запускает минимум PlaybackMs; shutdown останавливает таймер и очищает регистрацию. */ |
|
#pragma once |
|
|
|
#include <QObject> |
|
#include <QTimer> |
|
#include <QHash> |
|
#include <QElapsedTimer> |
|
|
|
class LottieIcon; |
|
|
|
class AnimTimer : public QObject { |
|
Q_OBJECT |
|
public: |
|
static AnimTimer *instance(); |
|
|
|
void registerIcon(const QString &key, LottieIcon *icon); |
|
void unregisterIcon(const QString &key); |
|
LottieIcon *icon(const QString &key) const; |
|
void logRegisteredIcons() const; |
|
|
|
// Наведение запускает минимум две секунды воспроизведения, затем каждый значок завершает свой цикл. |
|
static constexpr int PlaybackMs = 2000; |
|
void play(); |
|
static void shutdown(); |
|
|
|
signals: |
|
void ticked(); |
|
|
|
private slots: |
|
void onTimer(); |
|
|
|
private: |
|
AnimTimer(); |
|
QTimer m_timer; |
|
QHash<QString, LottieIcon *> m_icons; |
|
QElapsedTimer m_playback; |
|
};
|
|
|