12 QLinearGradient linearGradient;
13 for(
int i = 0; i < colors.count(); ++i)
15 linearGradient.setColorAt((i + 1) * 1.0 / colors.count(), colors[i]);
35 QPainter painter(
this);
36 painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
38 painter.setBrush(Qt::white);
39 painter.drawRect(0, 0, width(), height());
41 const int h = height() - 4 * 2;
42 painter.drawText(h + 2 * 4, 4, width() - h - 3 * 4, h, Qt::AlignCenter, text());
46 painter.drawRect(4, 4, h, h);
71 QLinearGradient linearGradient, maskLinearGradient;
72 for(
int i = 0; i < back.count(); ++i)
76 linearGradient.setColorAt((i + 1) * 1.0 / back.count(), rgb);
79 for(
int i = 0; i < front.count(); ++i)
81 QColor rgb = front[i];
83 maskLinearGradient.setColorAt((i + 1) * 1.0 / front.count(), rgb);
92 QPainter painter(
this);
93 painter.setRenderHint(QPainter::TextAntialiasing);
96 const int begin = (rect().height() - h) / 2;
101 painter.drawText(rect(), Qt::AlignLeft | Qt::AlignVCenter,
"This is TTKMusicPlayer");
103 painter.setPen(QColor(0, 0, 0, 200));
104 painter.drawText(rect(), Qt::AlignLeft | Qt::AlignVCenter,
"This is TTKMusicPlayer");
107 painter.drawText(1, 1, rect().width(), rect().height(), Qt::AlignLeft | Qt::AlignVCenter,
"This is TTKMusicPlayer");
110 painter.drawText(1, 1, 60, rect().height(), Qt::AlignLeft | Qt::AlignVCenter,
"This is TTKMusicPlayer");
QList< QColor > m_background
The class of the label previewed.
QLinearGradient m_maskLinearGradient
virtual void paintEvent(QPaintEvent *event) overridefinal
The class of the label widget that can click.
QList< QColor > m_frontground
QLinearGradient m_linearGradient
void setColors(const QList< QColor > &colors)
virtual void paintEvent(QPaintEvent *event) overridefinal
QList< QColor > m_gradientColors
QLinearGradient m_linearGradient
void setLinearGradient(const MusicPreviewLabelItem &item)
MusicPreviewLabel(QWidget *parent=nullptr)
QList< QColor > colors() const noexcept
MusicColorPreviewLabel(QWidget *parent=nullptr)