TTKMusicPlayer  3.7.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.setFont(m_font);
24  painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
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.setFont(m_font);
67 
68  const int fontHeight = TTK::Widget::fontTextHeight(m_font);
69  m_linearGradient.setFinalStop(0, fontHeight);
70  m_maskLinearGradient.setFinalStop(0, fontHeight);
71 
73  {
75  }
76 
77  painter.translate(m_position.y(), 0);
78  painter.rotate(TTK_AN_90);
79 
80  //Draw the underlying text, such as shadow, will make the effect more clearly,
81  //and more texture
82  painter.setPen(QColor(0, 0, 0, 2 * m_transparent));
83  painter.drawText(m_intervalCount + 1, 1, m_position.x(), m_position.y(), Qt::AlignLeft, text());
84 
85  //Then draw a gradient in the above
86  painter.setPen(QPen(m_linearGradient, 0));
87  painter.drawText(m_intervalCount, 0, m_position.x(), m_position.y(), Qt::AlignLeft, text());
88 
89  int offsetValue = m_lrcMaskWidth;
91  {
92  offsetValue = (m_lrcMaskWidth != 0) ? m_position.x() : m_lrcMaskWidth;
93  }
94 
95  //Set lyrics mask
96  painter.setPen(QPen(m_maskLinearGradient, 0));
97  painter.drawText(m_intervalCount, 0, offsetValue, 60, Qt::AlignLeft, text());
98  painter.translate(-m_position.y(), 0);
99 }
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:336
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