From 9816a4243fae2fac971a98fc7e4829f2cb980277 Mon Sep 17 00:00:00 2001 From: Loren Eteval Date: Sun, 23 Feb 2025 17:42:48 +0800 Subject: [PATCH] Add showUnrecognizedConfigMBox Signed-off-by: Loren Eteval --- Furious/Externals/GenTranslation.py | 8 +++++++ Furious/QtFramework/QtWidgets.py | 27 +++++++++++++++++++++++ Furious/Widget/UserServersQTableWidget.py | 4 +++- Furious/Window/AppMainWindow.py | 5 +++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Furious/Externals/GenTranslation.py b/Furious/Externals/GenTranslation.py index 66b1d88..f150b8b 100644 --- a/Furious/Externals/GenTranslation.py +++ b/Furious/Externals/GenTranslation.py @@ -35,6 +35,14 @@ TRANSLATION = { "ZH": "新的更改将于下次生效", "isReviewed": "True" }, + "Unrecognized Configuration. Please modify it in the editor": { + "source": [ + "Furious.QtFramework.QtWidgets" + ], + "RU": "Нераспознанная конфигурация. Пожалуйста, измените его в редакторе", + "ZH": "无法识别的配置。请在编辑器中修改", + "isReviewed": "True" + }, "New version available": { "source": [ "Furious.QtFramework.UpdatesManager" diff --git a/Furious/QtFramework/QtWidgets.py b/Furious/QtFramework/QtWidgets.py index 7a82a9a..a5993a8 100644 --- a/Furious/QtFramework/QtWidgets.py +++ b/Furious/QtFramework/QtWidgets.py @@ -51,6 +51,8 @@ __all__ = [ 'QuestionDeleteMBox', 'NewChangesNextTimeMBox', 'showNewChangesNextTimeMBox', + 'UnrecognizedConfigMBox', + 'showUnrecognizedConfigMBox', ] needTrans = functools.partial(needTransFn, source=__name__) @@ -609,3 +611,28 @@ def showNewChangesNextTimeMBox(**kwargs): # Any non-exit exceptions pass + + +needTrans( + 'Unrecognized Configuration. Please modify it in the editor', +) + + +class UnrecognizedConfigMBox(AppQMessageBox): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.setIcon(AppQMessageBox.Icon.Critical) + self.setText(_('Unrecognized Configuration. Please modify it in the editor')) + + +def showUnrecognizedConfigMBox(**kwargs): + mbox = UnrecognizedConfigMBox(**kwargs) + + if isinstance(mbox.parent(), QMainWindow): + mbox.setWindowModality(QtCore.Qt.WindowModality.WindowModal) + else: + mbox.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) + + # Show the MessageBox asynchronously + mbox.open() diff --git a/Furious/Widget/UserServersQTableWidget.py b/Furious/Widget/UserServersQTableWidget.py index e4064be..6c8f290 100644 --- a/Furious/Widget/UserServersQTableWidget.py +++ b/Furious/Widget/UserServersQTableWidget.py @@ -921,7 +921,9 @@ class UserServersQTableWidget(QTranslatable, AppQTableWidget): guiEditor = self.getGuiEditorByFactory(factory, translatable=False) if guiEditor is None: - # Unrecognized. Do nothing + # Unrecognized. + showUnrecognizedConfigMBox() + return guiEditor.setWindowTitle(f'{index + 1} - ' + factory.getExtras('remark')) diff --git a/Furious/Window/AppMainWindow.py b/Furious/Window/AppMainWindow.py index 3288bf0..b9a2fc6 100644 --- a/Furious/Window/AppMainWindow.py +++ b/Furious/Window/AppMainWindow.py @@ -248,6 +248,11 @@ class AppMainWindow(AppQMainWindow): Protocol.Hysteria2, _('Add Hysteria2 Server...') ), ), + AppQSeperator(), + AppQAction( + _('New Empty Configuration'), + callback=lambda: self.userServersQTableWidget.newEmptyItem(), + ), ] subsActions = [