210 lines
7.3 KiB
Python
210 lines
7.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
UI 설정 다이얼로그 모듈
|
|
섹션별 필드의 보이기/숨기기를 설정하는 다이얼로그입니다.
|
|
"""
|
|
|
|
from PySide6.QtWidgets import (
|
|
QWidget, QVBoxLayout, QHBoxLayout, QTabWidget,
|
|
QLabel, QFrame, QScrollArea, QCheckBox,
|
|
QGroupBox, QGridLayout
|
|
)
|
|
from PySide6.QtCore import Qt
|
|
from PySide6.QtGui import QFont
|
|
|
|
from ui.base.base_dialog import BaseDialog
|
|
from ui.components.custom_button import CustomButton
|
|
from core.config import ConfigManager
|
|
from core.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class UiSettingsDialog(BaseDialog):
|
|
"""
|
|
UI 설정 다이얼로그
|
|
|
|
섹션별 필드의 보이기/숨기기를 설정합니다.
|
|
"""
|
|
|
|
# 섹션별 필드 정의
|
|
SECTION_FIELDS = {
|
|
"지시": [
|
|
("created_date", "생성일", True), # 필수 필드는 항상 표시
|
|
("created_team", "생성팀", True),
|
|
("instructor", "지시자", False),
|
|
("instruction_content", "지시내용", False),
|
|
("instruction_date", "지시일자", False),
|
|
("is_continuous", "지속", False),
|
|
("team_confirmations", "확인팀", False),
|
|
("is_completed", "완료", False),
|
|
],
|
|
"고장": [
|
|
("created_date", "생성일", True),
|
|
("created_team", "생성팀", True),
|
|
("occurrence_date", "발생일", False),
|
|
("train_number", "편성", False),
|
|
("car_number", "호차", False),
|
|
("fault_code", "고장코드", False),
|
|
("device_category", "장치분류", False),
|
|
("occurrence_station", "발생역", False),
|
|
("occurrence_time", "발생시간", False),
|
|
("fault_content", "고장내용", False),
|
|
("action_content", "조치내용", False),
|
|
("action_team", "조치팀", False),
|
|
("team_confirmations", "확인팀", False),
|
|
("is_completed", "완료", False),
|
|
],
|
|
"작업": [
|
|
("created_date", "생성일", True),
|
|
("created_team", "생성팀", True),
|
|
("work_date", "작업일", False),
|
|
("work_entity", "작업주체", False),
|
|
("target_train", "대상편성", False),
|
|
("target_device", "대상기기", False),
|
|
("work_content", "작업내용", False),
|
|
("remarks", "특이사항", False),
|
|
("team_confirmations", "확인팀", False),
|
|
("is_completed", "완료", False),
|
|
],
|
|
"기타": [
|
|
("created_date", "생성일", True),
|
|
("created_team", "생성팀", True),
|
|
("reporter", "전달자", False),
|
|
("report_content", "전달내용", False),
|
|
("remarks", "특이사항", False),
|
|
("related_document", "관련문서", False),
|
|
("team_confirmations", "확인팀", False),
|
|
("is_completed", "완료", False),
|
|
],
|
|
}
|
|
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent, title="UI 설정", width=600, height=700, resizable=True)
|
|
|
|
self.config = ConfigManager()
|
|
self.field_checkboxes = {} # 섹션별 필드 체크박스 저장
|
|
|
|
self._setup_tabs()
|
|
self.add_confirm_cancel_buttons("저장", "취소")
|
|
|
|
def _setup_tabs(self):
|
|
"""탭 설정"""
|
|
self.tabs = QTabWidget()
|
|
self.tabs.setFont(QFont("GmarketSans", 12))
|
|
|
|
# 각 섹션별 탭 생성
|
|
for section_name in self.SECTION_FIELDS.keys():
|
|
tab = self._create_section_tab(section_name)
|
|
self.tabs.addTab(tab, section_name)
|
|
|
|
# 스타일 적용
|
|
theme = self.config.theme
|
|
if theme == 'dark':
|
|
self.tabs.setStyleSheet("""
|
|
QTabWidget::pane {
|
|
border: 1px solid #334155;
|
|
border-radius: 8px;
|
|
background-color: #1e293b;
|
|
}
|
|
QTabBar::tab {
|
|
background-color: #1e293b;
|
|
color: #94a3b8;
|
|
padding: 8px 16px;
|
|
border-top-left-radius: 6px;
|
|
border-top-right-radius: 6px;
|
|
}
|
|
QTabBar::tab:selected {
|
|
background-color: #334155;
|
|
color: #f8fafc;
|
|
}
|
|
""")
|
|
else:
|
|
self.tabs.setStyleSheet("""
|
|
QTabWidget::pane {
|
|
border: 1px solid #e2e8f0;
|
|
border-radius: 8px;
|
|
background-color: #ffffff;
|
|
}
|
|
QTabBar::tab {
|
|
background-color: #f8fafc;
|
|
color: #64748b;
|
|
padding: 8px 16px;
|
|
border-top-left-radius: 6px;
|
|
border-top-right-radius: 6px;
|
|
}
|
|
QTabBar::tab:selected {
|
|
background-color: #ffffff;
|
|
color: #1e293b;
|
|
}
|
|
""")
|
|
|
|
self.content_layout.addWidget(self.tabs)
|
|
|
|
def _create_section_tab(self, section_name: str) -> QWidget:
|
|
"""섹션별 탭 생성"""
|
|
widget = QWidget()
|
|
layout = QVBoxLayout(widget)
|
|
layout.setContentsMargins(20, 20, 20, 20)
|
|
layout.setSpacing(20)
|
|
|
|
# 설명 라벨
|
|
info_label = QLabel(f"{section_name} 섹션의 표시할 필드를 선택하세요.")
|
|
info_label.setWordWrap(True)
|
|
layout.addWidget(info_label)
|
|
|
|
# 스크롤 영역
|
|
scroll = QScrollArea()
|
|
scroll.setWidgetResizable(True)
|
|
scroll.setFrameShape(QFrame.NoFrame)
|
|
|
|
scroll_widget = QWidget()
|
|
scroll_layout = QVBoxLayout(scroll_widget)
|
|
scroll_layout.setContentsMargins(0, 0, 0, 0)
|
|
scroll_layout.setSpacing(10)
|
|
|
|
# 필드 체크박스들
|
|
self.field_checkboxes[section_name] = {}
|
|
fields = self.SECTION_FIELDS[section_name]
|
|
|
|
for field_name, field_label, is_required in fields:
|
|
checkbox = QCheckBox(field_label)
|
|
|
|
# 필수 필드는 체크 불가능하게 설정
|
|
if is_required:
|
|
checkbox.setChecked(True)
|
|
checkbox.setEnabled(False)
|
|
checkbox.setStyleSheet("color: #64748b;") # 회색으로 표시
|
|
else:
|
|
# 설정에서 읽어오기
|
|
config_key = f"field_visible_{section_name}_{field_name}"
|
|
is_visible = self.config.get('ui', config_key, True)
|
|
checkbox.setChecked(is_visible)
|
|
|
|
self.field_checkboxes[section_name][field_name] = checkbox
|
|
scroll_layout.addWidget(checkbox)
|
|
|
|
scroll_layout.addStretch()
|
|
scroll.setWidget(scroll_widget)
|
|
layout.addWidget(scroll)
|
|
|
|
return widget
|
|
|
|
def accept(self):
|
|
"""저장"""
|
|
# 설정 저장
|
|
for section_name, checkboxes in self.field_checkboxes.items():
|
|
for field_name, checkbox in checkboxes.items():
|
|
config_key = f"field_visible_{section_name}_{field_name}"
|
|
self.config.set('ui', config_key, checkbox.isChecked())
|
|
|
|
self.config.save()
|
|
logger.info("UI 설정 저장 완료")
|
|
|
|
super().accept()
|
|
|
|
|
|
|
|
|
|
|