From 2ab37d4a90c017f17aa6e668ca731cf2f695e8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:07:09 +0800 Subject: [PATCH] showfy --- .../LunaTranslator/gui/setting_display_text.py | 11 ++++++++++- LunaTranslator/LunaTranslator/gui/setting_hotkey.py | 1 + LunaTranslator/LunaTranslator/gui/translatorUI.py | 13 +++++++++++++ LunaTranslator/files/defaultconfig/config.json | 12 ++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/gui/setting_display_text.py b/LunaTranslator/LunaTranslator/gui/setting_display_text.py index 1b6c206b..2ce35930 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_display_text.py +++ b/LunaTranslator/LunaTranslator/gui/setting_display_text.py @@ -38,6 +38,9 @@ def __changeuibuttonstate(self, x): except: pass +def __changeuibuttonstate2(self, x): + gobject.baseobject.translation_ui.refreshtoolicon() + def createtextfontcom(key): font_comboBox = FocusFontCombo() @@ -361,7 +364,13 @@ def xianshigrid_text(self): ], [ "显示翻译", - D_getsimpleswitch(globalconfig, "showfanyi"), + D_getsimpleswitch( + globalconfig, + "showfanyi", + callback=lambda x: __changeuibuttonstate2(self, x), + name="show_fany_switch", + parent=self, + ), "", ("显示翻译器名称"), D_getsimpleswitch(globalconfig, "showfanyisource"), diff --git a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py index 05a4c056..2f73383d 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py +++ b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py @@ -44,6 +44,7 @@ def registrhotkeys(self): "_3": self.showsignal.emit, "_4": lambda: winsharedutils.clipboard_set(gobject.baseobject.currenttext), "_5": gobject.baseobject.translation_ui.changeshowhideraw, + "_51":gobject.baseobject.translation_ui.changeshowhidetrans, "_6": lambda: gobject.baseobject.transhis.showsignal.emit(), "_7": lambda: gobject.baseobject.readcurrent(force=True), "_8": lambda: gobject.baseobject.translation_ui.changemousetransparentstate(0), diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 5f7751d1..ec10e002 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -511,6 +511,12 @@ class QUnFrameWindow(resizableframeless): lambda: globalconfig["isshowrawtext"], lambda: globalconfig["isshowrawtext"], ), + ( + "showtrans", + self.changeshowhidetrans, + lambda: globalconfig["showfanyi"], + lambda: globalconfig["showfanyi"], + ), ("history", lambda: gobject.baseobject.transhis.showsignal.emit()), ( "noundict", @@ -1064,6 +1070,13 @@ class QUnFrameWindow(resizableframeless): globalconfig["isshowrawtext"] = not globalconfig["isshowrawtext"] self.refreshtoolicon() + def changeshowhidetrans(self): + try: + gobject.baseobject.settin_ui.show_fany_switch.clicksignal.emit() + except: + globalconfig["showfanyi"] = not globalconfig["showfanyi"] + self.refreshtoolicon() + def changeTranslateMode(self): globalconfig["autorun"] = not globalconfig["autorun"] self.refreshtoolicon() diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 73886142..787953b7 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -756,6 +756,13 @@ "icon2": "fa.eye-slash", "align": 2 }, + "showtrans": { + "use": false, + "tip": "显示/隐藏翻译", + "icon": "fa.eye", + "icon2": "fa.eye-slash", + "align": 2 + }, "langdu": { "use": true, "tip": "朗读", @@ -920,6 +927,11 @@ "name": "显示/隐藏原文", "keystring": "" }, + "_51": { + "use": false, + "name": "显示/隐藏翻译", + "keystring": "" + }, "_6": { "use": false, "name": "显示/隐藏历史翻译",