Clock_out_Time_Calculator/ui/today_summary.py
68893236+KINDNICK@users.noreply.github.com c5df37ca57 v2.8.0: 도전과제 시스템 + 다크 디자인 리뉴얼 + 안정성 강화
Added — 도전과제 시스템 (153개 자동 평가)
- core/achievements.py: 16개 카테고리, 5단계 등급, 시크릿 9개, 메타 도전과제
- ui/achievements_view.py: 4탭 다이얼로그 (전체/진행중/완료/시크릿)
- 5분 throttle 자동 평가 + 시스템 알림 + Discord embed push
- achievements 테이블 확장 (code/category/tier/is_secret/progress/target)
- hire_date 자동 추적, 뷰 진입 카운터 8개 settings 키

Changed — 다크 테마 디자인 리뉴얼
- ui/dark_components.py: 재사용 가능한 다크 컴포넌트 (header/card/button/progress)
- 통계/도움말/도전과제 다이얼로그 일관 다크 톤
- matplotlib 차트 다크 테마 적용 (figure/axes/grid/legend)
- 등급별 카드 그라디언트 (브론즈/실버/골드/플래티넘/레전드)

Fixed — 안정성·일관성
- 타임존 자정 경계 버그 (has_notification_today UTC vs localtime mismatch)
- DB 연결 누수: _conn() 컨텍스트 매니저 도입, 40+ 메서드 변환
- DB 이중 부트스트랩 제거 (MainWindow(db=None) 옵션 인자)
- crash_handler 다단계 폴백 (DB → 파일 → stderr)
- updater PID race: 지수 backoff 재시도 (총 ~9초)
- Discord URL 형식 검증 (snowflake regex)
- 일일 보고서 저녁 섹션, MealTimeDialog 출/퇴근 범위 검증
- check_dinner_reminder 신규, 알림 임계값 5개 설정화
- closeEvent timer/notifier 정리 (aboutToQuit hook)
- 마이그레이션 12개 모두 _conn() + try/finally
- DB 인덱스 5개 추가 (break/overtime/leave date)

Tests
- pytest 116/116 PASS, 통합 시나리오 48/48 PASS

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 01:11:13 +09:00

94 lines
3.4 KiB
Python

"""
퇴근 후 표시되는 "오늘 요약" 카드 위젯.
다음 출근 시 자동 숨김. 메인 화면 상단에 conditional하게 표시.
"""
from __future__ import annotations
from PyQt5.QtWidgets import QFrame, QVBoxLayout, QHBoxLayout, QLabel, QPushButton
from PyQt5.QtCore import Qt
class TodaySummaryCard(QFrame):
"""퇴근 처리 직후 표시되는 요약 카드."""
def __init__(self, parent=None):
super().__init__(parent)
self.setObjectName("today_summary_card")
self.setStyleSheet("""
QFrame#today_summary_card {
background-color: rgba(76, 175, 80, 0.08);
border: 1px solid rgba(76, 175, 80, 0.4);
border-radius: 8px;
padding: 6px;
}
QLabel { padding: 1px; }
""")
self.setVisible(False)
layout = QVBoxLayout()
layout.setContentsMargins(10, 6, 10, 6)
layout.setSpacing(2)
header = QHBoxLayout()
title = QLabel("📋 오늘의 요약")
title.setStyleSheet("font-weight: bold; font-size: 13px;")
header.addWidget(title)
header.addStretch()
close_btn = QPushButton("")
close_btn.setFixedSize(20, 20)
close_btn.setStyleSheet("border: none; font-weight: bold;")
close_btn.clicked.connect(self.hide)
header.addWidget(close_btn)
layout.addLayout(header)
self.total_label = QLabel("")
self.detail_label = QLabel("")
self.detail_label.setStyleSheet("color: #888; font-size: 11px;")
self.salary_label = QLabel("")
self.salary_label.setStyleSheet("color: #4caf50; font-weight: bold;")
layout.addWidget(self.total_label)
layout.addWidget(self.detail_label)
layout.addWidget(self.salary_label)
self.setLayout(layout)
def show_summary(self, total_hours: float, lunch_minutes: int,
break_minutes: int, overtime_actual: int,
overtime_earned: int, salary_text: str = "",
dinner_minutes: int = 0) -> None:
"""카드 내용 채우고 표시.
Args:
total_hours: 총 근무시간(시간)
lunch_minutes: 점심 시간(분)
break_minutes: 외출 시간(분, 식사 제외)
overtime_actual: 실제 연장근무(분)
overtime_earned: 적립 연장근무(분)
salary_text: 추정 급여 표시 문자열 (옵션 활성 시)
dinner_minutes: 저녁 시간(분), 0이면 표시 안 함
"""
h = int(total_hours)
m = int((total_hours - h) * 60)
self.total_label.setText(f"⏱ 총 근무: {h}시간 {m}")
details = []
if lunch_minutes > 0:
details.append(f"점심 {lunch_minutes}")
if dinner_minutes > 0:
details.append(f"저녁 {dinner_minutes}")
if break_minutes > 0:
details.append(f"외출 {break_minutes}")
if overtime_actual > 0:
details.append(f"연장 {overtime_actual}분 → 적립 {overtime_earned}")
self.detail_label.setText(" · ".join(details) if details else "")
self.detail_label.setVisible(bool(details))
if salary_text:
self.salary_label.setText(f"💰 {salary_text}")
self.salary_label.setVisible(True)
else:
self.salary_label.setVisible(False)
self.setVisible(True)