Phase 3 (also v2.5.0 in CHANGELOG): - Weekly auto report on Monday - Matplotlib chart hover annotation - Clock-in time distribution histogram - Leave usage calendar with color coding Phase 4 (v2.6.0): - Font scale 100/125/150% (instant apply) - High-contrast mode (black bg + yellow text) - Authenticode signing infra in release.ps1 (env-gated, optional) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
83 lines
2.7 KiB
Python
83 lines
2.7 KiB
Python
"""
|
|
접근성 — 글꼴 크기 / 고대비 모드 적용.
|
|
|
|
QApplication 글로벌 폰트 + 추가 QSS 오버레이.
|
|
설정 변경 즉시 반영 (재시작 불필요).
|
|
"""
|
|
from __future__ import annotations
|
|
from PyQt5.QtWidgets import QApplication
|
|
from PyQt5.QtGui import QFont
|
|
|
|
|
|
# 고대비 QSS — 검정 배경 + 노란 텍스트 + 굵은 테두리
|
|
HIGH_CONTRAST_QSS = """
|
|
* {
|
|
background-color: #000000;
|
|
color: #FFEB3B;
|
|
border-color: #FFEB3B;
|
|
}
|
|
QPushButton, QLineEdit, QSpinBox, QComboBox, QTextEdit, QTableWidget, QGroupBox {
|
|
border: 2px solid #FFEB3B;
|
|
background-color: #000000;
|
|
color: #FFEB3B;
|
|
}
|
|
QPushButton:hover { background-color: #333333; }
|
|
QPushButton:pressed { background-color: #FFEB3B; color: #000000; }
|
|
QPushButton:disabled { color: #888; border-color: #888; }
|
|
QGroupBox::title { color: #FFEB3B; padding: 0 4px; }
|
|
QProgressBar { border: 2px solid #FFEB3B; }
|
|
QProgressBar::chunk { background-color: #FFEB3B; }
|
|
QToolTip { background-color: #000; color: #FFEB3B; border: 2px solid #FFEB3B; }
|
|
"""
|
|
|
|
|
|
def apply_font_scale(scale: float) -> None:
|
|
"""전역 글꼴 크기 배율 적용 (1.0 = 기본, 1.25 = 125%, 1.5 = 150%)."""
|
|
app = QApplication.instance()
|
|
if app is None:
|
|
return
|
|
base = app.font()
|
|
if base.pointSize() > 0:
|
|
# 기존 배율 무시하고 새 배율로 (기본 9pt 가정)
|
|
base_pt = 9
|
|
base.setPointSize(int(round(base_pt * scale)))
|
|
else:
|
|
base_px = 12
|
|
base.setPixelSize(int(round(base_px * scale)))
|
|
app.setFont(base)
|
|
|
|
|
|
def apply_high_contrast(enabled: bool, base_qss: str = "") -> None:
|
|
"""고대비 모드 ON/OFF. base_qss는 평소 테마 QSS (OFF 시 복원용)."""
|
|
app = QApplication.instance()
|
|
if app is None:
|
|
return
|
|
if enabled:
|
|
app.setStyleSheet(base_qss + "\n" + HIGH_CONTRAST_QSS)
|
|
else:
|
|
app.setStyleSheet(base_qss)
|
|
|
|
|
|
def apply_from_settings(db) -> None:
|
|
"""db에서 font_scale + high_contrast 읽어 적용."""
|
|
try:
|
|
scale = float(db.get_setting('font_scale', '1.0') or 1.0)
|
|
except (ValueError, TypeError):
|
|
scale = 1.0
|
|
scale = max(0.8, min(2.0, scale))
|
|
apply_font_scale(scale)
|
|
|
|
enabled = db.get_setting('high_contrast', 'false').lower() == 'true'
|
|
# base_qss는 main_window에서 apply_theme() 호출 직후 적용되므로,
|
|
# 여기서는 현재 styleSheet 그대로 두고 high_contrast만 추가.
|
|
app = QApplication.instance()
|
|
if app is None:
|
|
return
|
|
current = app.styleSheet() or ""
|
|
# 기존에 추가된 HIGH_CONTRAST_QSS 제거
|
|
base = current.replace(HIGH_CONTRAST_QSS, "").rstrip() + "\n"
|
|
if enabled:
|
|
app.setStyleSheet(base + HIGH_CONTRAST_QSS)
|
|
else:
|
|
app.setStyleSheet(base.rstrip())
|