From bc47a3791d55c2dd9b04135387bc92a931900023 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: Sun, 15 Sep 2024 20:25:35 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/LunaTranslator.py | 3 ++- .../LunaTranslator/rendertext/textbrowser.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 1881e190..7da93eef 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -450,7 +450,8 @@ class MAINUI: ) if result: # 预翻译 - callback(result, 0) + callback(result, 1) + callback(result, 2) else: self.translators[engine].gettask(task) diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py index 6d56d4cc..1e3255db 100644 --- a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py +++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py @@ -467,8 +467,12 @@ class TextBrowser(QWidget, dataget): def _showyinyingtext2(self, color, iter_context_class, pos, text, font): if iter_context_class not in self.iteryinyinglabelsave: self.iteryinyinglabelsave[iter_context_class] = [] + count = 0 for label in self.iteryinyinglabelsave[iter_context_class]: - label.hide() + if label.isVisible(): + count += 1 + else: + label.hide() maxh = self.maxvisheight subtext = [] @@ -489,6 +493,7 @@ class TextBrowser(QWidget, dataget): if text[i] != "\n": subtext[-1] += text[i] collects = [] + needmovenexts = len(subtext) != count for i in range(len(subtext)): if i >= len(self.iteryinyinglabelsave[iter_context_class]): @@ -503,7 +508,8 @@ class TextBrowser(QWidget, dataget): _.adjustSize() _.move(subpos[i].x(), subpos[i].y() + self.labeloffset_y) _.show() - + if not needmovenexts: + return self.textcursor.setPosition(pos) self.textbrowser.setTextCursor(self.textcursor) tl1 = self.textbrowser.cursorRect(self.textcursor).topLeft()