This repository was archived by the owner on May 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidebaritem.cpp
More file actions
53 lines (48 loc) · 1.45 KB
/
Copy pathsidebaritem.cpp
File metadata and controls
53 lines (48 loc) · 1.45 KB
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
#include "sidebaritem.h"
#include "ui_sidebaritem.h"
SideBarItem::SideBarItem(QWidget *parent) :
QWidget(parent),
ui(new Ui::SideBarItem)
{
ui->setupUi(this);
setSelected(false); // 默认没有选中
}
SideBarItem::~SideBarItem()
{
delete ui;
}
void SideBarItem::setContent(QString _icon, QString label){
icon=_icon;
setIcon(icon);
ui->label->setText(label);
}
void SideBarItem::setIcon(QString icon){
ui->icon->setStyleSheet(QString("image: url(:/mplayer/").append(icon).append(".svg);"));
}
void SideBarItem::setSelected(bool selected){
if(selected){
ui->decoration->setGraphicsEffect(NULL);
ui->itemContainer->setStyleSheet("#itemContainer{\
border-image: url(:/mplayer/mplayer-item.png);\
border-radius:19px;\
}\
#itemContainer *{\
background-color:rgba(0,0,0,0);\
}");
setIcon(icon+"_w");
ui->label->setStyleSheet("color:rgb(253,253,253);");
}else{
QGraphicsOpacityEffect *op=new QGraphicsOpacityEffect;
op->setOpacity(0);
ui->decoration->setGraphicsEffect(op);
ui->itemContainer->setStyleSheet("#itemContainer{\
background-color: transparent;\
border-radius:19px;\
}\
#itemContainer *{\
background-color:rgba(0,0,0,0);\
}");
setIcon(icon);
ui->label->setStyleSheet("color:rgb(2,2,2);");
}
}