diff --git a/docs/en/fastkeys.md b/docs/en/fastkeys.md index 395a671031..7dd2d8ce75 100644 --- a/docs/en/fastkeys.md +++ b/docs/en/fastkeys.md @@ -136,6 +136,9 @@ 1. #### Retrieve and search for words Search for words in the text currently selected by the mouse +1. #### OCR word search + Select the OCR range for one OCR and then search for words + 1. #### Anki Recording Shortcut key for the recording function in the Anki add interface in the dictionary lookup window. diff --git a/docs/ja/fastkeys.md b/docs/ja/fastkeys.md index 44b10656ea..bd411e5345 100644 --- a/docs/ja/fastkeys.md +++ b/docs/ja/fastkeys.md @@ -136,6 +136,9 @@ 1. #### 単語を取って単語を調べる 現在マウスで選択されているテキストの単語検索 +1. #### OCR単語検索 + OCR範囲を選択してOCRを1回実行し、単語を調べる + 1. #### Anki録音 辞書検索ウィンドウのAnki追加インターフェースの録音機能のショートカットキー。 diff --git a/docs/zh/fastkeys.md b/docs/zh/fastkeys.md index 192673a7e2..ff2996ef87 100644 --- a/docs/zh/fastkeys.md +++ b/docs/zh/fastkeys.md @@ -137,6 +137,9 @@ 1. #### 取词查词 对当前鼠标选取到的文本进行查词 +1. #### OCR 查词 + 选取OCR范围进行一次OCR然后查词 + 1. #### Anki 录音 查词窗口中的Anki添加界面中的录音功能的快捷键 diff --git a/py/LunaTranslator/gui/setting_hotkey.py b/py/LunaTranslator/gui/setting_hotkey.py index a11163fd40..74b5519d90 100644 --- a/py/LunaTranslator/gui/setting_hotkey.py +++ b/py/LunaTranslator/gui/setting_hotkey.py @@ -96,6 +96,7 @@ def registrhotkeys(self): "37": lambda: gobject.baseobject.searchwordW.search_word.emit( winsharedutils.GetSelectedText(), False ), + "39": lambda: gobject.baseobject.searchwordW.ocr_once_signal.emit( ), "38": lambda: gobject.baseobject.textgetmethod( winsharedutils.GetSelectedText(), False ), @@ -114,7 +115,7 @@ def registrhotkeys(self): ["剪贴板", ["36", "_4", "_28"]], ["TTS", ["_32", "_7", "_7_1"]], ["游戏", ["_15", "_20", "_21", "_22", "_25", "_27", "_31"]], - ["查词", ["37", "_29", "_30", "_35", "_33"]], + ["查词", ["37","39", "_29", "_30", "_35", "_33"]], ] diff --git a/py/LunaTranslator/gui/showword.py b/py/LunaTranslator/gui/showword.py index 43633138be..3737e1d3e3 100644 --- a/py/LunaTranslator/gui/showword.py +++ b/py/LunaTranslator/gui/showword.py @@ -993,6 +993,7 @@ class searchwordW(closeashidewindow): search_word = pyqtSignal(str, bool) show_dict_result = pyqtSignal(float, str, str) search_word_in_new_window = pyqtSignal(str) + ocr_once_signal = pyqtSignal() def __init__(self, parent): super(searchwordW, self).__init__(parent, globalconfig["sw_geo"]) @@ -1000,8 +1001,22 @@ def __init__(self, parent): self.search_word.connect(self.__click_word_search_function) self.search_word_in_new_window.connect(self.searchwinnewwindow) self.show_dict_result.connect(self.__show_dict_result_function) + self.ocr_once_signal.connect( + lambda: rangeselct_function(self.ocr_do_function, False) + ) self.state = 0 + @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: + self.search_word.emit(text, False) + def __load(self): if self.state != 0: return diff --git a/py/files/defaultconfig/config.json b/py/files/defaultconfig/config.json index 886f6d9a96..93a54d74ac 100644 --- a/py/files/defaultconfig/config.json +++ b/py/files/defaultconfig/config.json @@ -1061,6 +1061,11 @@ "name": "取词翻译", "keystring": "" }, + "39": { + "use": false, + "name": "OCR_查词", + "keystring": "" + }, "_29": { "use": false, "name": "Anki_录音",