-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusiclist.cpp
129 lines (107 loc) · 3.59 KB
/
musiclist.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
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
#include "musiclist.h"
/**
* @author: jingbo
* @date: 2018/05/14
* @desc: 音乐列表
*/
MusicList::MusicList(QWidget *parent) : QWidget(parent)
{
playListBtn = new QPushButton;
cloudBtn = new QPushButton;
downloadBtn = new QPushButton;
phoneBtn = new QPushButton;
searchBtn = new QPushButton;
vbtnPtr.push_back(cloudBtn);
vbtnPtr.push_back(phoneBtn);
vbtnPtr.push_back(searchBtn);
vbtnPtr.push_back(playListBtn);
vbtnPtr.push_back(downloadBtn);
operNavLayout = new QHBoxLayout;
operObjLayout = new QStackedLayout;
musicListMainLayout = new QVBoxLayout;
playPage = new MusicListPlay;
this->setFixedSize(310,527);
this->setLayout(musicListMainLayout);
setControlsLayout();
setControlsForm();
setControlsStyle();
connectSlot();
}
//---------------slot
void MusicList::musicListItemSwitch()
{
QPushButton *senderBtn = qobject_cast<QPushButton *>(sender());
for(int i = 0; i < 4; ++i){
if(senderBtn == vbtnPtr[i]){
operObjLayout->setCurrentIndex(i);
QString url = ":/img/item1";
url += (i + '0');
url += ".png";
senderBtn->setIcon(QIcon(url));
}
else{
QString url = ":/img/item0";
url += (i + '0');
url += ".png";
vbtnPtr[i]->setIcon(QIcon(url));
}
}
}
//---------------Function
void MusicList::setControlsLayout()
{
operObjLayout->setMargin(0);
operObjLayout->setSpacing(0);
operObjLayout->addWidget(playPage);
operObjLayout->setCurrentIndex(0);
musicListMainLayout->setMargin(0);
musicListMainLayout->setSpacing(0);
musicListMainLayout->addLayout(operNavLayout);
musicListMainLayout->addLayout(operObjLayout);
}
void MusicList::setControlsForm()
{
playListBtn->setFixedSize(25,25);
playListBtn->setIconSize(QSize(25,25));
playListBtn->setIcon(QIcon(":/img/item03.png"));
playListBtn->setCursor(QCursor(Qt::PointingHandCursor));
cloudBtn->setFixedSize(25,25);
cloudBtn->setIconSize(QSize(25,25));
cloudBtn->setIcon(QIcon(":/img/item10.png"));
cloudBtn->setCursor(QCursor(Qt::PointingHandCursor));
downloadBtn->setFixedSize(25,25);
downloadBtn->setIconSize(QSize(25,25));
downloadBtn->setIcon(QIcon(":/img/item04.png"));
downloadBtn->setCursor(QCursor(Qt::PointingHandCursor));
phoneBtn->setFixedSize(25,25);
phoneBtn->setIconSize(QSize(25,25));
phoneBtn->setIcon(QIcon(":/img/item01.png"));
phoneBtn->setCursor(QCursor(Qt::PointingHandCursor));
searchBtn->setFixedSize(25,25);
searchBtn->setIconSize(QSize(25,25));
searchBtn->setIcon(QIcon(":/img/item02.png"));
searchBtn->setCursor(QCursor(Qt::PointingHandCursor));
this->setWindowFlags(Qt::FramelessWindowHint);
}
void MusicList::setControlsStyle()
{
this->setAutoFillBackground(true);
QPalette palette;
palette.setColor(QPalette::Background, QColor(255,255,255,20));
this->setPalette(palette);
QFile file(QString(":/qss/musicList.qss"));
file.open(QFile::ReadOnly);
if (file.isOpen())
{
QString styleSheet = this->styleSheet();
styleSheet += QLatin1String(file.readAll());
this->setStyleSheet(styleSheet);
}
}
void MusicList::connectSlot()
{
connect(cloudBtn, &QPushButton::clicked, this, &MusicList::musicListItemSwitch);
connect(phoneBtn, &QPushButton::clicked, this, &MusicList::musicListItemSwitch);
connect(searchBtn, &QPushButton::clicked, this, &MusicList::musicListItemSwitch);
connect(playListBtn, &QPushButton::clicked, this, &MusicList::musicListItemSwitch);
}