CCIMXDesktop
 
Loading...
Searching...
No Matches
DiskMusic.h
1#ifndef DISKMUSIC_H
2#define DISKMUSIC_H
3#include <QTimer>
4#include <QWidget>
5class QPropertyAnimation;
6class QVariantAnimation;
7namespace Ui {
8class DiskMusic;
9}
10
15class DiskMusic : public QWidget {
16 Q_OBJECT
20 Q_PROPERTY(qreal armAngle READ armAngle WRITE setArmAngle NOTIFY armAngleChanged);
21 static constexpr const unsigned int ANIMATION_DURATION = 300;
22 static constexpr const unsigned int ANIMATION_FPS = 60;
23 static constexpr const qreal BEGIN_ANGLE = -30;
24 static constexpr const qreal END_ANGLE = -10;
25 static constexpr const unsigned int SWITCH_COLOR_MSEC_INTERVAL = 20000;
26 static constexpr const unsigned int COLOR_SWITCH_PROCESS_INTERVAL = 2000;
27
28 /* every time the default color media first open */
29 static constexpr const QColor BEGIN_COLOR = QColor(173, 216, 230);
30 static constexpr const QColor END_COLOR = QColor(0, 51, 102);
31
32public:
38 explicit DiskMusic(QWidget* parent = nullptr);
39
45 void setStatus(bool set_is_playing);
46
51 void setPixmap(const QString& pixmap_path);
52
57 inline qreal armAngle() const {
58 return angle;
59 }
60
65 inline void setArmAngle(qreal angle) {
66 this->angle = angle;
67 update();
68 emit armAngleChanged();
69 }
70
75 ~DiskMusic();
76
77signals:
83
84protected:
89 void paintEvent(QPaintEvent* event) override;
90
91private:
92 Ui::DiskMusic* ui;
93 qreal angle { BEGIN_ANGLE };
94 float current_rotations {};
95 bool is_playing { false };
96 QTimer animate_timer;
97 QPropertyAnimation* animation { nullptr };
98 QVariantAnimation* color_animation { nullptr };
99
100 struct {
101 QPixmap coverPixmap;
102 QPixmap armPixmap;
103 QPixmap recordPixmap;
104 } pixmaps;
105 void initUi();
106 void initCore();
107
111 void process_rotation() {
112 current_rotations += 0.5;
113 if (current_rotations >= 360.0)
114 current_rotations -= 360.0;
115 update();
116 }
117 /* for current varient change */
118 void process_the_color_change(QPainter& p);
119 void startColorTransition();
120
121 QColor beginColor { BEGIN_COLOR };
122 QColor endColor { END_COLOR };
123 QColor targetStart;
124 QColor targetEnd;
125
126 QTimer color_switch_timer;
127};
128
129#endif // DISKMUSIC_H
The DiskMusic class is a Widget Class(Sorry for the non-class label) that holding all the details of ...
Definition DiskMusic.h:15
~DiskMusic()
Destroy the Disk Music object.
Definition DiskMusic.cpp:158
QPixmap coverPixmap
the cover pixmap
Definition DiskMusic.h:101
QPixmap armPixmap
the arm pixmap
Definition DiskMusic.h:102
QPixmap recordPixmap
the record pixmap
Definition DiskMusic.h:103
qreal armAngle() const
armAngle get the arm angle
Definition DiskMusic.h:57
void setStatus(bool set_is_playing)
setStatus set the status of the disk
Definition DiskMusic.cpp:46
qreal armAngle
property announced
Definition DiskMusic.h:20
void paintEvent(QPaintEvent *event) override
paintEvent the paint event for the disk
Definition DiskMusic.cpp:65
void setPixmap(const QString &pixmap_path)
setPixmap set the pixmap of the disk center display
Definition DiskMusic.cpp:61
void armAngleChanged()
armAngleChanged the signal indicating the arm angle changed
void setArmAngle(qreal angle)
setArmAngle set the arm angle
Definition DiskMusic.h:65