Added reconnect option under "direct rules not allowed in TUN mode"

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2025-12-02 15:34:31 +08:00
parent b1364a9fe3
commit 80fbefdecd
4 changed files with 69 additions and 19 deletions
+2 -16
View File
@@ -158,14 +158,7 @@ class CoreManager(Mixins.CleanupOnExit):
if routing == 'Bypass Mainland China':
# TUN Mode handling
if not proxyModeOnly and SystemRuntime.isTUNMode():
mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Critical)
mbox.setWindowTitle(_('Unable to connect'))
mbox.setText(
_('Routing option with direct rules is not allowed in TUN mode')
)
# Show the MessageBox asynchronously
mbox.open()
showDirectRulesNotAllowedMBox()
return None, False
@@ -235,14 +228,7 @@ class CoreManager(Mixins.CleanupOnExit):
if routing == 'Bypass Mainland China':
# TUN Mode handling
if not proxyModeOnly and SystemRuntime.isTUNMode():
mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Critical)
mbox.setWindowTitle(_('Unable to connect'))
mbox.setText(
_('Routing option with direct rules is not allowed in TUN mode')
)
# Show the MessageBox asynchronously
mbox.open()
showDirectRulesNotAllowedMBox()
return None, False
+11 -3
View File
@@ -956,7 +956,7 @@ TRANSLATION = {
},
"Unable to connect": {
"source": [
"Furious.Core.CoreManager",
"Furious.Qt.QtWidgets",
"Furious.TrayActions.Connect"
],
"RU": "Не удается подключиться",
@@ -1191,7 +1191,7 @@ TRANSLATION = {
"source": [
"Furious.TrayActions.Routing"
],
"RU": "Весь трафик",
"RU": "глобальный режим",
"ZH": "全球",
"isReviewed": "True"
},
@@ -1380,12 +1380,20 @@ TRANSLATION = {
},
"Routing option with direct rules is not allowed in TUN mode": {
"source": [
"Furious.Core.CoreManager"
"Furious.Qt.QtWidgets"
],
"RU": "Опция маршрутизации с прямыми правилами не разрешена в режиме TUN",
"ZH": "TUN模式下不允许使用直接规则的路由选项",
"isReviewed": "True"
},
"Switch to global and reconnect?": {
"source": [
"Furious.Qt.QtWidgets"
],
"RU": "Переключиться в глобальный режим и переподключиться?",
"ZH": "切换到全局模式并重新连接?",
"isReviewed": "True"
},
"Select and press Enter to activate configuration and connect": {
"source": [
"Furious.TrayActions.Connect"
+52
View File
@@ -50,6 +50,8 @@ __all__ = [
'QuestionDeleteMBox',
'NewChangesNextTimeMBox',
'showNewChangesNextTimeMBox',
'DirectRulesNotAllowedMBox',
'showDirectRulesNotAllowedMBox',
'UnrecognizedConfigMBox',
'showUnrecognizedConfigMBox',
]
@@ -695,6 +697,56 @@ def showNewChangesNextTimeMBox(**kwargs):
pass
class DirectRulesNotAllowedMBox(AppQMessageBox):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowTitle(_('Unable to connect'))
self.setIcon(AppQMessageBox.Icon.Critical)
self.setStandardButtons(
AppQMessageBox.StandardButton.Yes | AppQMessageBox.StandardButton.No
)
self.setText(self.customText())
@staticmethod
def customText() -> str:
return (
_('Routing option with direct rules is not allowed in TUN mode')
+ '\n\n'
+ _('Switch to global and reconnect?')
)
def retranslate(self):
self.setWindowTitle(_(self.windowTitle()))
self.setText(self.customText())
# Ignore informative text, buttons
self.moveToCenter()
def showDirectRulesNotAllowedMBox(**kwargs):
@QtCore.Slot(int)
def handleResultCode(code):
if code == PySide6Legacy.enumValueWrapper(AppQMessageBox.StandardButton.Yes):
APP().systemTray.RoutingAction.getGlobalAction().trigger()
APP().systemTray.ConnectAction.trigger()
else:
# Do nothing
pass
mbox = DirectRulesNotAllowedMBox(**kwargs)
mbox.finished.connect(handleResultCode)
if isinstance(mbox.parent(), QMainWindow):
mbox.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
else:
mbox.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
# Show the MessageBox asynchronously
mbox.open()
class UnrecognizedConfigMBox(AppQMessageBox):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+4
View File
@@ -68,3 +68,7 @@ class RoutingAction(AppQAction):
),
**kwargs,
)
def getGlobalAction(self):
# 2nd action
return self._menu.actions()[1]