287 lines
6.8 KiB
C++
287 lines
6.8 KiB
C++
#include "stylehelper.h"
|
|
|
|
void StyleHelper::applyGlobalStyle(QApplication *app)
|
|
{
|
|
app->setStyleSheet(getGlobalStyleSheet());
|
|
}
|
|
|
|
QString StyleHelper::getGlobalStyleSheet()
|
|
{
|
|
return R"(
|
|
/* 全局样式 */
|
|
QWidget {
|
|
font-family: "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
|
|
}
|
|
|
|
/* 主窗口 */
|
|
QMainWindow {
|
|
background-color: #F5F5F5;
|
|
}
|
|
|
|
/* 按钮样式 - 触摸屏优化 */
|
|
QPushButton {
|
|
background-color: #2196F3;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
padding: 10px 20px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
min-height: 38px;
|
|
}
|
|
|
|
QPushButton:hover {
|
|
background-color: #1976D2;
|
|
}
|
|
|
|
QPushButton:pressed {
|
|
background-color: #1565C0;
|
|
}
|
|
|
|
QPushButton:disabled {
|
|
background-color: #BDBDBD;
|
|
color: #757575;
|
|
}
|
|
|
|
/* 次要按钮 */
|
|
QPushButton[flat="true"] {
|
|
background-color: transparent;
|
|
color: #2196F3;
|
|
}
|
|
|
|
QPushButton[flat="true"]:hover {
|
|
background-color: rgba(33, 150, 243, 0.1);
|
|
}
|
|
|
|
/* 输入框 - 触摸屏优化 */
|
|
QLineEdit {
|
|
background-color: white;
|
|
border: 1px solid #E0E0E0;
|
|
border-radius: 8px;
|
|
padding: 10px 14px;
|
|
font-size: 14px;
|
|
color: #212121;
|
|
min-height: 38px;
|
|
}
|
|
|
|
QLineEdit:focus {
|
|
border-color: #2196F3;
|
|
border-width: 2px;
|
|
}
|
|
|
|
QLineEdit:disabled {
|
|
background-color: #FAFAFA;
|
|
color: #9E9E9E;
|
|
}
|
|
|
|
/* 下拉框 - 触摸屏优化 */
|
|
QComboBox {
|
|
background-color: white;
|
|
border: 1px solid #E0E0E0;
|
|
border-radius: 8px;
|
|
padding: 10px 14px;
|
|
font-size: 14px;
|
|
color: #212121;
|
|
min-height: 38px;
|
|
}
|
|
|
|
QComboBox:hover {
|
|
border-color: #BDBDBD;
|
|
}
|
|
|
|
QComboBox:focus {
|
|
border-color: #2196F3;
|
|
}
|
|
|
|
QComboBox::drop-down {
|
|
border: none;
|
|
width: 40px;
|
|
}
|
|
|
|
QComboBox::down-arrow {
|
|
image: url(:/icons/arrow_down.svg);
|
|
width: 16px;
|
|
height: 16px;
|
|
}
|
|
|
|
/* 滚动条 - 触摸屏优化 */
|
|
QScrollBar:vertical {
|
|
background-color: #F5F5F5;
|
|
width: 14px;
|
|
border-radius: 7px;
|
|
}
|
|
|
|
QScrollBar::handle:vertical {
|
|
background-color: #BDBDBD;
|
|
border-radius: 7px;
|
|
min-height: 50px;
|
|
}
|
|
|
|
QScrollBar::handle:vertical:hover {
|
|
background-color: #9E9E9E;
|
|
}
|
|
|
|
QScrollBar::add-line:vertical,
|
|
QScrollBar::sub-line:vertical {
|
|
height: 0px;
|
|
}
|
|
|
|
QScrollBar:horizontal {
|
|
background-color: #F5F5F5;
|
|
height: 14px;
|
|
border-radius: 7px;
|
|
}
|
|
|
|
QScrollBar::handle:horizontal {
|
|
background-color: #BDBDBD;
|
|
border-radius: 7px;
|
|
min-width: 50px;
|
|
}
|
|
|
|
QScrollBar::handle:horizontal:hover {
|
|
background-color: #9E9E9E;
|
|
}
|
|
|
|
QScrollBar::add-line:horizontal,
|
|
QScrollBar::sub-line:horizontal {
|
|
width: 0px;
|
|
}
|
|
|
|
/* 标签页 */
|
|
QTabWidget::pane {
|
|
border: 1px solid #E0E0E0;
|
|
border-radius: 8px;
|
|
background-color: white;
|
|
}
|
|
|
|
QTabBar::tab {
|
|
background-color: #F5F5F5;
|
|
color: #757575;
|
|
padding: 12px 24px;
|
|
border-top-left-radius: 8px;
|
|
border-top-right-radius: 8px;
|
|
margin-right: 2px;
|
|
}
|
|
|
|
QTabBar::tab:selected {
|
|
background-color: white;
|
|
color: #2196F3;
|
|
font-weight: 500;
|
|
}
|
|
|
|
QTabBar::tab:hover:!selected {
|
|
background-color: #EEEEEE;
|
|
}
|
|
|
|
/* 进度条 */
|
|
QProgressBar {
|
|
background-color: #E0E0E0;
|
|
border: none;
|
|
border-radius: 4px;
|
|
height: 8px;
|
|
text-align: center;
|
|
}
|
|
|
|
QProgressBar::chunk {
|
|
background-color: #2196F3;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
/* 工具提示 */
|
|
QToolTip {
|
|
background-color: #424242;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
padding: 8px 12px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
/* 消息框 */
|
|
QMessageBox {
|
|
background-color: white;
|
|
}
|
|
|
|
QMessageBox QLabel {
|
|
color: #212121;
|
|
font-size: 14px;
|
|
}
|
|
|
|
/* 分组框 */
|
|
QGroupBox {
|
|
background-color: white;
|
|
border: 1px solid #E0E0E0;
|
|
border-radius: 8px;
|
|
margin-top: 16px;
|
|
padding: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
QGroupBox::title {
|
|
subcontrol-origin: margin;
|
|
subcontrol-position: top left;
|
|
left: 16px;
|
|
padding: 0 8px;
|
|
color: #424242;
|
|
}
|
|
|
|
/* 列表 */
|
|
QListWidget {
|
|
background-color: white;
|
|
border: 1px solid #E0E0E0;
|
|
border-radius: 8px;
|
|
padding: 8px;
|
|
}
|
|
|
|
QListWidget::item {
|
|
padding: 12px;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
QListWidget::item:selected {
|
|
background-color: #E3F2FD;
|
|
color: #1976D2;
|
|
}
|
|
|
|
QListWidget::item:hover:!selected {
|
|
background-color: #F5F5F5;
|
|
}
|
|
|
|
/* 表格 */
|
|
QTableWidget {
|
|
background-color: white;
|
|
border: 1px solid #E0E0E0;
|
|
border-radius: 8px;
|
|
gridline-color: #EEEEEE;
|
|
}
|
|
|
|
QTableWidget::item {
|
|
padding: 12px;
|
|
}
|
|
|
|
QTableWidget::item:selected {
|
|
background-color: #E3F2FD;
|
|
color: #1976D2;
|
|
}
|
|
|
|
QHeaderView::section {
|
|
background-color: #FAFAFA;
|
|
color: #424242;
|
|
padding: 12px;
|
|
border: none;
|
|
border-bottom: 1px solid #E0E0E0;
|
|
font-weight: 500;
|
|
}
|
|
)";
|
|
}
|
|
|
|
QString StyleHelper::cardShadow()
|
|
{
|
|
return "0 4px 8px rgba(0,0,0,0.15)";
|
|
}
|
|
|
|
QString StyleHelper::buttonShadow()
|
|
{
|
|
return "0 2px 4px rgba(0,0,0,0.2)";
|
|
}
|