Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Dec 11, 2024
1 parent c43fdfc commit b255453
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions py/LunaTranslator/gui/showword.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ def langdu2(self):
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())
img.save(fname)
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)

Expand Down Expand Up @@ -434,7 +439,11 @@ def createaddtab(self):
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(
Expand Down

0 comments on commit b255453

Please sign in to comment.