-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.cpp
More file actions
142 lines (133 loc) · 4.81 KB
/
style.cpp
File metadata and controls
142 lines (133 loc) · 4.81 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
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
139
140
141
142
#include "style.h"
#include <QPushButton>
#include <QResizeEvent>
#include <QTreeWidget>
#include <QLineEdit>
void makeDefaultButton(QPushButton & button){
button.setStyleSheet(
"QPushButton {"
" background-color: #2155BF; /* 蓝色背景色,类似Material Design的蓝色 */"
" color: white; /* 白色文字 */"
" border: none; /* 无边框 */"
" padding: 8px 16px; /* 内边距,调整按钮内文字与边框间距 */"
" border-radius: 4px; /* 圆角,数值可按需调整 */"
"}"
"QPushButton::hover {"
" background-color: #5C6BC0; /* 鼠标悬停时背景色变深 */"
"}"
"QPushButton::pressed {"
" background-color: #303F9F; /* 按下时背景色 */"
"}"
"QPushButton:disabled {"
" background-color: #cccccc; /* 禁用状态背景色 */"
"color: #888888; /* 禁用状态文字色 */"
"}"
);
}
void makeAlertButton(QPushButton & button){
button.setStyleSheet(
"QPushButton {"
" color: #f44336; /* 红色文字 */"
" border: 1px solid #f44336; /* 红色边框 */"
" padding: 6px 12px; /* 内边距,调整文字与边框距离 */"
" border-radius: 4px; /* 圆角效果 */"
" background-color: white; /* 白色背景 */"
"}"
"QPushButton:hover {"
" background-color: #fefefe; /* 鼠标悬停时背景色微调 */"
"}"
"QPushButton:pressed {"
" background-color: #fce4ec; /* 按下时背景色 */"
"}"
);
}
void makeHelpButton(QPushButton & button){
button.setStyleSheet(
"QPushButton {"
" background-color: transparent; /* 背景 */"
" color: black; /* 黑色文字 */"
" border: 1px solid #ccc; /* 浅灰色边框 */"
" padding: 5px 10px; /* 内边距 */"
" border-radius: 3px; /* 圆角 */"
"}"
"QPushButton:hover {"
" background-color: #f5f5f5; /* 鼠标悬停时背景色变浅 */"
"}"
"QPushButton:pressed {"
" background-color: #e0e0e0; /* 按下时背景色 */"
"}"
);
}
void makeLeftTree(QTreeWidget & tree){
tree.setStyleSheet(
"QTreeWidget {"
" background-color: transparent;" // 背景色
" color: #333;" // 文字颜色
" font-size: 14px;" // 字号
" border: none;" // 无边框
"}"
"QTreeWidget::item {"
" height: 30px;" // 每行高度
" border-bottom: 1px solid #eee;" // 分隔线
"}"
"QTreeWidget::item:selected {"
" background-color: #d0e1f9;" // 选中项背景色
" color: #000;" // 选中项文字颜色
"}"
"QTreeWidget::item:hover {"
" background-color: #e8f4ff;" // 悬停项背景色
"}"
);
}
void makeLeftPanel(QWidget & panel){
panel.setStyleSheet("background-color: white;");
}
void makeDisplayLineEdit(QLineEdit & lineEdit){
lineEdit.setReadOnly(true);
lineEdit.setStyleSheet(
"QLineEdit:read-only {"
" background: transparent;" // 可选:设置透明背景
" border: none;" // 可选:移除边框
"}"
);
}
void makeRemoveButton(QPushButton & button){
button.setStyleSheet(R"(
QPushButton {
/* 背景透明 */
background-color: transparent;
/* 无边框 */
border: none;
/* 文字颜色 */
color: rgb(200, 50, 50);
/* 文字大小(可选) */
font-size: 12px;
/* 文字居中(可选) */
text-align: center;
}
QPushButton:hover {
/* 鼠标悬停时的背景色(可选) */
background-color: rgba(200, 50, 50, 30);
}
QPushButton:pressed {
/* 鼠标按下时的背景色(可选) */
background-color: rgba(200, 50, 50, 60);
}
)");
}
LabelWithInput::LabelWithInput(const QString & _label, QWidget * input, Qt::Alignment align)
: labelWidget(new QLabel(_label)), inputWidget(input){
mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(labelWidget, 0, align);
//mainLayout->addSpacing(10);
mainLayout->addWidget(inputWidget, 0, align);
//setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
//inputWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
void LabelWithInput::resizeEvent(QResizeEvent *event){
auto w = event->size().width()- 24;
//domainNameEdit->setFixedWidth(w);
inputWidget->setFixedWidth(w);
//visibleUsersEdit->setFixedWidth(w);
//descriptionEdit->setFixedWidth(w);
}