Rewritten about dialog
This commit is contained in:
@@ -47,6 +47,7 @@ __maintainer__ = "Veronica Berglyd Olsen"
|
||||
__email__ = "code@vkbo.net"
|
||||
__status__ = "Pre-Release"
|
||||
__url__ = "https://github.com/vkbo/novelWriter"
|
||||
__domain__ = "novelwriter.io"
|
||||
__docurl__ = "https://novelwriter.readthedocs.io"
|
||||
__credits__ = [
|
||||
"Veronica Berglyd Olsen (developer)",
|
||||
|
||||
+1
-1
@@ -233,7 +233,7 @@ class Config:
|
||||
self.graphPath = path.join(self.assetPath,"graphics")
|
||||
self.dictPath = path.join(self.assetPath,"dict")
|
||||
self.iconPath = path.join(self.assetPath,"icons")
|
||||
self.appIcon = path.join(self.iconPath, nwFiles.APP_ICON)
|
||||
self.appIcon = path.join(self.iconPath, "novelwriter.svg")
|
||||
|
||||
logger.verbose("App path: %s" % self.appPath)
|
||||
logger.verbose("Home path: %s" % self.homePath)
|
||||
|
||||
@@ -36,7 +36,6 @@ class nwConst():
|
||||
|
||||
class nwFiles():
|
||||
|
||||
APP_ICON = "novelWriter.svg"
|
||||
PROJ_FILE = "nwProject.nwx"
|
||||
PROJ_DICT = "wordlist.txt"
|
||||
PROJ_LOCK = "nwProject.lock"
|
||||
|
||||
+165
-2
@@ -28,9 +28,13 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox
|
||||
QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QTabWidget,
|
||||
QTextBrowser, QLabel
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -42,11 +46,52 @@ class GuiAbout(QDialog):
|
||||
|
||||
logger.debug("Initialising GuiAbout ...")
|
||||
|
||||
self.mainConf = nw.CONFIG
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theParent = theParent
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.innerBox = QHBoxLayout()
|
||||
self.innerBox.setSpacing(16)
|
||||
|
||||
self.setWindowTitle("About %s" % nw.__package__)
|
||||
self.setMinimumWidth(700)
|
||||
self.setMinimumHeight(600)
|
||||
|
||||
self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (96, 96))
|
||||
self.lblName = QLabel("<b>%s</b>" % nw.__package__)
|
||||
self.lblVers = QLabel("v%s" % nw.__version__)
|
||||
self.lblDate = QLabel(datetime.strptime(nw.__date__, "%Y-%m-%d").strftime("%x"))
|
||||
|
||||
self.leftBox = QVBoxLayout()
|
||||
self.leftBox.setSpacing(4)
|
||||
self.leftBox.addWidget(self.guiDeco, 0, Qt.AlignCenter)
|
||||
self.leftBox.addWidget(self.lblName, 0, Qt.AlignCenter)
|
||||
self.leftBox.addWidget(self.lblVers, 0, Qt.AlignCenter)
|
||||
self.leftBox.addWidget(self.lblDate, 0, Qt.AlignCenter)
|
||||
self.leftBox.addStretch(1)
|
||||
self.innerBox.addLayout(self.leftBox)
|
||||
|
||||
# Pages
|
||||
self.pageAbout = QTextBrowser()
|
||||
self.pageAbout.setOpenExternalLinks(True)
|
||||
self.pageAbout.document().setDocumentMargin(16)
|
||||
|
||||
# self.pageCredit = QTextBrowser()
|
||||
# self.pageCredit.setOpenExternalLinks(True)
|
||||
# self.pageCredit.document().setDocumentMargin(16)
|
||||
|
||||
self.pageLicense = QTextBrowser()
|
||||
self.pageLicense.setOpenExternalLinks(True)
|
||||
self.pageLicense.document().setDocumentMargin(16)
|
||||
|
||||
# Main Tab Area
|
||||
self.tabBox = QTabWidget()
|
||||
self.tabBox.addTab(self.pageAbout, "About")
|
||||
# self.tabBox.addTab(self.pageCredit, "Credit")
|
||||
self.tabBox.addTab(self.pageLicense, "License")
|
||||
self.innerBox.addWidget(self.tabBox)
|
||||
|
||||
# OK Button
|
||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
|
||||
self.buttonBox.accepted.connect(self._doClose)
|
||||
|
||||
@@ -54,6 +99,10 @@ class GuiAbout(QDialog):
|
||||
self.outerBox.addWidget(self.buttonBox)
|
||||
self.setLayout(self.outerBox)
|
||||
|
||||
self._setStyleSheet()
|
||||
self._fillAboutPage()
|
||||
self._fillLicensePage()
|
||||
|
||||
logger.debug("GuiAbout initialisation complete")
|
||||
|
||||
return
|
||||
@@ -62,6 +111,120 @@ class GuiAbout(QDialog):
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
def _fillAboutPage(self):
|
||||
"""Generate the content for the About page.
|
||||
"""
|
||||
listPrefix = " • "
|
||||
aboutMsg = (
|
||||
"<h2>About {name:s}</h2>"
|
||||
"<p>{copyright:s}.</p>"
|
||||
"<p>Website: <a href='{website:s}'>{domain:s}</a></p>"
|
||||
"<p>{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.</p>"
|
||||
"<p>{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.</p>"
|
||||
"<p>{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.</p>"
|
||||
"<p>See the License tab for the full text, or visit the GNU website at "
|
||||
"<a href='https://www.gnu.org/licenses/gpl-3.0.html'>GPL v3.0</a> for more details.</p>"
|
||||
"<h3>Credits</h3>"
|
||||
"<p>{credits:s}</p>"
|
||||
).format(
|
||||
name = nw.__package__,
|
||||
copyright = nw.__copyright__,
|
||||
website = nw.__url__,
|
||||
domain = nw.__domain__,
|
||||
credits = "<br/>".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]),
|
||||
)
|
||||
|
||||
theTheme = self.theParent.theTheme
|
||||
theIcons = self.theParent.theTheme.theIcons
|
||||
if theTheme.themeName:
|
||||
aboutMsg += (
|
||||
"<h4>Theme: {name:s}</h4>"
|
||||
"<p>"
|
||||
"<b>Author:</b> {author:s}<br/>"
|
||||
"<b>Credit:</b> {credit:s}<br/>"
|
||||
"<b>License:</b> <a href='{lic_url:s}'>{license:s}</a>"
|
||||
"</p>"
|
||||
).format(
|
||||
name = theTheme.themeName,
|
||||
author = theTheme.themeAuthor,
|
||||
credit = theTheme.themeCredit,
|
||||
license = theTheme.themeLicense,
|
||||
lic_url = theTheme.themeLicenseUrl,
|
||||
)
|
||||
if theIcons.themeName:
|
||||
aboutMsg += (
|
||||
"<h4>Icons: {name:s}</h4>"
|
||||
"<p>"
|
||||
"<b>Author:</b> {author:s}<br/>"
|
||||
"<b>Credit:</b> {credit:s}<br/>"
|
||||
"<b>License:</b> <a href='{lic_url:s}'>{license:s}</a>"
|
||||
"</p>"
|
||||
).format(
|
||||
name = theIcons.themeName,
|
||||
author = theIcons.themeAuthor,
|
||||
credit = theIcons.themeCredit,
|
||||
license = theIcons.themeLicense,
|
||||
lic_url = theIcons.themeLicenseUrl,
|
||||
)
|
||||
if theTheme.syntaxName:
|
||||
aboutMsg += (
|
||||
"<h4>Syntax: {name:s}</h4>"
|
||||
"<p>"
|
||||
"<b>Author:</b> {author:s}<br/>"
|
||||
"<b>Credit:</b> {credit:s}<br/>"
|
||||
"<b>License:</b> <a href='{lic_url:s}'>{license:s}</a>"
|
||||
"</p>"
|
||||
).format(
|
||||
name = theTheme.syntaxName,
|
||||
author = theTheme.syntaxAuthor,
|
||||
credit = theTheme.syntaxCredit,
|
||||
license = theTheme.syntaxLicense,
|
||||
lic_url = theTheme.syntaxLicenseUrl,
|
||||
)
|
||||
|
||||
self.pageAbout.setHtml(aboutMsg)
|
||||
|
||||
return
|
||||
|
||||
def _fillLicensePage(self):
|
||||
"""Load the content for the License page.
|
||||
"""
|
||||
docName = "gplv3_%s.htm" % self.mainConf.guiLang
|
||||
docPath = path.join(self.mainConf.assetPath, "text", docName)
|
||||
if path.isfile(docPath):
|
||||
with open(docPath, mode="r", encoding="utf8") as inFile:
|
||||
helpText = inFile.read()
|
||||
self.pageLicense.setHtml(helpText)
|
||||
else:
|
||||
self.pageLicense.setHtml("Error loading license text ...")
|
||||
return
|
||||
|
||||
def _setStyleSheet(self):
|
||||
"""Set stylesheet for all browser tabs
|
||||
"""
|
||||
styleSheet = (
|
||||
"h1, h2, h3, h4 {{"
|
||||
" color: rgb({hColR},{hColG},{hColB});"
|
||||
"}}\n"
|
||||
"a {{"
|
||||
" color: rgb({hColR},{hColG},{hColB});"
|
||||
"}}\n"
|
||||
).format(
|
||||
hColR = self.theParent.theTheme.colHead[0],
|
||||
hColG = self.theParent.theTheme.colHead[1],
|
||||
hColB = self.theParent.theTheme.colHead[2],
|
||||
)
|
||||
self.pageAbout.document().setDefaultStyleSheet(styleSheet)
|
||||
# self.pageCredit.document().setDefaultStyleSheet(styleSheet)
|
||||
self.pageLicense.document().setDefaultStyleSheet(styleSheet)
|
||||
|
||||
return
|
||||
|
||||
def _doClose(self):
|
||||
self.close()
|
||||
return
|
||||
|
||||
@@ -125,54 +125,6 @@ class GuiMainMenu(QMenuBar):
|
||||
if self.mainConf.showGUI:
|
||||
msgAbout = GuiAbout(self.theParent)
|
||||
msgAbout.exec_()
|
||||
# listPrefix = " • "
|
||||
# aboutMsg = (
|
||||
# "<h3>About {name:s}</h3>"
|
||||
# "<p>Version {version:s}, released {date:s}.</p>"
|
||||
# "<p>{copyright:s}.</p>"
|
||||
# "<p>{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.</p>"
|
||||
# "<p>{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.</p>"
|
||||
# "<p>{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.</p><p>See the "
|
||||
# "<a href='https://www.gnu.org/licenses/gpl-3.0.html'>GPL v3.0</a> "
|
||||
# "License for more details.</p>"
|
||||
# "<p>Website: <a href='{website:s}'>{website:s}</a></p>"
|
||||
# "<h4>Credits</h4>"
|
||||
# "<p>{credits:s}</p>"
|
||||
# ).format(
|
||||
# name = nw.__package__,
|
||||
# version = nw.__version__,
|
||||
# date = nw.__date__,
|
||||
# copyright = nw.__copyright__,
|
||||
# website = nw.__url__,
|
||||
# credits = "<br/>".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 += "<h4>GUI Theme and Syntax Highlighting</h4>"
|
||||
# aboutMsg += "<p>"
|
||||
# if theTheme.themeCredit != "":
|
||||
# aboutMsg += "%s\"%s\" by %s<br/>" % (
|
||||
# listPrefix, theTheme.themeName, theTheme.themeCredit
|
||||
# )
|
||||
# if theIcons.themeCredit != "":
|
||||
# aboutMsg += "%s\"%s\" by %s<br/>" % (
|
||||
# listPrefix, theIcons.themeName, theIcons.themeCredit
|
||||
# )
|
||||
# if theTheme.syntaxCredit != "":
|
||||
# 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
|
||||
|
||||
def _showAboutQt(self):
|
||||
|
||||
Reference in New Issue
Block a user