Fixed setting of font for doceditor and docviewer

This commit is contained in:
Veronica K. B. Olsen
2019-06-12 20:55:41 +02:00
parent 46bd7a8871
commit 8e73d6ac9a
6 changed files with 31 additions and 232 deletions
+6 -6
View File
@@ -126,13 +126,13 @@ class GuiDocEditor(QTextEdit):
self.setDictionaries()
# Set Font
if self.mainConf.textFont is not None:
self.setFontFamily(self.mainConf.textFont)
else:
theFont = QFont()
if self.mainConf.textFont is None:
# If none is defined, set the default back to config
theFont = self.theQDoc.defaultFont().family()
self.mainConf.textFont = theFont
self.setFontPointSize(self.mainConf.textSize)
self.mainConf.textFont = self.theQDoc.defaultFont().family()
theFont.setFamily(self.mainConf.textFont)
theFont.setPointSize(self.mainConf.textSize)
self.setFont(theFont)
# Set text fixed width, or alternatively, just margins
if self.mainConf.textFixedW:
+20 -4
View File
@@ -15,7 +15,7 @@ import nw
from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtWidgets import QTextBrowser
from PyQt5.QtGui import QTextOption
from PyQt5.QtGui import QTextOption, QFont
from nw.convert.tokenizer import Tokenizer
from nw.convert.tohtml import ToHtml
@@ -82,7 +82,7 @@ class GuiDocViewer(QTextBrowser):
aColB = self.theTheme.colLink[2],
))
self.setMinimumWidth(300)
self.initEditor()
self.initViewer()
theOpt = QTextOption()
if self.mainConf.doJustify:
@@ -98,15 +98,31 @@ class GuiDocViewer(QTextBrowser):
self.setSearchPaths([""])
return True
def initEditor(self):
"""Set editor settings from mani config.
def initViewer(self):
"""Set editor settings from main config.
"""
# Set Font
theFont = QFont()
if self.mainConf.textFont is None:
# If none is defined, set the default back to config
self.mainConf.textFont = self.theQDoc.defaultFont().family()
theFont.setFamily(self.mainConf.textFont)
theFont.setPointSize(self.mainConf.textSize)
self.setFont(theFont)
self.theQDoc.setDocumentMargin(self.mainConf.textMargin[0])
theOpt = QTextOption()
if self.mainConf.doJustify:
theOpt.setAlignment(Qt.AlignJustify)
self.theQDoc.setDefaultTextOption(theOpt)
# If we have a document open, we should reload it in case the font changed
if self.theHandle is not None:
tHandle = self.theHandle
self.clearViewer()
self.loadText(tHandle)
return True
def loadText(self, tHandle):
+1
View File
@@ -466,6 +466,7 @@ class GuiMain(QMainWindow):
logger.debug("Applying new preferences")
self.initMain()
self.docEditor.initEditor()
self.docViewer.initViewer()
return True
def editProjectDialog(self):