Helpviewer/HelpWindow.py

changeset 5224
7454861e4106
parent 5196
e7490a5e7549
child 5226
7d8cee42ab86
diff -r 4c0b3ee7d2d8 -r 7454861e4106 Helpviewer/HelpWindow.py
--- a/Helpviewer/HelpWindow.py	Mon Oct 10 19:21:22 2016 +0200
+++ b/Helpviewer/HelpWindow.py	Mon Oct 10 19:23:38 2016 +0200
@@ -72,7 +72,7 @@
     helpwindows = []
 
     _fromEric = False
-    useQtHelp = QTHELP_AVAILABLE
+    _useQtHelp = QTHELP_AVAILABLE
     
     _networkAccessManager = None
     _cookieJar = None
@@ -146,10 +146,10 @@
                 from E5Network.E5SslUtilities import initSSL
                 initSSL()
             
-            if self.useQtHelp:
-                self.__helpEngine = \
-                    QHelpEngine(os.path.join(Utilities.getConfigDir(),
-                                             "browser", "eric6help.qhc"), self)
+            if HelpWindow._useQtHelp:
+                self.__helpEngine = QHelpEngine(
+                    HelpWindow.getQtHelpCollectionFileName(),
+                    self)
                 self.__removeOldDocumentation()
                 self.__helpEngine.warning.connect(self.__warning)
             else:
@@ -184,7 +184,7 @@
             self.setCentralWidget(centralWidget)
             self.findDlg.hide()
             
-            if self.useQtHelp:
+            if HelpWindow._useQtHelp:
                 # setup the TOC widget
                 self.__tocWindow = HelpTocWidget(self.__helpEngine, self)
                 self.__tocDock = QDockWidget(self.tr("Contents"), self)
@@ -260,7 +260,7 @@
             
             # setup connections
             self.__activating = False
-            if self.useQtHelp:
+            if HelpWindow._useQtHelp:
                 # TOC window
                 self.__tocWindow.linkActivated.connect(self.__linkActivated)
                 self.__tocWindow.escapePressed.connect(
@@ -294,7 +294,7 @@
             
             self.flashCookieManager()
             
-            if self.useQtHelp:
+            if HelpWindow._useQtHelp:
                 QTimer.singleShot(0, self.__lookForNewDocumentation)
                 if self.__searchWord is not None:
                     QTimer.singleShot(0, self.__searchForWord)
@@ -1240,7 +1240,7 @@
                 self.__showFeaturePermissionDialog)
         self.__actions.append(self.featurePermissionAct)
 
