Added basic about dialog

This commit is contained in:
Veronica K. B. Olsen
2020-05-21 15:51:45 +02:00
parent cb36e90149
commit 4588addaef
4 changed files with 127 additions and 48 deletions
+2
View File
@@ -8,6 +8,7 @@ from nw.gui.statusbar import GuiMainStatus
from nw.gui.theme import GuiTheme from nw.gui.theme import GuiTheme
# Dialogs # Dialogs
from nw.gui.dialogs.about import GuiAbout
from nw.gui.dialogs.configeditor import GuiConfigEditor from nw.gui.dialogs.configeditor import GuiConfigEditor
from nw.gui.dialogs.docmerge import GuiDocMerge from nw.gui.dialogs.docmerge import GuiDocMerge
from nw.gui.dialogs.docsplit import GuiDocSplit from nw.gui.dialogs.docsplit import GuiDocSplit
@@ -38,6 +39,7 @@ __all__ = [
"GuiMainMenu", "GuiMainMenu",
"GuiMainStatus", "GuiMainStatus",
"GuiTheme", "GuiTheme",
"GuiAbout",
"GuiConfigEditor", "GuiConfigEditor",
"GuiDocMerge", "GuiDocMerge",
"GuiDocSplit", "GuiDocSplit",
+2
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from nw.gui.dialogs.about import GuiAbout
from nw.gui.dialogs.configeditor import GuiConfigEditor from nw.gui.dialogs.configeditor import GuiConfigEditor
from nw.gui.dialogs.docmerge import GuiDocMerge from nw.gui.dialogs.docmerge import GuiDocMerge
from nw.gui.dialogs.docsplit import GuiDocSplit from nw.gui.dialogs.docsplit import GuiDocSplit
@@ -9,6 +10,7 @@ from nw.gui.dialogs.projectload import GuiProjectLoad
from nw.gui.dialogs.sessionlog import GuiSessionLogView from nw.gui.dialogs.sessionlog import GuiSessionLogView
__all__ = [ __all__ = [
"GuiAbout",
"GuiConfigEditor", "GuiConfigEditor",
"GuiDocMerge", "GuiDocMerge",
"GuiDocSplit", "GuiDocSplit",
+69
View File
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""novelWriter GUI About Box
novelWriter GUI About Box
=============================
The about novelWriter dialog box
File History:
Created: 2020-05-21 [0.5.2]
This file is a part of novelWriter
Copyright 2020, Veronica Berglyd Olsen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import nw
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox
)
logger = logging.getLogger(__name__)
class GuiAbout(QDialog):
def __init__(self, theParent):
QDialog.__init__(self, theParent)
logger.debug("Initialising GuiAbout ...")
self.mainConf = nw.CONFIG
self.outerBox = QVBoxLayout()
self.innerBox = QHBoxLayout()
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
self.buttonBox.accepted.connect(self._doClose)
self.outerBox.addLayout(self.innerBox)
self.outerBox.addWidget(self.buttonBox)
self.setLayout(self.outerBox)
logger.debug("GuiAbout initialisation complete")
return
##
# Internal Functions
##
def _doClose(self):
self.close()
return
# END Class GuiAbout
+54 -48
View File
@@ -32,6 +32,7 @@ from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QDesktopServices from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QMenuBar, QAction, QMessageBox from PyQt5.QtWidgets import QMenuBar, QAction, QMessageBox
from nw.gui.dialogs import GuiAbout
from nw.constants import nwItemType, nwItemClass, nwDocAction from nw.constants import nwItemType, nwItemClass, nwDocAction
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -119,54 +120,59 @@ class GuiMainMenu(QMenuBar):
return True return True
def _showAbout(self): def _showAbout(self):
listPrefix = "&nbsp;&nbsp;&bull;&nbsp;&nbsp;" """Show the about dialog.
aboutMsg = ( """
"<h3>About {name:s}</h3>" if self.mainConf.showGUI:
"<p>Version {version:s}, released {date:s}.</p>" msgAbout = GuiAbout(self.theParent)
"<p>{copyright:s}.</p>" msgAbout.exec_()
"<p>{name:s} is a markdown-like text editor designed for organising " # listPrefix = "&nbsp;&nbsp;&bull;&nbsp;&nbsp;"
"and writing novels. It is written in Python 3 with a Qt5 GUI, " # aboutMsg = (
"using PyQt5.</p>" # "<h3>About {name:s}</h3>"
"<p>{name:s} is free software: you can redistribute it and/or " # "<p>Version {version:s}, released {date:s}.</p>"
"modify it under the terms of the GNU General Public License as " # "<p>{copyright:s}.</p>"
"published by the Free Software Foundation, either version 3 of the " # "<p>{name:s} is a markdown-like text editor designed for organising "
"License, or (at your option) any later version.</p>" # "and writing novels. It is written in Python 3 with a Qt5 GUI, "
"<p>{name:s} is distributed in the hope that it will be useful, " # "using PyQt5.</p>"
"but WITHOUT ANY WARRANTY; without even the implied warranty of " # "<p>{name:s} is free software: you can redistribute it and/or "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p><p>See the " # "modify it under the terms of the GNU General Public License as "
"<a href='https://www.gnu.org/licenses/gpl-3.0.html'>GPL v3.0</a> " # "published by the Free Software Foundation, either version 3 of the "
"License for more details.</p>" # "License, or (at your option) any later version.</p>"
"<p>Website: <a href='{website:s}'>{website:s}</a></p>" # "<p>{name:s} is distributed in the hope that it will be useful, "
"<h4>Credits</h4>" # "but WITHOUT ANY WARRANTY; without even the implied warranty of "
"<p>{credits:s}</p>" # "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p><p>See the "
).format( # "<a href='https://www.gnu.org/licenses/gpl-3.0.html'>GPL v3.0</a> "
name = nw.__package__, # "License for more details.</p>"
version = nw.__version__, # "<p>Website: <a href='{website:s}'>{website:s}</a></p>"
date = nw.__date__, # "<h4>Credits</h4>"
copyright = nw.__copyright__, # "<p>{credits:s}</p>"
website = nw.__url__, # ).format(
credits = "<br/>".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]), # name = nw.__package__,
) # version = nw.__version__,
theTheme = self.theParent.theTheme # date = nw.__date__,
theIcons = self.theParent.theTheme.theIcons # copyright = nw.__copyright__,
if theTheme.themeCredit != "" or theTheme.syntaxCredit != "": # website = nw.__url__,
aboutMsg += "<h4>GUI Theme and Syntax Highlighting</h4>" # credits = "<br/>".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]),
aboutMsg += "<p>" # )
if theTheme.themeCredit != "": # theTheme = self.theParent.theTheme
aboutMsg += "%s\"%s\" by %s<br/>" % ( # theIcons = self.theParent.theTheme.theIcons
listPrefix, theTheme.themeName, theTheme.themeCredit # if theTheme.themeCredit != "" or theTheme.syntaxCredit != "":
) # aboutMsg += "<h4>GUI Theme and Syntax Highlighting</h4>"
if theIcons.themeCredit != "": # aboutMsg += "<p>"
aboutMsg += "%s\"%s\" by %s<br/>" % ( # if theTheme.themeCredit != "":
listPrefix, theIcons.themeName, theIcons.themeCredit # aboutMsg += "%s\"%s\" by %s<br/>" % (
) # listPrefix, theTheme.themeName, theTheme.themeCredit
if theTheme.syntaxCredit != "": # )
aboutMsg += "%s\"%s\" by %s<br/>" % ( # if theIcons.themeCredit != "":
listPrefix, theTheme.syntaxName, theTheme.syntaxCredit # aboutMsg += "%s\"%s\" by %s<br/>" % (
) # listPrefix, theIcons.themeName, theIcons.themeCredit
aboutMsg += "</p>" # )
msgBox = QMessageBox() # if theTheme.syntaxCredit != "":
msgBox.about(self.theParent, "About %s" % nw.__package__, aboutMsg) # aboutMsg += "%s\"%s\" by %s<br/>" % (
# listPrefix, theTheme.syntaxName, theTheme.syntaxCredit
# )
# aboutMsg += "</p>"
# msgBox = QMessageBox()
# msgBox.about(self.theParent, "About %s" % nw.__package__, aboutMsg)
return True return True
def _showAboutQt(self): def _showAboutQt(self):