feat(ui): 吐司通知在主窗口隐藏时不再弹出
This commit is contained in:
@@ -567,7 +567,7 @@ class MaaPlanConfig(LQConfig):
|
|||||||
|
|
||||||
class AppConfig(GlobalConfig):
|
class AppConfig(GlobalConfig):
|
||||||
|
|
||||||
VERSION = "4.3.8.4"
|
VERSION = "4.3.8.0"
|
||||||
|
|
||||||
gameid_refreshed = Signal()
|
gameid_refreshed = Signal()
|
||||||
PASSWORD_refreshed = Signal()
|
PASSWORD_refreshed = Signal()
|
||||||
@@ -591,6 +591,7 @@ class AppConfig(GlobalConfig):
|
|||||||
self.PASSWORD = ""
|
self.PASSWORD = ""
|
||||||
self.running_list = []
|
self.running_list = []
|
||||||
self.silence_list = []
|
self.silence_list = []
|
||||||
|
self.info_bar_list = []
|
||||||
self.gameid_dict = {
|
self.gameid_dict = {
|
||||||
"ALL": {"value": [], "text": []},
|
"ALL": {"value": [], "text": []},
|
||||||
"Monday": {"value": [], "text": []},
|
"Monday": {"value": [], "text": []},
|
||||||
|
|||||||
@@ -35,23 +35,30 @@ from .config import Config
|
|||||||
class _MainInfoBar:
|
class _MainInfoBar:
|
||||||
"""信息通知栏"""
|
"""信息通知栏"""
|
||||||
|
|
||||||
def push_info_bar(self, mode: str, title: str, content: str, time: int):
|
# 模式到 InfoBar 方法的映射
|
||||||
|
mode_mapping = {
|
||||||
|
"success": InfoBar.success,
|
||||||
|
"warning": InfoBar.warning,
|
||||||
|
"error": InfoBar.error,
|
||||||
|
"info": InfoBar.info,
|
||||||
|
}
|
||||||
|
|
||||||
|
def push_info_bar(
|
||||||
|
self, mode: str, title: str, content: str, time: int, if_force: bool = False
|
||||||
|
):
|
||||||
"""推送到信息通知栏"""
|
"""推送到信息通知栏"""
|
||||||
if Config.main_window is None:
|
if Config.main_window is None:
|
||||||
logger.error("信息通知栏未设置父窗口")
|
logger.error("信息通知栏未设置父窗口")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 定义模式到 InfoBar 方法的映射
|
|
||||||
mode_mapping = {
|
|
||||||
"success": InfoBar.success,
|
|
||||||
"warning": InfoBar.warning,
|
|
||||||
"error": InfoBar.error,
|
|
||||||
"info": InfoBar.info,
|
|
||||||
}
|
|
||||||
|
|
||||||
# 根据 mode 获取对应的 InfoBar 方法
|
# 根据 mode 获取对应的 InfoBar 方法
|
||||||
info_bar_method = mode_mapping.get(mode)
|
info_bar_method = self.mode_mapping.get(mode)
|
||||||
if info_bar_method:
|
|
||||||
|
if not info_bar_method:
|
||||||
|
logger.error(f"未知的通知栏模式: {mode}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
if Config.main_window.isVisible():
|
||||||
info_bar_method(
|
info_bar_method(
|
||||||
title=title,
|
title=title,
|
||||||
content=content,
|
content=content,
|
||||||
@@ -61,8 +68,16 @@ class _MainInfoBar:
|
|||||||
duration=time,
|
duration=time,
|
||||||
parent=Config.main_window,
|
parent=Config.main_window,
|
||||||
)
|
)
|
||||||
else:
|
elif if_force:
|
||||||
logger.error(f"未知的通知栏模式: {mode}")
|
# 如果主窗口不可见且强制推送,则录入消息队列等待窗口显示后推送
|
||||||
|
info_bar_item = {
|
||||||
|
"mode": mode,
|
||||||
|
"title": title,
|
||||||
|
"content": content,
|
||||||
|
"time": time,
|
||||||
|
}
|
||||||
|
if info_bar_item not in Config.info_bar_list:
|
||||||
|
Config.info_bar_list.append(info_bar_item)
|
||||||
|
|
||||||
|
|
||||||
MainInfoBar = _MainInfoBar()
|
MainInfoBar = _MainInfoBar()
|
||||||
|
|||||||
@@ -302,6 +302,15 @@ class AUTO_MAA(MSFluentWindow):
|
|||||||
self.window().raise_()
|
self.window().raise_()
|
||||||
self.window().activateWindow()
|
self.window().activateWindow()
|
||||||
|
|
||||||
|
while Config.info_bar_list:
|
||||||
|
info_bar_item = Config.info_bar_list.pop(0)
|
||||||
|
MainInfoBar.push_info_bar(
|
||||||
|
info_bar_item["mode"],
|
||||||
|
info_bar_item["title"],
|
||||||
|
info_bar_item["content"],
|
||||||
|
info_bar_item["time"],
|
||||||
|
)
|
||||||
|
|
||||||
elif mode == "配置托盘":
|
elif mode == "配置托盘":
|
||||||
|
|
||||||
if Config.get(Config.ui_IfShowTray):
|
if Config.get(Config.ui_IfShowTray):
|
||||||
|
|||||||
@@ -462,6 +462,7 @@ class Setting(QWidget):
|
|||||||
"发现新版本",
|
"发现新版本",
|
||||||
f"{version_text(current_version)} --> {version_text(remote_version)}",
|
f"{version_text(current_version)} --> {version_text(remote_version)}",
|
||||||
3600000,
|
3600000,
|
||||||
|
if_force=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
MainInfoBar.push_info_bar("success", "更新检查", "已是最新版本~", 3000)
|
MainInfoBar.push_info_bar("success", "更新检查", "已是最新版本~", 3000)
|
||||||
@@ -545,7 +546,7 @@ class Setting(QWidget):
|
|||||||
):
|
):
|
||||||
|
|
||||||
MainInfoBar.push_info_bar(
|
MainInfoBar.push_info_bar(
|
||||||
"info", "有新公告", "请前往设置界面查看公告", 3600000
|
"info", "有新公告", "请前往设置界面查看公告", 3600000, if_force=True
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
{
|
{
|
||||||
"main_version": "4.3.8.4",
|
"main_version": "4.3.8.0",
|
||||||
"version_info": {
|
"version_info": {
|
||||||
|
"4.3.8.0": {
|
||||||
|
"新增功能": [
|
||||||
|
"吐司通知在主窗口隐藏时不再弹出"
|
||||||
|
]
|
||||||
|
},
|
||||||
"4.3.8.4": {
|
"4.3.8.4": {
|
||||||
"新增功能": [
|
"新增功能": [
|
||||||
"支持为每一个用户执行独立通知",
|
"支持为每一个用户执行独立通知",
|
||||||
@@ -29,7 +34,7 @@
|
|||||||
"日志分析忽略MAA超时提示"
|
"日志分析忽略MAA超时提示"
|
||||||
],
|
],
|
||||||
"程序优化": [
|
"程序优化": [
|
||||||
"配置类定义方法更新"
|
"配置类定义方法优化"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"4.3.8.1": {
|
"4.3.8.1": {
|
||||||
@@ -44,14 +49,6 @@
|
|||||||
"程序优化": [
|
"程序优化": [
|
||||||
"UI样式优化,进一步适配win10主题"
|
"UI样式优化,进一步适配win10主题"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"4.3.7.0": {
|
|
||||||
"新增功能": [
|
|
||||||
"下载器支持完整mirrorc列表"
|
|
||||||
],
|
|
||||||
"程序优化": [
|
|
||||||
"重构更新逻辑,去除独立更新器"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user