From 1a23b76c83a348e5a3912b42a471d4e7725993cd 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: Mon, 13 May 2024 16:34:04 +0800 Subject: [PATCH] append --- LunaTranslator/LunaTranslator/gui/showword.py | 6 ++++-- LunaTranslator/LunaTranslator/gui/textbrowser.py | 10 +++++++--- LunaTranslator/LunaTranslator/gui/translatorUI.py | 6 ++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 03fb2f77..234ae6f3 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -18,7 +18,7 @@ from gui.usefulwidget import closeashidewindow class searchwordW(closeashidewindow): - getnewsentencesignal = pyqtSignal(str) + getnewsentencesignal = pyqtSignal(str, bool) searchthreadsignal = pyqtSignal(str, dict, str) showtabsignal = pyqtSignal(str, str) @@ -104,8 +104,10 @@ class searchwordW(closeashidewindow): if gobject.baseobject.reader: gobject.baseobject.reader.read(self.searchtext.text(), True) - def getnewsentence(self, sentence): + def getnewsentence(self, sentence, append): self.showNormal() + if append: + sentence = self.searchtext.text() + sentence self.searchtext.setText(sentence) self.search(sentence) diff --git a/LunaTranslator/LunaTranslator/gui/textbrowser.py b/LunaTranslator/LunaTranslator/gui/textbrowser.py index eefbd9a4..0849f4ea 100644 --- a/LunaTranslator/LunaTranslator/gui/textbrowser.py +++ b/LunaTranslator/LunaTranslator/gui/textbrowser.py @@ -6,6 +6,7 @@ from PyQt5.QtGui import ( QTextCursor, QPixmap, QFontMetricsF, + QMouseEvent, ) from PyQt5.QtWidgets import ( QTextBrowser, @@ -36,18 +37,21 @@ class Qlabel_c(QLabel): pass # return super().mouseMoveEvent(ev) - def mouseReleaseEvent(self, ev): + def mouseReleaseEvent(self, event: QMouseEvent): try: if self.underMouse(): try: if self.pr: - self.callback() + if event.button() == Qt.RightButton: + self.callback(True) + else: + self.callback(False) except: print_exc() self.pr = False except: print_exc() - return super().mouseReleaseEvent(ev) + return super().mouseReleaseEvent(event) def enterEvent(self, a0) -> None: if self.company: diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 8dceb263..96f4e9c6 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -255,7 +255,7 @@ class QUnFrameWindow(resizableframeless): if hira: - def callback(word): + def callback(word, append): if globalconfig["usewordorigin"] == False: word = word["orig"] else: @@ -264,7 +264,9 @@ class QUnFrameWindow(resizableframeless): if globalconfig["usecopyword"]: winsharedutils.clipboard_set(word) if globalconfig["usesearchword"]: - gobject.baseobject.searchwordW.getnewsentencesignal.emit(word) + gobject.baseobject.searchwordW.getnewsentencesignal.emit( + word, append + ) self.translate_text.addsearchwordmask(hira, text, callback)