Skip to content

The only downloader you need. 下载器的集大成者。

feat(tray): 托盘菜单新增新建任务与设置 #1002

XiaoYouChR0004b466d67f
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 380191ce..b6e3427a 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -212,14 +212,14 @@ def startApp(application, primaryInstance, isSilent=False):
if sys.platform == "darwin":
from app.view.shell.mac_status_item import MacStatusItem
from app.view.shell.dock import setupDock
- statusItem = MacStatusItem(taskService)
+ statusItem = MacStatusItem(taskService, show)
statusItem.show()
speedMeter.speedChanged.connect(statusItem.setSpeed)
application.statusItem = statusItem
setupDock(speedMeter, taskService)
else:
from app.view.shell.tray import SystemTrayIcon
- tray = SystemTrayIcon(taskService, speedMeter, QIcon(":/image/logo.png"), parent=application)
+ tray = SystemTrayIcon(taskService, speedMeter, show, QIcon(":/image/logo.png"), parent=application)
tray.show()
if sys.platform == "linux":
from app.platform.taskbar import setLauncherProgress
diff --git a/app/assets/i18n/gd3.en_US.ts b/app/assets/i18n/gd3.en_US.ts
index 5f0e6d10..cde1df5f 100644
--- a/app/assets/i18n/gd3.en_US.ts
+++ b/app/assets/i18n/gd3.en_US.ts
@@ -5979,26 +5979,38 @@ Data will be copied to new location and the app will then exit. Please manually
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>Dashboard</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>New Task</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>Start All</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>Pause All</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>Settings</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>Exit</translation>
</message>
diff --git a/app/assets/i18n/gd3.es_ES.ts b/app/assets/i18n/gd3.es_ES.ts
index 81d382bb..7598cc98 100644
--- a/app/assets/i18n/gd3.es_ES.ts
+++ b/app/assets/i18n/gd3.es_ES.ts
@@ -4932,26 +4932,38 @@ Data will be copied to new location and the program will then exit. Por favor ma
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>Panel</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>Nueva tarea</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>Iniciar todo</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>Pausar todo</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>Ajustes</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>Salir</translation>
</message>
diff --git a/app/assets/i18n/gd3.ja_JP.ts b/app/assets/i18n/gd3.ja_JP.ts
index b5d6f3fe..4bd9a4a9 100644
--- a/app/assets/i18n/gd3.ja_JP.ts
+++ b/app/assets/i18n/gd3.ja_JP.ts
@@ -6024,26 +6024,38 @@ FFmpeg: {2}</translation>
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>ダッシュボード</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>新規タスク</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>すべて開始</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>すべて一時停止</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>設定</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>終了</translation>
</message>
diff --git a/app/assets/i18n/gd3.pt_BR.ts b/app/assets/i18n/gd3.pt_BR.ts
index 2d63ec1d..7ec0d3f3 100644
--- a/app/assets/i18n/gd3.pt_BR.ts
+++ b/app/assets/i18n/gd3.pt_BR.ts
@@ -5224,26 +5224,38 @@ Os dados serão copiados para o novo local e o programa será encerrado. Reabra
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>Painel</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>Nova tarefa</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>Iniciar tudo</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>Pausar tudo</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>Configurações</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>Sair do programa</translation>
</message>
diff --git a/app/assets/i18n/gd3.ru_RU.ts b/app/assets/i18n/gd3.ru_RU.ts
index 103c513d..102ccebd 100644
--- a/app/assets/i18n/gd3.ru_RU.ts
+++ b/app/assets/i18n/gd3.ru_RU.ts
@@ -6024,26 +6024,38 @@ FFmpeg: {2}</translation>
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>Панель</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>Новая</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>Запустить все</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>Пауза для всех</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>Настройки</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>Выйти</translation>
</message>
diff --git a/app/assets/i18n/gd3.zh_CN.ts b/app/assets/i18n/gd3.zh_CN.ts
index ce092337..d9629c8d 100644
--- a/app/assets/i18n/gd3.zh_CN.ts
+++ b/app/assets/i18n/gd3.zh_CN.ts
@@ -4475,26 +4475,38 @@ http://example.com/{mp4,mkv}/video</source>
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation type="unfinished"></translation>
</message>
diff --git a/app/assets/i18n/gd3.zh_HK.ts b/app/assets/i18n/gd3.zh_HK.ts
index 35fca43e..bf2842e3 100644
--- a/app/assets/i18n/gd3.zh_HK.ts
+++ b/app/assets/i18n/gd3.zh_HK.ts
@@ -6028,26 +6028,38 @@ FFmpeg: {2}</translation>
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>儀錶板</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>新增任務</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>全部開始</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>全部暫停</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>設定</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>退出程式</translation>
</message>
diff --git a/app/assets/i18n/gd3.zh_TW.ts b/app/assets/i18n/gd3.zh_TW.ts
index 21aeec43..e6eb185c 100644
--- a/app/assets/i18n/gd3.zh_TW.ts
+++ b/app/assets/i18n/gd3.zh_TW.ts
@@ -6028,26 +6028,38 @@ FFmpeg: {2}</translation>
<context>
<name>SystemTrayIcon</name>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="97"/>
- <location filename="../../view/shell/tray.py" line="181"/>
+ <location filename="../../view/shell/mac_status_item.py" line="105"/>
+ <location filename="../../view/shell/tray.py" line="183"/>
<source>仪表盘</source>
<translation>儀表盤</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="98"/>
- <location filename="../../view/shell/tray.py" line="183"/>
+ <location filename="../../view/shell/mac_status_item.py" line="106"/>
+ <location filename="../../view/shell/tray.py" line="185"/>
+ <source>新建任务</source>
+ <translation>新建任務</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="107"/>
+ <location filename="../../view/shell/tray.py" line="187"/>
<source>全部开始</source>
<translation>全部開始</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="99"/>
- <location filename="../../view/shell/tray.py" line="185"/>
+ <location filename="../../view/shell/mac_status_item.py" line="108"/>
+ <location filename="../../view/shell/tray.py" line="189"/>
<source>全部暂停</source>
<translation>全部暫停</translation>
</message>
<message>
- <location filename="../../view/shell/mac_status_item.py" line="100"/>
- <location filename="../../view/shell/tray.py" line="188"/>
+ <location filename="../../view/shell/mac_status_item.py" line="109"/>
+ <location filename="../../view/shell/tray.py" line="191"/>
+ <source>设置</source>
+ <translation>設定</translation>
+ </message>
+ <message>
+ <location filename="../../view/shell/mac_status_item.py" line="111"/>
+ <location filename="../../view/shell/tray.py" line="194"/>
<source>退出程序</source>
<translation>結束程式</translation>
</message>
diff --git a/app/view/shell/mac_status_item.py b/app/view/shell/mac_status_item.py
index 4125df86..b2ed129a 100644
--- a/app/view/shell/mac_status_item.py
+++ b/app/view/shell/mac_status_item.py
@@ -21,7 +21,8 @@ from Foundation import NSData
from app.config.cfg import cfg
from app.format import toReadableSize
-from app.signal_bus import signalBus
+from app.view.pages.setting_page import SettingPage
+from app.view.pages.task_page import TaskPage
class MenuTarget(NSObject):
@@ -40,10 +41,13 @@ class MenuTarget(NSObject):
self.owner._statusItem.setMenu_(self.owner._menu)
self.owner._button.performClick_(None)
else:
- signalBus.activationRequested.emit()
+ self.owner._show()
def showDashboard_(self, sender):
- signalBus.activationRequested.emit()
+ self.owner._show().showPage(TaskPage)
+
+ def newTask_(self, sender):
+ self.owner._show().addUrls([])
def startAll_(self, sender):
self.owner._taskService.startAll()
@@ -51,6 +55,9 @@ class MenuTarget(NSObject):
def pauseAll_(self, sender):
self.owner._taskService.pauseAll()
+ def openSettings_(self, sender):
+ self.owner._show().showPage(SettingPage)
+
def quitApp_(self, sender):
QApplication.instance().quit()
@@ -58,8 +65,9 @@ class MenuTarget(NSObject):
class MacStatusItem:
ICON_SIZE = 16
- def __init__(self, taskService):
+ def __init__(self, taskService, show):
self._taskService = taskService
+ self._show = show
self._statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(
NSVariableStatusItemLength
)
@@ -71,8 +79,8 @@ class MacStatusItem:
self._target.owner = self
self._menu = self._buildMenu()
- self._startAllItem = self._menu.itemAtIndex_(1)
- self._pauseAllItem = self._menu.itemAtIndex_(2)
+ self._startAllItem = self._menu.itemAtIndex_(2)
+ self._pauseAllItem = self._menu.itemAtIndex_(3)
self._button.setTarget_(self._target)
self._button.setAction_("onClicked:")
@@ -93,12 +101,19 @@ class MacStatusItem:
menu = NSMenu.alloc().init()
menu.setAutoenablesItems_(False)
menu.setDelegate_(self._target)
- for title, selector, key, symbol in (
+ for entry in (
(QCoreApplication.translate("SystemTrayIcon", "仪表盘"), "showDashboard:", "", "gauge.open.with.lines.needle.33percent"),
+ (QCoreApplication.translate("SystemTrayIcon", "新建任务"), "newTask:", "", "plus"),
(QCoreApplication.translate("SystemTrayIcon", "全部开始"), "startAll:", "", "play.fill"),
(QCoreApplication.translate("SystemTrayIcon", "全部暂停"), "pauseAll:", "", "pause.fill"),
+ (QCoreApplication.translate("SystemTrayIcon", "设置"), "openSettings:", "", "gearshape"),
+ None,
(QCoreApplication.translate("SystemTrayIcon", "退出程序"), "quitApp:", "q", "power"),
):
+ if entry is None:
+ menu.addItem_(NSMenuItem.separatorItem())
+ continue
+ title, selector, key, symbol = entry
item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(title, selector, key)
item.setTarget_(self._target)
image = NSImage.imageWithSystemSymbolName_accessibilityDescription_(symbol, None)
diff --git a/app/view/shell/tray.py b/app/view/shell/tray.py
index 7f82468d..1a4c3a00 100644
--- a/app/view/shell/tray.py
+++ b/app/view/shell/tray.py
@@ -12,7 +12,8 @@ from qfluentwidgets import (
)
from app.format import toReadableSize
-from app.signal_bus import signalBus
+from app.view.pages.setting_page import SettingPage
+from app.view.pages.task_page import TaskPage
class GhostIcon(FluentIconBase, Enum):
@@ -171,19 +172,24 @@ else:
class SystemTrayIcon(QSystemTrayIcon):
NAME = "Ghost Downloader"
- def __init__(self, taskService, speedMeter, icon: QIcon, parent=None):
+ def __init__(self, taskService, speedMeter, show, icon: QIcon, parent=None):
super().__init__(icon, parent)
self._taskService = taskService
self._speedMeter = speedMeter
+ self._show = show
self.setToolTip(self.NAME)
self._menu = TrayMenu()
self._menu.addAction(Action(GhostIcon.GHOST, self.tr("仪表盘"), self._menu,
- triggered=lambda: signalBus.activationRequested.emit()))
+ triggered=lambda: self._show().showPage(TaskPage)))
+ self._menu.addAction(Action(FluentIcon.ADD, self.tr("新建任务"), self._menu,
+ triggered=lambda: self._show().addUrls([])))
self._menu.addAction(Action(FluentIcon.PLAY, self.tr("全部开始"), self._menu,
triggered=self._taskService.startAll))
self._menu.addAction(Action(FluentIcon.PAUSE, self.tr("全部暂停"), self._menu,
triggered=self._taskService.pauseAll))
+ self._menu.addAction(Action(FluentIcon.SETTING, self.tr("设置"), self._menu,
+ triggered=lambda: self._show().showPage(SettingPage)))
self._menu.addSeparator()
self._menu.addAction(Action(FluentIcon.CLOSE, self.tr("退出程序"), self._menu,
triggered=QApplication.instance().quit))
@@ -195,7 +201,7 @@ class SystemTrayIcon(QSystemTrayIcon):
def _onActivated(self, reason: QSystemTrayIcon.ActivationReason) -> None:
if reason == QSystemTrayIcon.ActivationReason.Trigger:
- signalBus.activationRequested.emit()
+ self._show()
def _onSpeedChanged(self, speed: int) -> None:
if speed > 0:
diff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.py
index 447ca39b..9c31fa9e 100644
--- a/app/view/windows/main_window.py
+++ b/app/view/windows/main_window.py
@@ -160,7 +160,7 @@ class MainWindow(MSFluentWindow):
)
self._addPage(SettingPage, FluentIcon.SETTING, self.tr("设置"),
NavigationItemPosition.BOTTOM)
- self._showPage(TaskPage)
+ self.showPage(TaskPage)
def setupPacks(self) -> None:
for PageClass in self._featureService.pages():
@@ -184,10 +184,10 @@ class MainWindow(MSFluentWindow):
position: NavigationItemPosition) -> None:
self.navigationInterface.addItem(
routeKey=pageClass.__name__, icon=icon, text=text,
- onClick=lambda: self._showPage(pageClass), position=position,
+ onClick=lambda: self.showPage(pageClass), position=position,
)
- def _showPage(self, pageClass: type[QWidget]) -> None:
+ def showPage(self, pageClass: type[QWidget]) -> None:
routeKey = pageClass.__name__
page = self._pages.get(routeKey)
if page is None:
@@ -342,7 +342,7 @@ class MainWindow(MSFluentWindow):
parent=self,
)
settingButton = PushButton(FluentIcon.SETTING, self.tr("前往设置"))
- settingButton.clicked.connect(lambda: (infoBar.close(), self._showPage(SettingPage)))
+ settingButton.clicked.connect(lambda: (infoBar.close(), self.showPage(SettingPage)))
infoBar.addWidget(settingButton)
infoBar.show()