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 "Utils/Pimpl.h"
25 
26 #include <QLabel>
27 #include <QPoint>
28 #include <QSize>
29 
34 class RatingLabel : public QLabel
35 {
36  Q_OBJECT
37  PIMPL(RatingLabel)
38 
39 signals:
40  void sig_finished(bool);
41 
42 
43 public:
44  RatingLabel(QWidget *parent, bool enabled=true);
45  virtual ~RatingLabel();
46 
47  void set_rating(Rating rating);
48  Rating get_rating() const;
49 
50  void set_offset_y(int offset);
51 
52 protected:
53  void paintEvent(QPaintEvent *e) override;
54  void focusInEvent(QFocusEvent* e) override;
55  void focusOutEvent(QFocusEvent* e) override;
56  void mousePressEvent(QMouseEvent *ev) override;
57  void mouseReleaseEvent(QMouseEvent* ev) override;
58  void mouseMoveEvent(QMouseEvent *ev) override;
59 
60  QSize sizeHint() const override;
61  QSize minimumSizeHint() const override;
62 
63 private:
64  void update_rating(Rating rating);
65  Rating calc_rating(QPoint pos) const;
66 };
67 
68 #endif // RATINGLABEL_H
The RatingLabel class.
Definition: RatingLabel.h:34