From b3df4ee0f2bb9721e2005b8882e138884df0386f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 9 Jun 2019 10:35:12 +0200 Subject: [PATCH] Added the code needed for opening documentation in the viewer --- help/en_GB/index.html | 8 ++++++++ nw/config.py | 1 + nw/gui/docviewer.py | 15 ++++++++++++++- nw/gui/mainmenu.py | 10 ++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 help/en_GB/index.html diff --git a/help/en_GB/index.html b/help/en_GB/index.html new file mode 100644 index 00000000..3fa9f0a0 --- /dev/null +++ b/help/en_GB/index.html @@ -0,0 +1,8 @@ + + + novelWriter Help + + +

novelWriter Help

+ + \ No newline at end of file diff --git a/nw/config.py b/nw/config.py index cdf07697..f65f9554 100644 --- a/nw/config.py +++ b/nw/config.py @@ -104,6 +104,7 @@ class Config: self.homePath = path.expanduser("~") self.appPath = path.dirname(__file__) self.appRoot = path.join(self.appPath,path.pardir) + self.helpPath = path.join(self.appRoot,"help","en_GB") self.guiPath = path.join(self.appPath,"gui") self.themePath = path.join(self.appPath,"themes") diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index a45718ea..38ae0893 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -13,7 +13,7 @@ import logging import nw -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QUrl from PyQt5.QtWidgets import QTextBrowser from PyQt5.QtGui import QTextOption @@ -59,6 +59,7 @@ class GuiDocViewer(QTextBrowser): def clearViewer(self): self.clear() + self.setSearchPaths([""]) return True def initEditor(self): @@ -74,6 +75,10 @@ class GuiDocViewer(QTextBrowser): def loadText(self, tHandle): + if tHandle == "Help": + self.loadHelp() + return True + tItem = self.theProject.getItem(tHandle) if tItem is None: logger.warning("Item not found") @@ -94,4 +99,12 @@ class GuiDocViewer(QTextBrowser): return True + def loadHelp(self): + + self.clearViewer() + self.setSearchPaths([self.mainConf.helpPath]) + self.setSource(QUrl("index.html")) + + return True + # END Class GuiDocViewer diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 9360f4d6..e170b408 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -516,6 +516,16 @@ class GuiMainMenu(QMenuBar): menuItem.triggered.connect(self._showAboutQt) self.helpMenu.addAction(menuItem) + # Help > Separator + self.helpMenu.addSeparator() + + # Document > Preview + menuItem = QAction(QIcon.fromTheme("text-html"), "Documentation", self) + menuItem.setStatusTip("View documentation") + menuItem.setShortcut("F1") + menuItem.triggered.connect(lambda : self.theParent.viewDocument("Help")) + self.helpMenu.addAction(menuItem) + return # END Class GuiMainMenu