feat(ui): 关机等电源操作添加100s倒计时
This commit is contained in:
@@ -27,7 +27,7 @@ v4.2
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtCore import QThread, QObject, Signal
|
||||
from qfluentwidgets import Dialog
|
||||
from qfluentwidgets import MessageBox
|
||||
import json
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
@@ -187,9 +187,10 @@ class _TaskManager(QObject):
|
||||
connect_gui = Signal(Task)
|
||||
push_info_bar = Signal(str, str, str, int)
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, main_window=None):
|
||||
super(_TaskManager, self).__init__()
|
||||
|
||||
self.main_window = main_window
|
||||
self.task_dict: Dict[str, Task] = {}
|
||||
|
||||
def add_task(
|
||||
@@ -281,16 +282,33 @@ class _TaskManager(QObject):
|
||||
"r", encoding="utf-8"
|
||||
) as f:
|
||||
info = json.load(f)
|
||||
System.set_power(info["QueueSet"]["AfterAccomplish"])
|
||||
|
||||
if info["QueueSet"]["AfterAccomplish"] != "None":
|
||||
|
||||
from app.ui import ProgressRingMessageBox
|
||||
|
||||
mode_book = {
|
||||
"Shutdown": "关机",
|
||||
"Hibernate": "休眠",
|
||||
"Sleep": "睡眠",
|
||||
"KillSelf": "关闭AUTO_MAA",
|
||||
}
|
||||
|
||||
choice = ProgressRingMessageBox(
|
||||
self.main_window,
|
||||
f"{mode_book[info['QueueSet']['AfterAccomplish']]}倒计时",
|
||||
)
|
||||
if choice.exec():
|
||||
System.set_power(info["QueueSet"]["AfterAccomplish"])
|
||||
|
||||
def push_dialog(self, name: str, title: str, content: str):
|
||||
"""推送对话框"""
|
||||
|
||||
choice = Dialog(title, content, None)
|
||||
choice = MessageBox(title, content, self.main_window)
|
||||
choice.yesButton.setText("是")
|
||||
choice.cancelButton.setText("否")
|
||||
|
||||
self.task_dict[name].question_response.emit(bool(choice.exec_()))
|
||||
self.task_dict[name].question_response.emit(bool(choice.exec()))
|
||||
|
||||
|
||||
TaskManager = _TaskManager()
|
||||
|
||||
@@ -26,7 +26,7 @@ v4.2
|
||||
"""
|
||||
|
||||
from PySide6.QtWidgets import QWidget, QWidget, QLabel, QHBoxLayout, QSizePolicy
|
||||
from PySide6.QtCore import Qt, QTime, QEvent, QSize
|
||||
from PySide6.QtCore import Qt, QTime, QTimer, QEvent, QSize
|
||||
from PySide6.QtGui import QIcon, QPixmap, QPainter, QPainterPath
|
||||
from qfluentwidgets import (
|
||||
LineEdit,
|
||||
@@ -54,6 +54,7 @@ from qfluentwidgets import (
|
||||
ExpandSettingCard,
|
||||
ToolButton,
|
||||
PushButton,
|
||||
ProgressRing,
|
||||
)
|
||||
from qfluentwidgets.common.overload import singledispatchmethod
|
||||
import os
|
||||
@@ -108,6 +109,52 @@ class ComboBoxMessageBox(MessageBoxBase):
|
||||
self.viewLayout.addWidget(Widget)
|
||||
|
||||
|
||||
class ProgressRingMessageBox(MessageBoxBase):
|
||||
"""进度环倒计时对话框"""
|
||||
|
||||
def __init__(self, parent, title: str):
|
||||
super().__init__(parent)
|
||||
self.title = SubtitleLabel(title)
|
||||
|
||||
self.time = 100
|
||||
Widget = QWidget()
|
||||
Layout = QHBoxLayout(Widget)
|
||||
self.ring = ProgressRing()
|
||||
self.ring.setRange(0, 100)
|
||||
self.ring.setValue(100)
|
||||
self.ring.setTextVisible(True)
|
||||
self.ring.setFormat("%p 秒")
|
||||
self.ring.setFixedSize(100, 100)
|
||||
self.ring.setStrokeWidth(4)
|
||||
Layout.addWidget(self.ring)
|
||||
|
||||
self.yesButton.hide()
|
||||
self.cancelButton.clicked.connect(self.__quit_timer)
|
||||
self.buttonLayout.insertStretch(1)
|
||||
|
||||
# 将组件添加到布局中
|
||||
self.viewLayout.addWidget(self.title)
|
||||
self.viewLayout.addWidget(Widget)
|
||||
|
||||
self.timer = QTimer(self)
|
||||
self.timer.timeout.connect(self.__update_time)
|
||||
self.timer.start(1000)
|
||||
|
||||
def __update_time(self):
|
||||
|
||||
self.time -= 1
|
||||
self.ring.setValue(self.time)
|
||||
|
||||
if self.time == 0:
|
||||
self.timer.stop()
|
||||
self.timer.deleteLater()
|
||||
self.yesButton.click()
|
||||
|
||||
def __quit_timer(self):
|
||||
self.timer.stop()
|
||||
self.timer.deleteLater()
|
||||
|
||||
|
||||
class LineEditSettingCard(SettingCard):
|
||||
"""Setting card with LineEdit"""
|
||||
|
||||
|
||||
@@ -30,5 +30,6 @@ __author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .main_window import AUTO_MAA
|
||||
from .Widget import ProgressRingMessageBox
|
||||
|
||||
__all__ = ["AUTO_MAA"]
|
||||
__all__ = ["AUTO_MAA", "ProgressRingMessageBox"]
|
||||
|
||||
@@ -72,6 +72,7 @@ class AUTO_MAA(MSFluentWindow):
|
||||
self.splashScreen = SplashScreen(self.windowIcon(), self)
|
||||
self.show_ui("显示主窗口", if_quick=True)
|
||||
|
||||
TaskManager.main_window = self.window()
|
||||
MainInfoBar.main_window = self.window()
|
||||
System.main_window = self.window()
|
||||
|
||||
@@ -260,7 +261,9 @@ class AUTO_MAA(MSFluentWindow):
|
||||
)
|
||||
if "网络错误" not in result:
|
||||
Up = PushButton("更新")
|
||||
Up.clicked.connect(lambda: self.setting.get_update(if_question=False))
|
||||
Up.clicked.connect(
|
||||
lambda: self.setting.get_update(if_question=False)
|
||||
)
|
||||
Up.clicked.connect(info.close)
|
||||
info.addWidget(Up)
|
||||
info.show()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"main_version": "4.2.5.2",
|
||||
"updater_version": "1.2.0.0",
|
||||
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n## 程序优化\n- 暂无",
|
||||
"announcement": "\n## 新增功能\n- 屏蔽MuMu模拟器开屏广告功能上线\n- 更新器支持多线程下载\n## 修复BUG\n- 修复统计信息HTML模板公招匹配错误\n- 修复密码显示按钮动画异常\n## 程序优化\n- 关机等电源操作添加100s倒计时",
|
||||
"proxy_list": [
|
||||
"",
|
||||
"https://gitproxy.click/",
|
||||
|
||||
Reference in New Issue
Block a user