diff --git a/cpp/version.cmake b/cpp/version.cmake index 347bb0e7..28b9f419 100644 --- a/cpp/version.cmake +++ b/cpp/version.cmake @@ -1,7 +1,7 @@ set(VERSION_MAJOR 6) set(VERSION_MINOR 9) -set(VERSION_PATCH 3) +set(VERSION_PATCH 4) set(VERSION_REVISION 0) set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp) diff --git a/py/LunaTranslator/LunaTranslator.py b/py/LunaTranslator/LunaTranslator.py index dd46106b..50def7b8 100644 --- a/py/LunaTranslator/LunaTranslator.py +++ b/py/LunaTranslator/LunaTranslator.py @@ -948,16 +948,18 @@ class MAINUI: ) @threader - def clickwordcallback(self, word): + def clickwordcallback(self, word, append=False): if globalconfig["usewordorigin"] == False: word = word["orig"] else: word = word.get("origorig", word["orig"]) if globalconfig["usecopyword"]: - winsharedutils.clipboard_set(word) + winsharedutils.clipboard_set( + (winsharedutils.clipboard_get() + word) if append else word + ) if globalconfig["usesearchword"]: - self.searchwordW.search_word.emit(word) + self.searchwordW.search_word.emit(word, append) def __dontshowintaborsetbackdrop(self, widget): window_flags = widget.windowFlags() diff --git a/py/LunaTranslator/gui/showword.py b/py/LunaTranslator/gui/showword.py index a1415be3..ad2122d3 100644 --- a/py/LunaTranslator/gui/showword.py +++ b/py/LunaTranslator/gui/showword.py @@ -846,7 +846,7 @@ class DynamicTreeModel(QStandardItemModel): if not self.data(index, isWordNode): return gobject.baseobject.searchwordW.search_word.emit( - self.itemFromIndex(index).text() + self.itemFromIndex(index).text(), False ) @@ -976,7 +976,7 @@ class showdiction(LMainWindow): class searchwordW(closeashidewindow): - search_word = pyqtSignal(str) + search_word = pyqtSignal(str, bool) show_dict_result = pyqtSignal(float, str, str) search_word_in_new_window = pyqtSignal(str) @@ -1143,7 +1143,9 @@ class searchwordW(closeashidewindow): self.tabks = [] self.setCentralWidget(ww) self.textOutput = auto_select_webview(self, True) - self.textOutput.add_menu(0, _TR("查词"), self.search_word.emit) + self.textOutput.add_menu( + 0, _TR("查词"), lambda w: self.search_word.emit(w, False) + ) self.textOutput.add_menu( 1, _TR("在新窗口中查词"), threader(self.search_word_in_new_window.emit) ) @@ -1201,11 +1203,13 @@ class searchwordW(closeashidewindow): res.insert(idx, {"dict": k, "content": v}) return res - def __click_word_search_function(self, word): + def __click_word_search_function(self, word, append): self.showNormal() if self.state != 2: return word = word.strip() + if append: + word = self.searchtext.text() + word self.searchtext.setText(word) self.search(word) diff --git a/py/LunaTranslator/rendertext/textbrowser.py b/py/LunaTranslator/rendertext/textbrowser.py index 23568471..3dc85cc0 100644 --- a/py/LunaTranslator/rendertext/textbrowser.py +++ b/py/LunaTranslator/rendertext/textbrowser.py @@ -23,7 +23,9 @@ class Qlabel_c(QLabel): try: if self.pr: if event.button() == Qt.MouseButton.LeftButton: - self.callback() + self.callback(False) + elif event.button() == Qt.MouseButton.RightButton: + self.callback(True) except: print_exc() self.pr = False @@ -111,9 +113,9 @@ class TextBrowser(QWidget, dataget): menu.addAction(tts) menu.addSeparator() menu.addAction(copy) - action = menu.exec(self.mapToGlobal(p)) + action = menu.exec(QCursor.pos()) if action == search: - gobject.baseobject.searchwordW.search_word.emit(curr) + gobject.baseobject.searchwordW.search_word.emit(curr, False) elif action == copy: winsharedutils.clipboard_set(curr) elif action == tts: @@ -658,13 +660,9 @@ class TextBrowser(QWidget, dataget): if isfenciclick: self.searchmasklabels_clicked[labeli].setGeometry(*pos1) self.searchmasklabels_clicked[labeli].show() - clickfunction = word.get("clickfunction", None) - if clickfunction: - self.searchmasklabels_clicked[labeli].callback = clickfunction - else: - self.searchmasklabels_clicked[labeli].callback = functools.partial( - gobject.baseobject.clickwordcallback, word - ) + self.searchmasklabels_clicked[labeli].callback = functools.partial( + gobject.baseobject.clickwordcallback, word + ) if isshow_fenci and color: self.searchmasklabels[labeli].setGeometry(*pos1) self.searchmasklabels[labeli].setStyleSheet( diff --git a/py/LunaTranslator/rendertext/webview.html b/py/LunaTranslator/rendertext/webview.html index c543f5b7..319e9ee5 100644 --- a/py/LunaTranslator/rendertext/webview.html +++ b/py/LunaTranslator/rendertext/webview.html @@ -45,14 +45,12 @@ if (!_call) _call = console.log; _call(h) - window.__resolve_h = h } function safe_calllunaclickedword(word) { let _call = window.calllunaclickedword; if (!_call) _call = console.log; _call(word) - window.__resolve_word = word }