Expose shared application service accessors

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-08-18 22:26:05 +08:00
parent a35b582f91
commit 7f92ec11e2
2 changed files with 25 additions and 0 deletions
+21
View File
@@ -26,6 +26,7 @@ import functools
__all__ = [
'APP',
'AppConnectionController',
'AppEndpointInfoService',
'AppFontName',
'AppLogManager',
'AppLogPage',
@@ -34,6 +35,7 @@ __all__ = [
'AppSettingsController',
'AppSystemTray',
'AppThreadPool',
'AppTrafficStatsManager',
]
APP = functools.partial(QApplication.instance)
@@ -44,8 +46,19 @@ def getAppAttributes(name: str):
return getattr(APP(), name)
def getAppNestedAttributes(*names: str):
"""Return an application-owned object through a stable attribute path."""
value = APP()
for name in names:
value = getattr(value, name)
return value
(
AppConnectionController,
AppEndpointInfoService,
AppFontName,
AppLogManager,
AppLogPage,
@@ -54,8 +67,15 @@ def getAppAttributes(name: str):
AppSettingsController,
AppSystemTray,
AppThreadPool,
AppTrafficStatsManager,
) = (
functools.partial(getAppAttributes, 'connectionController'),
functools.partial(
getAppNestedAttributes,
'mainWindow',
'metricsPage',
'endpointInfoService',
),
functools.partial(getAppAttributes, 'customFontName'),
functools.partial(getAppAttributes, 'logManager'),
functools.partial(getAppAttributes, 'logPage'),
@@ -64,4 +84,5 @@ def getAppAttributes(name: str):
functools.partial(getAppAttributes, 'settingsController'),
functools.partial(getAppAttributes, 'systemTray'),
functools.partial(getAppAttributes, 'threadPool'),
functools.partial(getAppNestedAttributes, 'mainWindow', 'trafficStatsManager'),
)
+4
View File
@@ -75,6 +75,7 @@ from .Enum import (
from .Globals import (
APP,
AppConnectionController,
AppEndpointInfoService,
AppFontName,
AppLogManager,
AppLogPage,
@@ -83,6 +84,7 @@ from .Globals import (
AppSettingsController,
AppSystemTray,
AppThreadPool,
AppTrafficStatsManager,
)
from .Mixins import Mixins
from .PySide6Legacy import PySide6Legacy
@@ -128,6 +130,7 @@ __all__ = [
'AppBuiltinProxyMode',
'AppBuiltinRouting',
'AppConnectionController',
'AppEndpointInfoService',
'AppFontName',
'AppLogManager',
'AppLogPage',
@@ -138,6 +141,7 @@ __all__ = [
'AppSettingsController',
'AppSystemTray',
'AppThreadPool',
'AppTrafficStatsManager',
'CORE_CHECK_ALIVE_INTERVAL',
'CRASH_LOG_DIR',
'DATA_DIR',