feat(ui): 初步完成用户通知相关界面
This commit is contained in:
@@ -191,6 +191,44 @@ class ProgressRingMessageBox(MessageBoxBase):
|
||||
self.timer.deleteLater()
|
||||
|
||||
|
||||
class SettingMessageBox(MessageBoxBase):
|
||||
"""设置二级菜单对话框"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent,
|
||||
title: str,
|
||||
setting_cards: List[Union[SettingCard, HeaderCardWidget]],
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
self.title = SubtitleLabel(title)
|
||||
self.button_yes = PrimaryPushButton("确认", self)
|
||||
self.v_layout = QVBoxLayout()
|
||||
self.v_layout.addStretch()
|
||||
self.v_layout.addWidget(self.button_yes)
|
||||
|
||||
self.buttonGroup.hide()
|
||||
|
||||
scrollArea = ScrollArea()
|
||||
scrollArea.setWidgetResizable(True)
|
||||
scrollArea.setContentsMargins(0, 0, 0, 0)
|
||||
scrollArea.setStyleSheet("background: transparent; border: none;")
|
||||
|
||||
content_widget = QWidget()
|
||||
content_layout = QVBoxLayout(content_widget)
|
||||
for setting_card in setting_cards:
|
||||
content_layout.addWidget(setting_card)
|
||||
scrollArea.setWidget(content_widget)
|
||||
|
||||
# 将组件添加到布局中
|
||||
self.viewLayout.addWidget(self.title)
|
||||
self.viewLayout.addWidget(scrollArea)
|
||||
self.viewLayout.addLayout(self.v_layout)
|
||||
|
||||
self.button_yes.clicked.connect(self.yesButton.click)
|
||||
|
||||
|
||||
class NoticeMessageBox(MessageBoxBase):
|
||||
"""公告对话框"""
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ from .Widget import (
|
||||
LineEditSettingCard,
|
||||
SpinBoxSettingCard,
|
||||
ComboBoxMessageBox,
|
||||
SettingMessageBox,
|
||||
EditableComboBoxSettingCard,
|
||||
PasswordLineEditSettingCard,
|
||||
UserLableSettingCard,
|
||||
@@ -1530,138 +1531,32 @@ class MemberManager(QWidget):
|
||||
)
|
||||
|
||||
# 新增单独通知卡片
|
||||
self.card_NotifyEnable = SwitchSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="启用单独通知",
|
||||
content="启用后,任务结束将向该用户单独推送通知",
|
||||
self.card_NotifySet = PushAndSwitchButtonSettingCard(
|
||||
icon=FluentIcon.MAIL,
|
||||
title="用户单独通知设置",
|
||||
content="",
|
||||
text="设置",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_Enable,
|
||||
parent=self
|
||||
configItem=self.config.Notify_Enabled,
|
||||
parent=self,
|
||||
)
|
||||
self.card_NotifyIfSMTP = SwitchSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="启用SMTP通知",
|
||||
content="是否启用单独通知的SMTP邮件推送",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_IfSMTP,
|
||||
parent=self
|
||||
self.card_EMail = self.EMailSettingCard(self.config, self)
|
||||
self.card_ServerChan = self.ServerChanSettingCard(
|
||||
self.config, self
|
||||
)
|
||||
self.card_NotifySMTP = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="SMTP服务器地址",
|
||||
content="单独通知的SMTP服务器地址",
|
||||
text="请输入SMTP服务器地址",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_SMTPServerAddress,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyAuthCode = PasswordLineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="授权码",
|
||||
content="单独通知的邮箱授权码",
|
||||
text="请输入授权码",
|
||||
algorithm="AUTO",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_AuthorizationCode,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyFrom = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="发件人邮箱",
|
||||
content="单独通知的发件人邮箱",
|
||||
text="请输入发件人邮箱",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_FromAddress,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyTo = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="收件人邮箱",
|
||||
content="单独通知的收件人邮箱",
|
||||
text="请输入收件人邮箱",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ToAddress,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyIfServerChan = SwitchSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="启用ServerChan",
|
||||
content="是否启用单独通知的ServerChan推送",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_IfServerChan,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyServerChanKey = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="ServerChanKey",
|
||||
content="单独通知的ServerChan SendKey",
|
||||
text="请输入ServerChanKey",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ServerChanKey,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyServerChanChannel = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="ServerChanChannel",
|
||||
content="单独通知的ServerChan Channel",
|
||||
text="请输入ServerChanChannel",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ServerChanChannel,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyServerChanTag = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="ServerChanTag",
|
||||
content="单独通知的ServerChan Tag",
|
||||
text="请输入ServerChanTag",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ServerChanTag,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyIfCompanyWebHookBot = SwitchSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="启用企业微信机器人",
|
||||
content="是否启用单独通知的企业微信机器人推送",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_IfCompanyWebHookBot,
|
||||
parent=self
|
||||
)
|
||||
self.card_NotifyCompanyWebHookBotUrl = LineEditSettingCard(
|
||||
icon=FluentIcon.INFO,
|
||||
title="企业微信机器人WebhookUrl",
|
||||
content="单独通知的企业微信机器人Webhook地址",
|
||||
text="请输入WebhookUrl",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_CompanyWebHookBotUrl,
|
||||
parent=self
|
||||
self.card_CompanyWebhookBot = (
|
||||
self.CompanyWechatPushSettingCard(self.config, self)
|
||||
)
|
||||
|
||||
# 设置通知卡片默认隐藏
|
||||
self.card_NotifyIfSMTP.setVisible(False)
|
||||
self.card_NotifySMTP.setVisible(False)
|
||||
self.card_NotifyAuthCode.setVisible(False)
|
||||
self.card_NotifyFrom.setVisible(False)
|
||||
self.card_NotifyTo.setVisible(False)
|
||||
self.card_NotifyIfServerChan.setVisible(False)
|
||||
self.card_NotifyServerChanKey.setVisible(False)
|
||||
self.card_NotifyServerChanChannel.setVisible(False)
|
||||
self.card_NotifyServerChanTag.setVisible(False)
|
||||
self.card_NotifyIfCompanyWebHookBot.setVisible(False)
|
||||
self.card_NotifyCompanyWebHookBotUrl.setVisible(False)
|
||||
self.card_NotifySet_list = [
|
||||
self.card_EMail,
|
||||
self.card_ServerChan,
|
||||
self.card_CompanyWebhookBot,
|
||||
]
|
||||
|
||||
# 连接通知启用开关的信号
|
||||
self.card_NotifyEnable.checkedChanged.connect(self.toggle_notify_settings)
|
||||
self.card_NotifyIfSMTP.checkedChanged.connect(self.toggle_smtp_settings)
|
||||
|
||||
# 根据配置状态初始化显示
|
||||
if self.config.get(self.config.Notify_Enable):
|
||||
self.toggle_notify_settings(True)
|
||||
if self.config.get(self.config.Notify_IfSMTP):
|
||||
self.toggle_smtp_settings(True)
|
||||
if self.config.get(self.config.Notify_IfServerChan):
|
||||
self.toggle_serverchan_settings(True)
|
||||
if self.config.get(self.config.Notify_IfCompanyWebHookBot):
|
||||
self.toggle_webhook_settings(True)
|
||||
self.NotifySetCard = SettingMessageBox(
|
||||
self.window(), "用户通知设置", self.card_NotifySet_list
|
||||
)
|
||||
|
||||
h1_layout = QHBoxLayout()
|
||||
h1_layout.addWidget(self.card_Name)
|
||||
@@ -1700,27 +1595,7 @@ class MemberManager(QWidget):
|
||||
Layout.addLayout(h6_layout)
|
||||
Layout.addLayout(h7_layout)
|
||||
Layout.addLayout(h8_layout)
|
||||
|
||||
# 创建通知设置容器
|
||||
notify_container = QWidget()
|
||||
notify_layout = QVBoxLayout(notify_container)
|
||||
notify_layout.setContentsMargins(0, 0, 0, 0)
|
||||
notify_layout.setSpacing(0)
|
||||
|
||||
notify_layout.addWidget(self.card_NotifyEnable)
|
||||
notify_layout.addWidget(self.card_NotifyIfSMTP)
|
||||
notify_layout.addWidget(self.card_NotifySMTP)
|
||||
notify_layout.addWidget(self.card_NotifyAuthCode)
|
||||
notify_layout.addWidget(self.card_NotifyFrom)
|
||||
notify_layout.addWidget(self.card_NotifyTo)
|
||||
notify_layout.addWidget(self.card_NotifyIfServerChan)
|
||||
notify_layout.addWidget(self.card_NotifyServerChanKey)
|
||||
notify_layout.addWidget(self.card_NotifyServerChanChannel)
|
||||
notify_layout.addWidget(self.card_NotifyServerChanTag)
|
||||
notify_layout.addWidget(self.card_NotifyIfCompanyWebHookBot)
|
||||
notify_layout.addWidget(self.card_NotifyCompanyWebHookBotUrl)
|
||||
|
||||
Layout.addWidget(notify_container)
|
||||
Layout.addWidget(self.card_NotifySet)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
@@ -1740,17 +1615,12 @@ class MemberManager(QWidget):
|
||||
self.card_InfrastMode.clicked.connect(
|
||||
self.set_infrastructure
|
||||
)
|
||||
self.card_NotifySet.clicked.connect(
|
||||
self.NotifySetCard.exec_
|
||||
)
|
||||
Config.gameid_refreshed.connect(self.refresh_gameid)
|
||||
Config.PASSWORD_refreshed.connect(self.refresh_password)
|
||||
|
||||
# 连接ServerChan和企业微信机器人的开关信号
|
||||
self.card_NotifyIfServerChan.checkedChanged.connect(
|
||||
lambda checked: self.toggle_serverchan_settings(checked)
|
||||
)
|
||||
self.card_NotifyIfCompanyWebHookBot.checkedChanged.connect(
|
||||
lambda checked: self.toggle_webhook_settings(checked)
|
||||
)
|
||||
|
||||
self.switch_mode()
|
||||
self.switch_infrastructure()
|
||||
|
||||
@@ -1873,46 +1743,118 @@ class MemberManager(QWidget):
|
||||
},
|
||||
)
|
||||
|
||||
def toggle_notify_settings(self, checked: bool):
|
||||
"""切换通知设置卡片的显示状态"""
|
||||
self.card_NotifyIfSMTP.setVisible(checked)
|
||||
self.card_NotifyIfServerChan.setVisible(checked)
|
||||
self.card_NotifyIfCompanyWebHookBot.setVisible(checked)
|
||||
|
||||
# 根据SMTP开关状态控制相关设置
|
||||
if checked and self.config.get(self.config.Notify_IfSMTP):
|
||||
self.toggle_smtp_settings(True)
|
||||
else:
|
||||
self.toggle_smtp_settings(False)
|
||||
|
||||
# 根据ServerChan开关状态控制相关设置
|
||||
if checked and self.config.get(self.config.Notify_IfServerChan):
|
||||
self.toggle_serverchan_settings(True)
|
||||
else:
|
||||
self.toggle_serverchan_settings(False)
|
||||
|
||||
# 根据企业微信机器人开关状态控制相关设置
|
||||
if checked and self.config.get(self.config.Notify_IfCompanyWebHookBot):
|
||||
self.toggle_webhook_settings(True)
|
||||
else:
|
||||
self.toggle_webhook_settings(False)
|
||||
class EMailSettingCard(HeaderCardWidget):
|
||||
|
||||
def toggle_smtp_settings(self, checked: bool):
|
||||
"""切换SMTP相关设置的显示状态"""
|
||||
if self.config.get(self.config.Notify_Enable):
|
||||
self.card_NotifySMTP.setVisible(checked)
|
||||
self.card_NotifyAuthCode.setVisible(checked)
|
||||
self.card_NotifyFrom.setVisible(checked)
|
||||
self.card_NotifyTo.setVisible(checked)
|
||||
def __init__(self, config: MaaUserConfig, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("用户邮箱通知")
|
||||
|
||||
def toggle_serverchan_settings(self, checked: bool):
|
||||
"""切换ServerChan相关设置的显示状态"""
|
||||
if self.config.get(self.config.Notify_Enable):
|
||||
self.card_NotifyServerChanKey.setVisible(checked)
|
||||
self.card_NotifyServerChanChannel.setVisible(checked)
|
||||
self.card_NotifyServerChanTag.setVisible(checked)
|
||||
self.config = config
|
||||
|
||||
def toggle_webhook_settings(self, checked: bool):
|
||||
"""切换企业微信机器人相关设置的显示状态"""
|
||||
if self.config.get(self.config.Notify_Enable):
|
||||
self.card_NotifyCompanyWebHookBotUrl.setVisible(checked)
|
||||
self.card_IfSendMail = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送用户邮件通知",
|
||||
content="是否启用用户邮件通知功能",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_IfSendMail,
|
||||
parent=self,
|
||||
)
|
||||
self.card_ToAddress = LineEditSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="用户收信邮箱地址",
|
||||
content="接收用户通知的邮箱地址",
|
||||
text="请输入用户收信邮箱地址",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ToAddress,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfSendMail)
|
||||
Layout.addWidget(self.card_ToAddress)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
|
||||
class ServerChanSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, config: MaaUserConfig, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("用户ServerChan通知")
|
||||
|
||||
self.config = config
|
||||
|
||||
self.card_IfServerChan = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送用户Server酱通知",
|
||||
content="是否启用用户Server酱通知功能",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_IfServerChan,
|
||||
parent=self,
|
||||
)
|
||||
self.card_ServerChanKey = LineEditSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="用户SendKey",
|
||||
content="SC3与SCT均须填写",
|
||||
text="请输入用户SendKey",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ServerChanKey,
|
||||
parent=self,
|
||||
)
|
||||
self.card_ServerChanChannel = LineEditSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="用户ServerChanChannel代码",
|
||||
content="留空则默认,多个请使用“|”隔开",
|
||||
text="请输入Channel代码,仅SCT生效",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ServerChanChannel,
|
||||
parent=self,
|
||||
)
|
||||
self.card_ServerChanTag = LineEditSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="用户Tag内容",
|
||||
content="留空则默认,多个请使用“|”隔开",
|
||||
text="请输入加入推送的Tag,仅SC3生效",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_ServerChanTag,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfServerChan)
|
||||
Layout.addWidget(self.card_ServerChanKey)
|
||||
Layout.addWidget(self.card_ServerChanChannel)
|
||||
Layout.addWidget(self.card_ServerChanTag)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
|
||||
class CompanyWechatPushSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, config: MaaUserConfig, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("用户企业微信推送")
|
||||
|
||||
self.config = config
|
||||
|
||||
self.card_IfCompanyWechat = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送用户企业微信机器人通知",
|
||||
content="是否启用用户企微机器人通知功能",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_IfCompanyWebHookBot,
|
||||
parent=self,
|
||||
)
|
||||
self.card_CompanyWebHookBotUrl = LineEditSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="WebhookUrl",
|
||||
content="用户企微群机器人Webhook地址",
|
||||
text="请输入用户Webhook的Url",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Notify_CompanyWebHookBotUrl,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfCompanyWechat)
|
||||
Layout.addWidget(self.card_CompanyWebHookBotUrl)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
|
||||
Reference in New Issue
Block a user