This commit is contained in:
恍兮惚兮 2024-05-13 16:34:04 +08:00
parent 9b7cc6b173
commit 1a23b76c83
3 changed files with 15 additions and 7 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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)