Simplify the About dialog
This commit is contained in:
@@ -33,14 +33,14 @@ from PyQt5.QtWidgets import (
|
|||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.common import cssCol, readTextFile
|
from novelwriter.common import cssCol, readTextFile
|
||||||
from novelwriter.extensions.configlayout import NColourLabel
|
from novelwriter.extensions.configlayout import NColourLabel
|
||||||
from novelwriter.extensions.modified import NNonBlockingDialog
|
from novelwriter.extensions.modified import NDialog
|
||||||
from novelwriter.extensions.versioninfo import VersionInfoWidget
|
from novelwriter.extensions.versioninfo import VersionInfoWidget
|
||||||
from novelwriter.types import QtAlignRightTop, QtDialogClose
|
from novelwriter.types import QtAlignRightTop, QtDialogClose
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class GuiAbout(NNonBlockingDialog):
|
class GuiAbout(NDialog):
|
||||||
|
|
||||||
def __init__(self, parent: QWidget) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
@@ -106,7 +106,9 @@ class GuiAbout(NNonBlockingDialog):
|
|||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
self.setSizeGripEnabled(True)
|
self.setSizeGripEnabled(True)
|
||||||
|
|
||||||
self._setStyleSheet()
|
self._setStyleSheet()
|
||||||
|
self._fillCreditsPage()
|
||||||
|
|
||||||
logger.debug("Ready: GuiAbout")
|
logger.debug("Ready: GuiAbout")
|
||||||
|
|
||||||
@@ -116,11 +118,6 @@ class GuiAbout(NNonBlockingDialog):
|
|||||||
logger.debug("Delete: GuiAbout")
|
logger.debug("Delete: GuiAbout")
|
||||||
return
|
return
|
||||||
|
|
||||||
def populateGUI(self) -> None:
|
|
||||||
"""Populate tabs with text."""
|
|
||||||
self._fillCreditsPage()
|
|
||||||
return
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Events
|
# Events
|
||||||
##
|
##
|
||||||
@@ -137,16 +134,14 @@ class GuiAbout(NNonBlockingDialog):
|
|||||||
|
|
||||||
def _fillCreditsPage(self) -> None:
|
def _fillCreditsPage(self) -> None:
|
||||||
"""Load the content for the Credits page."""
|
"""Load the content for the Credits page."""
|
||||||
docPath = CONFIG.assetPath("text") / "credits_en.htm"
|
if html := readTextFile(CONFIG.assetPath("text") / "credits_en.htm"):
|
||||||
docText = readTextFile(docPath)
|
self.txtCredits.setHtml(html)
|
||||||
if docText:
|
|
||||||
self.txtCredits.setHtml(docText)
|
|
||||||
else:
|
else:
|
||||||
self.txtCredits.setHtml("Error loading credits text ...")
|
self.txtCredits.setHtml("Error loading credits text ...")
|
||||||
return
|
return
|
||||||
|
|
||||||
def _setStyleSheet(self) -> None:
|
def _setStyleSheet(self) -> None:
|
||||||
"""Set stylesheet for all browser tabs."""
|
"""Set stylesheet text document."""
|
||||||
baseCol = cssCol(self.palette().window().color())
|
baseCol = cssCol(self.palette().window().color())
|
||||||
self.txtCredits.setStyleSheet(
|
self.txtCredits.setStyleSheet(
|
||||||
f"QTextBrowser {{border: none; background: {baseCol};}} "
|
f"QTextBrowser {{border: none; background: {baseCol};}} "
|
||||||
|
|||||||
@@ -827,8 +827,7 @@ class GuiMain(QMainWindow):
|
|||||||
def showAboutNWDialog(self) -> None:
|
def showAboutNWDialog(self) -> None:
|
||||||
"""Show the novelWriter about dialog."""
|
"""Show the novelWriter about dialog."""
|
||||||
dialog = GuiAbout(self)
|
dialog = GuiAbout(self)
|
||||||
dialog.activateDialog()
|
dialog.exec()
|
||||||
dialog.populateGUI()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ from novelwriter.dialogs.about import GuiAbout
|
|||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the novelWriter about dialogs."""
|
"""Test the novelWriter about dialogs."""
|
||||||
# NW About
|
monkeypatch.setattr(GuiAbout, "exec", lambda *a: None)
|
||||||
nwGUI.showAboutNWDialog()
|
|
||||||
|
|
||||||
|
nwGUI.showAboutNWDialog()
|
||||||
qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiAbout) is not None, timeout=1000)
|
qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiAbout) is not None, timeout=1000)
|
||||||
msgAbout = SHARED.findTopLevelWidget(GuiAbout)
|
msgAbout = SHARED.findTopLevelWidget(GuiAbout)
|
||||||
assert isinstance(msgAbout, GuiAbout)
|
assert isinstance(msgAbout, GuiAbout)
|
||||||
|
|||||||
Reference in New Issue
Block a user