WebBrowser/WebBrowserWindow.py

changeset 5224
7454861e4106
parent 5200
0f0efb52fda6
child 5341
d874aeb629dc
diff -r 4c0b3ee7d2d8 -r 7454861e4106 WebBrowser/WebBrowserWindow.py
--- a/WebBrowser/WebBrowserWindow.py	Mon Oct 10 19:21:22 2016 +0200
+++ b/WebBrowser/WebBrowserWindow.py	Mon Oct 10 19:23:38 2016 +0200
@@ -83,7 +83,7 @@
     BrowserWindows = []
 
     _fromEric = False
-    UseQtHelp = QTHELP_AVAILABLE
+    _useQtHelp = QTHELP_AVAILABLE
     _isPrivate = False
     
     _webProfile = None
@@ -187,10 +187,9 @@
                 from E5Network.E5SslUtilities import initSSL
                 initSSL()
             
-            if WebBrowserWindow.useQtHelp:
+            if WebBrowserWindow._useQtHelp:
                 self.__helpEngine = QHelpEngine(
-                    os.path.join(Utilities.getConfigDir(),
-                                 "web_browser", "eric6help.qhc"),
+                    WebBrowserWindow.getQtHelpCollectionFileName(),
                     self)
                 self.__removeOldDocumentation()
                 self.__helpEngine.warning.connect(self.__warning)
@@ -228,7 +227,7 @@
             self.setCentralWidget(centralWidget)
             self.__searchWidget.hide()
             
-            if WebBrowserWindow.useQtHelp:
+            if WebBrowserWindow._useQtHelp:
                 # setup the TOC widget
                 self.__tocWindow = HelpTocWidget(self.__helpEngine)
                 self.__tocDock = QDockWidget(self.tr("Contents"), self)
@@ -327,7 +326,7 @@
             
             # setup connections
             self.__activating = False
-            if WebBrowserWindow.useQtHelp:
+            if WebBrowserWindow._useQtHelp:
                 # TOC window
                 self.__tocWindow.escapePressed.connect(
                     self.__activateCurrentBrowser)
@@ -372,7 +371,7 @@
             
             self.flashCookieManager()
             
-            if WebBrowserWindow.useQtHelp:
+            if WebBrowserWindow._useQtHelp:
                 QTimer.singleShot(0, self.__lookForNewDocumentation)
                 if self.__searchWord is not None:
                     QTimer.singleShot(0, self.__searchForWord)
@@ -1392,7 +1391,7 @@
                 self.__showFeaturePermissionDialog)
         self.__actions.append(self.featurePermissionAct)
         
-        if WebBrowserWindow.useQtHelp or self.__initShortcutsOnly:
+        if WebBrowserWindow._useQtHelp or self.__initShortcutsOnly:
             self.syncTocAct = E5Action(
                 self.tr('Sync with Table of Contents'),
                 UI.PixmapCache.getIcon("syncToc.png"),
@@ -1828,7 +1827,7 @@
         menu.addSeparator()
         menu.addAction(self.stopAct)
         menu.addAction(self.reloadAct)
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             menu.addSeparator()
             menu.addAction(self.syncTocAct)
         
@@ -1894,7 +1893,7 @@
         menu.addAction(self.userAgentManagerAct)
         menu.addSeparator()
         
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             menu.addAction(self.manageQtHelpDocsAct)
             menu.addAction(self.manageQtHelpFiltersAct)
             menu.addAction(self.reindexDocumentationAct)
@@ -1914,7 +1913,7 @@
         menu.addAction(self.showDownloadManagerAct)
         menu.addAction(self.showJavaScriptConsoleAct)
         menu.addAction(self.showTabManagerAct)
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             menu.addSeparator()
             menu.addAction(self.showTocAct)
             menu.addAction(self.showIndexAct)
@@ -1992,7 +1991,7 @@
         findtb.addAction(self.findNextAct)
         findtb.addAction(self.findPrevAct)
         
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             filtertb = self.addToolBar(self.tr("Filter"))
             filtertb.setObjectName("FilterToolBar")
             self.filterCombo = QComboBox()
@@ -2553,7 +2552,7 @@
             # it is the last window
             self.tabManager().close()
         
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.__searchEngine.cancelIndexing()
             self.__searchEngine.cancelSearching()
             
@@ -2886,9 +2885,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):
@@ -2897,15 +2896,27 @@
         
         @return reference to the help engine (QHelpEngine)
         """
-        if cls.useQtHelp:
+        if cls._useQtHelp:
             if cls._helpEngine is None:
-                cls._helpEngine = \
-                    QHelpEngine(os.path.join(Utilities.getConfigDir(),
-                                             "web_browser", "eric6help.qhc"))
+                cls._helpEngine = QHelpEngine(
+                    WebBrowserWindow.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 networkManager(cls):
         """
