From 6bcf46191d070a7dffed3507a9ac9030925ea152 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 8 Aug 2020 14:58:19 +0200 Subject: [PATCH] better checking before launching local help --- nw/config.py | 1 + nw/gui/mainmenu.py | 22 +++++++++++++++------- nw/guimain.py | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/nw/config.py b/nw/config.py index 9e17b6ca..619125fa 100644 --- a/nw/config.py +++ b/nw/config.py @@ -321,6 +321,7 @@ class Config: # Check if local help files exist self.helpPath = path.join(self.assetPath, "help", "novelWriter.qhc") self.hasHelp = path.isfile(self.helpPath) + self.hasHelp &= path.isfile(path.join(self.assetPath, "help", "novelWriter.qch")) logger.debug("Config initialisation complete") diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index ed42c2ba..7f996dda 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -169,12 +169,14 @@ class GuiMainMenu(QMenuBar): """Open the documentation in Qt Assistant. """ if not self.mainConf.hasHelp: + self._openWebsite(nw.__docurl__) return False self.assistProc = QProcess(self) self.assistProc.start("assistant", ["-collectionFile", self.mainConf.helpPath]) if not self.assistProc.waitForStarted(10000): + self._openWebsite(nw.__docurl__) return False return True @@ -864,15 +866,21 @@ class GuiMainMenu(QMenuBar): self.helpMenu.addSeparator() # Document > Documentation - self.aHelp = QAction("Documentation", self) if self.mainConf.hasHelp and self.mainConf.hasAssistant: - self.aHelp.setStatusTip("View local documentation with Qt Assistant") - self.aHelp.triggered.connect(self._openAssistant) + self.aHelpLoc = QAction("Documentation (Local)", self) + self.aHelpLoc.setStatusTip("View local documentation with Qt Assistant") + self.aHelpLoc.triggered.connect(self._openAssistant) + self.aHelpLoc.setShortcut("F1") + self.helpMenu.addAction(self.aHelpLoc) + + self.aHelpWeb = QAction("Documentation (Online)", self) + self.aHelpWeb.setStatusTip("View online documentation") + self.aHelpWeb.triggered.connect(lambda: self._openWebsite(nw.__docurl__)) + if self.mainConf.hasHelp and self.mainConf.hasAssistant: + self.aHelpWeb.setShortcut("Shift+F1") else: - self.aHelp.setStatusTip("View online documentation") - self.aHelp.triggered.connect(lambda: self._openWebsite(nw.__docurl__)) - self.aHelp.setShortcut("F1") - self.helpMenu.addAction(self.aHelp) + self.aHelpWeb.setShortcuts(["F1","Shift+F1"]) + self.helpMenu.addAction(self.aHelpWeb) # Document > Go to Website self.aWebsite = QAction("Open the novelWriter Website", self) diff --git a/nw/guimain.py b/nw/guimain.py index 2571d819..f4dc33d8 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1034,7 +1034,9 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aPreferences) # Help - self.addAction(self.mainMenu.aHelp) + if self.mainConf.hasHelp and self.mainConf.hasAssistant: + self.addAction(self.mainMenu.aHelpLoc) + self.addAction(self.mainMenu.aHelpWeb) return True