def initHelpEngine(self): self.helpRootUrl = 'qthelp://com.trolltech.qt.%d%d%d/qdoc/' % (QtCore.QT_VERSION >> 16, (QtCore.QT_VERSION >> 8) & 0xff, QtCore.QT_VERSION & 0xff) # Store help collection file in cache dir of assistant. cacheDir = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DataLocation) + '/Trolltech/Assistant/' helpDataFile = 'qtdemo_%s.qhc' % QtCore.QT_VERSION_STR dir = QtCore.QDir() if not dir.exists(cacheDir): dir.mkpath(cacheDir) # Create help engine (and new helpDataFile if it does not exist). self.helpEngine = QtHelp.QHelpEngineCore(cacheDir + helpDataFile) self.helpEngine.setupData() qtDocRoot = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.DocumentationPath) + '/qch' qtDocRoot = QtCore.QDir(qtDocRoot).absolutePath() qchFiles = ['/qt.qch', '/designer.qch', '/linguist.qch'] oldDir = self.helpEngine.customValue('docDir', '') if oldDir != qtDocRoot: for qchFile in qchFiles: self.helpEngine.unregisterDocumentation(QtHelp.QHelpEngineCore.namespaceName(qtDocRoot + qchFile)) # If the data that the engine will work on is not yet registered, do it # now. for qchFile in qchFiles: self.helpEngine.registerDocumentation(qtDocRoot + qchFile) self.helpEngine.setCustomValue('docDir', qtDocRoot)
def __init__ (self, parent, qhcpath): """Initialize dialog and load qhc help project from given path.""" super(HelpWindow, self).__init__(parent) self.engine = QtHelp.QHelpEngine(qhcpath, self) self.engine.setupData() self.setWindowTitle(u"%s Help" % configuration.AppName) self.build_ui()
def __init__(self, parent=None, collection_filename='qch_viewer_docs.qhc'): QtGui.QWidget.__init__(self, parent) self.setWindowTitle('QchViewer') self._engine = QtHelp.QHelpEngine(collection_filename) # The main players: self._content = self._engine.contentWidget() self._helpBrowser = HelpBrowser(self._engine) self.content_model = self._engine.contentModel() self.splitter = QtGui.QSplitter(self) self.splitter.addWidget(self._content) self.splitter.addWidget(self._helpBrowser) layout = QtGui.QVBoxLayout(self) layout.addWidget(self.splitter) # Connect clicks: self._content.linkActivated.connect(self._helpBrowser.setSource) # Important, call setup data to load the files: self._engine.setupData()