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;  /* 鼠标悬停时颜色 */
    }
"""

# ====================== QMessageBox 样式宏定义 ======================
# 基础消息框样式
MESSAGE_BOX_STYLE = f"""
    QMessageBox {{
        font-family: "{FONT_FAMILY}";
        font-size: {CONTENT_FONT_SIZE}pt;
        background-color: {LIGHT_COLOR};
        color: {TEXT_COLOR};
    }}
    QMessageBox QLabel {{
        {LABEL_STYLE}
        min-width: 300px;
        min-height: 60px;
    }}
    QMessageBox QPushButton {{
        {BUTTON_STYLE}
        min-width: 80px;
    }}
"""

# 信息消息框样式
INFO_MESSAGE_BOX_STYLE = f"""
    {MESSAGE_BOX_STYLE}
    QMessageBox {{
        border-top: 4px solid {ACCENT_COLOR};
    }}
    QMessageBox QLabel[text^="<html>"] {{
        color: {PRIMARY_COLOR};
    }}
"""

# 警告消息框样式
WARNING_MESSAGE_BOX_STYLE = f"""
    {MESSAGE_BOX_STYLE}
    QMessageBox {{
        border-top: 4px solid #f39c12;
    }}
    QMessageBox QLabel[text^="<html>"] {{
        color: #e67e22;
    }}
"""

# 错误消息框样式
CRITICAL_MESSAGE_BOX_STYLE = f"""
    {MESSAGE_BOX_STYLE}
    QMessageBox {{
        border-top: 4px solid #e74c3c;
    }}
    QMessageBox QLabel[text^="<html>"] {{
        color: #c0392b;
    }}
"""

# 提问消息框样式
QUESTION_MESSAGE_BOX_STYLE = f"""
    {MESSAGE_BOX_STYLE}
    QMessageBox {{
        border-top: 4px solid {SUCCESS_COLOR};
    }}
    QMessageBox QLabel[text^="<html>"] {{
        color: {SECONDARY_COLOR};
    }}
"""

# 消息框按钮样式
MESSAGE_BOX_BUTTON_STYLE = f"""
    QMessageBox QPushButton {{
        {PRIMARY_BUTTON_STYLE}
        min-width: 80px;
        max-width: 120px;
    }}
    QMessageBox QPushButton[text="Yes"],
    QMessageBox QPushButton[text="OK"] {{
        background-color: {SUCCESS_COLOR};
        color: {LIGHT_TEXT_COLOR};
    }}
    QMessageBox QPushButton[text="No"],
    QMessageBox QPushButton[text="Cancel"] {{
        background-color: #e74c3c;
        color: {LIGHT_TEXT_COLOR};
    }}
"""

# ====================== 缺陷描述编辑相关样式 ======================
# 缺陷描述编辑窗口样式
DEFECT_EDIT_WINDOW_STYLE = f"""
    QWidget {{
        background-color: {LIGHT_COLOR};
    }}
"""

# 输入框样式
LINE_EDIT_STYLE = f"""
    QLineEdit {{
        font-family: "{FONT_FAMILY}";
        font-size: {CONTENT_FONT_SIZE}pt;
        min-height: {COMBO_BOX_HEIGHT + 5}px;
        padding: 5px 10px;
        border: 1px solid #bdc3c7;
        border-radius: 4px;
    }}
"""

# 尺寸输入框样式
DIMENSION_EDIT_STYLE = f"""
    QLineEdit {{
        {LINE_EDIT_STYLE}
        min-width: 60px;
    }}
"""

# 尺寸标签样式
DIMENSION_LABEL_STYLE = f"""
    QLabel {{
        {LABEL_STYLE}
        min-width: 60px;
    }}
"""

# 尺寸控件容器样式
DIMENSION_CONTAINER_STYLE = f"""
    QWidget {{
        background-color: transparent;
    }}
"""
