图标优化;添加最小化到托盘功能;更新器摆脱UI文件限制

This commit is contained in:
DLmaster
2024-11-27 00:04:37 +08:00
parent 3e17d94904
commit b04df40b7d
9 changed files with 213 additions and 139 deletions

View File

@@ -83,12 +83,10 @@ jobs:
- name: Create Zip
id: create_zip
run: |
move gui\ui\updater.ui .\
move gui\ico\AUTO_MAA_Updater.ico .\
Compress-Archive -Path gui,res,AUTO_MAA.py,Updater.py,package.py,dist/AUTO_MAA.exe,requirements.txt,README.md,LICENSE -DestinationPath AUTO_MAA_${{ env.AUTO_MAA_version }}.zip
del gui\ui\main.ui
del gui\ico\AUTO_MAA.ico
move updater.ui gui\ui
move AUTO_MAA_Updater.ico gui\ico
Compress-Archive -Path gui,dist/Updater.exe -DestinationPath Updater_${{ env.updater_version }}.zip
- name: Upload Artifact

View File

@@ -29,6 +29,8 @@ from PySide6.QtWidgets import (
QWidget,
QMainWindow,
QApplication,
QSystemTrayIcon,
QMenu,
QInputDialog,
QFileDialog,
QMessageBox,
@@ -45,7 +47,7 @@ from PySide6.QtWidgets import (
QTextBrowser,
)
from PySide6.QtUiTools import QUiLoader
from PySide6.QtGui import QIcon
from PySide6.QtGui import QIcon, QCloseEvent
from PySide6 import QtCore
from functools import partial
from plyer import notification
@@ -1263,6 +1265,8 @@ class Main(QWidget):
self.mail_address = self.ui.findChild(QLineEdit, "lineEdit_mailaddress")
self.mail_address.textChanged.connect(self.change_config)
self.show_tray = self.ui.findChild(QPushButton, "pushButton_show_tray")
self.check_update = self.ui.findChild(QPushButton, "pushButton_check_update")
self.check_update.clicked.connect(self.check_version)
@@ -2641,8 +2645,9 @@ class Main(QWidget):
class AUTO_MAA(QMainWindow):
def __init__(self):
super().__init__()
super(AUTO_MAA, self).__init__()
self.main = Main()
self.setCentralWidget(self.main.ui)
@@ -2656,7 +2661,53 @@ class AUTO_MAA(QMainWindow):
)
self.setGeometry(location[0], location[1], size[0], size[1])
def closeEvent(self, event):
# 设置系统托盘图标
self.tray = QSystemTrayIcon(
QIcon(f"{self.main.app_path}/gui/ico/AUTO_MAA.ico"), self
)
self.tray_menu = QMenu()
self.main.show_tray.clicked.connect(self.show_tray)
# 显示主界面动作
show_main = self.tray_menu.addAction("显示主界面")
show_main.triggered.connect(self.show_main)
# 开始任务动作
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("人工排查"))
# 退出动作
kill = self.tray_menu.addAction("退出主程序")
kill.triggered.connect(self.kill_main)
self.tray.setContextMenu(self.tray_menu)
self.tray.activated.connect(self.on_tray_activated)
def show_tray(self):
self.hide()
self.tray.show()
def show_main(self):
self.show()
self.tray.hide()
def on_tray_activated(self, reason):
if reason == QSystemTrayIcon.DoubleClick:
self.show_main()
def start_task(self, mode):
if not self.main.MainTimer.is_maa_run:
self.main.maa_starter(mode)
def kill_main(self):
self.close()
app.quit()
def closeEvent(self, event: QCloseEvent):
"""清理残余进程"""
# 保存窗口最终大小与位置

View File

