55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QLineEdit, QPushButton, QHBoxLayout
|
|
from utils.config import ConfigManager
|
|
|
|
class PercentySettingsDialog(QDialog):
|
|
def __init__(self, config: ConfigManager):
|
|
super().__init__()
|
|
self.config = config
|
|
self.setWindowTitle('퍼센티 설정')
|
|
self.init_ui()
|
|
|
|
def init_ui(self):
|
|
layout = QVBoxLayout()
|
|
|
|
self.user_id_label = QLabel('사용자 아이디:')
|
|
self.user_id_input = QLineEdit(self)
|
|
layout.addWidget(self.user_id_label)
|
|
layout.addWidget(self.user_id_input)
|
|
|
|
self.password_label = QLabel('비밀번호:')
|
|
self.password_input = QLineEdit(self)
|
|
self.password_input.setEchoMode(QLineEdit.Password)
|
|
layout.addWidget(self.password_label)
|
|
layout.addWidget(self.password_input)
|
|
|
|
button_layout = QHBoxLayout()
|
|
save_button = QPushButton('저장')
|
|
save_button.clicked.connect(self.save_settings)
|
|
cancel_button = QPushButton('취소')
|
|
cancel_button.clicked.connect(self.reject)
|
|
button_layout.addWidget(save_button)
|
|
button_layout.addWidget(cancel_button)
|
|
|
|
layout.addLayout(button_layout)
|
|
self.setLayout(layout)
|
|
|
|
# 기존 설정 불러오기
|
|
self.load_settings()
|
|
|
|
def load_settings(self):
|
|
user_id = self.config.get('USER', 'user_id', fallback='')
|
|
encrypted_password = self.config.get('USER', 'password', fallback='')
|
|
password = self.config.decrypt(encrypted_password) if encrypted_password else ''
|
|
|
|
self.user_id_input.setText(user_id)
|
|
self.password_input.setText(password)
|
|
|
|
def save_settings(self):
|
|
user_id = self.user_id_input.text()
|
|
password = self.password_input.text()
|
|
|
|
self.config.set('USER', 'user_id', user_id)
|
|
self.config.set('USER', 'password', self.config.encrypt(password))
|
|
|
|
self.accept()
|