aboutsummaryrefslogtreecommitdiff
path: root/src/animationloader.h
diff options
context:
space:
mode:
authorSalanto <62221668+Salanto@users.noreply.github.com>2024-05-24 04:54:48 +0200
committerGitHub <noreply@github.com>2024-05-24 04:54:48 +0200
commit4c56a25463d15cf12e21fe512a598bee91b3363d (patch)
treeb0478364cd4d267c97334164aa876b41c1a841f9 /src/animationloader.h
parent4b0f7e4d806c79313e493a3c58818e995af25847 (diff)
parenteb024cb93131cddba8ec1a6094abde8bf1f4eaf3 (diff)
Merge pull request #966 from AttorneyOnline/coolslide-rebased
[Feature] Courtroom slides + major AOLayer overhaul
Diffstat (limited to 'src/animationloader.h')
-rw-r--r--src/animationloader.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/animationloader.h b/src/animationloader.h
new file mode 100644
index 00000000..a3a10367
--- /dev/null
+++ b/src/animationloader.h
@@ -0,0 +1,55 @@
+#pragma once
+
+#include <QFuture>
+#include <QImageReader>
+#include <QMutex>
+#include <QObject>
+#include <QPixmap>
+#include <QString>
+#include <QWaitCondition>
+
+#include <atomic>
+
+namespace kal
+{
+class AnimationFrame
+{
+public:
+ QPixmap texture;
+ int duration = 0;
+};
+
+class AnimationLoader
+{
+ Q_DISABLE_COPY_MOVE(AnimationLoader)
+
+public:
+ explicit AnimationLoader(QThreadPool *threadPool);
+ virtual ~AnimationLoader();
+
+ QString loadedFileName() const;
+ void load(const QString &fileName);
+ void stopLoading();
+
+ QSize size();
+
+ int frameCount();
+ AnimationFrame frame(int frameNumber);
+
+ int loopCount();
+
+private:
+ QThreadPool *m_thread_pool;
+ QString m_file_name;
+ QSize m_size;
+ int m_frame_count = 0;
+ int m_loop_count = -1;
+ QList<AnimationFrame> m_frames;
+ QFuture<void> m_task;
+ std::atomic_bool m_exit_task = false;
+ QMutex m_task_lock;
+ QWaitCondition m_task_signal;
+
+ void populateVector(QImageReader *reader);
+};
+} // namespace kal