feat(ui): UI界面添加自动日常代理任务序列设置项
This commit is contained in:
@@ -434,7 +434,21 @@ class MaaUserConfig(LQConfig):
|
||||
"Data", "CustomInfrastPlanIndex", "0"
|
||||
)
|
||||
|
||||
# 新增用户单独通知字段
|
||||
self.Task_IfWakeUp = ConfigItem("Task", "IfWakeUp", True, BoolValidator())
|
||||
self.Task_IfRecruiting = ConfigItem(
|
||||
"Task", "IfRecruiting", True, BoolValidator()
|
||||
)
|
||||
self.Task_IfBase = ConfigItem("Task", "IfBase", True, BoolValidator())
|
||||
self.Task_IfCombat = ConfigItem("Task", "IfCombat", True, BoolValidator())
|
||||
self.Task_IfMall = ConfigItem("Task", "IfMall", True, BoolValidator())
|
||||
self.Task_IfMission = ConfigItem("Task", "IfMission", True, BoolValidator())
|
||||
self.Task_IfAutoRoguelike = ConfigItem(
|
||||
"Task", "IfAutoRoguelike", False, BoolValidator()
|
||||
)
|
||||
self.Task_IfReclamation = ConfigItem(
|
||||
"Task", "IfReclamation", False, BoolValidator()
|
||||
)
|
||||
|
||||
self.Notify_Enabled = ConfigItem("Notify", "Enabled", False, BoolValidator())
|
||||
self.Notify_IfSendStatistic = ConfigItem(
|
||||
"Notify", "IfSendStatistic", False, BoolValidator()
|
||||
|
||||
@@ -274,9 +274,23 @@ class MaaManager(QObject):
|
||||
)
|
||||
|
||||
# 解析任务构成
|
||||
if user_data["Info"]["Mode"] == "简洁":
|
||||
if mode == "Routine":
|
||||
|
||||
self.task_dict = {
|
||||
"WakeUp": str(user_data["Task"]["IfWakeUp"]),
|
||||
"Recruiting": str(user_data["Task"]["IfRecruiting"]),
|
||||
"Base": str(user_data["Task"]["IfBase"]),
|
||||
"Combat": str(user_data["Task"]["IfCombat"]),
|
||||
"Mission": str(user_data["Task"]["IfMission"]),
|
||||
"Mall": str(user_data["Task"]["IfMall"]),
|
||||
"AutoRoguelike": str(user_data["Task"]["IfAutoRoguelike"]),
|
||||
"Reclamation": str(user_data["Task"]["IfReclamation"]),
|
||||
}
|
||||
|
||||
elif mode == "Annihilation":
|
||||
|
||||
if user_data["Info"]["Mode"] == "简洁":
|
||||
|
||||
if mode == "Annihilation":
|
||||
self.task_dict = {
|
||||
"WakeUp": "True",
|
||||
"Recruiting": "False",
|
||||
@@ -288,52 +302,40 @@ class MaaManager(QObject):
|
||||
"Reclamation": "False",
|
||||
}
|
||||
|
||||
elif mode == "Routine":
|
||||
elif user_data["Info"]["Mode"] == "详细":
|
||||
|
||||
with (self.data[user[2]]["Path"] / f"{mode}/gui.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
|
||||
self.task_dict = {
|
||||
"WakeUp": "True",
|
||||
"Recruiting": "True",
|
||||
"Base": "True",
|
||||
"Combat": "True",
|
||||
"Mission": "True",
|
||||
"Mall": "True",
|
||||
"AutoRoguelike": "False",
|
||||
"Reclamation": "False",
|
||||
"WakeUp": data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
],
|
||||
"Recruiting": data["Configurations"]["Default"][
|
||||
"TaskQueue.Recruiting.IsChecked"
|
||||
],
|
||||
"Base": data["Configurations"]["Default"][
|
||||
"TaskQueue.Base.IsChecked"
|
||||
],
|
||||
"Combat": data["Configurations"]["Default"][
|
||||
"TaskQueue.Combat.IsChecked"
|
||||
],
|
||||
"Mission": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mission.IsChecked"
|
||||
],
|
||||
"Mall": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mall.IsChecked"
|
||||
],
|
||||
"AutoRoguelike": data["Configurations"]["Default"][
|
||||
"TaskQueue.AutoRoguelike.IsChecked"
|
||||
],
|
||||
"Reclamation": data["Configurations"]["Default"][
|
||||
"TaskQueue.Reclamation.IsChecked"
|
||||
],
|
||||
}
|
||||
|
||||
elif user_data["Info"]["Mode"] == "详细":
|
||||
|
||||
with (self.data[user[2]]["Path"] / f"{mode}/gui.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
|
||||
self.task_dict = {
|
||||
"WakeUp": data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
],
|
||||
"Recruiting": data["Configurations"]["Default"][
|
||||
"TaskQueue.Recruiting.IsChecked"
|
||||
],
|
||||
"Base": data["Configurations"]["Default"][
|
||||
"TaskQueue.Base.IsChecked"
|
||||
],
|
||||
"Combat": data["Configurations"]["Default"][
|
||||
"TaskQueue.Combat.IsChecked"
|
||||
],
|
||||
"Mission": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mission.IsChecked"
|
||||
],
|
||||
"Mall": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mall.IsChecked"
|
||||
],
|
||||
"AutoRoguelike": data["Configurations"]["Default"][
|
||||
"TaskQueue.AutoRoguelike.IsChecked"
|
||||
],
|
||||
"Reclamation": data["Configurations"]["Default"][
|
||||
"TaskQueue.Reclamation.IsChecked"
|
||||
],
|
||||
}
|
||||
|
||||
# 尝试次数循环
|
||||
for i in range(self.set["RunSet"]["RunTimesLimit"]):
|
||||
|
||||
@@ -1275,6 +1277,9 @@ class MaaManager(QObject):
|
||||
]["Id"]
|
||||
|
||||
# 按预设设定任务
|
||||
data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
] = "True" # 开始唤醒
|
||||
data["Configurations"]["Default"]["TaskQueue.Recruiting.IsChecked"] = (
|
||||
self.task_dict["Recruiting"]
|
||||
) # 自动公招
|
||||
@@ -1299,10 +1304,6 @@ class MaaManager(QObject):
|
||||
|
||||
if user_data["Info"]["Mode"] == "简洁":
|
||||
|
||||
data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
] = "True" # 开始唤醒
|
||||
|
||||
data["Configurations"]["Default"]["Start.ClientType"] = user_data[
|
||||
"Info"
|
||||
][
|
||||
|
||||
179
app/ui/Widget.py
179
app/ui/Widget.py
@@ -82,6 +82,7 @@ from qfluentwidgets import (
|
||||
Pivot,
|
||||
PivotItem,
|
||||
FlyoutViewBase,
|
||||
PushSettingCard,
|
||||
)
|
||||
from qfluentwidgets.common.overload import singledispatchmethod
|
||||
|
||||
@@ -306,6 +307,8 @@ class SettingFlyoutView(FlyoutViewBase):
|
||||
self.viewLayout.addWidget(self.title)
|
||||
self.viewLayout.addWidget(scrollArea)
|
||||
|
||||
self.setVisible(False)
|
||||
|
||||
|
||||
class SwitchSettingCard(SettingCard):
|
||||
"""Setting card with switch button"""
|
||||
@@ -557,57 +560,6 @@ class PasswordLineEditSettingCard(SettingCard):
|
||||
self.LineEdit.textChanged.connect(self.__textChanged)
|
||||
|
||||
|
||||
class UserLableSettingCard(SettingCard):
|
||||
"""Setting card with User's Lable"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
qconfig: QConfig,
|
||||
configItems: Dict[str, ConfigItem],
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItems = configItems
|
||||
self.Lable = SubtitleLabel(self)
|
||||
|
||||
if configItems:
|
||||
for configItem in configItems.values():
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
self.setValue()
|
||||
|
||||
self.hBoxLayout.addWidget(self.Lable, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
def setValue(self):
|
||||
if self.configItems:
|
||||
|
||||
text_list = []
|
||||
if not self.qconfig.get(self.configItems["IfPassCheck"]):
|
||||
text_list.append("未通过人工排查")
|
||||
text_list.append(
|
||||
f"今日已代理{self.qconfig.get(self.configItems["ProxyTimes"])}次"
|
||||
if Config.server_date().strftime("%Y-%m-%d")
|
||||
== self.qconfig.get(self.configItems["LastProxyDate"])
|
||||
else "今日未进行代理"
|
||||
)
|
||||
text_list.append(
|
||||
"本周剿灭已完成"
|
||||
if datetime.strptime(
|
||||
self.qconfig.get(self.configItems["LastAnnihilationDate"]),
|
||||
"%Y-%m-%d",
|
||||
).isocalendar()[:2]
|
||||
== Config.server_date().isocalendar()[:2]
|
||||
else "本周剿灭未完成"
|
||||
)
|
||||
|
||||
self.Lable.setText(" | ".join(text_list))
|
||||
|
||||
|
||||
class PushAndSwitchButtonSettingCard(SettingCard):
|
||||
"""Setting card with push & switch button"""
|
||||
|
||||
@@ -1128,6 +1080,115 @@ class TimeEditSettingCard(SettingCard):
|
||||
self.TimeEdit.setTime(QTime.fromString(value, "HH:mm"))
|
||||
|
||||
|
||||
class UserLableSettingCard(SettingCard):
|
||||
"""Setting card with User's Lable"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
qconfig: QConfig,
|
||||
configItems: Dict[str, ConfigItem],
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItems = configItems
|
||||
self.Lable = SubtitleLabel(self)
|
||||
|
||||
if configItems:
|
||||
for configItem in configItems.values():
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
self.setValue()
|
||||
|
||||
self.hBoxLayout.addWidget(self.Lable, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
def setValue(self):
|
||||
|
||||
text_list = []
|
||||
|
||||
if self.configItems:
|
||||
|
||||
if not self.qconfig.get(self.configItems["IfPassCheck"]):
|
||||
text_list.append("未通过人工排查")
|
||||
text_list.append(
|
||||
f"今日已代理{self.qconfig.get(self.configItems["ProxyTimes"])}次"
|
||||
if Config.server_date().strftime("%Y-%m-%d")
|
||||
== self.qconfig.get(self.configItems["LastProxyDate"])
|
||||
else "今日未进行代理"
|
||||
)
|
||||
text_list.append(
|
||||
"本周剿灭已完成"
|
||||
if datetime.strptime(
|
||||
self.qconfig.get(self.configItems["LastAnnihilationDate"]),
|
||||
"%Y-%m-%d",
|
||||
).isocalendar()[:2]
|
||||
== Config.server_date().isocalendar()[:2]
|
||||
else "本周剿灭未完成"
|
||||
)
|
||||
|
||||
self.Lable.setText(" | ".join(text_list))
|
||||
|
||||
|
||||
class UserTaskSettingCard(PushSettingCard):
|
||||
"""Setting card with User's Task"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
text: str,
|
||||
qconfig: QConfig,
|
||||
configItems: Dict[str, ConfigItem],
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(text, icon, title, content, parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItems = configItems
|
||||
self.Lable = SubtitleLabel(self)
|
||||
|
||||
if configItems:
|
||||
for config_item in configItems.values():
|
||||
config_item.valueChanged.connect(self.setValues)
|
||||
self.setValues()
|
||||
|
||||
self.hBoxLayout.addWidget(self.Lable, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
def setValues(self):
|
||||
|
||||
text_list = []
|
||||
|
||||
if self.configItems:
|
||||
|
||||
if self.qconfig.get(self.configItems["IfWakeUp"]):
|
||||
text_list.append("开始唤醒")
|
||||
if self.qconfig.get(self.configItems["IfRecruiting"]):
|
||||
text_list.append("自动公招")
|
||||
if self.qconfig.get(self.configItems["IfBase"]):
|
||||
text_list.append("基建换班")
|
||||
if self.qconfig.get(self.configItems["IfCombat"]):
|
||||
text_list.append("刷理智")
|
||||
if self.qconfig.get(self.configItems["IfMall"]):
|
||||
text_list.append("获取信用及购物")
|
||||
if self.qconfig.get(self.configItems["IfMission"]):
|
||||
text_list.append("领取奖励")
|
||||
if self.qconfig.get(self.configItems["IfAutoRoguelike"]):
|
||||
text_list.append("自动肉鸽")
|
||||
if self.qconfig.get(self.configItems["IfReclamation"]):
|
||||
text_list.append("生息演算")
|
||||
|
||||
if text_list:
|
||||
self.setContent(f"任务序列:{" - ".join(text_list)}")
|
||||
else:
|
||||
self.setContent("未启用任何任务项")
|
||||
|
||||
|
||||
class UserNoticeSettingCard(PushAndSwitchButtonSettingCard):
|
||||
"""Setting card with User's Notice"""
|
||||
|
||||
@@ -1184,7 +1245,7 @@ class UserNoticeSettingCard(PushAndSwitchButtonSettingCard):
|
||||
# 普通字符串:末尾3字符
|
||||
return f"***{s[-3:]}" if len(s) > 3 else s
|
||||
|
||||
content_list = []
|
||||
text_list = []
|
||||
|
||||
if self.configItems:
|
||||
|
||||
@@ -1192,27 +1253,27 @@ class UserNoticeSettingCard(PushAndSwitchButtonSettingCard):
|
||||
self.qconfig.get(self.configItems["IfSendStatistic"])
|
||||
or self.qconfig.get(self.configItems["IfSendSixStar"])
|
||||
):
|
||||
content_list.append("未启用任何通知项")
|
||||
text_list.append("未启用任何通知项")
|
||||
|
||||
if self.qconfig.get(self.configItems["IfSendStatistic"]):
|
||||
content_list.append("统计信息已启用")
|
||||
text_list.append("统计信息已启用")
|
||||
if self.qconfig.get(self.configItems["IfSendSixStar"]):
|
||||
content_list.append("六星喜报已启用")
|
||||
text_list.append("六星喜报已启用")
|
||||
|
||||
if self.qconfig.get(self.configItems["IfSendMail"]):
|
||||
content_list.append(
|
||||
text_list.append(
|
||||
f"邮箱通知:{short_str(self.qconfig.get(self.configItems["ToAddress"]))}"
|
||||
)
|
||||
if self.qconfig.get(self.configItems["IfServerChan"]):
|
||||
content_list.append(
|
||||
text_list.append(
|
||||
f"Server酱通知:{short_str(self.qconfig.get(self.configItems["ServerChanKey"]))}"
|
||||
)
|
||||
if self.qconfig.get(self.configItems["IfCompanyWebHookBot"]):
|
||||
content_list.append(
|
||||
text_list.append(
|
||||
f"企业微信通知:{short_str(self.qconfig.get(self.configItems["CompanyWebHookBotUrl"]))}"
|
||||
)
|
||||
|
||||
self.setContent(" | ".join(content_list))
|
||||
self.setContent(" | ".join(text_list))
|
||||
|
||||
|
||||
class StatusSwitchSetting(SwitchButton):
|
||||
|
||||
@@ -73,6 +73,7 @@ from .Widget import (
|
||||
SpinBoxWithPlanSettingCard,
|
||||
PasswordLineEditSettingCard,
|
||||
UserLableSettingCard,
|
||||
UserTaskSettingCard,
|
||||
ComboBoxSettingCard,
|
||||
SwitchSettingCard,
|
||||
PushAndSwitchButtonSettingCard,
|
||||
@@ -1587,7 +1588,106 @@ class MemberManager(QWidget):
|
||||
parent=self,
|
||||
)
|
||||
|
||||
# 新增单独通知卡片
|
||||
# 单独任务卡片
|
||||
self.card_TaskSet = UserTaskSettingCard(
|
||||
icon=FluentIcon.LIBRARY,
|
||||
title="自动日常代理任务序列",
|
||||
content="未启用任何任务项",
|
||||
text="设置",
|
||||
qconfig=self.config,
|
||||
configItems={
|
||||
"IfWakeUp": self.config.Task_IfWakeUp,
|
||||
"IfRecruiting": self.config.Task_IfRecruiting,
|
||||
"IfBase": self.config.Task_IfBase,
|
||||
"IfCombat": self.config.Task_IfCombat,
|
||||
"IfMall": self.config.Task_IfMall,
|
||||
"IfMission": self.config.Task_IfMission,
|
||||
"IfAutoRoguelike": self.config.Task_IfAutoRoguelike,
|
||||
"IfReclamation": self.config.Task_IfReclamation,
|
||||
},
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfWakeUp = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="开始唤醒",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfWakeUp,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfRecruiting = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="自动公招",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfRecruiting,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfBase = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="基建换班",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfBase,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfCombat = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="刷理智",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfCombat,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfMall = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="获取信用及购物",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfMall,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfMission = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="领取奖励",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfMission,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfAutoRoguelike = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="自动肉鸽",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfAutoRoguelike,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfReclamation = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="生息演算",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfReclamation,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self.TaskSetCard = SettingFlyoutView(
|
||||
self,
|
||||
"自动日常代理任务序列设置",
|
||||
[
|
||||
self.card_IfWakeUp,
|
||||
self.card_IfRecruiting,
|
||||
self.card_IfBase,
|
||||
self.card_IfCombat,
|
||||
self.card_IfMall,
|
||||
self.card_IfMission,
|
||||
self.card_IfAutoRoguelike,
|
||||
self.card_IfReclamation,
|
||||
],
|
||||
)
|
||||
|
||||
# 单独通知卡片
|
||||
self.card_NotifySet = UserNoticeSettingCard(
|
||||
icon=FluentIcon.MAIL,
|
||||
title="用户单独通知设置",
|
||||
@@ -1618,17 +1718,16 @@ class MemberManager(QWidget):
|
||||
self.CompanyWechatPushSettingCard(self.config, self)
|
||||
)
|
||||
|
||||
self.card_NotifySet_list = [
|
||||
self.card_NotifyContent,
|
||||
self.card_EMail,
|
||||
self.card_ServerChan,
|
||||
self.card_CompanyWebhookBot,
|
||||
]
|
||||
|
||||
self.NotifySetCard = SettingFlyoutView(
|
||||
self, "用户通知设置", self.card_NotifySet_list
|
||||
self,
|
||||
"用户通知设置",
|
||||
[
|
||||
self.card_NotifyContent,
|
||||
self.card_EMail,
|
||||
self.card_ServerChan,
|
||||
self.card_CompanyWebhookBot,
|
||||
],
|
||||
)
|
||||
self.NotifySetCard.setVisible(False)
|
||||
|
||||
h1_layout = QHBoxLayout()
|
||||
h1_layout.addWidget(self.card_Name)
|
||||
@@ -1667,6 +1766,7 @@ class MemberManager(QWidget):
|
||||
Layout.addLayout(h6_layout)
|
||||
Layout.addLayout(h7_layout)
|
||||
Layout.addLayout(h8_layout)
|
||||
Layout.addWidget(self.card_TaskSet)
|
||||
Layout.addWidget(self.card_NotifySet)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
@@ -1687,6 +1787,7 @@ class MemberManager(QWidget):
|
||||
self.card_InfrastMode.clicked.connect(
|
||||
self.set_infrastructure
|
||||
)
|
||||
self.card_TaskSet.clicked.connect(self.set_task)
|
||||
self.card_NotifySet.clicked.connect(self.set_notify)
|
||||
self.card_GameIdMode.comboBox.currentIndexChanged.connect(
|
||||
self.switch_gameid_mode
|
||||
@@ -1851,6 +1952,18 @@ class MemberManager(QWidget):
|
||||
},
|
||||
)
|
||||
|
||||
def set_task(self) -> None:
|
||||
"""设置用户任务序列相关配置"""
|
||||
|
||||
self.TaskSetCard.setVisible(True)
|
||||
Flyout.make(
|
||||
self.TaskSetCard,
|
||||
self.card_TaskSet,
|
||||
self,
|
||||
aniType=FlyoutAnimationType.PULL_UP,
|
||||
isDeleteOnClose=False,
|
||||
)
|
||||
|
||||
def set_notify(self) -> None:
|
||||
"""设置用户通知相关配置"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user