39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
|
|
# encoding:utf-8
|
||
|
|
from PyQt6.QtCore import Qt
|
||
|
|
from PyQt6.QtWidgets import QSystemTrayIcon
|
||
|
|
from qfluentwidgets import Action, InfoBar, InfoBarPosition, MessageBox, SystemTrayMenu
|
||
|
|
|
||
|
|
|
||
|
|
class SystemTrayIcon(QSystemTrayIcon):
|
||
|
|
|
||
|
|
def __init__(self, parent=None):
|
||
|
|
super().__init__(parent=parent)
|
||
|
|
self.setIcon(parent.windowIcon())
|
||
|
|
self.setToolTip("-六棱光界-")
|
||
|
|
|
||
|
|
self.menu = SystemTrayMenu(parent=parent)
|
||
|
|
self.menu.addActions(
|
||
|
|
[
|
||
|
|
Action("🙂 显示界面", triggered=self.showSofware),
|
||
|
|
Action("🙃 退出软件", triggered=self.exitSoftware),
|
||
|
|
]
|
||
|
|
)
|
||
|
|
self.setContextMenu(self.menu)
|
||
|
|
|
||
|
|
|
||
|
|
def exitSoftware(self):
|
||
|
|
self.parent().window().showNormal()
|
||
|
|
InfoBar.info("提示","你正在进行退出操作,请返回软件",Qt.Orientation.Horizontal,True,5000,InfoBarPosition.BOTTOM_RIGHT,InfoBar.desktopView())
|
||
|
|
w = MessageBox(
|
||
|
|
title="提示",
|
||
|
|
content="确定退出软件吗?正在进行的任务将会取消",
|
||
|
|
parent=self.parent().window(),
|
||
|
|
)
|
||
|
|
w.yesButton.setText("确定退出")
|
||
|
|
w.cancelButton.setText("算了我想想")
|
||
|
|
if w.exec():
|
||
|
|
self.parent().window().close()
|
||
|
|
|
||
|
|
def showSofware(self):
|
||
|
|
self.parent().window().showNormal()
|