@@ -2966,7 +2977,7 @@
         """
         Private slot to synchronize the TOC with the currently shown page.
         """
-        if WebBrowserWindow.UseQtHelp:
+        if WebBrowserWindow._useQtHelp:
             QApplication.setOverrideCursor(Qt.WaitCursor)
             url = self.currentBrowser().source()
             self.__showTocWindow()
@@ -2979,21 +2990,21 @@
         """
         Private method to show the table of contents window.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.__activateDock(self.__tocWindow)
         
     def __showIndexWindow(self):
         """
         Private method to show the index window.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.__activateDock(self.__indexWindow)
         
     def __showSearchWindow(self):
         """
         Private method to show the search window.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.__activateDock(self.__searchWindow)
         
     def __activateDock(self, widget):
@@ -3010,7 +3021,7 @@
         """
         Private slot to setup the filter combo box.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             curFilter = self.filterCombo.currentText()
             if not curFilter:
                 curFilter = self.__helpEngine.currentFilter()
@@ -3034,7 +3045,7 @@
         """
         Private slot to manage the QtHelp documentation database.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             from .QtHelp.QtHelpDocumentationDialog import \
                 QtHelpDocumentationDialog
             dlg = QtHelpDocumentationDialog(self.__helpEngine, self)
@@ -3056,7 +3067,7 @@
         """
         Private slot to manage the QtHelp filters.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             from .QtHelp.QtHelpFiltersDialog import QtHelpFiltersDialog
             dlg = QtHelpFiltersDialog(self.__helpEngine, self)
             dlg.exec_()
@@ -3065,7 +3076,7 @@
         """
         Private slot to handle the start of the indexing process.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.__indexing = True
             if self.__indexingProgress is None:
                 self.__indexingProgress = QWidget()
@@ -3092,7 +3103,7 @@
         """
         Private slot to handle the start of the indexing process.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.statusBar().removeWidget(self.__indexingProgress)
             self.__indexingProgress = None
             self.__indexing = False
@@ -3103,7 +3114,7 @@
         """
         Private slot to search for a word.
         """
-        if WebBrowserWindow.useQtHelp and not self.__indexing and \
+        if WebBrowserWindow._useQtHelp and not self.__indexing and \
                 self.__searchWord is not None:
             self.__searchDock.show()
             self.__searchDock.raise_()
@@ -3118,7 +3129,7 @@
         
         @param word word to search for (string)
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             self.__searchWord = word
             self.__searchForWord()
         
@@ -3136,7 +3147,7 @@
         Private slot to look for new documentation to be loaded into the
         help database.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             from .QtHelp.HelpDocsInstaller import HelpDocsInstaller
             self.__helpInstaller = HelpDocsInstaller(
                 self.__helpEngine.collectionFile())
@@ -3166,7 +3177,7 @@
         @param installed flag indicating that documents were installed
             (boolean)
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             if installed:
                 self.__helpEngine.setupData()
             self.statusBar().clearMessage()
@@ -3175,7 +3186,7 @@
         """
         Private slot to initialize the documentation database.
         """
-        if WebBrowserWindow.useQtHelp:
+        if WebBrowserWindow._useQtHelp:
             if not self.__helpEngine.setupData():
                 return
             

eric ide

mercurial