-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectlistitem.h
81 lines (69 loc) · 1.98 KB
/
selectlistitem.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef SELECTLISTITEM_H
#define SELECTLISTITEM_H
#include <QWidget>
#include <QBoxLayout>
#include <QVariantMap>
#include "croplabel.h"
#include "icon.h"
extern QString blue;
class SelectListItem : public QWidget
{
Q_OBJECT
public:
SelectListItem(QVariantMap data)
{
iconURL = data["icon"].toString();
selected = data["selected"].toBool();
icon = new Icon(iconURL,"#666",16,16);
selectIcon = new Icon(":res/img/checked.svg","#666",12,12);
text = new CropLabel(data["text"].toString(),"");
layout->addWidget(selectIcon);
layout->addWidget(icon);
layout->addWidget(text);
layout->setMargin(0);
layout->setContentsMargins(3,5,3,5);
setAttribute(Qt::WA_Hover, true);
setAutoFillBackground(true);
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor("#FFF"));
setPalette(pal);
}
QString iconURL;
bool selected;
QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight,this);
Icon *icon;
Icon *selectIcon;
CropLabel *text;
void enterEvent(QEvent * event){
icon->setColor("#FFF");
text->setStyleSheet("color:#FFF");
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(blue));
setPalette(pal);
if(true){
selectIcon->setColor("#FFF");
}
else{
selectIcon->setColor(blue);
}
}
void leaveEvent(QEvent * event){
icon->setColor("#666");
text->setStyleSheet("color:#666");
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor("#FFF"));
setPalette(pal);
if(true){
selectIcon->setColor("#666");
}
else{
selectIcon->setColor("#FFF");
}
}
void mouseReleaseEvent(QMouseEvent *eventPress){
this->itemSelected(this);
}
signals:
void itemSelected(SelectListItem *item);
};
#endif // SELECTLISTITEM_H