-        if self.useQtHelp or self.initShortcutsOnly:
+        if HelpWindow._useQtHelp or self.initShortcutsOnly:
             self.syncTocAct = E5Action(
                 self.tr('Sync with Table of Contents'),
                 UI.PixmapCache.getIcon("syncToc.png"),
@@ -1657,7 +1657,7 @@
         menu.addSeparator()
         menu.addAction(self.stopAct)
         menu.addAction(self.reloadAct)
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             menu.addSeparator()
             menu.addAction(self.syncTocAct)
         
@@ -1721,7 +1721,7 @@
         menu.addAction(self.userAgentManagerAct)
         menu.addSeparator()
         
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             menu.addAction(self.manageQtHelpDocsAct)
             menu.addAction(self.manageQtHelpFiltersAct)
             menu.addAction(self.reindexDocumentationAct)
@@ -1741,7 +1741,7 @@
         menu = mb.addMenu(self.tr("&Window"))
         menu.setTearOffEnabled(True)
         menu.addAction(self.showDownloadManagerAct)
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             menu.addSeparator()
             menu.addAction(self.showTocAct)
             menu.addAction(self.showIndexAct)
@@ -1807,7 +1807,7 @@
         findtb.addAction(self.findNextAct)
         findtb.addAction(self.findPrevAct)
         
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             filtertb = self.addToolBar(self.tr("Filter"))
             filtertb.setObjectName("FilterToolBar")
             self.filterCombo = QComboBox()
@@ -2262,7 +2262,7 @@
         
         self.searchEdit.openSearchManager().close()
         
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__searchEngine.cancelIndexing()
             self.__searchEngine.cancelSearching()
             
@@ -2587,9 +2587,9 @@
         @param use flag indicating usage (boolean)
         """
         if use:
-            cls.useQtHelp = use and QTHELP_AVAILABLE
+            cls._useQtHelp = use and QTHELP_AVAILABLE
         else:
-            cls.useQtHelp = False
+            cls._useQtHelp = False
     
     @classmethod
     def helpEngine(cls):
@@ -2600,13 +2600,25 @@
         """
         if cls.useQtHelp:
             if cls._helpEngine is None:
-                cls._helpEngine = \
-                    QHelpEngine(os.path.join(Utilities.getConfigDir(),
-                                             "browser", "eric6help.qhc"))
+                cls._helpEngine = QHelpEngine(
+                    HelpWindow.getQtHelpCollectionFileName())
             return cls._helpEngine
         else:
             return None
-        
+    
+    @classmethod
+    def getQtHelpCollectionFileName(cls):
+        """
+        Class method to determine the name of the QtHelp collection file.
+        
+        @return path of the QtHelp collection file
+        @rtype str
+        """
+        qthelpDir = os.path.join(Utilities.getConfigDir(), "qthelp")
+        if not os.path.exists(qthelpDir):
+            os.makedirs(qthelpDir)
+        return os.path.join(qthelpDir, "eric6help.qhc")
+    
     @classmethod
     def networkAccessManager(cls):
         """
@@ -2680,7 +2692,7 @@
         """
         Private slot to synchronize the TOC with the currently shown page.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             QApplication.setOverrideCursor(Qt.WaitCursor)
             url = self.currentBrowser().source()
             self.__showTocWindow()
@@ -2693,42 +2705,42 @@
         """
         Private method to show the table of contents window.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__activateDock(self.__tocWindow)
         
     def __hideTocWindow(self):
         """
         Private method to hide the table of contents window.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__tocDock.hide()
         
     def __showIndexWindow(self):
         """
         Private method to show the index window.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__activateDock(self.__indexWindow)
         
     def __hideIndexWindow(self):
         """
         Private method to hide the index window.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__indexDock.hide()
         
     def __showSearchWindow(self):
         """
         Private method to show the search window.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__activateDock(self.__searchWindow)
         
     def __hideSearchWindow(self):
         """
         Private method to hide the search window.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__searchDock.hide()
         
     def __activateDock(self, widget):
@@ -2745,7 +2757,7 @@
         """
         Private slot to setup the filter combo box.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             curFilter = self.filterCombo.currentText()
             if not curFilter:
                 curFilter = self.__helpEngine.currentFilter()
@@ -2769,7 +2781,7 @@
         """
         Private slot to manage the QtHelp documentation database.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             from .QtHelpDocumentationDialog import QtHelpDocumentationDialog
             dlg = QtHelpDocumentationDialog(self.__helpEngine, self)
             dlg.exec_()
@@ -2790,7 +2802,7 @@
         """
         Private slot to manage the QtHelp filters.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             from .QtHelpFiltersDialog import QtHelpFiltersDialog
             dlg = QtHelpFiltersDialog(self.__helpEngine, self)
             dlg.exec_()
@@ -2799,7 +2811,7 @@
         """
         Private slot to handle the start of the indexing process.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__indexing = True
             if self.__indexingProgress is None:
                 self.__indexingProgress = QWidget()
@@ -2826,7 +2838,7 @@
         """
         Private slot to handle the start of the indexing process.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.statusBar().removeWidget(self.__indexingProgress)
             self.__indexingProgress = None
             self.__indexing = False
@@ -2837,7 +2849,7 @@
         """
         Private slot to search for a word.
         """
-        if self.useQtHelp and not self.__indexing and \
+        if HelpWindow._useQtHelp and not self.__indexing and \
                 self.__searchWord is not None:
             self.__searchDock.show()
             self.__searchDock.raise_()
@@ -2852,7 +2864,7 @@
         
         @param word word to search for (string)
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             self.__searchWord = word
             self.__searchForWord()
         
@@ -2870,7 +2882,7 @@
         Private slot to look for new documentation to be loaded into the
         help database.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             from .HelpDocsInstaller import HelpDocsInstaller
             self.__helpInstaller = HelpDocsInstaller(
                 self.__helpEngine.collectionFile())
@@ -2900,7 +2912,7 @@
         @param installed flag indicating that documents were installed
             (boolean)
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             if installed:
                 self.__helpEngine.setupData()
             self.statusBar().clearMessage()
@@ -2909,7 +2921,7 @@
         """
         Private slot to initialize the documentation database.
         """
-        if self.useQtHelp:
+        if HelpWindow._useQtHelp:
             if not self.__helpEngine.setupData():
                 return
             

eric ide

mercurial