This commit is contained in:
恍兮惚兮 2024-05-08 16:27:32 +08:00
parent aef3f37f34
commit 1a4bafd426

View File

@ -213,7 +213,6 @@ class Textbrowser:
self.yinyinglabels = [] self.yinyinglabels = []
self.addtaged = False
self.yinyingpos = 0 self.yinyingpos = 0
self.yinyingposline = 0 self.yinyingposline = 0
self.lastcolor = None self.lastcolor = None
@ -278,19 +277,16 @@ class Textbrowser:
b2 = self.textbrowser.document().blockCount() b2 = self.textbrowser.document().blockCount()
if True: # self.addtaged: fh = globalconfig["extra_space"]
if self.addtaged: for i in range(self.blockcount, self.textbrowser.document().blockCount()):
self.addtaged = False 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: if len(tag) > 0:
self.addtag(tag) self.addtag(tag)
@ -586,19 +582,14 @@ class Textbrowser:
def addtag(self, x): def addtag(self, x):
pos = 0 pos = 0
self.addtaged = True
fhall, fontorig = self.getfh(False) fhall, fontorig = self.getfh(False)
fhhalf, fonthira = self.getfh(True) fhhalf, fonthira = self.getfh(True)
fh, _ = self.getfh(False, True)
fh += globalconfig["extra_space"]
for i in range(0, self.textbrowser.document().blockCount()): for i in range(0, self.textbrowser.document().blockCount()):
b = self.textbrowser.document().findBlockByNumber(i) b = self.textbrowser.document().findBlockByNumber(i)
tf = b.blockFormat() tf = b.blockFormat()
# tf.setLineHeight(fh,QTextBlockFormat.LineDistanceHeight) tf.setLineHeight(fhall + fhhalf, QTextBlockFormat.FixedHeight)
tf.setLineHeight(max(fh, fhall + fhhalf), QTextBlockFormat.FixedHeight)
self.textcursor.setPosition(b.position()) self.textcursor.setPosition(b.position())
self.textcursor.setBlockFormat(tf) self.textcursor.setBlockFormat(tf)