TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiclrcmanager.h
Go to the documentation of this file.
1 #ifndef MUSICLRCMANAGER_H
2 #define MUSICLRCMANAGER_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
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  * (at your option) 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 along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QTimer>
23 #include <QAction>
24 #include <QMouseEvent>
25 #include "musicglobaldefine.h"
26 #include "musicwidgetheaders.h"
27 
28 static constexpr int LRC_PER_TIME = 30;
29 static constexpr int LRC_COLOR_OFFSET = 9;
30 
35 {
36 public:
37  enum class Color
38  {
39  Null = -1,
40  IYellow,
41  IBlue,
42  IGray,
43  IPink,
44  IGreen,
45  IRed,
46  IPurple,
47  IOrange,
48  IIndigo,
50  DWhite,
51  DBlue,
52  DRed,
53  DBlack,
54  DYellow,
55  DPurple,
56  DGreen
57  };
58 
62  MusicLrcColor();
63  MusicLrcColor(const QList<QColor> &front, const QList<QColor> &back, Color index = Color::Null);
64 
65  QList<QColor> m_frontColor;
66  QList<QColor> m_backColor;
68 
69 };
70 
71 
75 namespace TTK
76 {
84  QList<QColor> readColorConfig(const QString &value);
88  QString writeColorConfig(const QList<QColor> &colors);
89 
90 }
91 
92 
96 class TTK_MODULE_EXPORT MusicLrcManager : public QLabel
97 {
98  Q_OBJECT
100 public:
104  explicit MusicLrcManager(QWidget *parent = nullptr);
108  ~MusicLrcManager();
109 
113  void startDrawLrc();
117  void startDrawLrcMask(qint64 intervaltime);
121  void stopDrawLrc();
122 
126  void setFontFamily(int index);
130  void setFontType(int type);
134  void setLinearGradientColor(const MusicLrcColor &color);
135 
139  inline void setSpeedLevel(int l) { m_speedLevel = l; }
143  inline void setFontTransparent(int t) { m_transparent = t; }
144 
148  void setSelfPosition(int x, int y);
152  void setSelfPosition(const QPoint &point);
153 
157  int x() const;
161  int y() const;
165  void setX(int x);
169  void setY(int y);
170 
174  void reset();
175 
179  void setLrcFontSize(int size);
183  inline int lrcFontSize() const { return m_font.pointSize(); }
184 
185 public Q_SLOTS:
189  void updateMask();
193  void setText(const QString &str);
194 
195 protected:
196  QFont m_font;
197  QTimer *m_timer;
198  QLinearGradient m_linearGradient, m_maskLinearGradient;
199  float m_lrcMaskWidth, m_lrcMaskWidthInterval, m_intervalCount;
200 
201  int m_lrcPerWidth, m_transparent, m_speedLevel;
202  QPoint m_position;
203 
204 };
205 
206 #endif // MUSICLRCMANAGER_H
#define TTK_MODULE_EXPORT
The class of the lrc manager base.
The class of the lrc color.
static constexpr int LRC_PER_TIME
voidpf void uLong size
Definition: ioapi.h:136
MusicLrcColor::Color m_index
float m_lrcMaskWidthInterval
QString writeColorConfig(const QList< QColor > &colors)
static constexpr int LRC_COLOR_OFFSET
QList< QColor > m_backColor
QLinearGradient m_maskLinearGradient
void setSpeedLevel(int l)
The namespace of the process utils.
Definition: ttkcompat.h:24
int lrcFontSize() const
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
MusicLrcColor mapIndexToColor(MusicLrcColor::Color index)
QList< QColor > m_frontColor
QList< QColor > readColorConfig(const QString &value)
void setFontTransparent(int t)