Fix a bug with editor init on preferences update

This commit is contained in:
Veronica Berglyd Olsen
2024-01-08 22:13:33 +01:00
parent 2504965f8d
commit 944e2455d5
2 changed files with 16 additions and 15 deletions
+9 -8
View File
@@ -319,10 +319,10 @@ class GuiDocEditor(QPlainTextEdit):
SHARED.updateSpellCheckLanguage() SHARED.updateSpellCheckLanguage()
# Set font # Set font
textFont = QFont() font = QFont()
textFont.setFamily(CONFIG.textFont) font.setFamily(CONFIG.textFont)
textFont.setPointSize(CONFIG.textSize) font.setPointSize(CONFIG.textSize)
self.setFont(textFont) self.setFont(font)
# Set default text margins # Set default text margins
# Due to cursor visibility, a part of the margin must be # Due to cursor visibility, a part of the margin must be
@@ -358,13 +358,14 @@ class GuiDocEditor(QPlainTextEdit):
# Refresh the tab stops # Refresh the tab stops
self.setTabStopDistance(CONFIG.getTabWidth()) self.setTabStopDistance(CONFIG.getTabWidth())
# If we have a document open, we should reload it in case the # If we have a document open, we should refresh it in case the
# font changed, otherwise we just clear the editor entirely, # font changed, otherwise we just clear the editor entirely,
# which makes it read only. # which makes it read only.
if self._docHandle is None: if self._docHandle:
self.clearEditor()
else:
self._qDocument.syntaxHighlighter.rehighlight() self._qDocument.syntaxHighlighter.rehighlight()
self.docHeader.setTitleFromHandle(self._docHandle)
else:
self.clearEditor()
return return
+7 -7
View File
@@ -142,10 +142,10 @@ class GuiDocViewer(QTextBrowser):
self._makeStyleSheet() self._makeStyleSheet()
# Set Font # Set Font
textFont = QFont() font = QFont()
textFont.setFamily(CONFIG.textFont) font.setFamily(CONFIG.textFont)
textFont.setPointSize(CONFIG.textSize) font.setPointSize(CONFIG.textSize)
self.setFont(textFont) self.setFont(font)
# Set the widget colours to match syntax theme # Set the widget colours to match syntax theme
mainPalette = self.palette() mainPalette = self.palette()
@@ -164,10 +164,10 @@ class GuiDocViewer(QTextBrowser):
# Set default text margins # Set default text margins
self.document().setDocumentMargin(0) self.document().setDocumentMargin(0)
theOpt = QTextOption() options = QTextOption()
if CONFIG.doJustify: if CONFIG.doJustify:
theOpt.setAlignment(Qt.AlignmentFlag.AlignJustify) options.setAlignment(Qt.AlignmentFlag.AlignJustify)
self.document().setDefaultTextOption(theOpt) self.document().setDefaultTextOption(options)
# Scroll bars # Scroll bars
if CONFIG.hideVScroll: if CONFIG.hideVScroll: