TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiclrcmanagerfordesktop.cpp
Go to the documentation of this file.
2 #include "musicsettingmanager.h"
3 #include "musicwidgetutils.h"
4 
6  : MusicLrcManager(parent)
7 {
8  m_font.setPointSize(30);
9  m_speedLevel = 50;
10 }
11 
12 
13 
16 {
17 
18 }
19 
21 {
22  QPainter painter(this);
23  painter.setRenderHint(QPainter::TextAntialiasing);
24  painter.setFont(m_font);
25 
26  const int fontHeight = TTK::Widget::fontTextHeight(m_font);
27  const int begin = (rect().height() - fontHeight) / 2;
28  m_linearGradient.setFinalStop(0, fontHeight);
29  m_maskLinearGradient.setFinalStop(0, fontHeight);
30 
32  {
34  }
35 
36  //Draw the underlying text, such as shadow, will make the effect more clearly,
37  //and more texture
38  painter.setPen(QColor(0, 0, 0, 2 * m_transparent));
39  painter.drawText(m_intervalCount + 1, begin + 1, m_position.x(), m_position.y(), Qt::AlignLeft, text());
40 
41  //Then draw a gradient in the above
42  painter.setPen(QPen(m_linearGradient, 0));
43  painter.drawText(m_intervalCount, begin, m_position.x(), m_position.y(), Qt::AlignLeft, text());
44 
45  int offsetValue = m_lrcMaskWidth;
47  {
48  offsetValue = (m_lrcMaskWidth != 0) ? m_position.x() : m_lrcMaskWidth;
49  }
50 
51  //Set lyrics mask
52  painter.setPen(QPen(m_maskLinearGradient, 0));
53  painter.drawText(m_intervalCount, begin, offsetValue, 60, Qt::AlignLeft, text());
54 }
55 
56 
59 {
60 
61 }
62 
64 {
65  QPainter painter(this);
66  painter.setRenderHint(QPainter::TextAntialiasing);
67  painter.setFont(m_font);
68 
69  const int fontHeight = TTK::Widget::fontTextHeight(m_font);
70  m_linearGradient.setFinalStop(0, fontHeight);
71  m_maskLinearGradient.setFinalStop(0, fontHeight);
72 
74  {
76  }
77 
78  painter.translate(m_position.y(), 0);
79  painter.rotate(TTK_AN_90);
80 
81  //Draw the underlying text, such as shadow, will make the effect more clearly,
82  //and more texture
83  painter.setPen(QColor(0, 0, 0, 2 * m_transparent));
84  painter.drawText(m_intervalCount + 1, 1, m_position.x(), m_position.y(), Qt::AlignLeft, text());
85 
86  //Then draw a gradient in the above
87  painter.setPen(QPen(m_linearGradient, 0));
88  painter.drawText(m_intervalCount, 0, m_position.x(), m_position.y(), Qt::AlignLeft, text());
89 
90  int offsetValue = m_lrcMaskWidth;
92  {
93  offsetValue = (m_lrcMaskWidth != 0) ? m_position.x() : m_lrcMaskWidth;
94  }
95 
96  //Set lyrics mask
97  painter.setPen(QPen(m_maskLinearGradient, 0));
98  painter.drawText(m_intervalCount, 0, offsetValue, 60, Qt::AlignLeft, text());
99  painter.translate(-m_position.y(), 0);
100 }
The class of the lrc manager base.
MusicLrcManagerHorizontalDesktop(QWidget *parent=nullptr)
virtual void paintEvent(QPaintEvent *event) overridefinal
float m_lrcMaskWidthInterval
#define TTK_AN_90
Definition: ttkglobal.h:415
MusicLrcManagerForDesktop(QWidget *parent=nullptr)
MusicLrcManagerVerticalDesktop(QWidget *parent=nullptr)
The class of the desktop lrc manager.
QLinearGradient m_maskLinearGradient
virtual void paintEvent(QPaintEvent *event) overridefinal
TTK_MODULE_EXPORT int fontTextHeight(const QFont &font)
QLinearGradient m_linearGradient
#define G_SETTING_PTR