mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-14 01:59:26 +03:00
Expose application UI accessors
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -23,7 +23,11 @@ from Furious.Controllers.ConnectionController import (
|
||||
ConnectionError,
|
||||
ConnectionState,
|
||||
)
|
||||
from Furious.Frozenlib import APP, AppConnectionController, AppSettings
|
||||
from Furious.Frozenlib import (
|
||||
AppConnectionController,
|
||||
AppSettings,
|
||||
AppSystemTray,
|
||||
)
|
||||
from Furious.Qt import AppQAction, AppQMessageBox, bootstrapIcon
|
||||
from Furious.Qt import gettext as _
|
||||
from Furious.Widget.ConnectionProgressWidget import ConnectionProgressWidget
|
||||
@@ -112,7 +116,7 @@ class ConnectAction(AppQAction):
|
||||
def showNotification(message: str):
|
||||
"""Present a controller notification through the system tray."""
|
||||
try:
|
||||
APP().systemTray.showMessage(message)
|
||||
AppSystemTray().showMessage(message)
|
||||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class ShowHomePageAction(AppQAction):
|
||||
|
||||
def triggeredCallback(self, checked):
|
||||
"""Handle activation of the action."""
|
||||
mainWindow = APP().mainWindow
|
||||
mainWindow = AppMainWindow()
|
||||
|
||||
if mainWindow.isMinimized():
|
||||
mainWindow.showNormal()
|
||||
|
||||
@@ -75,7 +75,7 @@ def importURIFromClipboard(clipboard: str):
|
||||
if not factory.isValid():
|
||||
showMBoxImportError(clipboard)
|
||||
else:
|
||||
APP().mainWindow.appendNewItemByFactory(factory)
|
||||
AppMainWindow().appendNewItemByFactory(factory)
|
||||
|
||||
mbox = MBoxImportSuccess(icon=AppQMessageBox.Icon.Information)
|
||||
mbox.remark = factory.itemRemark
|
||||
@@ -91,7 +91,7 @@ def importURIs(*uris, failureCallback: Union[Callable[[], None], None] = None):
|
||||
dialog = ImportURIsProgressDialog(
|
||||
uris,
|
||||
failureCallback=failureCallback,
|
||||
parent=getattr(APP(), 'mainWindow', None),
|
||||
parent=AppMainWindow(),
|
||||
)
|
||||
dialog.open()
|
||||
|
||||
@@ -104,7 +104,7 @@ def importURIs(*uris, failureCallback: Union[Callable[[], None], None] = None):
|
||||
factory = profileFromAny(uri.strip())
|
||||
|
||||
if factory.isValid():
|
||||
APP().mainWindow.appendNewItemByFactory(factory)
|
||||
AppMainWindow().appendNewItemByFactory(factory)
|
||||
|
||||
imported.append(factory.itemRemark)
|
||||
|
||||
@@ -252,7 +252,7 @@ class ImportURIsProgressDialog(AppQDialog):
|
||||
|
||||
self.currentRemark = self.limitedRemark(remark)
|
||||
|
||||
APP().mainWindow.appendNewItemByFactory(factory)
|
||||
AppMainWindow().appendNewItemByFactory(factory)
|
||||
|
||||
self.imported.append(remark)
|
||||
else:
|
||||
@@ -432,7 +432,7 @@ class ImportFromFileAction(AppQAction):
|
||||
factory = profileFromAny(plainText, remark=os.path.basename(filename))
|
||||
|
||||
if factory.isValid():
|
||||
APP().mainWindow.appendNewItemByFactory(factory)
|
||||
AppMainWindow().appendNewItemByFactory(factory)
|
||||
|
||||
mbox = MBoxImportSuccess(icon=AppQMessageBox.Icon.Information)
|
||||
mbox.remark = factory.itemRemark
|
||||
|
||||
@@ -238,7 +238,7 @@ class TrayIcon(
|
||||
def handleActivated(self, reason):
|
||||
"""Handle activated."""
|
||||
if reason == QSystemTrayIcon.ActivationReason.DoubleClick:
|
||||
APP().mainWindow.show()
|
||||
AppMainWindow().show()
|
||||
|
||||
def setCustomToolTip(self):
|
||||
"""Set custom tool tip."""
|
||||
|
||||
@@ -111,11 +111,11 @@ class SettingsController:
|
||||
|
||||
try:
|
||||
if enabled:
|
||||
APP().systemTray.setMonochromeIcon()
|
||||
AppSystemTray().setMonochromeIcon()
|
||||
elif AppConnectionController().isConnected():
|
||||
APP().systemTray.setConnectedIcon()
|
||||
AppSystemTray().setConnectedIcon()
|
||||
else:
|
||||
APP().systemTray.setDisconnectedIcon()
|
||||
AppSystemTray().setDisconnectedIcon()
|
||||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
@@ -182,7 +182,7 @@ class SettingsController:
|
||||
cls._setBinary(METRICS_COLLECTION_SETTING, enabled)
|
||||
|
||||
try:
|
||||
APP().mainWindow.trafficStatsManager.setCollectionEnabled(enabled)
|
||||
AppMainWindow().trafficStatsManager.setCollectionEnabled(enabled)
|
||||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
@@ -193,8 +193,8 @@ class SettingsController:
|
||||
|
||||
try:
|
||||
if enabled:
|
||||
APP().mainWindow.showTabAndSpaces()
|
||||
AppMainWindow().showTabAndSpaces()
|
||||
else:
|
||||
APP().mainWindow.hideTabAndSpaces()
|
||||
AppMainWindow().hideTabAndSpaces()
|
||||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
Vendored
+15
-13
@@ -424,7 +424,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Invalid server configuration": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection",
|
||||
"Furious.Controllers.ConnectionController",
|
||||
"Furious.Window.TextEditorWindow"
|
||||
],
|
||||
"RU": "Неверная конфигурация сервера",
|
||||
@@ -867,7 +867,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Unable to connect": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection",
|
||||
"Furious.Controllers.ConnectionController",
|
||||
"Furious.Qt.QtWidgets"
|
||||
],
|
||||
"RU": "Не удается подключиться",
|
||||
@@ -876,7 +876,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Server configuration empty. Please configure your server first": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Конфигурация сервера пуста. Пожалуйста, сначала настройте свой сервер",
|
||||
"ZH": "服务器配置为空。请先配置服务器",
|
||||
@@ -884,7 +884,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Connected": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Подключен",
|
||||
"ZH": "已连接",
|
||||
@@ -892,7 +892,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Unknown error": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Неизвестная ошибка",
|
||||
"ZH": "未知错误",
|
||||
@@ -900,7 +900,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Failed to start core": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Сбой при запуске ядра",
|
||||
"ZH": "内核启动失败",
|
||||
@@ -908,7 +908,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Core terminated unexpectedly": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Неожиданное завершение работы ядра",
|
||||
"ZH": "内核意外终止",
|
||||
@@ -916,7 +916,8 @@ TRANSLATION = {
|
||||
},
|
||||
"Disconnected": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController",
|
||||
"Furious.Widget.ServerTableView"
|
||||
],
|
||||
"RU": "Отключен",
|
||||
"ZH": "已断开",
|
||||
@@ -932,7 +933,8 @@ TRANSLATION = {
|
||||
},
|
||||
"Routing": {
|
||||
"source": [
|
||||
"Furious.Actions.Routing"
|
||||
"Furious.Actions.Routing",
|
||||
"Furious.Widget.RoutingSelector"
|
||||
],
|
||||
"RU": "Маршрутизация",
|
||||
"ZH": "路由",
|
||||
@@ -1117,7 +1119,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Furious cannot find any valid http proxy endpoint in the configuration": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Я не могу найти ни одной допустимой конечной точки http-прокси в конфигурации",
|
||||
"ZH": "Furious在配置中无法找到任何有效的http代理端点",
|
||||
@@ -1125,7 +1127,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Please complete your server configuration": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Пожалуйста, завершите настройку вашего сервера",
|
||||
"ZH": "请完善服务器配置",
|
||||
@@ -1255,7 +1257,7 @@ TRANSLATION = {
|
||||
},
|
||||
"Select and press Enter to activate configuration and connect": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "Выберите конфигурацию и нажмите Enter, чтобы активировать ее и подключиться",
|
||||
"ZH": "选择并按下Enter键以激活配置并连接",
|
||||
@@ -1293,7 +1295,7 @@ TRANSLATION = {
|
||||
},
|
||||
"is available to download": {
|
||||
"source": [
|
||||
"Furious.Actions.Connection"
|
||||
"Furious.Controllers.ConnectionController"
|
||||
],
|
||||
"RU": "доступен для скачивания",
|
||||
"ZH": "可供下载",
|
||||
|
||||
@@ -29,8 +29,10 @@ __all__ = [
|
||||
'AppFontName',
|
||||
'AppLogManager',
|
||||
'AppLogPage',
|
||||
'AppMainWindow',
|
||||
'AppRoutingController',
|
||||
'AppSettingsController',
|
||||
'AppSystemTray',
|
||||
'AppThreadPool',
|
||||
]
|
||||
|
||||
@@ -47,15 +49,19 @@ def getAppAttributes(name: str):
|
||||
AppFontName,
|
||||
AppLogManager,
|
||||
AppLogPage,
|
||||
AppMainWindow,
|
||||
AppRoutingController,
|
||||
AppSettingsController,
|
||||
AppSystemTray,
|
||||
AppThreadPool,
|
||||
) = (
|
||||
functools.partial(getAppAttributes, 'connectionController'),
|
||||
functools.partial(getAppAttributes, 'customFontName'),
|
||||
functools.partial(getAppAttributes, 'logManager'),
|
||||
functools.partial(getAppAttributes, 'logPage'),
|
||||
functools.partial(getAppAttributes, 'mainWindow'),
|
||||
functools.partial(getAppAttributes, 'routingController'),
|
||||
functools.partial(getAppAttributes, 'settingsController'),
|
||||
functools.partial(getAppAttributes, 'systemTray'),
|
||||
functools.partial(getAppAttributes, 'threadPool'),
|
||||
)
|
||||
|
||||
@@ -73,8 +73,10 @@ from .Globals import (
|
||||
AppFontName,
|
||||
AppLogManager,
|
||||
AppLogPage,
|
||||
AppMainWindow,
|
||||
AppRoutingController,
|
||||
AppSettingsController,
|
||||
AppSystemTray,
|
||||
AppThreadPool,
|
||||
)
|
||||
from .Mixins import Mixins
|
||||
@@ -123,10 +125,12 @@ __all__ = [
|
||||
'AppFontName',
|
||||
'AppLogManager',
|
||||
'AppLogPage',
|
||||
'AppMainWindow',
|
||||
'AppResources',
|
||||
'AppSettings',
|
||||
'AppRoutingController',
|
||||
'AppSettingsController',
|
||||
'AppSystemTray',
|
||||
'AppThreadPool',
|
||||
'CORE_CHECK_ALIVE_INTERVAL',
|
||||
'CRASH_LOG_DIR',
|
||||
|
||||
@@ -913,7 +913,7 @@ class SubscriptionTableView(Mixins.QTranslatable, AppQTableView):
|
||||
else:
|
||||
realHttpProxy = httpProxy
|
||||
|
||||
APP().mainWindow.updateSubsByUnique(
|
||||
AppMainWindow().updateSubsByUnique(
|
||||
unique, realHttpProxy, showMessageBox=showMessageBox, **kwargs
|
||||
)
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ class TextEditorWindow(AppQMainWindow):
|
||||
Storage.UserServers()[index] = new
|
||||
|
||||
try:
|
||||
APP().mainWindow.flushRow(index, new)
|
||||
AppMainWindow().flushRow(index, new)
|
||||
except Exception:
|
||||
# Any non-exit exceptions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user