TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicratinglabel.cpp
Go to the documentation of this file.
1 #include "musicratinglabel.h"
2 
3 #include <QPainter>
4 
6  : MusicRatingLabel(0, parent)
7 {
8 
9 }
10 
11 MusicRatingLabel::MusicRatingLabel(int value, QWidget *parent)
12  : QLabel(parent),
13  m_value(value)
14 {
15  setFixedSize(26 * 5, 22);
16 }
17 
19 {
20  m_value = value;
21 }
22 
23 void MusicRatingLabel::paintEvent(QPaintEvent *)
24 {
25  QPainter painter(this);
26 
27  for(int i = 0; i < 5; ++i)
28  {
29  const bool active = m_value - i - 1 >= 0;
30  painter.drawPixmap(i * 26, 0, QPixmap(active ? ":/tiny/lb_star" : ":/tiny/lb_unstar"));
31  }
32 }
MusicRatingLabel(QWidget *parent=nullptr)
virtual void paintEvent(QPaintEvent *event) overridefinal
void setValue(int value)
The class of the rating label.