ReportGeneratorLocal/info_core/defines.py

207 lines
4.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from PySide6.QtGui import QFont
# ====================== 样式宏定义 ======================
# 字体设置
FONT_PATH = "font/SourceHanSerifCN-Medium.ttf" # 指定字体文件路径
FONT_FAMILY = "Source Han Serif CN" # 字体家族名称
TITLE_FONT_SIZE = 12
CONTENT_FONT_SIZE = 11
BUTTON_FONT_SIZE = 11
# 颜色定义
PRIMARY_COLOR = "#2c3e50"
SECONDARY_COLOR = "#34495e"
ACCENT_COLOR = "#3498db"
SUCCESS_COLOR = "#2ecc71"
LIGHT_COLOR = "#ecf0f1"
DARK_COLOR = "#2c3e50"
TEXT_COLOR = "#2c3e50"
LIGHT_TEXT_COLOR = "#ecf0f1"
# 按钮样式
BUTTON_WIDTH = 200
BUTTON_HEIGHT = 20
BUTTON_RADIUS = 4
BUTTON_FONT_WEIGHT = QFont.Weight.Medium
BUTTON_STYLE = f"""
QPushButton {{
font-family: "{FONT_FAMILY}";
font-size: {BUTTON_FONT_SIZE}pt;
font-weight: {BUTTON_FONT_WEIGHT};
color: {TEXT_COLOR};
background-color: {LIGHT_COLOR};
border: 1px solid {SECONDARY_COLOR};
border-radius: {BUTTON_RADIUS}px;
padding: 6px 12px;
min-width: {BUTTON_WIDTH}px;
min-height: {BUTTON_HEIGHT}px;
}}
QPushButton:hover {{
background-color: #dfe6ec;
}}
QPushButton:pressed {{
background-color: #d0d7dd;
}}
"""
PRIMARY_BUTTON_STYLE = f"""
QPushButton {{
font-family: "{FONT_FAMILY}";
font-size: {BUTTON_FONT_SIZE + 1}pt;
font-weight: {BUTTON_FONT_WEIGHT};
color: {LIGHT_TEXT_COLOR};
background-color: {PRIMARY_COLOR};
border: 1px solid {DARK_COLOR};
border-radius: {BUTTON_RADIUS}px;
padding: 8px 16px;
}}
QPushButton:hover {{
background-color: #34495e;
}}
QPushButton:pressed {{
background-color: #2c3e50;
}}
"""
# 下拉框样式
COMBO_BOX_HEIGHT = 10
COMBO_BOX_STYLE = f"""
QComboBox {{
font-family: "{FONT_FAMILY}";
font-size: {CONTENT_FONT_SIZE}pt;
min-height: {COMBO_BOX_HEIGHT}px;
padding: 5px 10px;
border: 1px solid #bdc3c7;
border-radius: 4px;
}}
QComboBox::drop-down {{
width: 30px;
border-left: 1px solid #bdc3c7;
}}
"""
# 组框样式
GROUP_BOX_MIN_WIDTH = 300
GROUP_BOX_MIN_HEIGHT = 120
GROUP_BOX_SPACING = 5
GROUP_BOX_MARGINS = (1, 1, 1, 1)
GROUP_BOX_STYLE = f"""
QGroupBox {{
font-family: "{FONT_FAMILY}";
font-size: {TITLE_FONT_SIZE}pt;
font-weight: bold;
color: {PRIMARY_COLOR};
border: 1px solid #bdc3c7;
border-radius: 5px;
margin-top: 10px;
}}
QGroupBox::title {{
subcontrol-origin: margin;
left: 10px;
padding: 0 3px;
}}
"""
# 标签样式
LABEL_STYLE = f"""
QLabel {{
font-family: "{FONT_FAMILY}";
font-size: {CONTENT_FONT_SIZE}pt;
color: {TEXT_COLOR};
}}
"""
PATH_DISPLAY_STYLE = f"""
QLabel {{
font-family: "{FONT_FAMILY}";
font-size: {CONTENT_FONT_SIZE}pt;
background-color: {LIGHT_COLOR};
border: 1px solid #dee2e6;
border-radius: 4px;
padding: 10px;
min-height: 80px;
color: {TEXT_COLOR};
}}
"""
# 主窗口样式
WINDOW_MIN_WIDTH = 1000
WINDOW_MIN_HEIGHT = 720
MAIN_LAYOUT_SPACING = 10
MAIN_LAYOUT_MARGINS = (5, 5, 5, 5)
# 信息标签样式 (左侧固定标签)
INFO_LABEL_STYLE = f"""
QLabel {{
{LABEL_STYLE}
min-height: {COMBO_BOX_HEIGHT}px;
padding: 5px;
min-width: 100px;
}}
"""
# 信息显示样式 (右侧内容)
INFO_DISPLAY_STYLE = f"""
QLabel {{
{PATH_DISPLAY_STYLE}
min-height: {COMBO_BOX_HEIGHT}px;
border-radius: 4px;
}}
"""
# 分隔线样式
SEPARATOR_STYLE = """
QFrame {
border: 1px solid #dee2e6;
margin: 10px 0;
}
"""
# 等待提示样式
WAITING_LABEL_STYLE = f"""
QLabel {{
{LABEL_STYLE}
font-size: {TITLE_FONT_SIZE}pt;
qproperty-alignment: AlignCenter;
}}
"""
CHECKBOX_SIZE = 16 # 复选框大小
CHECKBOX_MARGIN = 1 # 边距
# 基础CheckBox样式
CHECKBOX_STYLE = f"""
QCheckBox {{
font-family: "{FONT_FAMILY}";
font-size: {CONTENT_FONT_SIZE}pt;
color: {TEXT_COLOR};
spacing: 8px;
padding: {CHECKBOX_MARGIN}px;
}}
QCheckBox::indicator {{
width: {CHECKBOX_SIZE}px;
height: {CHECKBOX_SIZE}px;
}}
"""
# 主色调CheckBox
PRIMARY_CHECKBOX_STYLE = f"""
{CHECKBOX_STYLE}
QCheckBox::indicator {{
border: 1px solid {PRIMARY_COLOR};
border-radius: 3px;
}}
QCheckBox::indicator:checked {{
background-color: {PRIMARY_COLOR};
}}
"""
SPLITTER_STYLE = """
QSplitter::handle {
background: #a0a0a0; /* 分割线颜色 */
height: 4px; /* 水平分割线高度(垂直分割线用 width */
}
QSplitter::handle:hover {
background: #808080; /* 鼠标悬停时颜色 */
}
"""