From 80e2dd0f0875e729db305162aa3a34cb167a2b0b 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: Sun, 18 Aug 2024 18:57:49 +0800 Subject: [PATCH] mergebtn --- .../LunaTranslator/gui/setting_hotkey.py | 1 - .../LunaTranslator/gui/translatorUI.py | 27 +++++++++---------- .../LunaTranslator/myutils/config.py | 2 +- .../files/defaultconfig/config.json | 16 +---------- LunaTranslator/files/lang/ar.json | 1 - LunaTranslator/files/lang/cht.json | 1 - LunaTranslator/files/lang/cs.json | 1 - LunaTranslator/files/lang/de.json | 1 - LunaTranslator/files/lang/en.json | 1 - LunaTranslator/files/lang/es.json | 1 - LunaTranslator/files/lang/fr.json | 1 - LunaTranslator/files/lang/it.json | 1 - LunaTranslator/files/lang/ja.json | 1 - LunaTranslator/files/lang/ko.json | 1 - LunaTranslator/files/lang/nl.json | 1 - LunaTranslator/files/lang/pl.json | 1 - LunaTranslator/files/lang/pt.json | 1 - LunaTranslator/files/lang/ru.json | 1 - LunaTranslator/files/lang/sv.json | 1 - LunaTranslator/files/lang/th.json | 1 - LunaTranslator/files/lang/tr.json | 1 - LunaTranslator/files/lang/uk.json | 1 - LunaTranslator/files/lang/vi.json | 1 - LunaTranslator/files/lang/zh.json | 1 - docs/zh/alltoolbuttons.md | 9 +++---- 25 files changed, 18 insertions(+), 57 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py index 2f73383d..c4b5a5ce 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_hotkey.py +++ b/LunaTranslator/LunaTranslator/gui/setting_hotkey.py @@ -65,7 +65,6 @@ def registrhotkeys(self): windows.FindWindow("WNDCLS_Magpie_Core_CLI_Message", None), windows.RegisterWindowMessage("Magpie_Core_CLI_Message_ToggleOverlay"), ), - "_26": gobject.baseobject.translation_ui.ocr_once_signal.emit, "_27": gobject.baseobject.translation_ui.simulate_key_enter, "_28": lambda: winsharedutils.clipboard_set( gobject.baseobject.currenttranslate diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index bd5e2e0b..2c726a84 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -245,7 +245,6 @@ class TranslatorWindow(resizableframeless): refreshtooliconsignal = pyqtSignal() hidesignal = pyqtSignal() muteprocessignal = pyqtSignal() - ocr_once_signal = pyqtSignal() resizesignal = pyqtSignal(QSize) move_signal = pyqtSignal(QPoint) closesignal = pyqtSignal() @@ -467,13 +466,6 @@ class TranslatorWindow(resizableframeless): else: gobject.baseobject.textgetmethod(text, False) - def ocr_once_function(self): - def ocroncefunction(rect): - self.ocr_once_follow_rect = rect - self.ocr_do_function(rect) - - rangeselct_function(ocroncefunction, False, False) - @threader def simulate_key_enter(self): windows.SetForegroundWindow(gobject.baseobject.hwnd) @@ -654,7 +646,6 @@ class TranslatorWindow(resizableframeless): 1, ), ), - ("ocr_once", self.ocr_once_signal.emit), ( "ocr_once_follow", lambda: self.ocr_do_function(self.ocr_once_follow_rect), @@ -827,7 +818,6 @@ class TranslatorWindow(resizableframeless): self.displaylink.connect(self.displaylink_f) self.displayglobaltooltip.connect(self.displayglobaltooltip_f) self.displaymessagebox.connect(self.displaymessagebox_f) - self.ocr_once_signal.connect(self.ocr_once_function) self.displaystatus.connect(self.showstatus) self.showhideuisignal.connect(self.showhideui) self.displayres.connect(self.showres) @@ -1255,11 +1245,20 @@ class TranslatorWindow(resizableframeless): self.resizesignal.emit(size) def clickRange(self, auto): - if globalconfig["sourcestatus2"]["ocr"]["use"] == False: - return - self.showhidestate = False - rangeselct_function(self.afterrange, auto, auto) + def ocroncefunction(rect): + self.ocr_once_follow_rect = rect + self.ocr_do_function(rect) + + def inocrmode(rect): + self.showhidestate = False + self.afterrange(rect) + + if globalconfig["sourcestatus2"]["ocr"]["use"] == False: + f = ocroncefunction + else: + f = inocrmode + rangeselct_function(f, auto, auto) @tryprint def afterrange(self, rect): diff --git a/LunaTranslator/LunaTranslator/myutils/config.py b/LunaTranslator/LunaTranslator/myutils/config.py index 9fc0b872..bcb1d8a9 100644 --- a/LunaTranslator/LunaTranslator/myutils/config.py +++ b/LunaTranslator/LunaTranslator/myutils/config.py @@ -382,7 +382,7 @@ def syncconfig(config1, default, drop=False, deep=0, skipdict=False): if skipdict == False: syncconfig(config1[key], default[key], drop, deep - 1) if isinstance(config1, dict) and isinstance(default, dict): - for key in ("name", "tip", "argstype", "args"): + for key in ("name", "tip", "argstype", "args", "belong"): if key in config1 and key not in default: config1.pop(key) if drop and deep > 0: diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 68bf7584..2fca6b57 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -567,8 +567,8 @@ "copy_once", "open_relative_link", "open_game_setting", - "ocr_once", "selectable", + "ocr_once_follow", "minmize", "quit" ], @@ -650,9 +650,6 @@ "selectocrrange": { "use": true, "tip": "选取OCR范围", - "belong": [ - "ocr" - ], "icon": "fa.crop", "align": 2 }, @@ -665,12 +662,6 @@ "icon": "fa.square", "align": 2 }, - "ocr_once": { - "use": false, - "tip": "进行一次OCR", - "icon": "fa.crop", - "align": 0 - }, "ocr_once_follow": { "use": false, "tip": "再次进行OCR", @@ -1018,11 +1009,6 @@ "name": "Magpie_游戏内叠加层", "keystring": "" }, - "_26": { - "use": false, - "name": "进行一次OCR", - "keystring": "" - }, "_27": { "use": false, "name": "模拟按键Enter", diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index 4ce4216e..2a95f22b 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -486,7 +486,6 @@ "图标2": "أيقونات", "刷新": "منعش", "读取剪贴板": "قراءة الحافظة", - "进行一次OCR": "التعرف الضوئي على الحروف", "有道OCR": "التعرف الضوئي على الحروف", "免费试用": "محاكمة مجانية", "通用文字识别 API": "المعهد العالمي التعرف على الحروف", diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 43fabd56..c29b3630 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -486,7 +486,6 @@ "图标2": "圖示 2", "刷新": "重新整理", "读取剪贴板": "讀取剪貼簿", - "进行一次OCR": "進行一次 OCR", "有道OCR": "有道 OCR", "免费试用": "免費試用", "通用文字识别 API": "一般文字識別 API", diff --git a/LunaTranslator/files/lang/cs.json b/LunaTranslator/files/lang/cs.json index aa289239..6a3c09b1 100644 --- a/LunaTranslator/files/lang/cs.json +++ b/LunaTranslator/files/lang/cs.json @@ -485,7 +485,6 @@ "单次负载个数": "Počet jednotlivých nákladů", "过滤英文字母": "Filtrovat anglická písmena", "过滤包含乱码的文本行": "Filtrovat textové řádky obsahující zkreslené znaky", - "进行一次OCR": "Provést OCR jednou", "选取OCR范围——立即": "Vybrat rozsah OCR a okamžitě", "有道OCR": "OCR Youdao", "免费试用": "Zkušební verze zdarma", diff --git a/LunaTranslator/files/lang/de.json b/LunaTranslator/files/lang/de.json index f303410a..e43378dc 100644 --- a/LunaTranslator/files/lang/de.json +++ b/LunaTranslator/files/lang/de.json @@ -485,7 +485,6 @@ "单次负载个数": "Anzahl der Einzelladungen", "过滤英文字母": "Englische Buchstaben filtern", "过滤包含乱码的文本行": "Textzeilen mit verzerrten Zeichen filtern", - "进行一次OCR": "OCR einmal ausführen", "选取OCR范围——立即": "OCR-Bereich sofort auswählen", "有道OCR": "Youdao OCR", "免费试用": "Kostenlose Testversion", diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 2cfde14d..ee534c09 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -486,7 +486,6 @@ "图标2": "Icon 2", "刷新": "Refresh", "读取剪贴板": "Read Clipboard", - "进行一次OCR": "Perform OCR", "有道OCR": "Youdao OCR", "免费试用": "Free Trial", "通用文字识别 API": "General OCR API", diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index 736952af..74178882 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -486,7 +486,6 @@ "图标2": "Icono 2", "刷新": "Refrescar", "读取剪贴板": "Leer el portapapeles", - "进行一次OCR": "Realizar un OCR", "有道OCR": "Youdao OCR", "免费试用": "Prueba gratuita", "通用文字识别 API": "API universal de reconocimiento de texto", diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index 8df490a8..476d5f54 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -486,7 +486,6 @@ "图标2": "Icône 2", "刷新": "Rafraîchir", "读取剪贴板": "Lire le presse - papiers", - "进行一次OCR": "Faites une ocr", "有道OCR": "OCR avec piste", "免费试用": "Essai gratuit", "通用文字识别 API": "API de reconnaissance de texte universelle", diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index 27060c09..d34aa870 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -486,7 +486,6 @@ "图标2": "Icona 2", "刷新": "Aggiorna", "读取剪贴板": "Leggi gli appunti", - "进行一次OCR": "Condurre un OCR", "有道OCR": "OCR Youdao", "免费试用": "Prova gratuita", "通用文字识别 API": "API universale per il riconoscimento del testo", diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 241e381a..25e3c26e 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -486,7 +486,6 @@ "图标2": "アイコン2", "刷新": "リフレッシュ", "读取剪贴板": "クリップボードを読み込む", - "进行一次OCR": "OCRを1回実行する", "有道OCR": "チャネルOCR", "免费试用": "無料トライアル", "通用文字识别 API": "共通文字認識API", diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 3b66e73a..be755e2f 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -486,7 +486,6 @@ "图标2": "아이콘 2", "刷新": "새로 고침", "读取剪贴板": "클립보드 읽기", - "进行一次OCR": "OCR을 한번 진행해보도록 하겠습니다.", "有道OCR": "유도 OCR", "免费试用": "무료 평가판", "通用文字识别 API": "일반 문자 인식 API", diff --git a/LunaTranslator/files/lang/nl.json b/LunaTranslator/files/lang/nl.json index 06e51ae8..fa570e6b 100644 --- a/LunaTranslator/files/lang/nl.json +++ b/LunaTranslator/files/lang/nl.json @@ -485,7 +485,6 @@ "单次负载个数": "Aantal enkelvoudige ladingen", "过滤英文字母": "Engelse letters filteren", "过滤包含乱码的文本行": "Tekstregels met vervormde tekens filteren", - "进行一次OCR": "Eenmaal OCR uitvoeren", "选取OCR范围——立即": "OCR-bereik direct selecteren", "有道OCR": "Youdao OCR", "免费试用": "Gratis proefperiode", diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 99e114a4..4154d9ba 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -486,7 +486,6 @@ "图标2": "Ikona 2", "刷新": "Odśwież", "读取剪贴板": "Odczytaj schowek", - "进行一次OCR": "Przeprowadzenie OCR", "有道OCR": "OCR Youdao", "免费试用": "Bezpłatny próbny", "通用文字识别 API": "Uniwersalne rozpoznawanie tekstu API", diff --git a/LunaTranslator/files/lang/pt.json b/LunaTranslator/files/lang/pt.json index 2bca6a64..8a3a4902 100644 --- a/LunaTranslator/files/lang/pt.json +++ b/LunaTranslator/files/lang/pt.json @@ -485,7 +485,6 @@ "单次负载个数": "Número de cargas individuais", "过滤英文字母": "Filtrar letras inglesas", "过滤包含乱码的文本行": "Filtrar linhas de texto contendo caracteres distorcidos", - "进行一次OCR": "Executar OCR uma vez", "选取OCR范围——立即": "Seleccionar o intervalo OCR - Imediatamente", "有道OCR": "OCR Youdao", "免费试用": "Avaliação gratuita", diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 690e5395..e18e2efe 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -486,7 +486,6 @@ "图标2": "Значок 2", "刷新": "Обновить", "读取剪贴板": "Прочитать буфер обмена", - "进行一次OCR": "Выполнить OCR", "有道OCR": "Путь OCR", "免费试用": "Бесплатная пробная версия", "通用文字识别 API": "Универсальное распознавание текста API", diff --git a/LunaTranslator/files/lang/sv.json b/LunaTranslator/files/lang/sv.json index 8623d516..b7feea23 100644 --- a/LunaTranslator/files/lang/sv.json +++ b/LunaTranslator/files/lang/sv.json @@ -485,7 +485,6 @@ "单次负载个数": "Antal enskilda laster", "过滤英文字母": "Filtrera engelska bokstäver", "过滤包含乱码的文本行": "Filtrera textrader som innehåller förvrängda tecken", - "进行一次OCR": "Utför OCR en gång", "选取OCR范围——立即": "Välj OCR-område - omedelbart", "有道OCR": "Youdao OCR", "免费试用": "Gratis provperiod", diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 7d980fad..72b84991 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -485,7 +485,6 @@ "单次负载个数": "จำนวนชิ้นโหลดเดียว", "过滤英文字母": "กรองตัวอักษรภาษาอังกฤษ", "过滤包含乱码的文本行": "กรองบรรทัดข้อความที่มีรหัสยุ่งเหยิง", - "进行一次OCR": "ทำ OCR หนึ่งครั้ง", "选取OCR范围——立即": "เลือกช่วง OCR - ตอนนี้", "有道OCR": "เส้นทาง OCR", "免费试用": "ทดลองใช้ฟรี", diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index 3ff03c6c..cf7e0348 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -486,7 +486,6 @@ "图标2": "İşaretçi 2", "刷新": "Tazele", "读取剪贴板": "Pano Oku", - "进行一次OCR": "OCR yap", "有道OCR": "Youdao OCR", "免费试用": "Özgür dava", "通用文字识别 API": "Universal Text Recognition API", diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index af841a03..463a68ba 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -486,7 +486,6 @@ "图标2": "Піктограма 2", "刷新": "Оновити", "读取剪贴板": "Читати буфер обміну даними", - "进行一次OCR": "Виконати OCR", "有道OCR": "Youdao OCR", "免费试用": "Безкоштовне випробування", "通用文字识别 API": "Універсальний програмний інтерфейс розпізнавання тексту", diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index 69d4c4b5..912c1a60 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -486,7 +486,6 @@ "图标2": "Biểu tượng 2", "刷新": "Làm mới", "读取剪贴板": "Đọc bảng nháp", - "进行一次OCR": "Thực hiện OCR", "有道OCR": "Có OCR", "免费试用": "Dùng thử miễn phí", "通用文字识别 API": "API nhận dạng văn bản chung", diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 2b0c40d0..b97aa35c 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -485,7 +485,6 @@ "单次负载个数": "", "过滤英文字母": "", "过滤包含乱码的文本行": "", - "进行一次OCR": "", "选取OCR范围——立即": "", "有道OCR": "", "免费试用": "", diff --git a/docs/zh/alltoolbuttons.md b/docs/zh/alltoolbuttons.md index cf61f979..5d27778b 100644 --- a/docs/zh/alltoolbuttons.md +++ b/docs/zh/alltoolbuttons.md @@ -58,16 +58,13 @@ 点击按钮弹出选择游戏文本窗口,来选择要翻译哪条HOOK到的文本。
不过,选择文本窗口在选择进程后会自动弹出,这个按钮实际上是用来更换选择的文本,或修改一些设置用的。 1. #### 选取OCR范围 - **该按钮仅在OCR模式下可用**
- OCR模式先,选取OCR区域,或者更换OCR区域,或者当激活`OCR设置`->`其他`->`多重区域模式`时增加新的OCR区域 + **OCR模式下**,选取OCR区域,或者更换OCR区域,或者当激活`OCR设置`->`其他`->`多重区域模式`时增加新的OCR区域 + **非OCR模式下**,合并了原`进行一次OCR`按钮的功能,先进行OCR范围选择,然后进行一次OCR,然后进行翻译流程。一般用于,在HOOK模式下,遇到选择支时,临时使用一次OCR进行翻译选择支。或者在OCR模式下,临时去识别一次其他偶尔出现的新的位置。 1. #### 显示/隐藏范围框 **该按钮仅在OCR模式下可用**
当未选择任何OCR范围时,使用该按钮显示OCR范围,会自动设置OCR范围为上一次选择的OCR。 -1. #### 进行一次OCR - 该按钮和`读取剪贴板`类似,不管当前的默认文本输入源是什么,都会先进行OCR范围选择,然后进行一次OCR,然后进行翻译流程。
- 该按钮一般用于,在HOOK模式下,遇到选择支时,临时使用一次OCR进行翻译选择支。或者在OCR模式下,临时去识别一次其他偶尔出现的新的位置。
1. #### 再次进行OCR - 当使用过一次`进行一次OCR`后,使用这个按钮,可以在原来的位置上再次进行一次OCR而无需重新选择识别区域。 + **非OCR模式下**,当使用过一次`选取OCR范围`后,使用这个按钮,可以在原来的位置上再次进行一次OCR而无需重新选择识别区域。 1. #### 专有名词翻译_直接替换 1. #### 专有名词翻译_sakura_gpt_词典