From b25545387697dd939ff00cd508069c77faeebcba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Wed, 11 Dec 2024 16:20:09 +0800 Subject: [PATCH] . --- py/LunaTranslator/gui/showword.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/py/LunaTranslator/gui/showword.py b/py/LunaTranslator/gui/showword.py index ad2122d3..76bcf4d1 100644 --- a/py/LunaTranslator/gui/showword.py +++ b/py/LunaTranslator/gui/showword.py @@ -93,7 +93,10 @@ class AnkiWindow(QWidget): def asyncocr(self, img): self.__ocrsettext.emit(ocr_run(img)[0]) - def crop(self): + def crophide(self, s=False): + if s: + self.parent().parent().parent().hide() + def ocroncefunction(rect): img = imageCut(0, rect[0][0], rect[0][1], rect[1][0], rect[1][1]) fname = gobject.gettempdir(str(uuid.uuid4()) + "." + getimageformat()) @@ -101,6 +104,8 @@ class AnkiWindow(QWidget): self.settextsignal.emit(self.editpath, os.path.abspath(fname)) if globalconfig["ankiconnect"]["ocrcroped"]: self.asyncocr(img) + if s: + self.parent().parent().parent().show() rangeselct_function(ocroncefunction, False) @@ -434,7 +439,11 @@ class AnkiWindow(QWidget): soundbutton2 = QPushButton(qtawesome.icon("fa.music"), "") soundbutton2.clicked.connect(self.langdu2) cropbutton = QPushButton(qtawesome.icon("fa.crop"), "") - cropbutton.clicked.connect(self.crop) + cropbutton.clicked.connect(functools.partial(self.crophide, False)) + cropbutton.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) + cropbutton.customContextMenuRequested.connect( + functools.partial(self.crophide, True) + ) grabwindowbtn = QPushButton(qtawesome.icon("fa.camera"), "") grabwindowbtn.clicked.connect(