Add font init to viewer, and update manuscript tool preview

This commit is contained in:
Veronica Berglyd Olsen
2024-05-20 11:36:30 +02:00
parent 09b51badd4
commit cb19475409
3 changed files with 35 additions and 28 deletions
+7 -13
View File
@@ -380,20 +380,14 @@ class GuiDocEditor(QPlainTextEdit):
return
def initFont(self) -> None:
"""Set the font of the widget and document. This needs special
attention since there appears to be a bug in Qt 5.15.3. See
issues #1862 and #1875.
"""Set the font of the main widget and sub-widgets. This needs
special attention since there appears to be a bug in Qt 5.15.3.
See issues #1862 and #1875.
"""
wFont = self.font()
wFont.setFamily(CONFIG.textFont)
wFont.setPointSize(CONFIG.textSize)
dFont = self._qDocument.defaultFont()
dFont.setFamily(CONFIG.textFont)
dFont.setPointSize(CONFIG.textSize)
self.setFont(wFont)
self._qDocument.setDefaultFont(dFont)
font = self.font()
font.setFamily(CONFIG.textFont)
font.setPointSize(CONFIG.textSize)
self.setFont(font)
# Reset sub-widget font to GUI font
self.docHeader.setFont(SHARED.theme.guiFont)
+18 -10
View File
@@ -31,10 +31,7 @@ import logging
from enum import Enum
from PyQt5.QtCore import QPoint, Qt, QUrl, pyqtSignal, pyqtSlot
from PyQt5.QtGui import (
QCursor, QFont, QMouseEvent, QPalette, QResizeEvent, QTextCursor,
QTextOption
)
from PyQt5.QtGui import QCursor, QMouseEvent, QPalette, QResizeEvent, QTextCursor, QTextOption
from PyQt5.QtWidgets import (
QAction, QApplication, QFrame, QHBoxLayout, QLabel, QMenu, QTextBrowser,
QToolButton, QWidget
@@ -141,12 +138,7 @@ class GuiDocViewer(QTextBrowser):
def initViewer(self) -> None:
"""Set editor settings from main config."""
self._makeStyleSheet()
# Set Font
font = QFont()
font.setFamily(CONFIG.textFont)
font.setPointSize(CONFIG.textSize)
self.document().setDefaultFont(font)
self.initFont()
# Set the widget colours to match syntax theme
mainPalette = self.palette()
@@ -189,6 +181,22 @@ class GuiDocViewer(QTextBrowser):
return
def initFont(self) -> None:
"""Set the font of the main widget and sub-widgets. This needs
special attention since there appears to be a bug in Qt 5.15.3.
See issues #1862 and #1875.
"""
font = self.font()
font.setFamily(CONFIG.textFont)
font.setPointSize(CONFIG.textSize)
self.setFont(font)
# Reset sub-widget font to GUI font
self.docHeader.setFont(SHARED.theme.guiFont)
self.docFooter.setFont(SHARED.theme.guiFont)
return
def loadText(self, tHandle: str, updateHistory: bool = True) -> bool:
"""Load text into the viewer from an item handle."""
if not SHARED.project.tree.checkType(tHandle, nwItemType.FILE):