Make sure the assistant executable also exists

This commit is contained in:
Veronica K. B. Olsen
2020-08-04 21:23:25 +02:00
parent bf184c4e5a
commit 3708b3486b
2 changed files with 33 additions and 13 deletions
+18 -3
View File
@@ -33,6 +33,7 @@ import nw
from os import path, mkdir, unlink, rename from os import path, mkdir, unlink, rename
from time import time from time import time
from distutils import spawn
from PyQt5.Qt import PYQT_VERSION_STR from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo
@@ -76,9 +77,11 @@ class Config:
self.graphPath = None self.graphPath = None
self.dictPath = None self.dictPath = None
self.iconPath = None self.iconPath = None
self.helpPath = None
# Set default values # Runtime Settings and Variables
self.confChanged = False self.confChanged = False
self.hasHelp = False
## General ## General
self.guiTheme = "default" self.guiTheme = "default"
@@ -200,8 +203,9 @@ class Config:
self.kernelVer = "Unknown" self.kernelVer = "Unknown"
# Packages # Packages
self.hasEnchant = False self.hasEnchant = False
self.hasSymSpell = False self.hasSymSpell = False
self.hasAssistant = False # The Qt Assistant
# Recent Cache # Recent Cache
self.recentProj = {} self.recentProj = {}
@@ -315,6 +319,10 @@ class Config:
if self.spellLanguage is None: if self.spellLanguage is None:
self.spellLanguage = "en" self.spellLanguage = "en"
# Check if local help files exist
self.helpPath = path.join(self.assetPath, "help", "novelWriter.qhc")
self.hasHelp = path.isfile(self.helpPath)
logger.debug("Config initialisation complete") logger.debug("Config initialisation complete")
return True return True
@@ -893,6 +901,13 @@ class Config:
self.hasEnchant = False self.hasEnchant = False
logger.debug("Checking package pyenchant: Missing") logger.debug("Checking package pyenchant: Missing")
try:
self.hasAssistant = spawn.find_executable("assistant")
logger.debug("Checking executable assistant: Ok")
except:
self.hasAssistant = False
logger.debug("Checking executable assistant: Missing")
return return
# End Class Config # End Class Config
+15 -10
View File
@@ -49,10 +49,10 @@ class GuiMainMenu(QMenuBar):
self.theParent = theParent self.theParent = theParent
self.theProject = theParent.theProject self.theProject = theParent.theProject
# Internals
self.assistProc = None self.assistProc = None
self.helpPath = path.join(self.mainConf.assetPath, "help", "novelWriter.qhc")
self.hasHelp = path.isfile(self.helpPath)
# Build Menu
self._buildProjectMenu() self._buildProjectMenu()
self._buildDocumentMenu() self._buildDocumentMenu()
self._buildEditMenu() self._buildEditMenu()
@@ -79,8 +79,10 @@ class GuiMainMenu(QMenuBar):
def setAvailableRoot(self): def setAvailableRoot(self):
for itemClass in nwItemClass: for itemClass in nwItemClass:
if itemClass == nwItemClass.NO_CLASS: continue if itemClass == nwItemClass.NO_CLASS:
if itemClass == nwItemClass.TRASH: continue continue
if itemClass == nwItemClass.TRASH:
continue
self.rootItems[itemClass].setEnabled( self.rootItems[itemClass].setEnabled(
self.theProject.projTree.checkRootUnique(itemClass) self.theProject.projTree.checkRootUnique(itemClass)
) )
@@ -166,12 +168,15 @@ class GuiMainMenu(QMenuBar):
def _openAssistant(self): def _openAssistant(self):
"""Open the documentation in Qt Assistant. """Open the documentation in Qt Assistant.
""" """
self.assistProc = QProcess(self) if not self.mainConf.hasHelp:
self.assistProc.start("assistant", [
"-collectionFile", self.helpPath, "-enableRemoteControl"
])
if not self.assistProc.waitForStarted(20000):
return False return False
self.assistProc = QProcess(self)
self.assistProc.start("assistant", ["-collectionFile", self.mainConf.helpPath])
if not self.assistProc.waitForStarted(10000):
return False
return True return True
def _openWebsite(self, theUrl): def _openWebsite(self, theUrl):
@@ -860,7 +865,7 @@ class GuiMainMenu(QMenuBar):
# Document > Documentation # Document > Documentation
self.aHelp = QAction("Documentation", self) self.aHelp = QAction("Documentation", self)
if self.hasHelp: if self.mainConf.hasHelp and self.mainConf.hasAssistant:
self.aHelp.setStatusTip("View local documentation with Qt Assistant") self.aHelp.setStatusTip("View local documentation with Qt Assistant")
self.aHelp.triggered.connect(self._openAssistant) self.aHelp.triggered.connect(self._openAssistant)
else: else: