From 1a4bafd426f6448f0b1c06182c4ff5cc2bc0b0ee 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: Wed, 8 May 2024 16:27:32 +0800 Subject: [PATCH] fix --- .../LunaTranslator/gui/textbrowser.py | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/textbrowser.py b/LunaTranslator/LunaTranslator/gui/textbrowser.py index a5c4e969..4a2bf440 100644 --- a/LunaTranslator/LunaTranslator/gui/textbrowser.py +++ b/LunaTranslator/LunaTranslator/gui/textbrowser.py @@ -213,7 +213,6 @@ class Textbrowser: self.yinyinglabels = [] - self.addtaged = False self.yinyingpos = 0 self.yinyingposline = 0 self.lastcolor = None @@ -278,19 +277,16 @@ class Textbrowser: b2 = self.textbrowser.document().blockCount() - if True: # self.addtaged: - if self.addtaged: - self.addtaged = False + fh = globalconfig["extra_space"] + for i in range(self.blockcount, self.textbrowser.document().blockCount()): + b = self.textbrowser.document().findBlockByNumber(i) + tf = b.blockFormat() + tf.setLineHeight(fh, QTextBlockFormat.LineDistanceHeight) + self.textcursor.setPosition(b.position()) + self.textcursor.setBlockFormat(tf) + self.textbrowser.setTextCursor(self.textcursor) + self.blockcount = self.textbrowser.document().blockCount() - fh = globalconfig["extra_space"] - for i in range(self.blockcount, self.textbrowser.document().blockCount()): - b = self.textbrowser.document().findBlockByNumber(i) - tf = b.blockFormat() - tf.setLineHeight(fh, QTextBlockFormat.LineDistanceHeight) - self.textcursor.setPosition(b.position()) - self.textcursor.setBlockFormat(tf) - self.textbrowser.setTextCursor(self.textcursor) - self.blockcount = self.textbrowser.document().blockCount() if len(tag) > 0: self.addtag(tag) @@ -586,19 +582,14 @@ class Textbrowser: def addtag(self, x): pos = 0 - self.addtaged = True fhall, fontorig = self.getfh(False) - fhhalf, fonthira = self.getfh(True) - fh, _ = self.getfh(False, True) - fh += globalconfig["extra_space"] for i in range(0, self.textbrowser.document().blockCount()): b = self.textbrowser.document().findBlockByNumber(i) tf = b.blockFormat() - # tf.setLineHeight(fh,QTextBlockFormat.LineDistanceHeight) - tf.setLineHeight(max(fh, fhall + fhhalf), QTextBlockFormat.FixedHeight) + tf.setLineHeight(fhall + fhhalf, QTextBlockFormat.FixedHeight) self.textcursor.setPosition(b.position()) self.textcursor.setBlockFormat(tf)