/
customstreamwidget.h
55 lines (45 loc) · 1.23 KB
/
customstreamwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef CUSTOMSTREAMWIDGET_H
#define CUSTOMSTREAMWIDGET_H
#include <QLabel>
#include <QPainter>
#include <QDebug>
#include <QMouseEvent>
#include <QPropertyAnimation>
#define ARC_RADIUS 8
class CustomStreamWidget : public QLabel
{
Q_OBJECT
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
public:
explicit CustomStreamWidget(QString _s, QString label, QWidget *parent = 0);
~CustomStreamWidget();
void setNotActive();
void setActive();
bool equals(QString stream);
signals:
void change_sream(QString);
private:
QString streamUrl;
QPropertyAnimation animation;
enum StateFlags {
StateActive = 0x1,
StateClicked = 0x2,
StateHovered = 0x4
};
quint8 currentFlags;
QColor _backgroundColor;
void setBackgroundColor(QColor c) {
_backgroundColor = c;
}
QColor backgroundColor() const { return _backgroundColor;}
void updateAnimation();
static QColor normalColor;
static QColor highlightedColor;
static QColor clickedColor;
static QColor activeColor;
protected:
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *e);
void paintEvent(QPaintEvent *);
};
#endif // CUSTOMSTREAMWIDGET_H