Add font init to viewer, and update manuscript tool preview
This commit is contained in:
@@ -380,20 +380,14 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def initFont(self) -> None:
|
def initFont(self) -> None:
|
||||||
"""Set the font of the widget and document. This needs special
|
"""Set the font of the main widget and sub-widgets. This needs
|
||||||
attention since there appears to be a bug in Qt 5.15.3. See
|
special attention since there appears to be a bug in Qt 5.15.3.
|
||||||
issues #1862 and #1875.
|
See issues #1862 and #1875.
|
||||||
"""
|
"""
|
||||||
wFont = self.font()
|
font = self.font()
|
||||||
wFont.setFamily(CONFIG.textFont)
|
font.setFamily(CONFIG.textFont)
|
||||||
wFont.setPointSize(CONFIG.textSize)
|
font.setPointSize(CONFIG.textSize)
|
||||||
|
self.setFont(font)
|
||||||
dFont = self._qDocument.defaultFont()
|
|
||||||
dFont.setFamily(CONFIG.textFont)
|
|
||||||
dFont.setPointSize(CONFIG.textSize)
|
|
||||||
|
|
||||||
self.setFont(wFont)
|
|
||||||
self._qDocument.setDefaultFont(dFont)
|
|
||||||
|
|
||||||
# Reset sub-widget font to GUI font
|
# Reset sub-widget font to GUI font
|
||||||
self.docHeader.setFont(SHARED.theme.guiFont)
|
self.docHeader.setFont(SHARED.theme.guiFont)
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ import logging
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from PyQt5.QtCore import QPoint, Qt, QUrl, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import QPoint, Qt, QUrl, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import QCursor, QMouseEvent, QPalette, QResizeEvent, QTextCursor, QTextOption
|
||||||
QCursor, QFont, QMouseEvent, QPalette, QResizeEvent, QTextCursor,
|
|
||||||
QTextOption
|
|
||||||
)
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAction, QApplication, QFrame, QHBoxLayout, QLabel, QMenu, QTextBrowser,
|
QAction, QApplication, QFrame, QHBoxLayout, QLabel, QMenu, QTextBrowser,
|
||||||
QToolButton, QWidget
|
QToolButton, QWidget
|
||||||
@@ -141,12 +138,7 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
def initViewer(self) -> None:
|
def initViewer(self) -> None:
|
||||||
"""Set editor settings from main config."""
|
"""Set editor settings from main config."""
|
||||||
self._makeStyleSheet()
|
self._makeStyleSheet()
|
||||||
|
self.initFont()
|
||||||
# Set Font
|
|
||||||
font = QFont()
|
|
||||||
font.setFamily(CONFIG.textFont)
|
|
||||||
font.setPointSize(CONFIG.textSize)
|
|
||||||
self.document().setDefaultFont(font)
|
|
||||||
|
|
||||||
# Set the widget colours to match syntax theme
|
# Set the widget colours to match syntax theme
|
||||||
mainPalette = self.palette()
|
mainPalette = self.palette()
|
||||||
@@ -189,6 +181,22 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
|
|
||||||
return
|
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:
|
def loadText(self, tHandle: str, updateHistory: bool = True) -> bool:
|
||||||
"""Load text into the viewer from an item handle."""
|
"""Load text into the viewer from an item handle."""
|
||||||
if not SHARED.project.tree.checkType(tHandle, nwItemType.FILE):
|
if not SHARED.project.tree.checkType(tHandle, nwItemType.FILE):
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ from time import time
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QPalette, QResizeEvent
|
||||||
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
|
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
||||||
@@ -831,12 +831,17 @@ class _PreviewWidget(QTextBrowser):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def setTextFont(self, family: str, size: int) -> None:
|
def setTextFont(self, family: str, size: int) -> None:
|
||||||
"""Set the text font properties."""
|
"""Set the text font properties and then reset for sub-widgets.
|
||||||
if family:
|
This needs special attention since there appears to be a bug in
|
||||||
font = QFont()
|
Qt 5.15.3. See issues #1862 and #1875.
|
||||||
|
"""
|
||||||
|
if family and size > 4:
|
||||||
|
font = self.font()
|
||||||
font.setFamily(family)
|
font.setFamily(family)
|
||||||
font.setPointSize(size)
|
font.setPointSize(size)
|
||||||
self.document().setDefaultFont(font)
|
self.setFont(font)
|
||||||
|
self.ageLabel.setFont(SHARED.theme.guiFont)
|
||||||
|
self.buildProgress.setFont(SHARED.theme.guiFont)
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user