-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathartistlistitem.cpp
58 lines (43 loc) · 1.48 KB
/
artistlistitem.cpp
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
#include "artistlistitem.h"
extern QString blue;
extern QString path;
//Create an artists list item for the left bar
ArtistListItem::ArtistListItem(QVariantMap data)
{
setData(data);
setAutoFillBackground(true);
setObjectName("item");
setStyleSheet("#item{border-bottom:1px solid #EEE;border-radius:0}");
icon->setFixedSize(40,40);
icon->setObjectName("Ic");
layout->setMargin(8);
layout->addWidget(icon);
layout->addWidget(text);
}
//Set the artists info
void ArtistListItem::setData(QVariantMap data)
{
artistName = data["artist"].toString();
text = new CropLabel(data["artist"].toString(),"color:#888");
if(data["artWork"].toBool())
{
icon->setStyleSheet("#Ic{border-image:url(\""+path + "/Cuarzo Player/Artwork/"+data["artist"].toString()+"/"+data["album"].toString()+".jpg"+"\"); background-position: center;border-radius:4px}");
}
else{
icon->setStyleSheet("#Ic{border-image:url(\":res/img/artWork.png\"); background-position: center;border-radius:4px}");
}
}
void ArtistListItem::setSelected(bool selected)
{
if(selected){
text->setStyleSheet("color:#FFF");
setStyleSheet("#item{background:"+blue+";border-bottom:1px solid #EEE;border-radius:0}");
}
else{
text->setStyleSheet("color:#888");
setStyleSheet("#item{background:#FFF;border-bottom:1px solid #EEE;border-radius:0}");
}
}
void ArtistListItem::mousePressEvent(QMouseEvent*){
selected(artistName);
}