From 798de413bd43474487d61f3d41981d926323e6ea 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: Sat, 31 Aug 2024 15:05:53 +0800 Subject: [PATCH] iter --- LunaTranslator/LunaTranslator/gui/translatorUI.py | 7 +++++-- LunaTranslator/LunaTranslator/rendertext/textbrowser.py | 6 ++++-- plugins/CMakeLists.txt | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 327510d3..836ab733 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -306,7 +306,7 @@ class TranslatorWindow(resizableframeless): color = kwargs.get("color") res = kwargs.get("res") onlytrans = kwargs.get("onlytrans", False) # 仅翻译,不显示 - iter_context = kwargs.get("iter_context", (0, None)) + iter_context = kwargs.get("iter_context", None) clear = kwargs.get("clear", False) iter_res_status, iter_context_class = iter_context @@ -384,7 +384,10 @@ class TranslatorWindow(resizableframeless): atcenter = globalconfig["showatcenter"] if iter_context: - _, iter_context_class = iter_context + iter_res_status, iter_context_class = iter_context + else: + iter_res_status = 0 + if iter_res_status: self.translate_text.iter_append( iter_context_class, origin, atcenter, text, color ) diff --git a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py index c3de7186..217c50a8 100644 --- a/LunaTranslator/LunaTranslator/rendertext/textbrowser.py +++ b/LunaTranslator/LunaTranslator/rendertext/textbrowser.py @@ -457,11 +457,13 @@ class TextBrowser(QWidget, dataget): self.textcursor.setPosition(posx) posx += 1 tl1 = self.textbrowser.cursorRect(self.textcursor).topLeft() - if lastpos is None or tl1.y() != lastpos.y() or text[i] == "\n": + if lastpos is None or tl1.y() != lastpos.y(): lastpos = tl1 subpos.append(lastpos) subtext.append("") - subtext[-1] += text[i] + + if text[i] != "\n": + subtext[-1] += text[i] collects = [] for i in range(len(subtext)): diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 1aa5048a..a9dc2da2 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 32) -set(VERSION_PATCH 2) +set(VERSION_PATCH 3) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)