mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-09 15:19:56 +03:00
Move to APP().isConnected() call
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -173,7 +173,7 @@ class BuiltinRoutingChildAction(Action):
|
||||
# Activate
|
||||
APP().RoutesWidget.activateItemByIndex(routingToIndex(), activate=True)
|
||||
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
# Connected. Re-configure connection
|
||||
APP().tray.ConnectAction.connectingAction(
|
||||
showProgressBar=True,
|
||||
@@ -212,7 +212,7 @@ class RoutingChildAction(Action):
|
||||
routingToIndex(), activate=True
|
||||
)
|
||||
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
# Connected. Re-configure connection
|
||||
APP().tray.ConnectAction.connectingAction(
|
||||
showProgressBar=True,
|
||||
|
||||
@@ -85,28 +85,24 @@ class VPNModeAction(Action):
|
||||
def triggeredCallback(self, checked):
|
||||
assert isAdministrator()
|
||||
|
||||
# Reference
|
||||
ConnectAction = APP().tray.ConnectAction
|
||||
|
||||
if checked:
|
||||
APP().VPNMode = Switch.ON_
|
||||
|
||||
if ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
if isVPNMode():
|
||||
if PLATFORM == 'Windows' or PLATFORM == 'Darwin':
|
||||
# Currently VPN Mode is only supported on Windows and macOS
|
||||
ConnectAction.startTun2socks(
|
||||
APP().tray.ConnectAction.startTun2socks(
|
||||
successCallback=lambda: APP().tray.showMessage(
|
||||
_('VPN mode started')
|
||||
)
|
||||
)
|
||||
else:
|
||||
if ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
if isVPNMode():
|
||||
if PLATFORM == 'Windows' or PLATFORM == 'Darwin':
|
||||
# Currently VPN Mode is only supported on Windows and macOS
|
||||
ConnectAction.stopTun2socks()
|
||||
|
||||
APP().tray.ConnectAction.stopTun2socks()
|
||||
APP().tray.showMessage(_('VPN mode stopped'))
|
||||
|
||||
APP().VPNMode = Switch.OFF
|
||||
|
||||
@@ -337,6 +337,9 @@ class Application(SingletonApplication):
|
||||
|
||||
return self
|
||||
|
||||
def isConnected(self):
|
||||
return self.tray is not None and self.tray.ConnectAction.isConnected()
|
||||
|
||||
@QtCore.Slot()
|
||||
def cleanup(self):
|
||||
Proxy.off()
|
||||
|
||||
@@ -398,7 +398,7 @@ class SaveAsServerAction(Action):
|
||||
if myFocusIndex == self.parent().activatedItemIndex:
|
||||
# Activated configuration modified
|
||||
|
||||
if server and APP().tray.ConnectAction.isConnected():
|
||||
if server and APP().isConnected():
|
||||
questionReconnect(self.saveConfInfo)
|
||||
|
||||
return True
|
||||
@@ -2066,7 +2066,7 @@ class ServerWidget(Translatable, SupportConnectedCallback, TableWidget):
|
||||
# Set invalid first
|
||||
APP().ActivatedItemIndex = str(-1)
|
||||
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
# Trigger disconnect
|
||||
APP().tray.ConnectAction.trigger()
|
||||
|
||||
@@ -2341,7 +2341,7 @@ class ServerWidget(Translatable, SupportConnectedCallback, TableWidget):
|
||||
# Activate
|
||||
self.activateItemByIndex(newIndex, activate=True)
|
||||
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
APP().tray.ConnectAction.reconnectAction()
|
||||
|
||||
@QtCore.Slot(QtCore.QPoint)
|
||||
@@ -2660,7 +2660,7 @@ class EditConfigurationWidget(MainWindow):
|
||||
self.serverWidget.setCurrentItemByIndex(0)
|
||||
|
||||
# Try to be user-friendly in some extreme cases
|
||||
if not APP().tray.ConnectAction.isConnected():
|
||||
if not APP().isConnected():
|
||||
# Activate automatically
|
||||
self.serverWidget.activateItemByIndex(0)
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ class SaveAction(Action):
|
||||
if parentIndex == routingToIndex() - len(BUILTIN_ROUTING):
|
||||
# Activated routing modified
|
||||
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
questionFastReconnect(self.saveConfInfo)
|
||||
else:
|
||||
# Corresponding routing option has been deleted. Fake saved
|
||||
@@ -501,7 +501,7 @@ class EditRoutingAction(Action):
|
||||
if parentIndex == routingToIndex() - len(BUILTIN_ROUTING):
|
||||
# Activated routing modified
|
||||
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
questionFastReconnect(self.saveConfInfo)
|
||||
else:
|
||||
# Restore
|
||||
@@ -559,7 +559,7 @@ class RoutingEditor(MainWindow):
|
||||
self.isBuiltin = isBuiltin
|
||||
self.title = ''
|
||||
|
||||
if APP().tray is not None and APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
self.setWindowIcon(bootstrapIcon('rocket-takeoff-connected-dark.svg'))
|
||||
else:
|
||||
self.setWindowIcon(bootstrapIcon('rocket-takeoff-window.svg'))
|
||||
@@ -722,7 +722,7 @@ class RoutingDialog(Dialog):
|
||||
|
||||
self.isBuiltin = isBuiltin
|
||||
|
||||
if APP().tray is not None and APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
self.setWindowIcon(bootstrapIcon('rocket-takeoff-connected-dark.svg'))
|
||||
else:
|
||||
self.setWindowIcon(bootstrapIcon('rocket-takeoff-window.svg'))
|
||||
|
||||
@@ -212,7 +212,7 @@ class Menu(Translatable, SupportConnectedCallback, QMenu):
|
||||
# Do nothing
|
||||
pass
|
||||
|
||||
if APP().tray is not None and APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
self.setStyleSheet(self.getStyleSheet(Color.LIGHT_RED_))
|
||||
else:
|
||||
self.setStyleSheet(self.getStyleSheet(Color.LIGHT_BLUE))
|
||||
@@ -244,7 +244,7 @@ class MenuBar(SupportConnectedCallback, QMenuBar):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if APP().tray is not None and APP().tray.ConnectAction.isConnected():
|
||||
if APP().isConnected():
|
||||
self.setSelectionColor(Color.LIGHT_RED_)
|
||||
else:
|
||||
self.setSelectionColor(Color.LIGHT_BLUE)
|
||||
@@ -363,14 +363,10 @@ class TableWidget(QTableWidget):
|
||||
|
||||
item.setFont(font)
|
||||
|
||||
if APP().tray is None:
|
||||
# Initializing
|
||||
item.setForeground(QColor(Color.LIGHT_BLUE))
|
||||
if APP().isConnected():
|
||||
item.setForeground(QColor(Color.LIGHT_RED_))
|
||||
else:
|
||||
if APP().tray.ConnectAction.isConnected():
|
||||
item.setForeground(QColor(Color.LIGHT_RED_))
|
||||
else:
|
||||
item.setForeground(QColor(Color.LIGHT_BLUE))
|
||||
item.setForeground(QColor(Color.LIGHT_BLUE))
|
||||
else:
|
||||
for column in range(self.columnCount()):
|
||||
item = self.item(int(index), column)
|
||||
|
||||
Reference in New Issue
Block a user