Add an about tab which is shown when the program is started.

This commit is contained in:
Veronica K. B. Olsen
2018-10-02 23:11:02 +02:00
parent abd9d441ad
commit 0ab45f76f7
4 changed files with 105 additions and 5 deletions
+4 -2
View File
@@ -31,6 +31,7 @@ __date__ = "2018"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
__status__ = "Development"
__website__ = "https://github.com/vkbo/novelWriter"
#
# Logging
@@ -75,8 +76,9 @@ logger = logging.getLogger(__name__)
CONFIG = Config()
# Constants
DOCTYPE_DOC = 0
DOCTYPE_PROJECT = 1
DOCTYPE_ABOUT = 0
DOCTYPE_DOC = 1
DOCTYPE_PROJECT = 2
def main(sysArgs):
"""
+77
View File
@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*
"""novelWriter GUI About View
novelWriter GUI About View
==============================
Class holding the tab viewing the about information
File History:
Created: 2018-10-02 [0.1.0]
"""
import logging
import nw
from os import path
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QFont
logger = logging.getLogger(__name__)
class GuiAboutView(QWidget):
def __init__(self):
QWidget.__init__(self)
logger.debug("Initialising AboutView ...")
self.mainConf = nw.CONFIG
self.innerBox = QHBoxLayout()
self.outerBox = QVBoxLayout()
logoPath = path.abspath(path.join(self.mainConf.appPath,"..","novelWriter.svg"))
logger.vverbose("Loading image: %s" % logoPath)
nwLogo = QSvgWidget(logoPath)
nwLogo.setFixedSize(QSize(300,300))
nwName = QLabel()
nwName.setText(nw.__package__)
nwName.setAlignment(Qt.AlignCenter)
fnName = QFont()
fnName.setPointSize(22)
fnName.setBold(True)
nwName.setFont(fnName)
nwVersion = QLabel()
nwVersion.setText("Version %s" % nw.__version__)
nwVersion.setAlignment(Qt.AlignCenter)
nwCredits = QLabel()
nwCredits.setText("Created By: %s" % ",".join(nw.__credits__))
nwCredits.setAlignment(Qt.AlignCenter)
nwWebsite = QLabel()
nwWebsite.setText("<a href='%s'>%s</a>" % (nw.__website__,nw.__website__))
nwWebsite.setOpenExternalLinks(True)
nwWebsite.setAlignment(Qt.AlignCenter)
self.outerBox.addStretch(1)
self.innerBox.addStretch(1)
self.innerBox.addWidget(nwLogo)
self.innerBox.addStretch(1)
self.outerBox.addLayout(self.innerBox)
self.outerBox.addWidget(nwName)
self.outerBox.addWidget(nwVersion)
self.outerBox.addWidget(nwCredits)
self.outerBox.addWidget(nwWebsite)
self.outerBox.addStretch(1)
self.setLayout(self.outerBox)
logger.debug("AboutView initialisation complete")
return
# END Class GuiAboutView
-1
View File
@@ -13,7 +13,6 @@
import logging
import nw
from os import path
from PyQt5.QtWidgets import QWidget, QTextEdit, QVBoxLayout, QFrame, QSplitter, QToolBar, QAction
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon
+24 -2
View File
@@ -13,12 +13,12 @@
import logging
import nw
from os import path
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QTabWidget, QWidget, QVBoxLayout
from nw.gui.doceditor import GuiDocEditor
from nw.gui.projecteditor import GuiProjectEditor
from nw.gui.aboutview import GuiAboutView
logger = logging.getLogger(__name__)
@@ -32,13 +32,21 @@ class GuiDocTabs(QTabWidget):
self.tabList = []
self.resize(900,500)
self.setTabsClosable(True)
self.tabBar().tabCloseRequested.connect(self._doCloseTab)
self.createTab(None,nw.DOCTYPE_ABOUT)
logger.debug("DocTabs initialisation complete")
return
def createTab(self, theName=None, tabType=None):
if tabType == nw.DOCTYPE_DOC:
if tabType == nw.DOCTYPE_ABOUT:
self._createTabAbout()
return True
elif tabType == nw.DOCTYPE_DOC:
self._createTabDoc(theName)
return True
elif tabType == nw.DOCTYPE_PROJECT:
@@ -50,6 +58,12 @@ class GuiDocTabs(QTabWidget):
# Internal Functions
#
def _createTabAbout(self):
thisTab = GuiAboutView()
self.tabList.append(thisTab)
self.addTab(self.tabList[-1],"About")
return True
def _createTabDoc(self, docName=None):
if docName is None:
tabName = "New Document"
@@ -70,4 +84,12 @@ class GuiDocTabs(QTabWidget):
self.addTab(self.tabList[-1],tabName)
return True
#
# Signals
#
def _doCloseTab(self, tabIdx):
logger.verbose("User requested tab %d to be closed." % tabIdx)
return
# END Class GuiDocTabs