102 lines
3.2 KiB
Python
102 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
커스텀 체크박스 모듈
|
|
현대적인 디자인의 체크박스 위젯입니다.
|
|
"""
|
|
|
|
from PySide6.QtWidgets import QCheckBox, QStyleOptionButton, QStyle
|
|
from PySide6.QtCore import Qt, QRect
|
|
from PySide6.QtGui import QPainter, QColor, QPen
|
|
|
|
from ui.styles.style_manager import StyleManager
|
|
from core.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class CustomCheckBox(QCheckBox):
|
|
"""
|
|
커스텀 체크박스 위젯
|
|
|
|
현대적인 디자인의 체크박스입니다.
|
|
"""
|
|
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent)
|
|
self.style_manager = StyleManager()
|
|
self._apply_style()
|
|
|
|
def _apply_style(self):
|
|
"""스타일 적용"""
|
|
colors = self.style_manager.get_colors()
|
|
|
|
self.setStyleSheet(f"""
|
|
QCheckBox {{
|
|
spacing: 8px;
|
|
}}
|
|
QCheckBox::indicator {{
|
|
width: 24px;
|
|
height: 24px;
|
|
border: 2px solid {colors['border']};
|
|
border-radius: 6px;
|
|
background-color: {colors['input_bg']};
|
|
}}
|
|
QCheckBox::indicator:hover {{
|
|
border-color: {colors['accent']};
|
|
background-color: {colors['bg_hover']};
|
|
}}
|
|
QCheckBox::indicator:checked {{
|
|
background-color: {colors['accent']};
|
|
border-color: {colors['accent']};
|
|
}}
|
|
QCheckBox::indicator:checked:hover {{
|
|
background-color: {colors['accent_hover']};
|
|
border-color: {colors['accent_hover']};
|
|
}}
|
|
""")
|
|
|
|
def paintEvent(self, event):
|
|
"""체크 표시 커스텀 그리기"""
|
|
super().paintEvent(event)
|
|
|
|
if self.isChecked():
|
|
# 체크 표시 그리기
|
|
painter = QPainter(self)
|
|
painter.setRenderHint(QPainter.Antialiasing)
|
|
|
|
# 인디케이터 영역 찾기
|
|
opt = QStyleOptionButton()
|
|
self.initStyleOption(opt)
|
|
|
|
indicator_rect = self.style().subElementRect(
|
|
QStyle.SubElement.SE_CheckBoxIndicator,
|
|
opt,
|
|
self
|
|
)
|
|
|
|
if indicator_rect.isValid():
|
|
# 체크 표시 그리기 (✓)
|
|
painter.setPen(QPen(QColor("#ffffff"), 3))
|
|
painter.setRenderHint(QPainter.Antialiasing)
|
|
|
|
# 체크 표시 위치 계산
|
|
x = indicator_rect.x()
|
|
y = indicator_rect.y()
|
|
w = indicator_rect.width()
|
|
h = indicator_rect.height()
|
|
|
|
# ✓ 그리기 (V 모양)
|
|
center_x = x + w // 2
|
|
center_y = y + h // 2
|
|
|
|
# 체크 표시 (V 모양 - 두 선)
|
|
painter.drawLine(
|
|
center_x - 5, center_y,
|
|
center_x - 1, center_y + 4
|
|
)
|
|
painter.drawLine(
|
|
center_x - 1, center_y + 4,
|
|
center_x + 5, center_y - 4
|
|
)
|
|
|