UI/UserInterface.py

changeset 6291
94e0e688dcad
parent 6287
9a193ff6d24a
child 6296
db9b3a419845
diff -r bf4624957d2d -r 94e0e688dcad UI/UserInterface.py
--- a/UI/UserInterface.py	Tue May 15 18:25:26 2018 +0200
+++ b/UI/UserInterface.py	Tue May 15 19:39:46 2018 +0200
@@ -1776,7 +1776,7 @@
         self.__initQtDocActions()
         self.__initPythonDocActions()
         self.__initEricDocAction()
-        self.__initPySideDocAction()
+        self.__initPySideDocActions()
       
         self.versionAct = E5Action(
             self.tr('Show Versions'),
@@ -2439,7 +2439,8 @@
             """<b>Qt4 Documentation</b>"""
             """<p>Display the Qt4 Documentation. Dependent upon your"""
             """ settings, this will either show the help in Eric's internal"""
-            """ help viewer, or execute a web browser or Qt Assistant. </p>"""
+            """ help viewer/web browser, or execute a web browser or Qt"""
+            """ Assistant. </p>"""
         ))
         self.qt4DocAct.triggered.connect(self.__showQt4Doc)
         self.actions.append(self.qt4DocAct)
@@ -2453,7 +2454,8 @@
             """<b>Qt5 Documentation</b>"""
             """<p>Display the Qt5 Documentation. Dependent upon your"""
             """ settings, this will either show the help in Eric's internal"""
-            """ help viewer, or execute a web browser or Qt Assistant. </p>"""
+            """ help viewer/web browser, or execute a web browser or Qt"""
+            """ Assistant. </p>"""
         ))
         self.qt5DocAct.triggered.connect(self.__showQt5Doc)
         self.actions.append(self.qt5DocAct)
@@ -2469,8 +2471,8 @@
                 """<b>PyQt4 Documentation</b>"""
                 """<p>Display the PyQt4 Documentation. Dependent upon your"""
                 """ settings, this will either show the help in Eric's"""
-                """ internal help viewer, or execute a web browser or"""
-                """ Qt Assistant. </p>"""
+                """ internal help viewer/web browser, or execute a web"""
+                """ browser or Qt Assistant. </p>"""
             ))
             self.pyqt4DocAct.triggered.connect(self.__showPyQt4Doc)
             self.actions.append(self.pyqt4DocAct)
@@ -2489,8 +2491,8 @@
                 """<b>PyQt5 Documentation</b>"""
                 """<p>Display the PyQt5 Documentation. Dependent upon your"""
                 """ settings, this will either show the help in Eric's"""
-                """ internal help viewer, or execute a web browser or"""
-                """ Qt Assistant. </p>"""
+                """ internal help viewer/web browser, or execute a web"""
+                """ browser or Qt Assistant. </p>"""
             ))
             self.pyqt5DocAct.triggered.connect(self.__showPyQt5Doc)
             self.actions.append(self.pyqt5DocAct)
@@ -2559,12 +2561,13 @@
         self.ericDocAct.triggered.connect(self.__showEricDoc)
         self.actions.append(self.ericDocAct)
         
-    def __initPySideDocAction(self):
-        """
-        Private slot to initialize the action to show the PySide documentation.
-        """
-        pyside2, pyside3 = Utilities.checkPyside()
-        if pyside2 or pyside3:
+    def __initPySideDocActions(self):
+        """
+        Private slot to initialize the actions to show the PySide
+        documentation.
+        """
+        pyside_py2, pyside_py3 = Utilities.checkPyside("1")
+        if pyside_py2 or pyside_py3:
             self.pysideDocAct = E5Action(
                 self.tr('PySide Documentation'),
                 self.tr('Py&Side Documentation'),
@@ -2575,14 +2578,36 @@
                 """<b>PySide Documentation</b>"""
                 """<p>Display the PySide Documentation. Dependent upon your"""
                 """ settings, this will either show the help in Eric's"""
-                """ internal help viewer, or execute a web browser or"""
-                """ Qt Assistant. </p>"""
+                """ internal help viewer/web browser, or execute a web"""
+                """ browser or Qt Assistant. </p>"""
             ))
