From 8d69e43f720f47e4e3a608db3a66dd76f47830ba Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Thu, 22 May 2025 23:20:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E5=88=9D=E6=AD=A5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=91=A8=E8=AE=A1=E5=88=92=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 222 +++++++++++++++--------------------- app/ui/Widget.py | 188 ++++++++++++++++++++++++++++++- app/ui/main_window.py | 9 ++ app/ui/member_manager.py | 10 +- app/ui/plan_manager.py | 236 ++++++++------------------------------- app/ui/queue_manager.py | 6 +- app/ui/setting.py | 4 +- 7 files changed, 334 insertions(+), 341 deletions(-) diff --git a/app/core/config.py b/app/core/config.py index 3c5781c..e28c9e9 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -33,6 +33,7 @@ import sys import shutil import re import base64 +import calendar from datetime import datetime, timedelta, date from collections import defaultdict from pathlib import Path @@ -469,117 +470,49 @@ class MaaPlanConfig(LQConfig): self.Info_Name = ConfigItem("Info", "Name", "新表格") - self.Global_MedicineNumb = ConfigItem( - "Global", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Global_SeriesNumb = OptionsConfigItem( - "Global", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Global_GameId = ConfigItem("Global", "GameId", "-") - self.Global_GameId_1 = ConfigItem("Global", "GameId_1", "-") - self.Global_GameId_2 = ConfigItem("Global", "GameId_2", "-") - self.Global_GameId_Remain = ConfigItem("Global", "GameId_Remain", "-") + self.config_item_dict: dict[str, Dict[str, ConfigItem]] = {} - self.Monday_MedicineNumb = ConfigItem( - "Monday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Monday_SeriesNumb = OptionsConfigItem( + for group in [ + "ALL", "Monday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Monday_GameId = ConfigItem("Monday", "GameId", "-") - self.Monday_GameId_1 = ConfigItem("Monday", "GameId_1", "-") - self.Monday_GameId_2 = ConfigItem("Monday", "GameId_2", "-") - self.Monday_GameId_Remain = ConfigItem("Monday", "GameId_Remain", "-") - - self.Tuesday_MedicineNumb = ConfigItem( - "Tuesday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Tuesday_SeriesNumb = OptionsConfigItem( "Tuesday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Tuesday_GameId = ConfigItem("Tuesday", "GameId", "-") - self.Tuesday_GameId_1 = ConfigItem("Tuesday", "GameId_1", "-") - self.Tuesday_GameId_2 = ConfigItem("Tuesday", "GameId_2", "-") - self.Tuesday_GameId_Remain = ConfigItem("Tuesday", "GameId_Remain", "-") - - self.Wednesday_MedicineNumb = ConfigItem( - "Wednesday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Wednesday_SeriesNumb = OptionsConfigItem( "Wednesday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Wednesday_GameId = ConfigItem("Wednesday", "GameId", "-") - self.Wednesday_GameId_1 = ConfigItem("Wednesday", "GameId_1", "-") - self.Wednesday_GameId_2 = ConfigItem("Wednesday", "GameId_2", "-") - self.Wednesday_GameId_Remain = ConfigItem("Wednesday", "GameId_Remain", "-") - - self.Thursday_MedicineNumb = ConfigItem( - "Thursday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Thursday_SeriesNumb = OptionsConfigItem( "Thursday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Thursday_GameId = ConfigItem("Thursday", "GameId", "-") - self.Thursday_GameId_1 = ConfigItem("Thursday", "GameId_1", "-") - self.Thursday_GameId_2 = ConfigItem("Thursday", "GameId_2", "-") - self.Thursday_GameId_Remain = ConfigItem("Thursday", "GameId_Remain", "-") - - self.Friday_MedicineNumb = ConfigItem( - "Friday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Friday_SeriesNumb = OptionsConfigItem( "Friday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Friday_GameId = ConfigItem("Friday", "GameId", "-") - self.Friday_GameId_1 = ConfigItem("Friday", "GameId_1", "-") - self.Friday_GameId_2 = ConfigItem("Friday", "GameId_2", "-") - self.Friday_GameId_Remain = ConfigItem("Friday", "GameId_Remain", "-") - - self.Saturday_MedicineNumb = ConfigItem( - "Saturday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Saturday_SeriesNumb = OptionsConfigItem( "Saturday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Saturday_GameId = ConfigItem("Saturday", "GameId", "-") - self.Saturday_GameId_1 = ConfigItem("Saturday", "GameId_1", "-") - self.Saturday_GameId_2 = ConfigItem("Saturday", "GameId_2", "-") - self.Saturday_GameId_Remain = ConfigItem("Saturday", "GameId_Remain", "-") - - self.Sunday_MedicineNumb = ConfigItem( - "Sunday", "MedicineNumb", 0, RangeValidator(0, 1024) - ) - self.Sunday_SeriesNumb = OptionsConfigItem( "Sunday", - "SeriesNumb", - "0", - OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), - ) - self.Sunday_GameId = ConfigItem("Sunday", "GameId", "-") - self.Sunday_GameId_1 = ConfigItem("Sunday", "GameId_1", "-") - self.Sunday_GameId_2 = ConfigItem("Sunday", "GameId_2", "-") - self.Sunday_GameId_Remain = ConfigItem("Sunday", "GameId_Remain", "-") + ]: + self.config_item_dict[group] = {} + + self.config_item_dict[group]["MedicineNumb"] = ConfigItem( + group, "MedicineNumb", 0, RangeValidator(0, 1024) + ) + self.config_item_dict[group]["SeriesNumb"] = OptionsConfigItem( + group, + "SeriesNumb", + "0", + OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]), + ) + self.config_item_dict[group]["GameId"] = ConfigItem(group, "GameId", "-") + self.config_item_dict[group]["GameId_1"] = ConfigItem( + group, "GameId_1", "-" + ) + self.config_item_dict[group]["GameId_2"] = ConfigItem( + group, "GameId_2", "-" + ) + self.config_item_dict[group]["GameId_Remain"] = ConfigItem( + group, "GameId_Remain", "-" + ) + + for name in [ + "MedicineNumb", + "SeriesNumb", + "GameId", + "GameId_1", + "GameId_2", + "GameId_Remain", + ]: + setattr(self, f"{group}_{name}", self.config_item_dict[group][name]) class AppConfig(GlobalConfig): @@ -610,7 +543,13 @@ class AppConfig(GlobalConfig): self.silence_list = [] self.gameid_dict = { "ALL": {"value": [], "text": []}, - "Today": {"value": [], "text": []}, + "Monday": {"value": [], "text": []}, + "Tuesday": {"value": [], "text": []}, + "Wednesday": {"value": [], "text": []}, + "Thursday": {"value": [], "text": []}, + "Friday": {"value": [], "text": []}, + "Saturday": {"value": [], "text": []}, + "Sunday": {"value": [], "text": []}, } self.power_sign = "NoAction" self.if_ignore_silence = False @@ -732,39 +671,42 @@ class AppConfig(GlobalConfig): "近/特芯片组", ] - # 生成本日关卡信息 - days = self.server_date().isoweekday() + # # 生成本日关卡信息 + # days = self.server_date().isoweekday() - gameid_list = [ - {"value": "-", "text": "当前/上次", "days": [1, 2, 3, 4, 5, 6, 7]}, - {"value": "1-7", "text": "1-7", "days": [1, 2, 3, 4, 5, 6, 7]}, - {"value": "R8-11", "text": "R8-11", "days": [1, 2, 3, 4, 5, 6, 7]}, - { - "value": "12-17-HARD", - "text": "12-17-HARD", - "days": [1, 2, 3, 4, 5, 6, 7], - }, - {"value": "CE-6", "text": "龙门币-6/5", "days": [2, 4, 6, 7]}, - {"value": "AP-5", "text": "红票-5", "days": [1, 4, 6, 7]}, - {"value": "CA-5", "text": "技能-5", "days": [2, 3, 5, 7]}, - {"value": "LS-6", "text": "经验-6/5", "days": [1, 2, 3, 4, 5, 6, 7]}, - {"value": "SK-5", "text": "碳-5", "days": [1, 3, 5, 6]}, - {"value": "PR-A-1", "text": "奶/盾芯片", "days": [1, 4, 5, 7]}, - {"value": "PR-A-2", "text": "奶/盾芯片组", "days": [1, 4, 5, 7]}, - {"value": "PR-B-1", "text": "术/狙芯片", "days": [1, 2, 5, 6]}, - {"value": "PR-B-2", "text": "术/狙芯片组", "days": [1, 2, 5, 6]}, - {"value": "PR-C-1", "text": "先/辅芯片", "days": [3, 4, 6, 7]}, - {"value": "PR-C-2", "text": "先/辅芯片组", "days": [3, 4, 6, 7]}, - {"value": "PR-D-1", "text": "近/特芯片", "days": [2, 3, 6, 7]}, - {"value": "PR-D-2", "text": "近/特芯片组", "days": [2, 3, 6, 7]}, - ] + # 生成每日关卡信息 + for day in range(1, 8): - for gameid_info in gameid_list: - if days in gameid_info["days"]: - gameid_dict["value"].append(gameid_info["value"]) - gameid_dict["text"].append(gameid_info["text"]) + gameid_list = [ + {"value": "-", "text": "当前/上次", "days": [1, 2, 3, 4, 5, 6, 7]}, + {"value": "1-7", "text": "1-7", "days": [1, 2, 3, 4, 5, 6, 7]}, + {"value": "R8-11", "text": "R8-11", "days": [1, 2, 3, 4, 5, 6, 7]}, + { + "value": "12-17-HARD", + "text": "12-17-HARD", + "days": [1, 2, 3, 4, 5, 6, 7], + }, + {"value": "CE-6", "text": "龙门币-6/5", "days": [2, 4, 6, 7]}, + {"value": "AP-5", "text": "红票-5", "days": [1, 4, 6, 7]}, + {"value": "CA-5", "text": "技能-5", "days": [2, 3, 5, 7]}, + {"value": "LS-6", "text": "经验-6/5", "days": [1, 2, 3, 4, 5, 6, 7]}, + {"value": "SK-5", "text": "碳-5", "days": [1, 3, 5, 6]}, + {"value": "PR-A-1", "text": "奶/盾芯片", "days": [1, 4, 5, 7]}, + {"value": "PR-A-2", "text": "奶/盾芯片组", "days": [1, 4, 5, 7]}, + {"value": "PR-B-1", "text": "术/狙芯片", "days": [1, 2, 5, 6]}, + {"value": "PR-B-2", "text": "术/狙芯片组", "days": [1, 2, 5, 6]}, + {"value": "PR-C-1", "text": "先/辅芯片", "days": [3, 4, 6, 7]}, + {"value": "PR-C-2", "text": "先/辅芯片组", "days": [3, 4, 6, 7]}, + {"value": "PR-D-1", "text": "近/特芯片", "days": [2, 3, 6, 7]}, + {"value": "PR-D-2", "text": "近/特芯片组", "days": [2, 3, 6, 7]}, + ] - self.gameid_dict["Today"] = gameid_dict + for gameid_info in gameid_list: + if day in gameid_info["days"]: + gameid_dict["value"].append(gameid_info["value"]) + gameid_dict["text"].append(gameid_info["text"]) + + self.gameid_dict[calendar.day_name[day - 1]] = gameid_dict self.gameid_refreshed.emit() @@ -1207,7 +1149,7 @@ class AppConfig(GlobalConfig): maa_plan_config.load(maa_plan_dir / "config.json", maa_plan_config) maa_plan_config.save() - self.member_dict[maa_plan_dir.name] = { + self.plan_dict[maa_plan_dir.name] = { "Type": "Maa", "Path": maa_plan_dir, "Config": maa_plan_config, @@ -1264,6 +1206,16 @@ class AppConfig(GlobalConfig): if queue["Config"].get(queue["Config"].queue_Member_10) == old: queue["Config"].set(queue["Config"].queue_Member_10, new) + def change_plan(self, old: str, new: str) -> None: + """修改脚本管理所有下属用户的计划表配置参数""" + + for member in self.member_dict.values(): + + for user in member["UserData"].values(): + + if user["Config"].get(user["Config"].Info_GameIdMode) == old: + user["Config"].set(user["Config"].Info_GameIdMode, new) + def change_user_info( self, name: str, user_data: Dict[str, Dict[str, Union[str, Path, dict]]] ) -> None: diff --git a/app/ui/Widget.py b/app/ui/Widget.py index 4aa98be..e308046 100644 --- a/app/ui/Widget.py +++ b/app/ui/Widget.py @@ -1065,6 +1065,190 @@ class StatusSwitchSetting(SwitchButton): self.setChecked(isChecked) +class ComboBoxSetting(ComboBox): + + def __init__( + self, + texts: List[str], + qconfig: QConfig, + configItem: OptionsConfigItem, + parent=None, + ): + + super().__init__(parent) + self.qconfig = qconfig + self.configItem = configItem + + self.optionToText = {o: t for o, t in zip(configItem.options, texts)} + for text, option in zip(texts, configItem.options): + self.addItem(text, userData=option) + + self.setCurrentText(self.optionToText[self.qconfig.get(configItem)]) + self.currentIndexChanged.connect(self._onCurrentIndexChanged) + configItem.valueChanged.connect(self.setValue) + + def _onCurrentIndexChanged(self, index: int): + + self.qconfig.set(self.configItem, self.itemData(index)) + + def setValue(self, value): + if value not in self.optionToText: + return + + self.setCurrentText(self.optionToText[value]) + self.qconfig.set(self.configItem, value) + + +class NoOptionComboBoxSetting(ComboBox): + + def __init__( + self, + value: List[str], + texts: List[str], + qconfig: QConfig, + configItem: OptionsConfigItem, + parent=None, + ): + + super().__init__(parent) + self.qconfig = qconfig + self.configItem = configItem + + self.optionToText = {o: t for o, t in zip(value, texts)} + for text, option in zip(texts, value): + self.addItem(text, userData=option) + + self.setCurrentText(self.optionToText[self.qconfig.get(configItem)]) + self.currentIndexChanged.connect(self._onCurrentIndexChanged) + configItem.valueChanged.connect(self.setValue) + + def _onCurrentIndexChanged(self, index: int): + + self.qconfig.set(self.configItem, self.itemData(index)) + + def setValue(self, value): + if value not in self.optionToText: + return + + self.setCurrentText(self.optionToText[value]) + self.qconfig.set(self.configItem, value) + + def reLoadOptions(self, value: List[str], texts: List[str]): + + self.currentIndexChanged.disconnect() + self.clear() + self.optionToText = {o: t for o, t in zip(value, texts)} + for text, option in zip(texts, value): + self.addItem(text, userData=option) + self.setCurrentText(self.optionToText[self.qconfig.get(self.configItem)]) + self.currentIndexChanged.connect(self._onCurrentIndexChanged) + + +class EditableComboBoxSetting(EditableComboBox): + + def __init__( + self, + value: List[str], + texts: List[str], + qconfig: QConfig, + configItem: OptionsConfigItem, + parent=None, + ): + + super().__init__(parent) + self.qconfig = qconfig + self.configItem = configItem + + self.optionToText = {o: t for o, t in zip(value, texts)} + for text, option in zip(texts, value): + self.addItem(text, userData=option) + + if qconfig.get(configItem) not in self.optionToText: + self.optionToText[qconfig.get(configItem)] = qconfig.get(configItem) + self.addItem(qconfig.get(configItem), userData=qconfig.get(configItem)) + + self.setCurrentText(self.optionToText[qconfig.get(configItem)]) + self.currentIndexChanged.connect(self._onCurrentIndexChanged) + configItem.valueChanged.connect(self.setValue) + + def _onCurrentIndexChanged(self, index: int): + + self.qconfig.set( + self.configItem, + (self.itemData(index) if self.itemData(index) else self.itemText(index)), + ) + + def setValue(self, value): + if value not in self.optionToText: + self.optionToText[value] = value + if self.findText(value) == -1: + self.addItem(value, userData=value) + else: + self.setItemData(self.findText(value), value) + + self.setCurrentText(self.optionToText[value]) + self.qconfig.set(self.configItem, value) + + def reLoadOptions(self, value: List[str], texts: List[str]): + + self.currentIndexChanged.disconnect() + self.clear() + self.optionToText = {o: t for o, t in zip(value, texts)} + for text, option in zip(texts, value): + self.addItem(text, userData=option) + if self.qconfig.get(self.configItem) not in self.optionToText: + self.optionToText[self.qconfig.get(self.configItem)] = self.qconfig.get( + self.configItem + ) + self.addItem( + self.qconfig.get(self.configItem), + userData=self.qconfig.get(self.configItem), + ) + self.setCurrentText(self.optionToText[self.qconfig.get(self.configItem)]) + self.currentIndexChanged.connect(self._onCurrentIndexChanged) + + def _onReturnPressed(self): + if not self.text(): + return + + index = self.findText(self.text()) + if index >= 0 and index != self.currentIndex(): + self._currentIndex = index + self.currentIndexChanged.emit(index) + elif index == -1: + self.addItem(self.text()) + self.setCurrentIndex(self.count() - 1) + self.currentIndexChanged.emit(self.count() - 1) + + +class SpinBoxSetting(SpinBox): + + def __init__( + self, + range: tuple[int, int], + qconfig: QConfig, + configItem: ConfigItem, + parent=None, + ): + + super().__init__(parent) + self.qconfig = qconfig + self.configItem = configItem + self.setRange(range[0], range[1]) + + if configItem: + self.set_value(qconfig.get(configItem)) + configItem.valueChanged.connect(self.set_value) + + self.valueChanged.connect(self.set_value) + + def set_value(self, value: int): + if self.configItem: + self.qconfig.set(self.configItem, value) + + self.setValue(value) + + class HistoryCard(HeaderCardWidget): def __init__(self, qconfig: QConfig, configItem: ConfigItem, parent=None): @@ -1184,9 +1368,7 @@ class UrlListSettingCard(ExpandSettingCard): """show confirm dialog""" choice = MessageBox( - "确认", - f"确定要删除 {item.url} 代理网址吗?", - self.window(), + "确认", f"确定要删除 {item.url} 代理网址吗?", self.window() ) if choice.exec(): self.__removeUrl(item) diff --git a/app/ui/main_window.py b/app/ui/main_window.py index 1f31457..9fc9a69 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -49,6 +49,7 @@ from app.core import Config, TaskManager, MainTimer, MainInfoBar from app.services import Notify, Crypto, System from .home import Home from .member_manager import MemberManager +from .plan_manager import PlanManager from .queue_manager import QueueManager from .dispatch_center import DispatchCenter from .history import History @@ -81,6 +82,7 @@ class AUTO_MAA(MSFluentWindow): # 创建主窗口 self.home = Home(self) self.member_manager = MemberManager(self) + self.plan_manager = PlanManager(self) self.queue_manager = QueueManager(self) self.dispatch_center = DispatchCenter(self) self.history = History(self) @@ -100,6 +102,13 @@ class AUTO_MAA(MSFluentWindow): FluentIcon.ROBOT, NavigationItemPosition.TOP, ) + self.addSubInterface( + self.plan_manager, + FluentIcon.CALENDAR, + "计划管理", + FluentIcon.CALENDAR, + NavigationItemPosition.TOP, + ) self.addSubInterface( self.queue_manager, FluentIcon.BOOK_SHELF, diff --git a/app/ui/member_manager.py b/app/ui/member_manager.py index 4e96e69..cf4e1d6 100644 --- a/app/ui/member_manager.py +++ b/app/ui/member_manager.py @@ -197,11 +197,7 @@ class MemberManager(QWidget): ) return None - choice = MessageBox( - "确认", - f"确定要删除 {name} 实例吗?", - self.window(), - ) + choice = MessageBox("确认", f"确定要删除 {name} 实例吗?", self.window()) if choice.exec(): self.member_manager.clear_SettingBox() @@ -866,9 +862,7 @@ class MemberManager(QWidget): return None choice = MessageBox( - "确认", - f"确定要删除 {name} 吗?", - self.window(), + "确认", f"确定要删除 {name} 吗?", self.window() ) if choice.exec(): diff --git a/app/ui/plan_manager.py b/app/ui/plan_manager.py index b0fab53..f236b88 100644 --- a/app/ui/plan_manager.py +++ b/app/ui/plan_manager.py @@ -28,49 +28,28 @@ v4.3 from loguru import logger from PySide6.QtWidgets import ( QWidget, - QFileDialog, - QHBoxLayout, QVBoxLayout, QStackedWidget, - QTableWidgetItem, QHeaderView, ) -from PySide6.QtGui import QIcon from qfluentwidgets import ( Action, - ScrollArea, FluentIcon, MessageBox, HeaderCardWidget, CommandBar, - ExpandGroupSettingCard, - PushSettingCard, TableWidget, - PrimaryToolButton, ) -from PySide6.QtCore import Signal -from datetime import datetime -from functools import partial -from pathlib import Path from typing import List import shutil -import json -from app.core import Config, MainInfoBar, TaskManager, MaaPlanConfig, Network +from app.core import Config, MainInfoBar, MaaPlanConfig from app.services import Crypto -from .downloader import DownloadManager from .Widget import ( - LineEditMessageBox, - LineEditSettingCard, - SpinBoxSettingCard, ComboBoxMessageBox, - EditableComboBoxSettingCard, - PasswordLineEditSettingCard, - UserLableSettingCard, - ComboBoxSettingCard, - SwitchSettingCard, - PushAndSwitchButtonSettingCard, - PushAndComboBoxSettingCard, + SpinBoxSetting, + EditableComboBoxSetting, + ComboBoxSetting, PivotArea, ) @@ -142,7 +121,7 @@ class PlanManager(QWidget): "Config": maa_plan_config, } - self.plan_manager.add_MaaSettingBox(index) + self.plan_manager.add_MaaPlanSettingBox(index) self.plan_manager.switch_SettingBox(index) logger.success(f"计划管理 计划_{index} 添加成功") @@ -169,11 +148,7 @@ class PlanManager(QWidget): ) return None - choice = MessageBox( - "确认", - f"确定要删除 {name} 吗?", - self.window(), - ) + choice = MessageBox("确认", f"确定要删除 {name} 吗?", self.window()) if choice.exec(): self.plan_manager.clear_SettingBox() @@ -185,7 +160,7 @@ class PlanManager(QWidget): Config.plan_dict[f"计划_{i}"]["Path"].rename( Config.plan_dict[f"计划_{i}"]["Path"].with_name(f"计划_{i-1}") ) - Config.change_queue(f"计划_{i}", f"计划_{i-1}") + Config.change_plan(f"计划_{i}", f"计划_{i-1}") self.plan_manager.show_SettingBox(max(int(name[3:]) - 1, 1)) @@ -225,15 +200,15 @@ class PlanManager(QWidget): Config.plan_dict[name]["Path"].rename( Config.plan_dict[name]["Path"].with_name("计划_0") ) - Config.change_queue(name, "计划_0") + Config.change_plan(name, "计划_0") Config.plan_dict[f"计划_{index-1}"]["Path"].rename( Config.plan_dict[name]["Path"] ) - Config.change_queue(f"计划_{index-1}", name) + Config.change_plan(f"计划_{index-1}", name) Config.plan_dict[name]["Path"].with_name("计划_0").rename( Config.plan_dict[f"计划_{index-1}"]["Path"] ) - Config.change_queue("计划_0", f"计划_{index-1}") + Config.change_plan("计划_0", f"计划_{index-1}") self.plan_manager.show_SettingBox(index - 1) @@ -273,27 +248,21 @@ class PlanManager(QWidget): Config.plan_dict[name]["Path"].rename( Config.plan_dict[name]["Path"].with_name("计划_0") ) - Config.change_queue(name, "计划_0") + Config.change_plan(name, "计划_0") Config.plan_dict[f"计划_{index+1}"]["Path"].rename( Config.plan_dict[name]["Path"] ) - Config.change_queue(f"计划_{index+1}", name) + Config.change_plan(f"计划_{index+1}", name) Config.plan_dict[name]["Path"].with_name("计划_0").rename( Config.plan_dict[f"计划_{index+1}"]["Path"] ) - Config.change_queue("计划_0", f"计划_{index+1}") + Config.change_plan("计划_0", f"计划_{index+1}") self.plan_manager.show_SettingBox(index + 1) logger.success(f"计划表 {name} 右移成功") MainInfoBar.push_info_bar("success", "操作成功", f"右移计划表 {name}", 3000) - def refresh_dashboard(self): - """刷新所有计划表的用户仪表盘""" - - for script in self.plan_manager.script_list: - script.user_setting.user_manager.user_dashboard.load_info() - class PlanSettingBox(QWidget): """计划管理子页面组""" @@ -331,7 +300,7 @@ class PlanManager(QWidget): for name, info in Config.plan_dict.items(): if info["Type"] == "Maa": - self.add_MaaSettingBox(int(name[3:])) + self.add_MaaPlanSettingBox(int(name[3:])) self.switch_SettingBox(index) @@ -378,20 +347,23 @@ class PlanManager(QWidget): self.config = Config.plan_dict[f"计划_{uid}"]["Config"] self.dashboard = TableWidget(self) - self.dashboard.setColumnCount(11) + self.dashboard.setColumnCount(8) + self.dashboard.setRowCount(6) self.dashboard.setHorizontalHeaderLabels( + ["全局", "周一", "周二", "周三", "周四", "周五", "周六", "周日"] + ) + self.dashboard.setVerticalHeaderLabels( [ "吃理智药", "连战次数", "关卡选择", - "备选关卡 - 1", - "备选关卡 - 2", - "剩余理智关卡", + "备选 - 1", + "备选 - 2", + "剩余理智", ] ) self.dashboard.setEditTriggers(TableWidget.NoEditTriggers) - self.dashboard.verticalHeader().setVisible(False) - for col in range(6): + for col in range(8): self.dashboard.horizontalHeader().setSectionResizeMode( col, QHeaderView.ResizeMode.Stretch ) @@ -399,143 +371,33 @@ class PlanManager(QWidget): self.viewLayout.addWidget(self.dashboard) self.viewLayout.setContentsMargins(3, 0, 3, 3) - Config.PASSWORD_refreshed.connect(self.load_info) + for col, (group, name_dict) in enumerate( + self.config.config_item_dict.items() + ): - def load_info(self): + for row, (name, configItem) in enumerate(name_dict.items()): - self.user_data = Config.plan_dict[self.name]["UserData"] - - self.dashboard.setRowCount(len(self.user_data)) - - for name, info in self.user_data.items(): - - config = info["Config"] - - text_list = [] - if not config.get(config.Data_IfPassCheck): - text_list.append("未通过人工排查") - text_list.append( - f"今日已代理{config.get(config.Data_ProxyTimes)}次" - if Config.server_date().strftime("%Y-%m-%d") - == config.get(config.Data_LastProxyDate) - else "今日未进行代理" - ) - text_list.append( - "本周剿灭已完成" - if datetime.strptime( - config.get(config.Data_LastAnnihilationDate), - "%Y-%m-%d", - ).isocalendar()[:2] - == Config.server_date().isocalendar()[:2] - else "本周剿灭未完成" - ) - - button = PrimaryToolButton(FluentIcon.CHEVRON_RIGHT, self) - button.setFixedSize(32, 32) - button.clicked.connect(partial(self.switch_to.emit, name)) - - self.dashboard.setItem( - int(name[3:]) - 1, - 0, - QTableWidgetItem(config.get(config.Info_Name)), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 1, - QTableWidgetItem(config.get(config.Info_Id)), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 2, - QTableWidgetItem( - Crypto.AUTO_decryptor( - config.get(config.Info_Password), - Config.PASSWORD, + if name == "MedicineNumb": + setting_item = SpinBoxSetting( + range=(0, 1024), + qconfig=self.config, + configItem=configItem, + parent=self, ) - if Config.PASSWORD - else "******" - ), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 3, - QTableWidgetItem( - "启用" - if config.get(config.Info_Status) - and config.get(config.Info_RemainedDay) != 0 - else "禁用" - ), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 4, - QTableWidgetItem(" | ".join(text_list)), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 5, - QTableWidgetItem(str(config.get(config.Info_MedicineNumb))), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 6, - QTableWidgetItem( - Config.gameid_dict["ALL"]["text"][ - Config.gameid_dict["ALL"]["value"].index( - config.get(config.Info_GameId) - ) - ] - if config.get(config.Info_GameId) - in Config.gameid_dict["ALL"]["value"] - else config.get(config.Info_GameId) - ), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 7, - QTableWidgetItem( - Config.gameid_dict["ALL"]["text"][ - Config.gameid_dict["ALL"]["value"].index( - config.get(config.Info_GameId_1) - ) - ] - if config.get(config.Info_GameId_1) - in Config.gameid_dict["ALL"]["value"] - else config.get(config.Info_GameId_1) - ), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 8, - QTableWidgetItem( - Config.gameid_dict["ALL"]["text"][ - Config.gameid_dict["ALL"]["value"].index( - config.get(config.Info_GameId_2) - ) - ] - if config.get(config.Info_GameId_2) - in Config.gameid_dict["ALL"]["value"] - else config.get(config.Info_GameId_2) - ), - ) - self.dashboard.setItem( - int(name[3:]) - 1, - 9, - QTableWidgetItem( - "不使用" - if config.get(config.Info_GameId_Remain) == "-" - else ( - ( - Config.gameid_dict["ALL"]["text"][ - Config.gameid_dict["ALL"]["value"].index( - config.get(config.Info_GameId_Remain) - ) - ] - ) - if config.get(config.Info_GameId_Remain) - in Config.gameid_dict["ALL"]["value"] - else config.get(config.Info_GameId_Remain) + elif name == "SeriesNumb": + setting_item = ComboBoxSetting( + texts=["AUTO", "6", "5", "4", "3", "2", "1", "不选择"], + qconfig=self.config, + configItem=configItem, + parent=self, ) - ), - ) - self.dashboard.setCellWidget(int(name[3:]) - 1, 10, button) + elif "GameId" in name: + setting_item = EditableComboBoxSetting( + value=Config.gameid_dict[group]["value"], + texts=Config.gameid_dict[group]["text"], + qconfig=self.config, + configItem=configItem, + parent=self, + ) + + self.dashboard.setCellWidget(row, col, setting_item) diff --git a/app/ui/queue_manager.py b/app/ui/queue_manager.py index a8ff7a4..5120167 100644 --- a/app/ui/queue_manager.py +++ b/app/ui/queue_manager.py @@ -136,11 +136,7 @@ class QueueManager(QWidget): ) return None - choice = MessageBox( - "确认", - f"确定要删除 {name} 吗?", - self.window(), - ) + choice = MessageBox("确认", f"确定要删除 {name} 吗?", self.window()) if choice.exec(): self.queue_manager.clear_SettingBox() diff --git a/app/ui/setting.py b/app/ui/setting.py index 2f2be41..e26ead3 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -252,9 +252,7 @@ class Setting(QWidget): choice.exec() else: choice = MessageBox( - "确认", - "您没有输入管理密钥,是否取消修改管理密钥?", - self.window(), + "确认", "您没有输入管理密钥,是否取消修改管理密钥?", self.window() ) if choice.exec(): break