diff --git a/app/config.py b/app/config.py
index c5264e5..8323da6 100644
--- a/app/config.py
+++ b/app/config.py
@@ -49,8 +49,6 @@ class AppConfig:
# 检查文件完整性
self.initialize()
- self.check_config()
- self.check_database()
def initialize(self) -> None:
"""初始化程序的配置文件"""
@@ -83,6 +81,9 @@ class AppConfig:
encoding="utf-8",
)
+ self.check_config()
+ self.check_database()
+
def check_config(self) -> None:
"""检查配置文件字段完整性并补全"""
diff --git a/app/services/notification.py b/app/services/notification.py
index d8c45f8..4afd7f5 100644
--- a/app/services/notification.py
+++ b/app/services/notification.py
@@ -48,7 +48,7 @@ class Notification:
title=title,
message=message,
app_name="AUTO_MAA",
- app_icon=self.config.app_path / "resources/icons/AUTO_MAA.ico",
+ app_icon=str(self.config.app_path / "resources/icons/AUTO_MAA.ico"),
timeout=t,
ticker=ticker,
toast=True,
diff --git a/app/ui/gui.py b/app/ui/gui.py
index ea7fcc1..d19fd28 100644
--- a/app/ui/gui.py
+++ b/app/ui/gui.py
@@ -26,26 +26,35 @@ v4.2
"""
from PySide6.QtWidgets import (
- QWidget,
- QMainWindow,
- QApplication,
- QSystemTrayIcon,
- QMenu,
- QInputDialog,
- QFileDialog,
- QMessageBox,
- QLineEdit,
- QTabWidget,
- QToolBox,
- QTableWidget,
- QTableWidgetItem,
- QComboBox,
- QPushButton,
- QHeaderView,
- QSpinBox,
- QTimeEdit,
- QCheckBox,
- QTextBrowser,
+ QWidget, #
+ QMainWindow, #
+ QApplication, #
+ QSystemTrayIcon, #
+ QFileDialog, #
+ QTabWidget, #
+ QToolBox, #
+ QComboBox, #
+ QTableWidgetItem, #
+ QHeaderView, #
+)
+from qfluentwidgets import (
+ Action,
+ PushButton,
+ LineEdit,
+ PasswordLineEdit,
+ TextBrowser,
+ TableWidget,
+ TimePicker,
+ ComboBox,
+ CheckBox,
+ SpinBox,
+ FluentIcon,
+ RoundMenu,
+ MessageBox,
+ MessageBoxBase,
+ HeaderCardWidget,
+ BodyLabel,
+ SubtitleLabel,
)
from PySide6.QtUiTools import QUiLoader
from PySide6.QtGui import QIcon, QCloseEvent
@@ -149,32 +158,22 @@ class Main(QWidget):
"-",
]
+ uiLoader.registerCustomWidget(PushButton)
+ uiLoader.registerCustomWidget(LineEdit)
+ uiLoader.registerCustomWidget(TextBrowser)
+ uiLoader.registerCustomWidget(TableWidget)
+ uiLoader.registerCustomWidget(TimePicker)
+ uiLoader.registerCustomWidget(SpinBox)
+ uiLoader.registerCustomWidget(CheckBox)
+ uiLoader.registerCustomWidget(HeaderCardWidget)
+ uiLoader.registerCustomWidget(BodyLabel)
+
# 导入ui配置
self.ui = uiLoader.load(self.config.app_path / "resources/gui/main.ui")
self.ui.setWindowIcon(
QIcon(str(self.config.app_path / "resources/icons/AUTO_MAA.ico"))
)
- # 生成管理密钥
- if not self.config.key_path.exists():
- while True:
- self.PASSWORD, ok_pressed = QInputDialog.getText(
- self.ui,
- "请设置管理密钥",
- "未检测到管理密钥,请设置您的管理密钥:",
- QLineEdit.Password,
- "",
- )
- if ok_pressed and self.PASSWORD != "":
- self.crypto.get_PASSWORD(self.PASSWORD)
- break
- else:
- choice = QMessageBox.question(
- self.ui, "确认", "您没有输入管理密钥,确定要暂时跳过这一步吗?"
- )
- if choice == QMessageBox.Yes:
- break
-
# 初始化控件
self.main_tab: QTabWidget = self.ui.findChild(QTabWidget, "tabWidget_main")
self.main_tab.currentChanged.connect(self.change_config)
@@ -182,141 +181,144 @@ class Main(QWidget):
self.user_set: QToolBox = self.ui.findChild(QToolBox, "toolBox_userset")
self.user_set.currentChanged.connect(lambda: self.update_user_info("normal"))
- self.user_list_simple: QTableWidget = self.ui.findChild(
- QTableWidget, "tableWidget_userlist_simple"
+ self.user_list_simple: TableWidget = self.ui.findChild(
+ TableWidget, "tableWidget_userlist_simple"
)
self.user_list_simple.itemChanged.connect(
lambda item: self.change_user_Item(item, "simple")
)
- self.user_list_beta: QTableWidget = self.ui.findChild(
- QTableWidget, "tableWidget_userlist_beta"
+ self.user_list_beta: TableWidget = self.ui.findChild(
+ TableWidget, "tableWidget_userlist_beta"
)
self.user_list_beta.itemChanged.connect(
lambda item: self.change_user_Item(item, "beta")
)
- self.user_add: QPushButton = self.ui.findChild(QPushButton, "pushButton_new")
+ self.user_add: PushButton = self.ui.findChild(PushButton, "pushButton_new")
+ self.user_add.setIcon(FluentIcon.ADD_TO)
self.user_add.clicked.connect(self.add_user)
- self.user_del: QPushButton = self.ui.findChild(QPushButton, "pushButton_del")
+ self.user_del: PushButton = self.ui.findChild(PushButton, "pushButton_del")
+ self.user_del.setIcon(FluentIcon.REMOVE_FROM)
self.user_del.clicked.connect(self.del_user)
- self.user_switch: QPushButton = self.ui.findChild(
- QPushButton, "pushButton_switch"
+ self.user_switch: PushButton = self.ui.findChild(
+ PushButton, "pushButton_switch"
)
+ self.user_switch.setIcon(FluentIcon.MOVE)
self.user_switch.clicked.connect(self.switch_user)
- self.read_PASSWORD: QPushButton = self.ui.findChild(
- QPushButton, "pushButton_password"
+ self.read_PASSWORD: PushButton = self.ui.findChild(
+ PushButton, "pushButton_password"
)
+ self.read_PASSWORD.setIcon(FluentIcon.HIDE)
self.read_PASSWORD.clicked.connect(lambda: self.read("key"))
- self.refresh: QPushButton = self.ui.findChild(QPushButton, "pushButton_refresh")
+ self.refresh: PushButton = self.ui.findChild(PushButton, "pushButton_refresh")
+ self.refresh.setIcon(FluentIcon.SYNC)
self.refresh.clicked.connect(lambda: self.update_user_info("clear"))
- self.run_now: QPushButton = self.ui.findChild(QPushButton, "pushButton_runnow")
+ self.run_now: PushButton = self.ui.findChild(PushButton, "pushButton_runnow")
+ self.run_now.setIcon(FluentIcon.PLAY)
self.run_now.clicked.connect(lambda: self.maa_starter("日常代理"))
- self.check_start: QPushButton = self.ui.findChild(
- QPushButton, "pushButton_checkstart"
+ self.check_start: PushButton = self.ui.findChild(
+ PushButton, "pushButton_checkstart"
)
+ self.check_start.setIcon(FluentIcon.PLAY)
self.check_start.clicked.connect(lambda: self.maa_starter("人工排查"))
- self.maa_path: QLineEdit = self.ui.findChild(QLineEdit, "lineEdit_MAApath")
+ self.maa_path: LineEdit = self.ui.findChild(LineEdit, "lineEdit_MAApath")
self.maa_path.textChanged.connect(self.change_config)
self.maa_path.setReadOnly(True)
- self.get_maa_path: QPushButton = self.ui.findChild(
- QPushButton, "pushButton_getMAApath"
+ self.get_maa_path: PushButton = self.ui.findChild(
+ PushButton, "pushButton_getMAApath"
)
+ self.get_maa_path.setIcon(FluentIcon.FOLDER)
self.get_maa_path.clicked.connect(lambda: self.read("file_path_maa"))
- self.set_maa: QPushButton = self.ui.findChild(QPushButton, "pushButton_setMAA")
+ self.set_maa: PushButton = self.ui.findChild(PushButton, "pushButton_setMAA")
+ self.set_maa.setIcon(FluentIcon.SETTING)
self.set_maa.clicked.connect(lambda: self.maa_starter("设置MAA_全局"))
- self.routine: QSpinBox = self.ui.findChild(QSpinBox, "spinBox_routine")
+ self.routine: SpinBox = self.ui.findChild(SpinBox, "spinBox_routine")
self.routine.valueChanged.connect(self.change_config)
- self.annihilation: QSpinBox = self.ui.findChild(
- QSpinBox, "spinBox_annihilation"
- )
+ self.annihilation: SpinBox = self.ui.findChild(SpinBox, "spinBox_annihilation")
self.annihilation.valueChanged.connect(self.change_config)
- self.num: QSpinBox = self.ui.findChild(QSpinBox, "spinBox_numt")
+ self.num: SpinBox = self.ui.findChild(SpinBox, "spinBox_numt")
self.num.valueChanged.connect(self.change_config)
- self.if_self_start: QCheckBox = self.ui.findChild(
- QCheckBox, "checkBox_ifselfstart"
+ self.if_self_start: CheckBox = self.ui.findChild(
+ CheckBox, "checkBox_ifselfstart"
)
self.if_self_start.stateChanged.connect(self.change_config)
- self.if_sleep: QCheckBox = self.ui.findChild(QCheckBox, "checkBox_ifsleep")
+ self.if_sleep: CheckBox = self.ui.findChild(CheckBox, "checkBox_ifsleep")
self.if_sleep.stateChanged.connect(self.change_config)
- self.if_proxy_directly: QCheckBox = self.ui.findChild(
- QCheckBox, "checkBox_ifproxydirectly"
+ self.if_proxy_directly: CheckBox = self.ui.findChild(
+ CheckBox, "checkBox_ifproxydirectly"
)
self.if_proxy_directly.stateChanged.connect(self.change_config)
- self.if_send_mail: QCheckBox = self.ui.findChild(
- QCheckBox, "checkBox_ifsendmail"
- )
+ self.if_send_mail: CheckBox = self.ui.findChild(CheckBox, "checkBox_ifsendmail")
self.if_send_mail.stateChanged.connect(self.change_config)
- self.mail_address: QLineEdit = self.ui.findChild(
- QLineEdit, "lineEdit_mailaddress"
+ self.mail_address: LineEdit = self.ui.findChild(
+ LineEdit, "lineEdit_mailaddress"
)
self.mail_address.textChanged.connect(self.change_config)
- self.if_send_error_only: QCheckBox = self.ui.findChild(
- QCheckBox, "checkBox_ifonlyerror"
+ self.if_send_error_only: CheckBox = self.ui.findChild(
+ CheckBox, "checkBox_ifonlyerror"
)
self.if_send_error_only.stateChanged.connect(self.change_config)
- self.if_silence: QCheckBox = self.ui.findChild(QCheckBox, "checkBox_silence")
+ self.if_silence: CheckBox = self.ui.findChild(CheckBox, "checkBox_silence")
self.if_silence.stateChanged.connect(self.change_config)
- self.boss_key: QLineEdit = self.ui.findChild(QLineEdit, "lineEdit_boss")
+ self.boss_key: LineEdit = self.ui.findChild(LineEdit, "lineEdit_boss")
self.boss_key.textChanged.connect(self.change_config)
- self.if_to_tray: QCheckBox = self.ui.findChild(QCheckBox, "checkBox_iftotray")
+ self.if_to_tray: CheckBox = self.ui.findChild(CheckBox, "checkBox_iftotray")
self.if_to_tray.stateChanged.connect(self.change_config)
- self.check_update: QCheckBox = self.ui.findChild(
- QPushButton, "pushButton_check_update"
+ self.check_update: PushButton = self.ui.findChild(
+ PushButton, "pushButton_check_update"
)
+ self.check_update.setIcon(FluentIcon.UPDATE)
self.check_update.clicked.connect(self.check_version)
- self.tips: QTextBrowser = self.ui.findChild(QTextBrowser, "textBrowser_tips")
+ self.tips: TextBrowser = self.ui.findChild(TextBrowser, "textBrowser_tips")
self.tips.setOpenExternalLinks(True)
- self.run_text: QTextBrowser = self.ui.findChild(QTextBrowser, "textBrowser_run")
- self.wait_text: QTextBrowser = self.ui.findChild(
- QTextBrowser, "textBrowser_wait"
+ self.run_text: TextBrowser = self.ui.findChild(TextBrowser, "textBrowser_run")
+ self.wait_text: TextBrowser = self.ui.findChild(TextBrowser, "textBrowser_wait")
+ self.over_text: TextBrowser = self.ui.findChild(TextBrowser, "textBrowser_over")
+ self.error_text: TextBrowser = self.ui.findChild(
+ TextBrowser, "textBrowser_error"
)
- self.over_text: QTextBrowser = self.ui.findChild(
- QTextBrowser, "textBrowser_over"
- )
- self.error_text: QTextBrowser = self.ui.findChild(
- QTextBrowser, "textBrowser_error"
- )
- self.log_text: QTextBrowser = self.ui.findChild(QTextBrowser, "textBrowser_log")
+ self.log_text: TextBrowser = self.ui.findChild(TextBrowser, "textBrowser_log")
- self.start_time: List[Tuple[QCheckBox, QTimeEdit]] = []
+ self.start_time: List[Tuple[CheckBox, TimePicker]] = []
for i in range(10):
self.start_time.append(
[
- self.ui.findChild(QCheckBox, f"checkBox_t{i + 1}"),
- self.ui.findChild(QTimeEdit, f"timeEdit_{i + 1}"),
+ self.ui.findChild(CheckBox, f"checkBox_t{i + 1}"),
+ self.ui.findChild(TimePicker, f"timeEdit_{i + 1}"),
]
)
self.start_time[i][0].stateChanged.connect(self.change_config)
self.start_time[i][1].timeChanged.connect(self.change_config)
- self.change_password: QPushButton = self.ui.findChild(
- QPushButton, "pushButton_changePASSWORD"
+ self.change_password: PushButton = self.ui.findChild(
+ PushButton, "pushButton_changePASSWORD"
)
+ self.change_password.setIcon(FluentIcon.VPN)
self.change_password.clicked.connect(self.change_PASSWORD)
# 初始化线程
@@ -345,6 +347,24 @@ class Main(QWidget):
if self.config.content["Default"]["SelfSet.IfProxyDirectly"] == "True":
self.maa_starter("日常代理")
+ def check_PASSWORD(self) -> None:
+ """检查并配置管理密钥"""
+
+ if self.config.key_path.exists():
+ return None
+
+ while True:
+
+ if self.read("setkey"):
+ self.crypto.get_PASSWORD(self.PASSWORD)
+ break
+ else:
+ choice = MessageBox(
+ "确认", "您没有输入管理密钥,确定要暂时跳过这一步吗?", self.ui
+ )
+ if choice.exec():
+ break
+
def change_PASSWORD(self) -> None:
"""修改管理密钥"""
@@ -353,24 +373,30 @@ class Main(QWidget):
data = self.config.cur.fetchall()
if len(data) == 0:
- QMessageBox.information(self.ui, "验证通过", "当前无用户,验证自动通过")
+ choice = MessageBox("验证通过", "当前无用户,验证自动通过", self.ui)
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
# 获取新的管理密钥
- while True:
- PASSWORD_new = self.read("newkey")
- if PASSWORD_new == 0:
- choice = QMessageBox.question(
- self.ui,
- "确认",
- "您没有输入新的管理密钥,是否取消修改管理密钥?",
- )
- if choice == QMessageBox.Yes:
- break
- else:
- # 修改管理密钥
- self.PASSWORD = PASSWORD_new
- self.crypto.get_PASSWORD(self.PASSWORD)
- QMessageBox.information(self.ui, "操作成功", "管理密钥修改成功")
- break
+ if choice.exec():
+ while True:
+ PASSWORD_new = self.read("newkey")
+ if PASSWORD_new == None:
+ choice = MessageBox(
+ "确认",
+ "您没有输入新的管理密钥,是否取消修改管理密钥?",
+ self.ui,
+ )
+ if choice.exec():
+ break
+ else:
+ # 修改管理密钥
+ self.PASSWORD = PASSWORD_new
+ self.crypto.get_PASSWORD(self.PASSWORD)
+ choice = MessageBox("操作成功", "管理密钥修改成功", self.ui)
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ break
else:
# 验证管理密钥
if_change = True
@@ -378,18 +404,22 @@ class Main(QWidget):
if self.read("oldkey"):
# 验证旧管理密钥
if not self.crypto.check_PASSWORD(self.PASSWORD):
- QMessageBox.critical(self.ui, "错误", "管理密钥错误")
+ choice = MessageBox("错误", "管理密钥错误", self.ui)
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ pass
else:
# 获取新的管理密钥
while True:
PASSWORD_new = self.read("newkey")
- if PASSWORD_new == 0:
- choice = QMessageBox.question(
- self.ui,
+ if PASSWORD_new == None:
+ choice = MessageBox(
"确认",
"您没有输入新的管理密钥,是否取消修改管理密钥?",
+ self.ui,
)
- if choice == QMessageBox.Yes:
+ if choice.exec():
if_change = False
break
# 修改管理密钥
@@ -398,16 +428,21 @@ class Main(QWidget):
data, self.PASSWORD, PASSWORD_new
)
self.PASSWORD = PASSWORD_new
- QMessageBox.information(
- self.ui, "操作成功", "管理密钥修改成功"
+ choice = MessageBox(
+ "操作成功", "管理密钥修改成功", self.ui
)
- if_change = False
- break
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ if_change = False
+ break
else:
- choice = QMessageBox.question(
- self.ui, "确认", "您没有输入管理密钥,是否取消修改管理密钥?"
+ choice = MessageBox(
+ "确认",
+ "您没有输入管理密钥,是否取消修改管理密钥?",
+ self.ui,
)
- if choice == QMessageBox.Yes:
+ if choice.exec():
break
def update_user_info(self, operation: str) -> None:
@@ -444,7 +479,7 @@ class Main(QWidget):
# 生成表格组件
if j == 2:
- item = QComboBox()
+ item = ComboBox()
item.addItems(["官服", "B服"])
if value == "Official":
item.setCurrentIndex(0)
@@ -524,7 +559,7 @@ class Main(QWidget):
# 生成表格组件
if j in [4, 9, 10]:
- item = QComboBox()
+ item = ComboBox()
if j == 4:
item.addItems(["启用", "禁用"])
elif j in [9, 10]:
@@ -579,11 +614,11 @@ class Main(QWidget):
# 设置列表可编辑状态
if self.if_user_list_editable:
- self.user_list_simple.setEditTriggers(QTableWidget.AllEditTriggers)
- self.user_list_beta.setEditTriggers(QTableWidget.AllEditTriggers)
+ self.user_list_simple.setEditTriggers(TableWidget.AllEditTriggers)
+ self.user_list_beta.setEditTriggers(TableWidget.AllEditTriggers)
else:
- self.user_list_simple.setEditTriggers(QTableWidget.NoEditTriggers)
- self.user_list_beta.setEditTriggers(QTableWidget.NoEditTriggers)
+ self.user_list_simple.setEditTriggers(TableWidget.NoEditTriggers)
+ self.user_list_beta.setEditTriggers(TableWidget.NoEditTriggers)
# 允许GUI改变被同步到本地数据库
self.if_update_database = True
@@ -683,12 +718,15 @@ class Main(QWidget):
# 判断是否已设置管理密钥
if not self.config.key_path.exists():
- QMessageBox.critical(
- self.ui,
+ choice = MessageBox(
"错误",
"请先设置管理密钥再执行添加用户操作",
+ self.ui,
)
- return None
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ return None
# 插入预设用户数据
set_book = [
@@ -719,8 +757,11 @@ class Main(QWidget):
# 判断选择合理性
if row == -1:
- QMessageBox.critical(self.ui, "错误", "请选中一个用户后再执行删除操作")
- return None
+ choice = MessageBox("错误", "请选中一个用户后再执行删除操作", self.ui)
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ return None
# 确认待删除用户信息
self.config.cur.execute(
@@ -731,12 +772,10 @@ class Main(QWidget):
),
)
data = self.config.cur.fetchall()
- choice = QMessageBox.question(
- self.ui, "确认", f"确定要删除用户 {data[0][0]} 吗?"
- )
+ choice = MessageBox("确认", f"确定要删除用户 {data[0][0]} 吗?", self.ui)
# 删除用户
- if choice == QMessageBox.Yes:
+ if choice.exec():
# 删除所选用户
self.config.cur.execute(
"DELETE FROM adminx WHERE mode = ? AND uid = ?",
@@ -791,8 +830,11 @@ class Main(QWidget):
# 判断选择合理性
if row == -1:
- QMessageBox.critical(self.ui, "错误", "请选中一个用户后再执行切换操作")
- return None
+ choice = MessageBox("错误", "请选中一个用户后再执行切换操作", self.ui)
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ return None
# 确认待切换用户信息
self.config.cur.execute(
@@ -805,14 +847,14 @@ class Main(QWidget):
data = self.config.cur.fetchall()
mode_list = ["简洁", "高级"]
- choice = QMessageBox.question(
- self.ui,
+ choice = MessageBox(
"确认",
f"确定要将用户 {data[0][0]} 转为{mode_list[1 - self.user_set.currentIndex()]}配置模式吗?",
+ self.ui,
)
# 切换用户
- if choice == QMessageBox.Yes:
+ if choice.exec():
self.config.cur.execute("SELECT * FROM adminx WHERE True")
data = self.config.cur.fetchall()
if self.user_set.currentIndex() == 0:
@@ -886,12 +928,15 @@ class Main(QWidget):
)
return True
else:
- QMessageBox.critical(
- self.ui,
+ choice = MessageBox(
"错误",
"未选择自定义基建文件",
+ self.ui,
)
- return False
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ return False
# 获取高级用户MAA配置文件
elif info[2] in ["routine", "annihilation"]:
(
@@ -904,7 +949,7 @@ class Main(QWidget):
/ f"data/MAAconfig/{self.user_mode_list[info[0]]}/{info[1]}/{info[2]}",
)
- def change_user_Item(self, item: QTableWidget, mode):
+ def change_user_Item(self, item: TableWidget, mode):
"""将GUI中发生修改的用户配置表中的一般信息同步至本地数据库"""
# 验证能否写入本地数据库
@@ -1078,11 +1123,13 @@ class Main(QWidget):
)
self.get_maa_config(["Default"])
else:
- QMessageBox.critical(
- self.ui,
+ choice = MessageBox(
"错误",
"该路径下未找到MAA.exe或MAA配置文件,请重新设置MAA路径!",
+ self.ui,
)
+ if choice.exec():
+ pass
self.config.content["Default"][
"SelfSet.MainIndex"
@@ -1135,7 +1182,7 @@ class Main(QWidget):
self.config.content["Default"][f"TimeSet.set{i + 1}"] = "True"
else:
self.config.content["Default"][f"TimeSet.set{i + 1}"] = "False"
- time = self.start_time[i][1].time().toString("HH:mm")
+ time = self.start_time[i][1].getTime().toString("HH:mm")
self.config.content["Default"][f"TimeSet.run{i + 1}"] = time
# 将配置信息同步至本地JSON文件
@@ -1153,40 +1200,78 @@ class Main(QWidget):
def read(self, operation):
"""弹出对话框组件进行读入"""
+ class InputMessageBox(MessageBoxBase):
+ """输入对话框"""
+
+ def __init__(self, parent, title: str, content: str, mode: str):
+ super().__init__(parent)
+ self.title = SubtitleLabel(title)
+
+ if mode == "明文":
+ self.input = LineEdit()
+ elif mode == "密码":
+ self.input = PasswordLineEdit()
+
+ self.input.setPlaceholderText(content)
+ self.input.setClearButtonEnabled(True)
+
+ # 将组件添加到布局中
+ self.viewLayout.addWidget(self.title)
+ self.viewLayout.addWidget(self.input)
+
# 读入PASSWORD
if operation == "key":
- self.PASSWORD, ok_pressed = QInputDialog.getText(
- self.ui, "请输入管理密钥", "管理密钥:", QLineEdit.Password, ""
- )
- if ok_pressed and self.PASSWORD != "":
+
+ choice = InputMessageBox(self.ui, "请输入管理密钥", "管理密钥", "密码")
+ if choice.exec() and choice.input.text() != "":
+ self.PASSWORD = choice.input.text()
self.update_user_info("normal")
+
elif operation == "oldkey":
- self.PASSWORD, ok_pressed = QInputDialog.getText(
- self.ui, "请输入旧的管理密钥", "旧管理密钥:", QLineEdit.Password, ""
+
+ choice = InputMessageBox(
+ self.ui, "请输入旧的管理密钥", "旧管理密钥", "密码"
)
- if ok_pressed and self.PASSWORD != "":
+ if choice.exec() and choice.input.text() != "":
+ self.PASSWORD = choice.input.text()
return True
else:
return False
+
elif operation == "newkey":
- new_PASSWORD, ok_pressed = QInputDialog.getText(
- self.ui, "请输入新的管理密钥", "新管理密钥:", QLineEdit.Password, ""
+
+ choice = InputMessageBox(
+ self.ui, "请输入新的管理密钥", "新管理密钥", "密码"
)
- if ok_pressed and new_PASSWORD != "":
- return new_PASSWORD
+ if choice.exec() and choice.input.text() != "":
+ return choice.input.text()
else:
return None
+ elif operation == "setkey":
+
+ choice = InputMessageBox(
+ self.ui,
+ "未检测到管理密钥,请设置您的管理密钥",
+ "管理密钥",
+ "密码",
+ )
+ if choice.exec() and choice.input.text() != "":
+ self.PASSWORD = choice.input.text()
+ return True
+ else:
+ return False
+
# 读入选择
elif operation == "question_runner":
- choice = QMessageBox.question(
- self.ui,
+ choice = MessageBox(
self.MaaManager.question_title,
self.MaaManager.question_info,
+ None,
)
- if choice == QMessageBox.Yes:
+ if choice.exec():
self.MaaManager.question_choice = "Yes"
- elif choice == QMessageBox.No:
+ else:
self.MaaManager.question_choice = "No"
# 读入MAA文件目录
@@ -1334,8 +1419,11 @@ class Main(QWidget):
Path(self.config.content["Default"]["MaaSet.path"]) / "config/gui.json"
).exists()
):
- QMessageBox.critical(self.ui, "错误", "您还未正确配置MAA路径!")
- return None
+ choice = MessageBox("错误", "您还未正确配置MAA路径!", self.ui)
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ return None
self.maa_running_set(f"{mode}_开始")
@@ -1458,12 +1546,15 @@ class Main(QWidget):
err = e
time.sleep(0.1)
else:
- QMessageBox.critical(
- self.ui,
+ choice = MessageBox(
"错误",
f"获取版本信息时出错:\n{err}",
+ self.ui,
)
- return None
+ choice.cancelButton.hide()
+ choice.buttonLayout.insertStretch(1)
+ if choice.exec():
+ return None
main_version_remote = list(map(int, version_remote["main_version"].split(".")))
updater_version_remote = list(
@@ -1490,12 +1581,12 @@ class Main(QWidget):
)
# 询问是否开始版本更新
- choice = QMessageBox.question(
- self.ui,
+ choice = MessageBox(
"版本更新",
f"发现新版本:\n{main_version_info}{updater_version_info} 更新说明:\n{version_remote['announcement'].replace("\n# ","\n !").replace("\n## ","\n - ").replace("\n- ","\n · ")}\n\n是否开始更新?\n\n 注意:主程序更新时AUTO_MAA将自动关闭",
+ self.ui,
)
- if choice == QMessageBox.No:
+ if not choice.exec():
return None
# 更新更新器
@@ -1567,25 +1658,36 @@ class AUTO_MAA(QMainWindow):
self,
)
self.tray.setToolTip("AUTO_MAA")
- self.tray_menu = QMenu()
+ self.tray_menu = RoundMenu()
# 显示主界面菜单项
- show_main = self.tray_menu.addAction("显示主界面")
- show_main.triggered.connect(self.show_main)
+ self.tray_menu.addAction(
+ Action(FluentIcon.CAFE, "显示主界面", triggered=self.show_main)
+ )
+ self.tray_menu.addSeparator()
# 开始任务菜单项
- start_task_1 = self.tray_menu.addAction("运行日常代理")
- start_task_1.triggered.connect(lambda: self.start_task("日常代理"))
-
- start_task_2 = self.tray_menu.addAction("运行人工排查")
- start_task_2.triggered.connect(lambda: self.start_task("人工排查"))
-
- stop_task = self.tray_menu.addAction("中止当前任务")
- stop_task.triggered.connect(self.stop_task)
+ self.tray_menu.addActions(
+ [
+ Action(
+ FluentIcon.PLAY,
+ "运行日常代理",
+ triggered=lambda: self.start_task("日常代理"),
+ ),
+ # Action(
+ # FluentIcon.PLAY,
+ # "运行人工排查",
+ # triggered=lambda: self.start_task("人工排查"),
+ # ),
+ Action(FluentIcon.PAUSE, "中止当前任务", triggered=self.stop_task),
+ ]
+ )
+ self.tray_menu.addSeparator()
# 退出主程序菜单项
- kill = self.tray_menu.addAction("退出主程序")
- kill.triggered.connect(self.kill_main)
+ self.tray_menu.addAction(
+ Action(FluentIcon.POWER_BUTTON, "退出主程序", triggered=self.kill_main)
+ )
# 设置托盘菜单
self.tray.setContextMenu(self.tray_menu)
diff --git a/app/utils/Updater.py b/app/utils/Updater.py
index 8f50f43..86a335f 100644
--- a/app/utils/Updater.py
+++ b/app/utils/Updater.py
@@ -38,9 +38,8 @@ from PySide6.QtWidgets import (
QApplication,
QDialog,
QVBoxLayout,
- QLabel,
- QProgressBar,
)
+from qfluentwidgets import ProgressBar, BodyLabel
from PySide6.QtGui import QIcon
from PySide6.QtCore import QObject, QThread, Signal
@@ -265,10 +264,10 @@ class Updater(QObject):
# 创建垂直布局
self.Layout_v = QVBoxLayout(self.ui)
- self.info = QLabel("正在初始化", self.ui)
+ self.info = BodyLabel("正在初始化", self.ui)
self.Layout_v.addWidget(self.info)
- self.progress = QProgressBar(self.ui)
+ self.progress = ProgressBar(self.ui)
self.progress.setRange(0, 0)
self.Layout_v.addWidget(self.progress)
diff --git a/main.py b/main.py
index 0857c79..f185b0d 100644
--- a/main.py
+++ b/main.py
@@ -38,4 +38,5 @@ if __name__ == "__main__":
application = QApplication(sys.argv)
window = AUTO_MAA(config=config, notify=notify, crypto=crypto)
+ window.main.check_PASSWORD()
sys.exit(application.exec())
diff --git a/requirements.txt b/requirements.txt
index 5c175d2..b66d50a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,6 @@
plyer
PySide6
+PySide6-Fluent-Widgets[full]
psutil
pywin32
pyautogui
diff --git a/resources/gui/main.ui b/resources/gui/main.ui
index ccb3832..eb11ac9 100644
--- a/resources/gui/main.ui
+++ b/resources/gui/main.ui
@@ -39,21 +39,21 @@
-
-
-
+
新建
-
-
+
删除
-
-
+
转为
@@ -73,14 +73,14 @@
-
-
+
显示密码
-
-
+
刷新
@@ -107,7 +107,7 @@
-
-
+
用户名
@@ -191,7 +191,7 @@
-
-
+
用户名
@@ -253,7 +253,7 @@
定时执行
-
+
-
-
@@ -266,7 +266,7 @@
-
-
+
true
@@ -288,7 +288,7 @@
-
-
+
@@ -303,7 +303,7 @@
-
-
+
true
@@ -325,7 +325,7 @@
-
-
+
@@ -340,7 +340,7 @@
-
-
+
true
@@ -362,7 +362,7 @@
-
-
+
@@ -377,7 +377,7 @@
-
-
+
true
@@ -399,7 +399,7 @@
-
-
+
@@ -414,7 +414,7 @@
-
-
+
true
@@ -436,7 +436,7 @@
-
-
+
@@ -451,7 +451,7 @@
-
-
+
true
@@ -473,7 +473,7 @@
-
-
+
@@ -488,7 +488,7 @@
-
-
+
true
@@ -510,7 +510,7 @@
-
-
+
@@ -525,7 +525,7 @@
-
-
+
true
@@ -547,7 +547,7 @@
-
-
+
@@ -562,7 +562,7 @@
-
-
+
true
@@ -584,7 +584,7 @@
-
-
+
@@ -599,7 +599,7 @@
-
-
+
true
@@ -621,7 +621,7 @@
-
-
+
@@ -651,7 +651,7 @@
-
-
-
+
调度器
@@ -671,14 +671,14 @@
-
-
+
开始排查
-
-
+
立即执行
@@ -706,7 +706,7 @@
-
-
+
@@ -728,7 +728,7 @@
-
-
+
@@ -750,7 +750,7 @@
-
-
+
@@ -772,7 +772,7 @@
-
-
+
@@ -796,7 +796,7 @@
-
-
+
@@ -816,7 +816,7 @@
MAA设置
-
+
-
@@ -827,17 +827,17 @@
-
-
+
MAA路径
-
-
+
-
-
+
浏览
@@ -857,7 +857,7 @@
-
-
+
设置MAA
@@ -874,8 +874,8 @@
执行限制
-
-
-
+
+
-
QFrame::Shape::StyledPanel
@@ -885,7 +885,7 @@
-
-
+
日常限制
@@ -905,11 +905,11 @@
-
-
+
- 100
- 0
+ 140
+ 30
@@ -930,7 +930,7 @@
- -
+
-
QFrame::Shape::StyledPanel
@@ -940,7 +940,7 @@
-
-
+
剿灭限制
@@ -960,11 +960,11 @@
-
-
+
- 100
- 0
+ 140
+ 30
@@ -985,7 +985,7 @@
- -
+
-
QFrame::Shape::StyledPanel
@@ -995,7 +995,7 @@
-
-
+
运行失败重试次数上限
@@ -1015,11 +1015,11 @@
-
-
+
- 100
- 0
+ 140
+ 30
@@ -1072,7 +1072,7 @@
-
-
+
后台静默代理
@@ -1092,7 +1092,7 @@
-
-
+
安卓模拟器老板键
@@ -1124,7 +1124,7 @@
-
-
+
通过邮件通知结果
@@ -1144,14 +1144,14 @@
-
-
+
收信邮箱地址
-
-
+
仅推送异常信息
@@ -1170,7 +1170,7 @@
-
-
+
最小化到托盘
@@ -1202,7 +1202,7 @@
-
-
+
启动AUTO_MAA后直接代理
@@ -1247,7 +1247,7 @@
-
-
+
开机自动启动AUTO_MAA
@@ -1279,7 +1279,7 @@
-
-
+
AUTO_MAA启动时禁止电脑休眠
@@ -1350,7 +1350,7 @@
-
-
+
修改管理密钥
@@ -1408,7 +1408,7 @@
-
-
+
检查版本更新
@@ -1440,7 +1440,7 @@
-
-
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
@@ -1451,6 +1451,8 @@ li.checked::marker { content: "\2612"; }
</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">致用户:</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> 这是AUTO_MAA_v4.2.0-beta.1,项目初步进行界面美化。希望大家喜欢这个新年礼物!</p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> 使用本程序前,请先仔细阅读README.md。</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> 对于B服用户,由于我们无权替您同意用户协议,若出现用户协议弹窗,您需要自行完成确认,否则可能造成MAA卡死,代理任务失败。</p>
@@ -1468,7 +1470,7 @@ li.checked::marker { content: "\2612"; }
-
-
+
注意:在设置页执行的所有更改,不会对正在执行的任务生效;正在执行任务时,用户管理页无法编辑。
@@ -1496,6 +1498,48 @@ li.checked::marker { content: "\2612"; }
+
+
+ PushButton
+ QPushButton
+
+
+
+ TimePicker
+ QTimeEdit
+
+
+
+ TableWidget
+ QTableWidget
+
+
+
+ LineEdit
+ QLineEdit
+
+
+
+ SpinBox
+ QSpinBox
+
+
+
+ CheckBox
+ QCheckBox
+
+
+
+ TextBrowser
+ QTextBrowser
+
+
+
+ BodyLabel
+ QLabel
+
+
+
diff --git a/resources/version.json b/resources/version.json
index 6d64931..fbe690f 100644
--- a/resources/version.json
+++ b/resources/version.json
@@ -1,7 +1,7 @@
{
- "main_version": "4.2.0.0",
- "updater_version": "1.1.0.0",
- "announcement": "\n## 新增功能\n- 提供完整打包代码\n## 修复BUG\n- 同步MAA`v5.11.1`的字段修改\n- 清除自动化中无效的整合流程\n## 程序优化\n- 调整项目结构,模块化各功能组件\n- 改用`nuitka`编译,压缩软件体积,提升运行速度",
+ "main_version": "4.2.0.1",
+ "updater_version": "1.1.0.1",
+ "announcement": "\n## 新增功能\n- 初步引入`qfluentwidgets`,UI界面美化",
"proxy_list":[
"",
"https://gitproxy.click/",