feat(core): 电源相关选项改为所有任务完成后生效

This commit is contained in:
DLmaster361
2025-05-09 21:52:18 +08:00
parent 5893aa2426
commit 74ce441b90
4 changed files with 30 additions and 19 deletions

View File

@@ -649,6 +649,7 @@ class AppConfig(GlobalConfig):
"ALL": {"value": [], "text": []},
"Today": {"value": [], "text": []},
}
self.power_signal = None
self.if_ignore_silence = False
self.if_database_opened = False

View File

@@ -266,27 +266,11 @@ class _TaskManager(QObject):
Config.queue_dict[name]["Config"].queueSet_AfterAccomplish
)
!= "None"
and not Config.power_signal
):
from app.ui import ProgressRingMessageBox
mode_book = {
"Shutdown": "关机",
"Hibernate": "休眠",
"Sleep": "睡眠",
"KillSelf": "关闭AUTO_MAA",
}
choice = ProgressRingMessageBox(
Config.main_window,
f"{mode_book[Config.queue_dict[name]["Config"].get(Config.queue_dict[name]["Config"].queueSet_AfterAccomplish)]}倒计时",
Config.power_signal = Config.queue_dict[name]["Config"].get(
Config.queue_dict[name]["Config"].queueSet_AfterAccomplish
)
if choice.exec():
System.set_power(
Config.queue_dict[name]["Config"].get(
Config.queue_dict[name]["Config"].queueSet_AfterAccomplish
)
)
def check_maa_version(self, v: str):
"""检查MAA版本"""

View File

@@ -46,6 +46,7 @@ class _MainTimer(QWidget):
self.Timer = QTimer()
self.Timer.timeout.connect(self.timed_start)
self.Timer.timeout.connect(self.set_silence)
self.Timer.timeout.connect(self.check_power)
self.Timer.start(1000)
self.LongTimer = QTimer()
self.LongTimer.timeout.connect(self.long_timed_task)
@@ -113,5 +114,27 @@ class _MainTimer(QWidget):
logger.warning(f"FailSafeException: {e}")
self.if_FailSafeException = True
def check_power(self):
if Config.power_signal and not Config.running_list:
from app.ui import ProgressRingMessageBox
mode_book = {
"Shutdown": "关机",
"Hibernate": "休眠",
"Sleep": "睡眠",
"KillSelf": "关闭AUTO_MAA",
}
choice = ProgressRingMessageBox(
Config.main_window, f"{mode_book[Config.power_signal]}倒计时"
)
if choice.exec():
System.set_power(Config.power_signal)
Config.power_signal = None
else:
Config.power_signal = None
MainTimer = _MainTimer()