Sayonara Player
RatingLabel.h
1 /* RatingLabel.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef RATINGLABEL_H
22 #define RATINGLABEL_H
23 
24 #include <QLabel>
25 #include <QPoint>
26 
27 #include "Utils/Pimpl.h"
28 
33 class RatingLabel : public QLabel
34 {
35  Q_OBJECT
36  PIMPL(RatingLabel)
37 
38 signals:
39  void sig_finished(bool);
40 
41 
42 public:
43  RatingLabel(QWidget *parent, bool enabled=true);
44  virtual ~RatingLabel();
45 
46  void set_rating(int rating);
47  int get_rating() const;
48 
49 
50 protected:
51  void paintEvent(QPaintEvent *e) override;
52  void focusInEvent(QFocusEvent* e) override;
53  void focusOutEvent(QFocusEvent* e) override;
54  void mousePressEvent(QMouseEvent *ev) override;
55  void mouseReleaseEvent(QMouseEvent* ev) override;
56  void mouseMoveEvent(QMouseEvent *ev) override;
57 
58 private:
59  void update_rating(int rating);
60  int calc_rating(QPoint pos) const;
61 };
62 
63 #endif // RATINGLABEL_H
The RatingLabel class.
Definition: RatingLabel.h:33