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 time import time
from distutils import spawn
from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo
@@ -76,9 +77,11 @@ class Config:
self.graphPath = None
self.dictPath = None
self.iconPath = None
self.helpPath = None
# Set default values
# Runtime Settings and Variables
self.confChanged = False
self.hasHelp = False
## General
self.guiTheme = "default"
@@ -200,8 +203,9 @@ class Config:
self.kernelVer = "Unknown"
# Packages
self.hasEnchant = False
self.hasSymSpell = False
self.hasEnchant = False
self.hasSymSpell = False
self.hasAssistant = False # The Qt Assistant
# Recent Cache
self.recentProj = {}
@@ -315,6 +319,10 @@ class Config:
if self.spellLanguage is None:
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")
return True
@@ -893,6 +901,13 @@ class Config:
self.hasEnchant = False
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
# End Class Config
+15 -10
View File
@@ -49,10 +49,10 @@ class GuiMainMenu(QMenuBar):
self.theParent = theParent
self.theProject = theParent.theProject
# Internals
self.assistProc = None
self.helpPath = path.join(self.mainConf.assetPath, "help", "novelWriter.qhc")
self.hasHelp = path.isfile(self.helpPath)
# Build Menu
self._buildProjectMenu()
self._buildDocumentMenu()
self._buildEditMenu()
@@ -79,8 +79,10 @@ class GuiMainMenu(QMenuBar):
def setAvailableRoot(self):
for itemClass in nwItemClass:
if itemClass == nwItemClass.NO_CLASS: continue
if itemClass == nwItemClass.TRASH: continue
if itemClass == nwItemClass.NO_CLASS:
continue
if itemClass == nwItemClass.TRASH:
continue
self.rootItems[itemClass].setEnabled(
self.theProject.projTree.checkRootUnique(itemClass)
)
@@ -166,12 +168,15 @@ class GuiMainMenu(QMenuBar):
def _openAssistant(self):
"""Open the documentation in Qt Assistant.
"""
self.assistProc = QProcess(self)
self.assistProc.start("assistant", [
"-collectionFile", self.helpPath, "-enableRemoteControl"
])
if not self.assistProc.waitForStarted(20000):
if not self.mainConf.hasHelp:
return False
self.assistProc = QProcess(self)
self.assistProc.start("assistant", ["-collectionFile", self.mainConf.helpPath])
if not self.assistProc.waitForStarted(10000):
return False
return True
def _openWebsite(self, theUrl):
@@ -860,7 +865,7 @@ class GuiMainMenu(QMenuBar):
# Document > Documentation
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.triggered.connect(self._openAssistant)
else: