Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Dec 25, 2024
1 parent 06fa046 commit f039da9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/en/fastkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions docs/ja/fastkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
1. #### 単語を取って単語を調べる
現在マウスで選択されているテキストの単語検索

1. #### OCR単語検索
OCR範囲を選択してOCRを1回実行し、単語を調べる

1. #### Anki録音
辞書検索ウィンドウのAnki追加インターフェースの録音機能のショートカットキー。

Expand Down
3 changes: 3 additions & 0 deletions docs/zh/fastkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@
1. #### 取词查词
对当前鼠标选取到的文本进行查词

1. #### OCR 查词
选取OCR范围进行一次OCR然后查词

1. #### Anki 录音
查词窗口中的Anki添加界面中的录音功能的快捷键

Expand Down
3 changes: 2 additions & 1 deletion py/LunaTranslator/gui/setting_hotkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand All @@ -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"]],
]


Expand Down
15 changes: 15 additions & 0 deletions py/LunaTranslator/gui/showword.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,30 @@ 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"])
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
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
Expand Down
5 changes: 5 additions & 0 deletions py/files/defaultconfig/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,11 @@
"name": "取词翻译",
"keystring": ""
},
"39": {
"use": false,
"name": "OCR_查词",
"keystring": ""
},
"_29": {
"use": false,
"name": "Anki_录音",
Expand Down

0 comments on commit f039da9

Please sign in to comment.