Clean up font handling in HTML and ODT

This commit is contained in:
Veronica Berglyd Olsen
2024-05-22 23:13:16 +02:00
parent 411163f750
commit cf16b57f66
8 changed files with 40 additions and 37 deletions
+14 -1
View File
@@ -31,7 +31,8 @@ from time import time
from typing import TYPE_CHECKING, TypeVar
from PyQt5.QtCore import QObject, QRunnable, QThreadPool, QTimer, pyqtSignal
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QWidget
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QFileDialog, QFontDialog, QMessageBox, QWidget
from novelwriter.common import formatFileFilter
from novelwriter.constants import nwFiles
@@ -267,6 +268,18 @@ class SharedData(QObject):
)
return Path(selected) if selected else None
def getFont(self, current: QFont, native: bool) -> tuple[QFont, bool]:
"""Open the font dialog and select a font."""
if native:
font, status = QFontDialog.getFont(current, self.mainGui)
else:
options = QFontDialog.FontDialogOption.DontUseNativeDialog
font, status = QFontDialog.getFont(current, self.mainGui, options=options)
font.setOverline(False)
font.setStrikeOut(False)
font.setUnderline(False)
return font, status
def findTopLevelWidget(self, kind: type[NWWidget]) -> NWWidget | None:
"""Find a top level widget."""
for widget in self.mainGui.children():