Debian Codegraph @

src/album/module/slideshow/imageanimation.h

raw
1 /*
2 * Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
3 *
4 * Author: ZhangYong <[email protected]>
5 *
6 * Maintainer: ZhangYong <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef IMAGEANIMATION_H
22 #define IMAGEANIMATION_H
23
24 #include <QtGlobal>
25 #include <QWidget>
26 #include <QPropertyAnimation>
27 #include <QImageReader>
28 #include <QObject>
29
30 #define UPDATE_RATE 30
31 #define FACTOR_STEP 0.005f
32
33 //#define RENDER_DEVIATION 0.005f
34 //#define FACTOR_BEGIN 0.0f
35 //#define FACTOR_END 1.0f
36 //#define FACTOR_EXPECTATION 0.5f
37 //#define FACTOR_STANDARD_DEVIATION 5
38 //#define NORMAL_DISTRIBUTION_MAX 0.05
39
40 QT_BEGIN_NAMESPACE
41
42 class ImageAnimationPrivate;
43 class ImageAnimation : public QWidget
44 {
45 Q_OBJECT
46 enum AnimationType {
47 FadeEffect = 0, //图像1渐渐变淡,图像2渐渐显现
48 BlindsEffect = 1, //百叶窗效果
49 FlipRightToLeft = 2, //图像从右向左翻转
50 OutsideToInside = 3, //从外到内水平分割
51 MoveLeftToRightEffect = 4, //图像1从左至右退出可视区域,同时图像2从左至右进入可视区域
52 MoveRightToLeftEffect = 5, //图像1从左至右退出可视区域,同时图像2从左至右进入可视区域
53 MoveBottomToUpEffect = 6, //图像1从下至上退出可视区域,同时图像2从下至上进入可视区域
54 MoveUpToBottomEffect = 7, //图像1从上至下退出可视区域,同时图像2从上至下进入可视区域
55 MoveBottomToLeftUpEffect = 8//图像1不动,同时图像2从右下到左上
56 };
57
58 enum PaintTarget {
59 KeepStatic = -1,
60 EffectPlay = 0,
61 SkipToNext = 1,
62 TurnBackPre = 2
63 };
64
65 enum SlideModel {
66 ManualPlayModel = 0, //手动播放下一张
67 AutoPlayModel = 1, //自动动播放下一张
68 };
69
70 enum PlayOrStatue {
71 StopStatue = 0, //停止
72 PlayStatue = 1, //播放
73 };
74
75 public:
76 explicit ImageAnimation(QWidget *parent = nullptr);
77 ~ImageAnimation() override;
78
79 void startSlideShow(const QString &beginPath, const QStringList &pathlist);
80 void endSlider();
81
82 void playAndNext();
83 void playAndPre();
84 void pauseAndNext();
85 void ifPauseAndContinue();
86 //设置动画效果是否随机
87 void setIsRandom(bool isRandom);
88 // void pauseAndpre();
89
90 int currentIndex();
91 const QRect getCurScreenGeometry();
92 //signals:
93 // void singleAnimationEnd();
94 protected:
95 void paintEvent(QPaintEvent *) override;
96 void setPaintTarget(PaintTarget target);
97 private:
98 PaintTarget current_target;
99 ImageAnimationPrivate *const d_ptr;
100 Q_DECLARE_PRIVATE(ImageAnimation)
101 Q_DISABLE_COPY(ImageAnimation)
102 };
103
104 QT_END_NAMESPACE
105 #endif // IMAGEANIMATION_H