113 lines
3.8 KiB
Python
113 lines
3.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
팀 확인 위젯 모듈
|
|
각 팀의 확인 상태를 토글 방식으로 표시하는 위젯입니다.
|
|
"""
|
|
|
|
from typing import Dict, List
|
|
from PySide6.QtWidgets import QWidget, QGridLayout, QLabel
|
|
from PySide6.QtCore import Qt, Signal
|
|
|
|
from ui.components.toggle_switch import ToggleSwitch
|
|
from ui.styles.style_manager import StyleManager
|
|
from core.constants import TEAMS
|
|
from core.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class TeamConfirmationWidget(QWidget):
|
|
"""
|
|
팀 확인 위젯
|
|
|
|
각 팀의 확인 상태를 토글 스위치로 표시합니다.
|
|
확인한 팀만 표시되며, 2열로 배치됩니다.
|
|
"""
|
|
|
|
confirmation_changed = Signal(str, bool) # 팀명, 확인여부
|
|
|
|
def __init__(self, confirmations: Dict[str, bool] = None, parent=None):
|
|
super().__init__(parent)
|
|
|
|
self.style_manager = StyleManager()
|
|
self.confirmations = confirmations or {team: False for team in TEAMS}
|
|
self.toggles: Dict[str, ToggleSwitch] = {}
|
|
|
|
self._setup_ui()
|
|
|
|
def _setup_ui(self):
|
|
"""UI 설정"""
|
|
layout = QGridLayout(self)
|
|
layout.setContentsMargins(4, 4, 4, 4)
|
|
layout.setSpacing(8)
|
|
|
|
colors = self.style_manager.get_colors()
|
|
|
|
# 2열로 배치: 1열에 1팀,2팀, 2열에 3팀,4팀
|
|
for idx, team in enumerate(TEAMS):
|
|
row = idx // 2 # 0 또는 1
|
|
col = idx % 2 # 0 또는 1
|
|
|
|
# 팀명 레이블
|
|
team_label = QLabel(team)
|
|
team_font = self.style_manager.get_font("section", "content")
|
|
team_label.setFont(team_font)
|
|
team_label.setStyleSheet(f"color: {colors['text_secondary']};")
|
|
team_label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
|
|
|
# 토글 스위치
|
|
toggle = ToggleSwitch(
|
|
initial_state=self.confirmations.get(team, False),
|
|
width=45,
|
|
height=24
|
|
)
|
|
toggle.toggled.connect(lambda checked, t=team: self._on_toggle_changed(t, checked))
|
|
self.toggles[team] = toggle
|
|
|
|
# 레이아웃에 추가
|
|
layout.addWidget(team_label, row, col * 2) # 팀명은 0, 2 열
|
|
layout.addWidget(toggle, row, col * 2 + 1) # 토글은 1, 3 열
|
|
|
|
# 열 비율 설정
|
|
layout.setColumnStretch(0, 1)
|
|
layout.setColumnStretch(1, 0)
|
|
layout.setColumnStretch(2, 1)
|
|
layout.setColumnStretch(3, 0)
|
|
|
|
def _on_toggle_changed(self, team: str, checked: bool):
|
|
"""토글 변경 이벤트"""
|
|
self.confirmations[team] = checked
|
|
self.confirmation_changed.emit(team, checked)
|
|
logger.debug(f"팀 확인 상태 변경: {team} = {checked}")
|
|
|
|
def set_confirmations(self, confirmations: Dict[str, bool]):
|
|
"""확인 상태 설정"""
|
|
self.confirmations = confirmations
|
|
for team, toggle in self.toggles.items():
|
|
toggle.blockSignals(True)
|
|
toggle.set_state(confirmations.get(team, False), animate=False)
|
|
toggle.blockSignals(False)
|
|
|
|
def get_confirmations(self) -> Dict[str, bool]:
|
|
"""확인 상태 반환"""
|
|
return self.confirmations.copy()
|
|
|
|
def get_confirmed_teams(self) -> List[str]:
|
|
"""확인한 팀 목록 반환"""
|
|
return [team for team, confirmed in self.confirmations.items() if confirmed]
|
|
|
|
def all_confirmed(self) -> bool:
|
|
"""모든 팀 확인 여부"""
|
|
return all(self.confirmations.values())
|
|
|
|
def update_display(self):
|
|
"""표시 업데이트 (확인한 팀만 표시)"""
|
|
# 현재는 모든 팀을 표시하되, 확인한 팀은 토글이 켜진 상태로 표시
|
|
# 필요시 확인한 팀만 표시하도록 변경 가능
|
|
pass
|
|
|
|
|
|
|
|
|
|
|