Clean up font handling in HTML and ODT
This commit is contained in:
+14
-1
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user