diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py index 74706a6d..43cfc5dd 100644 --- a/nw/gui/__init__.py +++ b/nw/gui/__init__.py @@ -8,6 +8,7 @@ from nw.gui.statusbar import GuiMainStatus from nw.gui.theme import GuiTheme # Dialogs +from nw.gui.dialogs.about import GuiAbout from nw.gui.dialogs.configeditor import GuiConfigEditor from nw.gui.dialogs.docmerge import GuiDocMerge from nw.gui.dialogs.docsplit import GuiDocSplit @@ -38,6 +39,7 @@ __all__ = [ "GuiMainMenu", "GuiMainStatus", "GuiTheme", + "GuiAbout", "GuiConfigEditor", "GuiDocMerge", "GuiDocSplit", diff --git a/nw/gui/dialogs/__init__.py b/nw/gui/dialogs/__init__.py index 110b5b5e..c2625ee5 100644 --- a/nw/gui/dialogs/__init__.py +++ b/nw/gui/dialogs/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +from nw.gui.dialogs.about import GuiAbout from nw.gui.dialogs.configeditor import GuiConfigEditor from nw.gui.dialogs.docmerge import GuiDocMerge 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 __all__ = [ + "GuiAbout", "GuiConfigEditor", "GuiDocMerge", "GuiDocSplit", diff --git a/nw/gui/dialogs/about.py b/nw/gui/dialogs/about.py new file mode 100644 index 00000000..9e253981 --- /dev/null +++ b/nw/gui/dialogs/about.py @@ -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 . +""" + +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 diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 8126766b..76563d59 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -32,6 +32,7 @@ from PyQt5.QtCore import QUrl from PyQt5.QtGui import QDesktopServices from PyQt5.QtWidgets import QMenuBar, QAction, QMessageBox +from nw.gui.dialogs import GuiAbout from nw.constants import nwItemType, nwItemClass, nwDocAction logger = logging.getLogger(__name__) @@ -119,54 +120,59 @@ class GuiMainMenu(QMenuBar): return True def _showAbout(self): - listPrefix = "  •  " - aboutMsg = ( - "

About {name:s}

" - "

Version {version:s}, released {date:s}.

" - "

{copyright:s}.

" - "

{name:s} is a markdown-like text editor designed for organising " - "and writing novels. It is written in Python 3 with a Qt5 GUI, " - "using PyQt5.

" - "

{name:s} 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.

" - "

{name:s} 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 " - "GPL v3.0 " - "License for more details.

" - "

Website: {website:s}

" - "

Credits

" - "

{credits:s}

" - ).format( - name = nw.__package__, - version = nw.__version__, - date = nw.__date__, - copyright = nw.__copyright__, - website = nw.__url__, - credits = "
".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]), - ) - theTheme = self.theParent.theTheme - theIcons = self.theParent.theTheme.theIcons - if theTheme.themeCredit != "" or theTheme.syntaxCredit != "": - aboutMsg += "

GUI Theme and Syntax Highlighting

" - aboutMsg += "

" - if theTheme.themeCredit != "": - aboutMsg += "%s\"%s\" by %s
" % ( - listPrefix, theTheme.themeName, theTheme.themeCredit - ) - if theIcons.themeCredit != "": - aboutMsg += "%s\"%s\" by %s
" % ( - listPrefix, theIcons.themeName, theIcons.themeCredit - ) - if theTheme.syntaxCredit != "": - aboutMsg += "%s\"%s\" by %s
" % ( - listPrefix, theTheme.syntaxName, theTheme.syntaxCredit - ) - aboutMsg += "

" - msgBox = QMessageBox() - msgBox.about(self.theParent, "About %s" % nw.__package__, aboutMsg) + """Show the about dialog. + """ + if self.mainConf.showGUI: + msgAbout = GuiAbout(self.theParent) + msgAbout.exec_() + # listPrefix = "  •  " + # aboutMsg = ( + # "

About {name:s}

" + # "

Version {version:s}, released {date:s}.

" + # "

{copyright:s}.

" + # "

{name:s} is a markdown-like text editor designed for organising " + # "and writing novels. It is written in Python 3 with a Qt5 GUI, " + # "using PyQt5.

" + # "

{name:s} 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.

" + # "

{name:s} 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 " + # "GPL v3.0 " + # "License for more details.

" + # "

Website: {website:s}

" + # "

Credits

" + # "

{credits:s}

" + # ).format( + # name = nw.__package__, + # version = nw.__version__, + # date = nw.__date__, + # copyright = nw.__copyright__, + # website = nw.__url__, + # credits = "
".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]), + # ) + # theTheme = self.theParent.theTheme + # theIcons = self.theParent.theTheme.theIcons + # if theTheme.themeCredit != "" or theTheme.syntaxCredit != "": + # aboutMsg += "

GUI Theme and Syntax Highlighting

" + # aboutMsg += "

" + # if theTheme.themeCredit != "": + # aboutMsg += "%s\"%s\" by %s
" % ( + # listPrefix, theTheme.themeName, theTheme.themeCredit + # ) + # if theIcons.themeCredit != "": + # aboutMsg += "%s\"%s\" by %s
" % ( + # listPrefix, theIcons.themeName, theIcons.themeCredit + # ) + # if theTheme.syntaxCredit != "": + # aboutMsg += "%s\"%s\" by %s
" % ( + # listPrefix, theTheme.syntaxName, theTheme.syntaxCredit + # ) + # aboutMsg += "

" + # msgBox = QMessageBox() + # msgBox.about(self.theParent, "About %s" % nw.__package__, aboutMsg) return True def _showAboutQt(self):