@@ -34,14 +34,13 @@ import subprocess
from PySide6.QtWidgets import (
QApplication,
QDialog,
QVBoxLayout,
QLabel,
QProgressBar,
)
from PySide6.QtGui import QIcon
from PySide6.QtCore import QObject, QThread, Signal
from PySide6.QtUiTools import QUiLoader
uiLoader = QUiLoader()
class UpdateProcess(QThread):
@@ -136,15 +135,20 @@ class Updater(QObject):
def __init__(self, app_path, name, download_url, version):
super().__init__()
self.ui = uiLoader.load(f"{app_path}/gui/ui/updater.ui")
self.ui = QDialog()
self.ui.setWindowTitle("AUTO_MAA更新器")
self.ui.resize(500, 70)
self.ui.setWindowIcon(QIcon(f"{app_path}/gui/ico/AUTO_MAA_Updater.ico"))
self.info = self.ui.findChild(QLabel, "label")
self.info.setText("正在初始化")
# 创建垂直布局
self.Layout_v = QVBoxLayout(self.ui)
self.progress = self.ui.findChild(QProgressBar, "progressBar")
self.info = QLabel("正在初始化", self.ui)
self.Layout_v.addWidget(self.info)
self.progress = QProgressBar(self.ui)
self.progress.setRange(0, 0)
self.Layout_v.addWidget(self.progress)
self.update_process = UpdateProcess(app_path, name, download_url, version)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -189,8 +189,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1156</width>
<height>546</height>
<width>98</width>
<height>74</height>
</rect>
</property>
<attribute name="label">
@@ -1056,19 +1056,6 @@
<string>AUTO_MAA设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="1">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>231</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame_routine_3">
<property name="frameShape">
@@ -1101,37 +1088,18 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame_routine_4">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QCheckBox" name="checkBox_ifproxydirectly">
<property name="text">
<string>启动AUTO_MAA后直接代理</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</spacer>
</item>
<item row="0" column="2">
<widget class="QFrame" name="frame_routine_2">
@@ -1178,20 +1146,145 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<item row="1" column="0">
<widget class="QFrame" name="frame_routine_4">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QCheckBox" name="checkBox_ifproxydirectly">
<property name="text">
<string>启动AUTO_MAA后直接代理</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>231</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<item row="1" column="2" colspan="2">
<widget class="QFrame" name="frame_routine_5">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_22" stretch="0,1,3">
<item>
<widget class="QCheckBox" name="checkBox_ifsendmail">
<property name="text">
<string>通过邮件通知结果</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mailaddress"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame_show_tray">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_show_tray">
<property name="text">
<string>最小化到托盘</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>311</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QFrame" name="frame_check_update">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
@@ -1236,54 +1329,19 @@
</layout>
</widget>
</item>
<item row="3" column="1">
<spacer name="horizontalSpacer_12">
<item row="2" column="3">
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>311</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2">
<widget class="QFrame" name="frame_routine_5">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_22" stretch="0,1,3">
<item>
<widget class="QCheckBox" name="checkBox_ifsendmail">
<property name="text">
<string>通过邮件通知结果</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mailaddress"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@@ -1325,8 +1383,6 @@ li.checked::marker { content: &quot;\2612&quot;; }
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; 对于B服用户由于我们无权替您同意用户协议若出现用户协议弹窗您需要自行完成确认否则可能造成MAA卡死代理任务失败。&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; 老用户请务必备份原有数据,此次更新的代码改动较大,可能有数据遗失的风险。&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; 由于用户与项目贡献者的稀缺,我们无法确保正式版足够完善,还望谅解。&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; 当遇到严重漏洞,请先确保当前为最新版本。&lt;/p&gt;

View File

@@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>61</height>
</rect>
</property>
<property name="windowTitle">
<string>AUTO_MAA更新器</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -1,7 +1,7 @@
{
"main_version": "4.1.2.4",
"main_version": "4.1.2.5",
"main_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2_beta/AUTO_MAA_v4.1.2_beta.zip",
"updater_version": "1.0.4.0",
"updater_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2_beta/Updater_v1.0.4.zip",
"announcement": "\n## 新增功能\n- 记忆窗口位置\n- 邮件通知功能上线\n## 修复BUG\n- 解决程序启动后无法设置MAA的问题\n## 程序优化\n- 优化`MaaRunner`初始化流程\n- 合并MAA启动器配置流程"
"updater_version": "1.0.5.0",
"updater_download_url": "https://ghp.ci/https://github.com/DLmaster361/AUTO_MAA/releases/download/v4.1.2_beta/Updater_v1.0.5.zip",
"announcement": "\n## 新增功能\n- 记忆窗口位置\n- 邮件通知功能上线\n- 添加最小化到托盘功能\n## 修复BUG\n- 暂无\n## 程序优化\n- 优化`MaaRunner`初始化流程\n- 合并MAA启动器配置流程\n- 修复ico文件\n- Updater.exe不再依赖.ui文件"
}