-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalbum.h
138 lines (117 loc) · 4.55 KB
/
album.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef ALBUM_H
#define ALBUM_H
#include <QWidget>
#include <QBoxLayout>
#include <QLabel>
#include "croplabel.h"
#include "opbutton.h"
#include "pix.h";
extern QString blue;
extern QString path;
class Album:public QWidget
{
Q_OBJECT
public:
QString artist;
QString album;
int songsCount = 1;
Pix p;
QWidget *artWorkFrame = new QWidget();
QWidget *artWorkBottomFrame = new QWidget();
QWidget *nameFrame = new QWidget();
QWidget *rightFrame = new QWidget();
QWidget *songsFrame= new QWidget();
QFrame *infoFrame = new QFrame();
QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight,this);
QBoxLayout *artWorkLayout = new QBoxLayout(QBoxLayout::TopToBottom,artWorkFrame);
QBoxLayout *artWorkBottomLayout = new QBoxLayout(QBoxLayout::LeftToRight,artWorkBottomFrame);
QBoxLayout *songsLayout = new QBoxLayout(QBoxLayout::TopToBottom,songsFrame);
QBoxLayout *rightLayout = new QBoxLayout(QBoxLayout::TopToBottom,rightFrame);
QBoxLayout *infoLayout = new QBoxLayout(QBoxLayout::LeftToRight,infoFrame);
QBoxLayout *nameLayout = new QBoxLayout(QBoxLayout::TopToBottom,nameFrame);
QFrame *artWork = new QFrame();
CropLabel *albumName;
CropLabel *albumInfo;
QLabel *songsNumber = new QLabel();
OpButton *shuffle = new OpButton(":res/img/shuffle.svg",20,20,blue);
OpButton *more = new OpButton(":res/img/more.svg",20,20,blue);
Album(QVariantMap data)
{
artist = data["artist"].toString();
album = data["album"].toString();
albumName = new CropLabel(album,"font-size:20px;color:#444;font-weight:bold");
if(data["artWork"].toBool())
{
artWork->setStyleSheet("border-image:url(\""+path + "/Cuarzo Player/Artwork/" + data["artist"].toString() + "/" + data["album"].toString() + ".jpg"+"\"); background-position: center;border-radius:6px");
}
else{
artWork->setStyleSheet("border-image:url(\":res/img/artWork.png\"); background-position: center;border-radius:6px");
}
QString genre = data["genre"].toString();
QString year = QString::number(data["year"].toInt());
QString inf = "";
if(genre != "") inf += genre;
if(genre != "" && year != "0") inf += (" - " + year);
if(genre == "" && year != "0") inf += year;
if(inf != ""){
albumInfo = new CropLabel(inf ,"font-size:13px;color:#888");
}
else{
albumInfo = new CropLabel("" ,"font-size:13px;color:#888");
}
artWork->setFixedSize(180,180);
songsNumber->setStyleSheet("color:#888");
albumInfo->setFixedHeight(15);
layout->addWidget(artWorkFrame);
layout->addWidget(rightFrame,10);
layout->setMargin(0);
layout->setAlignment(Qt::AlignTop);
layout->setSpacing(25);
artWorkLayout->addWidget(artWork);
artWorkLayout->addWidget(artWorkBottomFrame);
artWorkLayout->addWidget(new QWidget(),10);
artWorkLayout->setAlignment(Qt::AlignTop);
artWorkLayout->setMargin(0);
artWorkLayout->setSpacing(0);
artWorkBottomLayout->setAlignment(Qt::AlignTop);
artWorkBottomLayout->addWidget(songsNumber,10);
artWorkBottomLayout->addWidget(shuffle);
artWorkBottomLayout->setContentsMargins(2,8,2,8);
rightLayout->addWidget(infoFrame);
rightLayout->addWidget(songsFrame,10);
rightLayout->setMargin(0);
infoLayout->addWidget(nameFrame,10);
infoLayout->addWidget(more);
infoLayout->setMargin(5);
infoFrame->setObjectName("info");
infoFrame->setStyleSheet("#info{border-bottom:1px solid #EEE;border-radius:0}");
nameLayout->setMargin(0);
nameLayout->addWidget(albumName);
nameLayout->addWidget(albumInfo);
songsLayout->setAlignment(Qt::AlignTop);
songsLayout->setMargin(0);
songsLayout->setSpacing(0);
connect(shuffle,SIGNAL(clicked(bool)),this,SLOT(shuffleAll()));
connect(more,SIGNAL(clicked(bool)),this,SLOT(moreAll()));
}
void refreshSongCount(){
if(songsCount == 1)
{
songsNumber->setText("1 Song");
}
else{
songsNumber->setText(QString::number(songsCount) + " Songs");
}
}
public slots:
void shuffleAll(){
shuffleAlbum(artist,album);
}
void moreAll(){
moreMenuAlbum(artist,album);
}
signals:
void shuffleAlbum(QString artist,QString album);
void moreMenuAlbum(QString artist,QString album);
};
#endif // ALBUM_H