Sayonara Player
Loading...
Searching...
No Matches
RatingLabel.h
1/* RatingLabel.h */
2
3/* Copyright (C) 2011-2024 Michael Lugmair (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
30namespace Gui
31{
39 public QLabel
40 {
41 Q_OBJECT
42 PIMPL(RatingLabel)
43
44 public:
45 RatingLabel(QWidget* parent, bool enabled = true);
46 ~RatingLabel() override;
47
52 void setRating(Rating rating);
53 Rating rating() const;
54
60 Rating ratingAt(QPoint pos) const;
61
66 void setVerticalOffset(int offset);
67
74 void paint(QPainter* painter, const QRect& rect);
75
80 QSize sizeHint() const override;
81
86 QSize minimumSizeHint() const override;
87 };
88
97 public QWidget
98 {
99 Q_OBJECT
100 PIMPL(RatingEditor)
101
102 signals:
103 void sigFinished(bool save);
104
105 public:
106 RatingEditor(QWidget* parent);
107 RatingEditor(Rating rating, QWidget* parent);
108 ~RatingEditor() override;
109
114 void setRating(Rating rating);
115
127 Rating rating() const;
128
133 void setVerticalOffset(int offset);
134
140 void setMouseTrackable(bool b);
141
146 QSize sizeHint() const override;
147
152 QSize minimumSizeHint() const override;
153
154 protected:
155 void paintEvent(QPaintEvent* e) override;
156
157 void focusInEvent(QFocusEvent* e) override;
158 void focusOutEvent(QFocusEvent* e) override;
159
160 void mousePressEvent(QMouseEvent* e) override;
161 void mouseMoveEvent(QMouseEvent* e) override;
162 void mouseReleaseEvent(QMouseEvent* e) override;
163 };
164}
165
166#endif // RATINGLABEL_H
This class is used for the actual editing of a RatingLabel While the RatingLabel class is used in pai...
Definition: RatingLabel.h:98
void setVerticalOffset(int offset)
Set an offset where to begin drawing stars.
QSize minimumSizeHint() const override
Same as RatingLabel::minimumSizeHint.
QSize sizeHint() const override
Same as RatingLabel::sizeHint.
void setMouseTrackable(bool b)
Enable mouse move events. If disabled, there's no live update.
Rating rating() const
Returns the actual rating. This is not neccessarily the rating currently visible. Consider the case w...
void setRating(Rating rating)
Sets the actual rating.
A simple label, not suitable for editing. For editing, use the RatingEditor class....
Definition: RatingLabel.h:40
Rating ratingAt(QPoint pos) const
Returns the rating regarding the current mouse position.
QSize sizeHint() const override
about 20px in height and 5x20px in width
QSize minimumSizeHint() const override
Same as sizeHint.
void paint(QPainter *painter, const QRect &rect)
Called from outside. Mostly from delegates or from the RatingEditor class.
void setVerticalOffset(int offset)
The y-offset where the stars should be painted.
void setRating(Rating rating)
Set a rating from one to 5.