DtkGui
DTK Gui module
载入中...
搜索中...
未找到
ddciiconplayer.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6#include <dtkgui_global.h>
7#include <DObject>
8#include <DDciIcon>
9
10#include <QObject>
11
12DGUI_BEGIN_NAMESPACE
13
14class DDciIconImage;
15class DDciIconPalette;
16class DDciIconImagePlayerPrivate;
17class DDciIconImagePlayer : public QObject, public DCORE_NAMESPACE::DObject
18{
19 D_DECLARE_PRIVATE(DDciIconImagePlayer)
20 Q_OBJECT
21 Q_PROPERTY(DGUI_NAMESPACE::DDciIconImagePlayer::State state READ state NOTIFY stateChanged)
22
23public:
24 enum State {
27 Running
28 };
29 Q_ENUM(State)
30
31 enum Flag {
32 Continue = 1,
33 CacheAll = 2,
34 InvertedOrder = 4,
35 IgnoreLastImageLoop = 8,
36 AllowNonLastImageLoop = 16,
37 ClearCacheOnStop = 32
38 };
39 Q_DECLARE_FLAGS(Flags, Flag)
40
41 explicit DDciIconImagePlayer(QObject *parent = nullptr);
42
43 void setImages(const QVector<DDciIconImage> &images);
44 QVector<DDciIconImage> images() const;
45 const DDciIconImage &currentImage() const;
46 bool currentLoopForever() const;
47
48 bool setPalette(const DDciIconPalette &palette);
49 DDciIconPalette palette() const;
50
51 void setLoopCount(int count);
52 int loopCount() const;
53 void abortLoop();
54
55 QImage readImage();
56 State state() const;
57
58 void clearCache();
59
60public Q_SLOTS:
61 bool start(float speed = 1.0, DGUI_NAMESPACE::DDciIconImagePlayer::Flags flags = {});
62 void stop();
63
64Q_SIGNALS:
65 void started();
66 void updated();
67 void finished();
69
70private:
71 void timerEvent(QTimerEvent *event) override;
72};
73
75class DDciIconPlayer : public QObject, public DCORE_NAMESPACE::DObject
76{
77 D_DECLARE_PRIVATE(DDciIconPlayer)
78 Q_OBJECT
79public:
80 enum State {
82 Busy
83 };
84 Q_ENUM(State)
85
86 explicit DDciIconPlayer(QObject *parent = nullptr);
87
88 State state() const;
89
90 void setIcon(const DDciIcon &icon);
91 DDciIcon icon() const;
92
93 void setTheme(DDciIcon::Theme theme);
94 DDciIcon::Theme theme() const;
95
96 void setMode(DDciIcon::Mode mode);
97 DDciIcon::Mode mode() const;
98
99 void setIconSize(int size);
100 int iconSize() const;
101
102 void setDevicePixelRatio(qreal devicePixelRatio);
103 qreal devicePixelRatio() const;
104
105 void setPalette(const DDciIconPalette &palette);
106
107 QImage currentImage() const;
108 void play(DDciIcon::Mode mode);
109 void stop();
110 void abort();
111
112Q_SIGNALS:
114 void updated();
116
117private:
118 D_PRIVATE_SLOT(void _q_playFromQueue(int))
119};
120
121DGUI_END_NAMESPACE
122Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_GUI_NAMESPACE::DDciIconImagePlayer::Flags)
Definition ddciiconplayer.h:18
Flag
播放参数
Definition ddciiconplayer.h:31
State
播放状态
Definition ddciiconplayer.h:24
@ NotRunning
未播放动画
Definition ddciiconplayer.h:25
@ WaitingRead
正在播放动画,且等待读取当前帧
Definition ddciiconplayer.h:26
Definition ddciicon.h:22
DCI图标调色板
Definition ddciiconpalette.h:21
Definition ddciiconplayer.cpp:493
Definition ddciiconplayer.h:76
void modeChanged(DDciIcon::Mode oldMode, DDciIcon::Mode newMode)
State
工作状态
Definition ddciiconplayer.h:80
@ Idle
处于空闲状态,一般表示此时未播放动画
Definition ddciiconplayer.h:81
Definition ddciicon.h:68
Theme
DCI图标主题
Definition ddciicon.h:76
Mode
DCI图标模式
Definition ddciicon.h:70