From 2152cc46a3228420c3a57f9b552776496399f112 Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Wed, 4 Mar 2026 23:52:01 +0800 Subject: [PATCH] =?UTF-8?q?style(*):=20=E4=BF=AE=E6=94=B9=20ConfigManager?= =?UTF-8?q?=20=E6=A8=A1=E5=9D=97=E7=9A=84=20import=20=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=20import=20=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/ALConfigWidget.py | 16 ++++++++-------- src/gui/ALMainWindow.py | 12 +++++------- src/gui/ALTimerTaskManageWidget.py | 10 +++++----- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/gui/ALConfigWidget.py b/src/gui/ALConfigWidget.py index ac67a42..976636a 100644 --- a/src/gui/ALConfigWidget.py +++ b/src/gui/ALConfigWidget.py @@ -21,10 +21,10 @@ from PySide6.QtGui import ( QCloseEvent, QAction ) +import utils.ConfigManager as ConfigManager + from utils.JSONReader import JSONReader from utils.JSONWriter import JSONWriter -from utils.ConfigManager import ConfigType, instance -from utils.ConfigManager import getValidateAutomationConfigPaths from gui.resources.ui.Ui_ALConfigWidget import Ui_ALConfigWidget from gui.ALSeatMapSelectDialog import ALSeatMapSelectDialog @@ -42,8 +42,8 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget): ): super().__init__(parent) - self.__cfg_mgr = instance() - self.__config_paths = getValidateAutomationConfigPaths() + self.__cfg_mgr = ConfigManager.instance() + self.__config_paths = ConfigManager.getValidateAutomationConfigPaths() self.__config_data = {"run": {}, "user": {}} self.setupUi(self) @@ -968,13 +968,13 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget): self.setRunConfigToWidget(data) self.__config_paths["run"] = run_config_path self.CurrentRunConfigEdit.setText(run_config_path) - paths = self.__cfg_mgr.get(ConfigType.GLOBAL, "automation.run_path.paths", []) + paths = self.__cfg_mgr.get(ConfigManager.ConfigType.GLOBAL, "automation.run_path.paths", []) if run_config_path not in paths: paths.append(run_config_path) index = len(paths) - 1 else: index = paths.index(run_config_path) - self.__cfg_mgr.set(ConfigType.GLOBAL, "automation.run_path", {"current": index, "paths": paths}) + self.__cfg_mgr.set(ConfigManager.ConfigType.GLOBAL, "automation.run_path", {"current": index, "paths": paths}) else: QMessageBox.warning( self, @@ -1003,13 +1003,13 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget): self.setUsersToTreeWidget(data) self.__config_paths["user"] = user_config_path self.CurrentUserConfigEdit.setText(user_config_path) - paths = self.__cfg_mgr.get(ConfigType.GLOBAL, "automation.user_path.paths", []) + paths = self.__cfg_mgr.get(ConfigManager.ConfigType.GLOBAL, "automation.user_path.paths", []) if user_config_path not in paths: paths.append(user_config_path) index = len(paths) - 1 else: index = paths.index(user_config_path) - self.__cfg_mgr.set(ConfigType.GLOBAL, "automation.user_path", {"current": index, "paths": paths}) + self.__cfg_mgr.set(ConfigManager.ConfigType.GLOBAL, "automation.user_path", {"current": index, "paths": paths}) else: QMessageBox.warning( self, diff --git a/src/gui/ALMainWindow.py b/src/gui/ALMainWindow.py index ebfad56..2b066be 100644 --- a/src/gui/ALMainWindow.py +++ b/src/gui/ALMainWindow.py @@ -7,11 +7,10 @@ This software is provided "as is", without any warranty of any kind. You may use, modify, and distribute this file under the terms of the MIT License. See the LICENSE file for details. """ -import os import queue from PySide6.QtCore import ( - Qt, Signal, Slot, QTimer, QDir, QUrl, + Qt, Signal, Slot, QTimer, QUrl, ) from PySide6.QtWidgets import ( QMainWindow, QMenu, QSystemTrayIcon, QMessageBox @@ -20,10 +19,9 @@ from PySide6.QtGui import ( QTextCursor, QCloseEvent, QFont, QIcon, QDesktopServices ) -from base.MsgBase import MsgBase +import utils.ConfigManager as ConfigManager -from utils.ConfigManager import ConfigType, instance -from utils.ConfigManager import getValidateAutomationConfigPaths +from base.MsgBase import MsgBase from gui.resources.ui.Ui_ALMainWindow import Ui_ALMainWindow from gui.resources import ALResource @@ -46,9 +44,9 @@ class ALMainWindow(MsgBase, QMainWindow, Ui_ALMainWindow): MsgBase.__init__(self, queue.Queue(), queue.Queue()) QMainWindow.__init__(self) - self.__cfg_mgr = instance() + self.__cfg_mgr = ConfigManager.instance() self.__timer_task_queue = queue.Queue() - self.__config_paths = getValidateAutomationConfigPaths() + self.__config_paths = ConfigManager.getValidateAutomationConfigPaths() self.__alTimerTaskManageWidget = None self.__alConfigWidget = None self.__auto_lib_thread = None diff --git a/src/gui/ALTimerTaskManageWidget.py b/src/gui/ALTimerTaskManageWidget.py index 4aeff70..662b44c 100644 --- a/src/gui/ALTimerTaskManageWidget.py +++ b/src/gui/ALTimerTaskManageWidget.py @@ -15,7 +15,7 @@ from enum import Enum from datetime import datetime, timedelta from PySide6.QtCore import ( - Qt, Signal, Slot, QTimer, QFileInfo, QDir + Qt, Signal, Slot, QTimer ) from PySide6.QtWidgets import ( QDialog, QWidget, QListWidgetItem, QMessageBox, @@ -25,7 +25,7 @@ from PySide6.QtGui import ( QCloseEvent ) -from utils.ConfigManager import ConfigType, instance +import utils.ConfigManager as ConfigManager from gui.resources.ui.Ui_ALTimerTaskManageWidget import Ui_ALTimerTaskManageWidget from gui.ALTimerTaskAddDialog import ALTimerTaskAddDialog, ALTimerTaskStatus @@ -145,7 +145,7 @@ class ALTimerTaskManageWidget(QWidget, Ui_ALTimerTaskManageWidget): ): super().__init__(parent) - self.__cfg_mgr = instance() + self.__cfg_mgr = ConfigManager.instance() self.__timer_tasks = [] self.__check_timer = None self.__sort_policy = self.SortPolicy.BY_EXECUTE_TIME @@ -199,7 +199,7 @@ class ALTimerTaskManageWidget(QWidget, Ui_ALTimerTaskManageWidget): ) -> list: try: - timer_tasks = self.__cfg_mgr.get(ConfigType.TIMERTASK) + timer_tasks = self.__cfg_mgr.get(ConfigManager.ConfigType.TIMERTASK) if timer_tasks and "timer_tasks" in timer_tasks: for task in timer_tasks["timer_tasks"]: task["add_time"] = datetime.strptime(task["add_time"], "%Y-%m-%d %H:%M:%S") @@ -226,7 +226,7 @@ class ALTimerTaskManageWidget(QWidget, Ui_ALTimerTaskManageWidget): task["add_time"] = task["add_time"].strftime("%Y-%m-%d %H:%M:%S") task["execute_time"] = task["execute_time"].strftime("%Y-%m-%d %H:%M:%S") task["status"] = task["status"].value - self.__cfg_mgr.set(ConfigType.TIMERTASK, "", { "timer_tasks": timer_tasks }) + self.__cfg_mgr.set(ConfigManager.ConfigType.TIMERTASK, "", { "timer_tasks": timer_tasks }) return True except Exception as e: QMessageBox.warning(