Sayonara Player
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Gui
Utils
Widgets
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
30
namespace
Gui
31
{
32
class
RatingLabel :
33
public
QLabel
34
{
35
Q_OBJECT
36
PIMPL(RatingLabel)
37
38
public
:
39
enum class
Alignment :
40
uint8_t
41
{
42
Left,
43
Centered
44
};
45
46
explicit
RatingLabel(QWidget* parent,
bool
enabled =
true
);
47
~RatingLabel()
override
;
48
49
void
setRating(Rating rating);
50
[[nodiscard]] Rating rating()
const
;
51
[[nodiscard]] Rating ratingAt(QPoint pos)
const
;
52
53
void
setVerticalOffset(
int
offset);
54
55
void
setHorizontalAlignment(Alignment alignment);
56
57
void
paint(QPainter* painter,
const
QRect& rect);
58
59
[[nodiscard]] QSize sizeHint()
const override
;
60
61
[[nodiscard]] QSize minimumSizeHint()
const override
;
62
63
private
:
64
using
QLabel::setAlignment;
65
};
66
67
class
RatingEditor :
68
public
QWidget
69
{
70
Q_OBJECT
71
PIMPL(RatingEditor)
72
73
signals:
74
void
sigFinished(
bool
save);
75
76
public
:
77
explicit
RatingEditor(QWidget* parent);
78
RatingEditor(Rating rating, QWidget* parent);
79
~RatingEditor()
override
;
80
81
void
setRating(Rating rating);
82
83
[[nodiscard]] Rating rating()
const
;
84
85
void
setVerticalOffset(
int
offset);
86
87
void
setHorizontalAlignment(RatingLabel::Alignment alignment);
88
89
void
setMouseTrackable(
bool
b);
90
91
[[nodiscard]] QSize sizeHint()
const override
;
92
93
[[nodiscard]] QSize minimumSizeHint()
const override
;
94
95
protected
:
96
void
paintEvent(QPaintEvent* e)
override
;
97
98
void
focusInEvent(QFocusEvent* e)
override
;
99
void
focusOutEvent(QFocusEvent* e)
override
;
100
101
void
mousePressEvent(QMouseEvent* e)
override
;
102
void
mouseMoveEvent(QMouseEvent* e)
override
;
103
void
mouseReleaseEvent(QMouseEvent* e)
override
;
104
};
105
}
106
107
#endif
// RATINGLABEL_H
Generated on
for Sayonara Player by
1.17.0