Add native font dialog option and fix tests

This commit is contained in:
Veronica Berglyd Olsen
2024-05-23 18:44:45 +02:00
parent 1fe7ca3db8
commit 69b362b9d2
6 changed files with 30 additions and 30 deletions
+9 -11
View File
@@ -256,8 +256,11 @@ class SharedData(QObject):
QThreadPool.globalInstance().start(runnable, priority=priority)
return
def getProjectPath(self, parent: QWidget, path: str | Path | None = None,
allowZip: bool = False) -> Path | None:
def getProjectPath(
self, parent: QWidget,
path: str | Path | None = None,
allowZip: bool = False
) -> Path | None:
"""Open the file dialog and select a novelWriter project file."""
label = (self.tr("novelWriter Project File or Zip File")
if allowZip else self.tr("novelWriter Project File"))
@@ -270,15 +273,10 @@ class SharedData(QObject):
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
kwargs = {}
if not native:
kwargs["options"] = QFontDialog.FontDialogOption.DontUseNativeDialog
return QFontDialog.getFont(current, self.mainGui, self.tr("Select Font"), **kwargs)
def findTopLevelWidget(self, kind: type[NWWidget]) -> NWWidget | None:
"""Find a top level widget."""