From 8b281849fb72b6e9ef6317f5c4cdc5a8249eaf4a 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: Tue, 9 Jul 2024 19:38:06 +0800 Subject: [PATCH] delay --- .../LunaTranslator/gui/translatorUI.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 8a7517a7..bf28d9cc 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -43,6 +43,7 @@ class QUnFrameWindow(resizableframeless): hidesignal = pyqtSignal() muteprocessignal = pyqtSignal() ocr_once_signal = pyqtSignal() + resizesignal = pyqtSignal(QSize) def hookfollowsignalsolve(self, code, other): if self._move_drag: @@ -558,6 +559,7 @@ class QUnFrameWindow(resizableframeless): self.muteprocessignal.connect(self.muteprocessfuntion) self.toolbarhidedelaysignal.connect(self.toolbarhidedelay) + self.resizesignal.connect(self.resize) def __init__(self): @@ -845,7 +847,20 @@ class QUnFrameWindow(resizableframeless): newHeight = ( limit + self.translate_text._padding + int(globalconfig["buttonsize"] * 1.5) ) - self.resize(self.width(), newHeight) + size = QSize(self.width(), newHeight) + self.autoresizesig = time.time() + if newHeight > self.height(): + self.resize(size) + else: + self.delaymaybeshrink(size, self.autoresizesig) + + @threader + def delaymaybeshrink(self, size: QSize, sig): + + time.sleep(0.1) + if sig != self.autoresizesig: + return + self.resizesignal.emit(size) def clickRange(self, auto): if globalconfig["sourcestatus2"]["ocr"]["use"] == False: