mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-09-22 23:08:08 +03:00
Fix itemSubscription field not shown due to circular import
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -19,6 +19,8 @@ from __future__ import annotations
|
||||
|
||||
from Furious.Interface.UserServersTableItem import *
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from typing import Union
|
||||
|
||||
import copy
|
||||
@@ -130,7 +132,20 @@ class ConfigFactory(UserServersTableItem, dict):
|
||||
|
||||
@property
|
||||
def itemSubscription(self) -> str:
|
||||
return ''
|
||||
try:
|
||||
app = QApplication.instance()
|
||||
|
||||
if app is None:
|
||||
return ''
|
||||
else:
|
||||
subsId = self.getExtras('subsId')
|
||||
subsOb = app._userSubs.get(subsId, {})
|
||||
|
||||
return subsOb.get('remark', '')
|
||||
except Exception:
|
||||
# Any non-exit exceptions
|
||||
|
||||
return ''
|
||||
|
||||
@property
|
||||
def itemLatency(self) -> str:
|
||||
|
||||
@@ -20,7 +20,6 @@ from __future__ import annotations
|
||||
from Furious.Frozenlib import *
|
||||
from Furious.Interface import *
|
||||
from Furious.Library.Encoder import *
|
||||
from Furious.Library.Storage import *
|
||||
|
||||
from typing import Union, Tuple
|
||||
|
||||
@@ -283,7 +282,7 @@ class ConfigXray(ConfigFactory):
|
||||
def __init__(self, config: Union[str, dict] = '', **kwargs):
|
||||
super().__init__(config, **kwargs)
|
||||
|
||||
def coreName(self):
|
||||
def coreName(self) -> str:
|
||||
return 'Xray-core'
|
||||
|
||||
@staticmethod
|
||||
@@ -1185,22 +1184,6 @@ class ConfigXray(ConfigFactory):
|
||||
|
||||
raise ValueError(f'Unrecognized URI scheme {URI}')
|
||||
|
||||
@property
|
||||
def itemRemark(self) -> str:
|
||||
return self.getExtras('remark')
|
||||
|
||||
@property
|
||||
def itemSubscription(self) -> str:
|
||||
try:
|
||||
subsId = self.getExtras('subsId')
|
||||
subsOb = Storage.UserSubs().get(subsId, {})
|
||||
|
||||
return subsOb.get('remark', '')
|
||||
except Exception:
|
||||
# Any non-exit exceptions
|
||||
|
||||
return ''
|
||||
|
||||
@property
|
||||
def itemProtocol(self) -> str:
|
||||
return Protocol.toEnum(self.proxyProtocol).value
|
||||
@@ -1538,25 +1521,9 @@ class ConfigHysteria1(ConfigFactory):
|
||||
def __init__(self, config: Union[str, dict] = '', **kwargs):
|
||||
super().__init__(config, **kwargs)
|
||||
|
||||
def coreName(self):
|
||||
def coreName(self) -> str:
|
||||
return 'Hysteria1'
|
||||
|
||||
@property
|
||||
def itemRemark(self) -> str:
|
||||
return self.getExtras('remark')
|
||||
|
||||
@property
|
||||
def itemSubscription(self) -> str:
|
||||
try:
|
||||
subsId = self.getExtras('subsId')
|
||||
subsOb = Storage.UserSubs().get(subsId, {})
|
||||
|
||||
return subsOb.get('remark', '')
|
||||
except Exception:
|
||||
# Any non-exit exceptions
|
||||
|
||||
return ''
|
||||
|
||||
@property
|
||||
def itemProtocol(self) -> str:
|
||||
return Protocol.Hysteria1.value
|
||||
@@ -1823,25 +1790,9 @@ class ConfigHysteria2(ConfigFactory):
|
||||
def __init__(self, config: Union[str, dict] = '', **kwargs):
|
||||
super().__init__(config, **kwargs)
|
||||
|
||||
def coreName(self):
|
||||
def coreName(self) -> str:
|
||||
return 'Hysteria2'
|
||||
|
||||
@property
|
||||
def itemRemark(self) -> str:
|
||||
return self.getExtras('remark')
|
||||
|
||||
@property
|
||||
def itemSubscription(self) -> str:
|
||||
try:
|
||||
subsId = self.getExtras('subsId')
|
||||
subsOb = Storage.UserSubs().get(subsId, {})
|
||||
|
||||
return subsOb.get('remark', '')
|
||||
except Exception:
|
||||
# Any non-exit exceptions
|
||||
|
||||
return ''
|
||||
|
||||
@property
|
||||
def itemProtocol(self) -> str:
|
||||
return Protocol.Hysteria2.value
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
from Furious.Frozenlib import *
|
||||
from Furious.Interface import *
|
||||
from Furious.Qt import gettext as _
|
||||
from Furious.Library import *
|
||||
from Furious.Utility import *
|
||||
from Furious.Widget.SystemTrayIcon import *
|
||||
from Furious.Window.AppMainWindow import *
|
||||
@@ -167,6 +168,17 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
self.mainWindow = None
|
||||
self.systemTray = None
|
||||
|
||||
# Logging window
|
||||
self.logViewerWindowSelf = None
|
||||
self.logViewerWindowCore = None
|
||||
self.logViewerWindowTun_ = None
|
||||
|
||||
# Protected storage access
|
||||
self._userActivatedItemIndex = None
|
||||
self._userServers = None
|
||||
self._userSubs = None
|
||||
self._userTUNSettings = None
|
||||
|
||||
# ThreadPool
|
||||
self.threadPool = QtCore.QThreadPool()
|
||||
self.threadPool.setMaxThreadCount(max(OS_CPU_COUNT // 2, 1))
|
||||
@@ -249,6 +261,13 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
# Xray environment variables
|
||||
os.environ['XRAY_LOCATION_ASSET'] = str(XRAY_ASSET_DIR)
|
||||
|
||||
def addStorage(self):
|
||||
# Protected storage access
|
||||
self._userActivatedItemIndex = Storage.UserActivatedItemIndex()
|
||||
self._userServers = Storage.UserServers()
|
||||
self._userSubs = Storage.UserSubs()
|
||||
self._userTUNSettings = Storage.UserTUNSettings()
|
||||
|
||||
def isSystemTrayConnected(self):
|
||||
if isinstance(self.systemTray, SystemTrayIcon):
|
||||
return self.systemTray.ConnectAction.isConnected()
|
||||
@@ -349,6 +368,7 @@ class Application(ApplicationFactory, SingletonApplication):
|
||||
)
|
||||
|
||||
self.addEnviron()
|
||||
self.addStorage()
|
||||
self.addCustomFont()
|
||||
self.configureLogging()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user