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 1/2] 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 From 2d9a9c2b22d58c19e7270c0c0674ef028b13fe3d Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 8 Aug 2020 15:03:09 +0200 Subject: [PATCH 2/2] Updated documentation on shortcuts --- docs/source/interface.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/interface.rst b/docs/source/interface.rst index 2a04329e..5d5f8114 100644 --- a/docs/source/interface.rst +++ b/docs/source/interface.rst @@ -362,8 +362,9 @@ Most features are available as keyboard shortcuts. These are as follows: ":kbd:`F9`", "Re-build the project index." ":kbd:`F10`", "Re-build the project outline." ":kbd:`F11`", "Activate full screen mode." + ":kbd:`Shift`:kbd:`F1`", "Open the online documentation in the system default browser." ":kbd:`Shift`:kbd:`F3`", "Find previous occurrence of search word in current document. (Same as :kbd:`Ctrl`:kbd:`Shift`:kbd:`G`)" - ":kbd:`Enter`", "If in the project tree, open a document for editing." + ":kbd:`Return`", "If in the project tree, open a document for editing." .. note:: On macOS, replace :kbd:`Ctrl` with :kbd:`Cmd`.