-            self.pysideDocAct.triggered.connect(self.__showPySideDoc)
+            self.pysideDocAct.triggered.connect(
+                lambda: self.__showPySideDoc("1"))
             self.actions.append(self.pysideDocAct)
         else:
             self.pysideDocAct = None
-      
+        
+        pyside2_py2, pyside2_py3 = Utilities.checkPyside("2")
+        if pyside2_py2 or pyside2_py3:
+            self.pyside2DocAct = E5Action(
+                self.tr('PySide2 Documentation'),
+                self.tr('PySide&2 Documentation'),
+                0, 0, self, 'pyside2_documentation')
+            self.pyside2DocAct.setStatusTip(self.tr(
+                'Open PySide2 Documentation'))
+            self.pyside2DocAct.setWhatsThis(self.tr(
+                """<b>PySide2 Documentation</b>"""
+                """<p>Display the PySide2 Documentation. Dependent upon your"""
+                """ settings, this will either show the help in Eric's"""
+                """ internal help viewer/web browser, or execute a web"""
+                """ browser or Qt Assistant. </p>"""
+            ))
+            self.pyside2DocAct.triggered.connect(
+                lambda: self.__showPySideDoc("2"))
+            self.actions.append(self.pyside2DocAct)
+        else:
+            self.pyside2DocAct = None
+    
     def __initMenus(self):
         """
         Private slot to create the menus.
@@ -2746,6 +2771,8 @@
             self.__menus["help"].addAction(self.pyqt5DocAct)
         if self.pysideDocAct is not None:
             self.__menus["help"].addAction(self.pysideDocAct)
+        if self.pyside2DocAct is not None:
+            self.__menus["help"].addAction(self.pyside2DocAct)
         self.__menus["help"].addSeparator()
         self.__menus["help"].addAction(self.versionAct)
         self.__menus["help"].addSeparator()
@@ -5373,20 +5400,34 @@
         else:
             self.__customViewer(home)
         
-    def __showPySideDoc(self):
-        """
-        Private slot to show the PySide documentation.
-        """
-        pysideDocDir = Preferences.getHelp("PySideDocDir")
-        if not pysideDocDir:
-            pysideDocDir = Utilities.getEnvironmentEntry("PYSIDEDOCDIR", None)
+    def __showPySideDoc(self, variant):
+        """
+        Private slot to show the PySide/PySide2 documentation.
+        
+        @param variant PySide variant (1 or 2)
+        @type str
+        """
+        assert variant in ("1", "2")
+        
+        if variant == "1":
+            pysideDocDir = Preferences.getHelp("PySideDocDir")
+            if not pysideDocDir:
+                pysideDocDir = Utilities.getEnvironmentEntry(
+                    "PYSIDEDOCDIR", None)
+        else:
+            pysideDocDir = Preferences.getHelp("PySide2DocDir")
+            if not pysideDocDir:
+                pysideDocDir = Utilities.getEnvironmentEntry(
+                    "PYSIDE2DOCDIR", None)
         
         if not pysideDocDir:
             E5MessageBox.warning(
                 self,
                 self.tr("Documentation"),
-                self.tr("""<p>The PySide documentation starting point"""
-                        """ has not been configured.</p>"""))
+                self.tr("""<p>The PySide{0} documentation starting point"""
+                        """ has not been configured.</p>""").format(
+                "" if variant == "1" else variant)
+            )
             return
         
         if not pysideDocDir.startswith(("http://", "https://", "qthelp://")):
@@ -5427,7 +5468,7 @@
             self.__webBrowser(home)
         else:
             self.__customViewer(home)
-        
+    
     @pyqtSlot(QUrl)
     def handleUrl(self, url):
         """
@@ -5517,7 +5558,7 @@
     
     def __helpViewer(self):
         """
-        Private slot to start an empty help viewer.
+        Private slot to start an empty help viewer/web browser.
         """
         searchWord = self.viewmanager.textForFind(False)
         if searchWord == "":

eric ide

mercurial