Update textbrowser.py

This commit is contained in:
恍兮惚兮 2024-07-30 21:17:38 +08:00
parent 85d6aa0ba3
commit da08cd19e8

View File

@ -263,6 +263,7 @@ class TextBrowser(QWidget, dataget):
return Qt.AlignmentFlag.AlignCenter if atcenter else Qt.AlignmentFlag.AlignLeft return Qt.AlignmentFlag.AlignCenter if atcenter else Qt.AlignmentFlag.AlignLeft
def _textbrowser_append(self, origin, atcenter, text, tag, color, cleared): def _textbrowser_append(self, origin, atcenter, text, tag, color, cleared):
self.textbrowser.document().blockSignals(True)
font = self._createqfont(origin) font = self._createqfont(origin)
self._setnextfont(font, cleared) self._setnextfont(font, cleared)
self.textbrowser.setAlignment(self._getqalignment(atcenter)) self.textbrowser.setAlignment(self._getqalignment(atcenter))
@ -272,6 +273,8 @@ class TextBrowser(QWidget, dataget):
self.textbrowser.insertPlainText(_space + text) self.textbrowser.insertPlainText(_space + text)
blockcount_after = self.textbrowser.document().blockCount() blockcount_after = self.textbrowser.document().blockCount()
self._setlineheight(blockcount, blockcount_after, origin, len(tag) > 0) self._setlineheight(blockcount, blockcount_after, origin, len(tag) > 0)
self.textbrowser.document().blockSignals(False)
self.textbrowser.document().contentsChanged.emit()
if len(tag) > 0: if len(tag) > 0:
self._addtag(tag) self._addtag(tag)
self._showyinyingtext(blockcount, blockcount_after, color, font) self._showyinyingtext(blockcount, blockcount_after, color, font)