From b739e403aa7e9b7a62761a6a8760a7e1d24f74f6 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:42:20 +0800 Subject: [PATCH] new btn --- .../LunaTranslator/gui/translatorUI.py | 25 +++++++++++++------ .../files/defaultconfig/config.json | 18 ++++++++----- LunaTranslator/files/lang/ar.json | 3 ++- LunaTranslator/files/lang/cht.json | 3 ++- LunaTranslator/files/lang/cs.json | 3 ++- LunaTranslator/files/lang/de.json | 3 ++- LunaTranslator/files/lang/en.json | 3 ++- LunaTranslator/files/lang/es.json | 3 ++- LunaTranslator/files/lang/fr.json | 3 ++- LunaTranslator/files/lang/it.json | 3 ++- LunaTranslator/files/lang/ja.json | 3 ++- LunaTranslator/files/lang/ko.json | 3 ++- LunaTranslator/files/lang/nl.json | 3 ++- LunaTranslator/files/lang/pl.json | 3 ++- LunaTranslator/files/lang/pt.json | 3 ++- LunaTranslator/files/lang/ru.json | 3 ++- LunaTranslator/files/lang/sv.json | 3 ++- LunaTranslator/files/lang/th.json | 3 ++- LunaTranslator/files/lang/tr.json | 3 ++- LunaTranslator/files/lang/uk.json | 3 ++- LunaTranslator/files/lang/vi.json | 3 ++- LunaTranslator/files/lang/zh.json | 3 ++- docs/zh/alltoolbuttons.md | 9 ++++--- plugins/CMakeLists.txt | 2 +- 24 files changed, 76 insertions(+), 38 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 215b046f..bd5e2e0b 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -456,15 +456,21 @@ class TranslatorWindow(resizableframeless): self.seteffect() self.changeextendstated() + @threader + def ocr_do_function(self, rect): + if not rect: + return + img = imageCut(0, rect[0][0], rect[0][1], rect[1][0], rect[1][1]) + text, infotype = ocr_run(img) + if infotype: + gobject.baseobject.displayinfomessage(text, infotype) + else: + gobject.baseobject.textgetmethod(text, False) + def ocr_once_function(self): - @threader def ocroncefunction(rect): - img = imageCut(0, rect[0][0], rect[0][1], rect[1][0], rect[1][1]) - text, infotype = ocr_run(img) - if infotype: - gobject.baseobject.displayinfomessage(text, infotype) - else: - gobject.baseobject.textgetmethod(text, False) + self.ocr_once_follow_rect = rect + self.ocr_do_function(rect) rangeselct_function(ocroncefunction, False, False) @@ -649,6 +655,10 @@ class TranslatorWindow(resizableframeless): ), ), ("ocr_once", self.ocr_once_signal.emit), + ( + "ocr_once_follow", + lambda: self.ocr_do_function(self.ocr_once_follow_rect), + ), ("minmize", self.hide_), ("quit", self.close), ( @@ -790,6 +800,7 @@ class TranslatorWindow(resizableframeless): self.thistimenotsetop = False self.isbindedwindow = False self.setontopthread_lock = threading.Lock() + self.ocr_once_follow_rect = None def displayglobaltooltip_f(self, string): QToolTip.showText(QCursor.pos(), string, self) diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 2de69ee1..68bf7584 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -656,12 +656,6 @@ "icon": "fa.crop", "align": 2 }, - "ocr_once": { - "use": false, - "tip": "进行一次OCR", - "icon": "fa.crop", - "align": 0 - }, "hideocrrange": { "use": true, "tip": "显示/隐藏范围框", @@ -671,6 +665,18 @@ "icon": "fa.square", "align": 2 }, + "ocr_once": { + "use": false, + "tip": "进行一次OCR", + "icon": "fa.crop", + "align": 0 + }, + "ocr_once_follow": { + "use": false, + "tip": "再次进行OCR", + "icon": "fa.spinner", + "align": 0 + }, "noundict_direct": { "use": false, "tip": "专有名词翻译_直接替换", diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index e873c409..4ce4216e 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -832,5 +832,6 @@ "背景窗口透明": "نافذة خلفية شفافة", "文件翻译": "ترجمة الوثائق", "文件": "الوثائق", - "最大结果条数": "أقصى عدد من النتائج" + "最大结果条数": "أقصى عدد من النتائج", + "再次进行OCR": "التعرف الضوئي على الحروف مرة أخرى" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 24a7803c..43fabd56 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -832,5 +832,6 @@ "背景窗口透明": "背景視窗透明", "文件翻译": "檔案翻譯", "文件": "文件", - "最大结果条数": "最大結果條數" + "最大结果条数": "最大結果條數", + "再次进行OCR": "再次進行OCR" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cs.json b/LunaTranslator/files/lang/cs.json index a9a3389f..aa289239 100644 --- a/LunaTranslator/files/lang/cs.json +++ b/LunaTranslator/files/lang/cs.json @@ -832,5 +832,6 @@ "背景窗口透明": "Okno pozadí transparentní", "文件翻译": "dokumentární překlad", "文件": "soubor", - "最大结果条数": "Maximální počet výsledků" + "最大结果条数": "Maximální počet výsledků", + "再次进行OCR": "Proveďte znovu OCR" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/de.json b/LunaTranslator/files/lang/de.json index ebc90f3a..f303410a 100644 --- a/LunaTranslator/files/lang/de.json +++ b/LunaTranslator/files/lang/de.json @@ -832,5 +832,6 @@ "背景窗口透明": "Hintergrundfenster transparent", "文件翻译": "Übersetzung von Dokumenten", "文件": "Datei", - "最大结果条数": "Maximale Anzahl der Ergebnisse" + "最大结果条数": "Maximale Anzahl der Ergebnisse", + "再次进行OCR": "OCR erneut ausführen" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index ee00f797..2cfde14d 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -832,5 +832,6 @@ "背景窗口透明": "Background window transparent", "文件翻译": "documentary translation", "文件": "file", - "最大结果条数": "Maximum number of results" + "最大结果条数": "Maximum number of results", + "再次进行OCR": "Perform OCR again" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index bafdccf3..736952af 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -832,5 +832,6 @@ "背景窗口透明": "La ventana de fondo es transparente", "文件翻译": "Traducción de documentos", "文件": "Documentos", - "最大结果条数": "Número máximo de resultados" + "最大结果条数": "Número máximo de resultados", + "再次进行OCR": "Volver a realizar OCR" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index 90254686..8df490a8 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -832,5 +832,6 @@ "背景窗口透明": "Fenêtre de fond transparente", "文件翻译": "Traduction de documents", "文件": "Documents", - "最大结果条数": "Nombre maximal de barres de résultats" + "最大结果条数": "Nombre maximal de barres de résultats", + "再次进行OCR": "OCR à nouveau" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index e326ea6c..27060c09 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -832,5 +832,6 @@ "背景窗口透明": "Finestra di sfondo trasparente", "文件翻译": "traduzione documentaria", "文件": "file", - "最大结果条数": "Numero massimo di risultati" + "最大结果条数": "Numero massimo di risultati", + "再次进行OCR": "Esegui nuovamente OCR" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index ffdd59bc..241e381a 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -832,5 +832,6 @@ "背景窗口透明": "背景ウィンドウの透過性", "文件翻译": "ファイル翻訳", "文件": "ファイル", - "最大结果条数": "最大結果バー数" + "最大结果条数": "最大結果バー数", + "再次进行OCR": "OCRを再実行" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index d61be119..3b66e73a 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -832,5 +832,6 @@ "背景窗口透明": "배경 창 투명도", "文件翻译": "파일 번역", "文件": "파일", - "最大结果条数": "최대 결과 개수" + "最大结果条数": "최대 결과 개수", + "再次进行OCR": "다시 OCR을 진행하도록 하겠습니다." } \ No newline at end of file diff --git a/LunaTranslator/files/lang/nl.json b/LunaTranslator/files/lang/nl.json index 46b9c3c8..06e51ae8 100644 --- a/LunaTranslator/files/lang/nl.json +++ b/LunaTranslator/files/lang/nl.json @@ -832,5 +832,6 @@ "背景窗口透明": "Achtergrondvenster transparant", "文件翻译": "documentaire vertaling", "文件": "bestand", - "最大结果条数": "Maximaal aantal resultaten" + "最大结果条数": "Maximaal aantal resultaten", + "再次进行OCR": "OCR opnieuw uitvoeren" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 41d49c00..99e114a4 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -832,5 +832,6 @@ "背景窗口透明": "Okno tła przejrzyste", "文件翻译": "tłumaczenie dokumentów", "文件": "plik", - "最大结果条数": "Maksymalna liczba wyników" + "最大结果条数": "Maksymalna liczba wyników", + "再次进行OCR": "Wykonaj ponownie OCR" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pt.json b/LunaTranslator/files/lang/pt.json index c8657f3c..2bca6a64 100644 --- a/LunaTranslator/files/lang/pt.json +++ b/LunaTranslator/files/lang/pt.json @@ -832,5 +832,6 @@ "背景窗口透明": "Janela de fundo transparente", "文件翻译": "tradução documental", "文件": "ficheiro", - "最大结果条数": "Número máximo de resultados" + "最大结果条数": "Número máximo de resultados", + "再次进行OCR": "Executar OCR novamente" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 13ded479..690e5395 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -832,5 +832,6 @@ "背景窗口透明": "Фоновое окно прозрачно", "文件翻译": "Перевод документов", "文件": "Документация", - "最大结果条数": "Максимальное число итоговых полос" + "最大结果条数": "Максимальное число итоговых полос", + "再次进行OCR": "Повторить OCR" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/sv.json b/LunaTranslator/files/lang/sv.json index 2d42e0e5..8623d516 100644 --- a/LunaTranslator/files/lang/sv.json +++ b/LunaTranslator/files/lang/sv.json @@ -832,5 +832,6 @@ "背景窗口透明": "Bakgrundsfönster genomskinligt", "文件翻译": "dokumentär översättning", "文件": "fil", - "最大结果条数": "Maximalt antal resultat" + "最大结果条数": "Maximalt antal resultat", + "再次进行OCR": "Utför OCR igen" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 5c1908b7..7d980fad 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -832,5 +832,6 @@ "背景窗口透明": "หน้าต่างพื้นหลังโปร่งใส", "文件翻译": "แปลเอกสาร", "文件": "แฟ้ม", - "最大结果条数": "จำนวนแถบผลลัพธ์สูงสุด" + "最大结果条数": "จำนวนแถบผลลัพธ์สูงสุด", + "再次进行OCR": "OCR อีกครั้ง" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index 22af9408..3ff03c6c 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -832,5 +832,6 @@ "背景窗口透明": "Arkaplan penceresi transparent", "文件翻译": "belgeler çeviri", "文件": "dosya", - "最大结果条数": "En yüksek sonuçların sayısı" + "最大结果条数": "En yüksek sonuçların sayısı", + "再次进行OCR": "OCR tekrar yap" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index 3d1325f0..af841a03 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -832,5 +832,6 @@ "背景窗口透明": "Прозоре вікно тла", "文件翻译": "документарний переклад", "文件": "файл", - "最大结果条数": "Максимальна кількість результатів" + "最大结果条数": "Максимальна кількість результатів", + "再次进行OCR": "Виконати OCR знову" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index 5bc9c6b3..69d4c4b5 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -832,5 +832,6 @@ "背景窗口透明": "Trong suốt cửa sổ nền", "文件翻译": "Dịch tài liệu", "文件": "Tài liệu", - "最大结果条数": "Số thanh kết quả tối đa" + "最大结果条数": "Số thanh kết quả tối đa", + "再次进行OCR": "OCR lần nữa" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 9994d7ac..2b0c40d0 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -832,5 +832,6 @@ "背景窗口透明": "", "文件翻译": "", "文件": "", - "最大结果条数": "" + "最大结果条数": "", + "再次进行OCR": "" } \ No newline at end of file diff --git a/docs/zh/alltoolbuttons.md b/docs/zh/alltoolbuttons.md index 5f3a9d6a..cf61f979 100644 --- a/docs/zh/alltoolbuttons.md +++ b/docs/zh/alltoolbuttons.md @@ -60,13 +60,14 @@ 1. #### 选取OCR范围 **该按钮仅在OCR模式下可用**
OCR模式先,选取OCR区域,或者更换OCR区域,或者当激活`OCR设置`->`其他`->`多重区域模式`时增加新的OCR区域 -1. #### 进行一次OCR - 该按钮和`读取剪贴板`类似,不管当前的默认文本输入源是什么,都会先进行OCR范围选择,然后进行一次OCR,然后进行翻译流程。
- 该按钮一般用于,在HOOK模式下,遇到选择支时,临时使用一次OCR进行翻译选择支。或者在OCR模式下,临时去识别一次其他偶尔出现的新的位置。
- 该按钮每次都需要进行翻译选择,不会进行记忆。 1. #### 显示/隐藏范围框 **该按钮仅在OCR模式下可用**
当未选择任何OCR范围时,使用该按钮显示OCR范围,会自动设置OCR范围为上一次选择的OCR。 +1. #### 进行一次OCR + 该按钮和`读取剪贴板`类似,不管当前的默认文本输入源是什么,都会先进行OCR范围选择,然后进行一次OCR,然后进行翻译流程。
+ 该按钮一般用于,在HOOK模式下,遇到选择支时,临时使用一次OCR进行翻译选择支。或者在OCR模式下,临时去识别一次其他偶尔出现的新的位置。
+1. #### 再次进行OCR + 当使用过一次`进行一次OCR`后,使用这个按钮,可以在原来的位置上再次进行一次OCR而无需重新选择识别区域。 1. #### 专有名词翻译_直接替换 1. #### 专有名词翻译_sakura_gpt_词典 diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 2b6b3f85..8bceb4c1 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 28) -set(VERSION_PATCH 3) +set(VERSION_PATCH 4) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)