PySide2 support: started to implement support for PySide2.

Tue, 15 May 2018 19:39:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 15 May 2018 19:39:46 +0200
changeset 6291
94e0e688dcad
parent 6290
bf4624957d2d
child 6292
e08a94e1ecdd

PySide2 support: started to implement support for PySide2.

CodeTemplates/impl_pyside2.py.tmpl file | annotate | diff | comparison | revisions
CodeTemplates/impl_pyside2.py2.tmpl file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/HelpDocumentationPage.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/HelpDocumentationPage.ui file | annotate | diff | comparison | revisions
Preferences/ProgramsDialog.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
Project/CreateDialogCodeDialog.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
Project/ProjectFormsBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectResourcesBrowser.py file | annotate | diff | comparison | revisions
Project/ProjectTranslationsBrowser.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
Utilities/PySideImporter.py file | annotate | diff | comparison | revisions
Utilities/__init__.py file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CodeTemplates/impl_pyside2.py.tmpl	Tue May 15 19:39:46 2018 +0200
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+"""
+Module implementing $CLASSNAME$.
+"""
+
+from PySide2.QtCore import Slot
+from PySide2.QtWidgets import $SUPERCLASS$
+
+from .Ui_$FORMFILE$ import Ui_$FORMCLASS$
+
+
+class $CLASSNAME$($SUPERCLASS$, Ui_$FORMCLASS$):
+    """
+    Class documentation goes here.
+    """
+    def __init__(self, parent=None):
+        """
+        Constructor
+        
+        @param parent reference to the parent widget
+        @type QWidget
+        """
+        super($CLASSNAME$, self).__init__(parent)
+        self.setupUi(self)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CodeTemplates/impl_pyside2.py2.tmpl	Tue May 15 19:39:46 2018 +0200
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+"""
+Module implementing $CLASSNAME$.
+"""
+
+from PySide2.QtCore import Slot
+from PySide2.QtWidgets import $SUPERCLASS$
+
+from .Ui_$FORMFILE$ import Ui_$FORMCLASS$
+
+
+class $CLASSNAME$($SUPERCLASS$, Ui_$FORMCLASS$):
+    """
+    Class documentation goes here.
+    """
+    def __init__(self, parent=None):
+        """
+        Constructor
+        
+        @param parent reference to the parent widget
+        @type QWidget
+        """
+        super($CLASSNAME$, self).__init__(parent)
+        self.setupUi(self)
--- a/Preferences/ConfigurationPages/HelpDocumentationPage.py	Tue May 15 18:25:26 2018 +0200
+++ b/Preferences/ConfigurationPages/HelpDocumentationPage.py	Tue May 15 19:39:46 2018 +0200
@@ -58,18 +58,27 @@
         self.pysideDocDirPicker.setMode(E5PathPickerModes.OpenFileMode)
         self.pysideDocDirPicker.setFilters(self.tr(
             "HTML Files (*.html *.htm);;All Files (*)"))
+        self.pyside2DocDirPicker.setMode(E5PathPickerModes.OpenFileMode)
+        self.pyside2DocDirPicker.setFilters(self.tr(
+            "HTML Files (*.html *.htm);;All Files (*)"))
         
         try:
             import PyQt5        # __IGNORE_WARNING__
         except ImportError:
             self.pyqt5Group.setEnabled(False)
         
-        pyside2, pyside3 = Utilities.checkPyside()
-        if pyside2 or pyside3:
+        pyside_py2, pyside_py3 = Utilities.checkPyside("1")
+        if pyside_py2 or pyside_py3:
             self.pysideGroup.setEnabled(True)
         else:
             self.pysideGroup.setEnabled(False)
         
+        pyside2_py2, pyside2_py3 = Utilities.checkPyside("2")
+        if pyside2_py2 or pyside2_py3:
+            self.pyside2Group.setEnabled(True)
+        else:
+            self.pyside2Group.setEnabled(False)
+        
         # set initial values
         self.ericDocDirPicker.setText(
             Preferences.getHelp("EricDocDir"), toNative=False)
@@ -87,6 +96,8 @@
             Preferences.getHelp("PyQt5DocDir"), toNative=False)
         self.pysideDocDirPicker.setText(
             Preferences.getHelp("PySideDocDir"), toNative=False)
+        self.pysideDocDirPicker.setText(
+            Preferences.getHelp("PySide2DocDir"), toNative=False)
         
     def save(self):
         """
@@ -116,6 +127,9 @@
         Preferences.setHelp(
             "PySideDocDir",
             self.pysideDocDirPicker.text(toNative=False))
+        Preferences.setHelp(
+            "PySide2DocDir",
+            self.pyside2DocDirPicker.text(toNative=False))
     
 
 def create(dlg):
--- a/Preferences/ConfigurationPages/HelpDocumentationPage.ui	Tue May 15 18:25:26 2018 +0200
+++ b/Preferences/ConfigurationPages/HelpDocumentationPage.ui	Tue May 15 19:39:46 2018 +0200
@@ -312,6 +312,41 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="pyside2Group">
+     <property name="title">
+      <string>PySide2 Documentation</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_10">
+      <item>
+       <widget class="E5PathPicker" name="pyside2DocDirPicker" native="true">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="focusPolicy">
+         <enum>Qt::StrongFocus</enum>
+        </property>
+        <property name="toolTip">
+         <string>Enter the PySide2 documentation directory</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="textLabel1_8_2_3">
+        <property name="text">
+         <string>&lt;b&gt;Note&lt;/b&gt;: Leave empty to use the PYSIDE2DOCDIR environment variable, if set.</string>
+        </property>
+        <property name="wordWrap">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <spacer>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
--- a/Preferences/ProgramsDialog.py	Tue May 15 18:25:26 2018 +0200
+++ b/Preferences/ProgramsDialog.py	Tue May 15 19:39:46 2018 +0200
@@ -169,21 +169,38 @@
             Utilities.generatePyQtToolPath("pyrcc5"),
             '-version', '', -1, versionRe='Resource Compiler|pyrcc5')
         
-        # 3. do the PySide programs
-        # 3a. Translation Extractor PySide
+        # 3.1 do the PySide programs
+        # 3.1a. Translation Extractor PySide
         self.__createProgramEntry(
             self.tr("Translation Extractor (Python, PySide)"),
-            Utilities.generatePySideToolPath("pyside-lupdate"),
+            Utilities.generatePySideToolPath("pyside-lupdate", "1"),
             '-version', '', -1, versionRe='lupdate')
-        # 3b. Forms Compiler PySide
+        # 3.1b. Forms Compiler PySide
         self.__createProgramEntry(
             self.tr("Forms Compiler (Python, PySide)"),
-            Utilities.generatePySideToolPath("pyside-uic"),
+            Utilities.generatePySideToolPath("pyside-uic", "1"),
             '--version', 'PySide User', 5, versionCleanup=(0, -1))
-        # 3.c Resource Compiler PySide
+        # 3.1c Resource Compiler PySide
         self.__createProgramEntry(
             self.tr("Resource Compiler (Python, PySide)"),
-            Utilities.generatePySideToolPath("pyside-rcc"),
+            Utilities.generatePySideToolPath("pyside-rcc", "1"),
+            '-version', 'Resource Compiler', -1)
+        
+        # 3.2 do the PySide2 programs
+        # 3.2a. Translation Extractor PySide2
+        self.__createProgramEntry(
+            self.tr("Translation Extractor (Python, PySide2)"),
+            Utilities.generatePySideToolPath("pyside2-lupdate", "2"),
+            '-version', '', -1, versionRe='lupdate')
+        # 3.2b. Forms Compiler PySide2
+        self.__createProgramEntry(
+            self.tr("Forms Compiler (Python, PySide2)"),
+            Utilities.generatePySideToolPath("pyside2-uic", "2"),
+            '--version', 'PySide2 User', -1, versionCleanup=(0, -1))
+        # 3.2c Resource Compiler PySide2
+        self.__createProgramEntry(
+            self.tr("Resource Compiler (Python, PySide2)"),
+            Utilities.generatePySideToolPath("pyside2-rcc", "2"),
             '-version', 'Resource Compiler', -1)
         
         # 4. do the Ruby programs
--- a/Preferences/__init__.py	Tue May 15 18:25:26 2018 +0200
+++ b/Preferences/__init__.py	Tue May 15 19:39:46 2018 +0200
@@ -846,6 +846,21 @@
             InterfacesBrowserFlag |
             OthersBrowserFlag |
             ProtocolsBrowserFlag),
+        "PySide2": (
+            SourcesBrowserFlag |
+            FormsBrowserFlag |
+            ResourcesBrowserFlag |
+            TranslationsBrowserFlag |
+            InterfacesBrowserFlag |
+            OthersBrowserFlag |
+            ProtocolsBrowserFlag),
+        "PySide2C": (
+            SourcesBrowserFlag |
+            ResourcesBrowserFlag |
+            TranslationsBrowserFlag |
+            InterfacesBrowserFlag |
+            OthersBrowserFlag |
+            ProtocolsBrowserFlag),
     }
     
     # defaults for the project browser colour settings
@@ -871,6 +886,7 @@
         "PyQt4DocDir": "",
         "PyQt5DocDir": "",
         "PySideDocDir": "",
+        "PySide2DocDir": "",
         "EricDocDir": "",
         "SingleHelpWindow": True,
         "SaveGeometry": True,
--- a/Project/CreateDialogCodeDialog.py	Tue May 15 18:25:26 2018 +0200
+++ b/Project/CreateDialogCodeDialog.py	Tue May 15 19:39:46 2018 +0200
@@ -217,7 +217,7 @@
         mapped = bytes(type_).decode()
         
         if self.project.getProjectLanguage() != "Python2" or \
-           self.project.getProjectType == "PySide":
+           self.project.getProjectType in ("PySide", "PySide2"):
             # 1. check for const
             mapped = mapped.replace("const ", "")
             
@@ -396,6 +396,10 @@
                         tmplName = os.path.join(
                             getConfig('ericCodeTemplatesDir'),
                             "impl_pyside.py2.tmpl")
+                    elif self.project.getProjectType() == "PySide2":
+                        tmplName = os.path.join(
+                            getConfig('ericCodeTemplatesDir'),
+                            "impl_pyside2.py2.tmpl")
                     elif self.project.getProjectType() == "PyQt5":
                         tmplName = os.path.join(
                             getConfig('ericCodeTemplatesDir'),
@@ -409,6 +413,10 @@
                         tmplName = os.path.join(
                             getConfig('ericCodeTemplatesDir'),
                             "impl_pyside.py.tmpl")
+                    elif self.project.getProjectType() == "PySide2":
+                        tmplName = os.path.join(
+                            getConfig('ericCodeTemplatesDir'),
+                            "impl_pyside2.py.tmpl")
                     elif self.project.getProjectType() in [
                             "PyQt5", "E6Plugin"]:
                         tmplName = os.path.join(
@@ -487,14 +495,14 @@
         
         # do the coding stuff
         if self.project.getProjectLanguage() == "Python2":
-            if self.project.getProjectType() == "PySide":
+            if self.project.getProjectType() in ("PySide", "PySide2"):
                 pyqtSignatureFormat = '@Slot({0})'
             elif self.project.getProjectType() == "PyQt5":
                 pyqtSignatureFormat = '@pyqtSlot({0})'
             else:
                 pyqtSignatureFormat = '@pyqtSignature("{0}")'
         else:
-            if self.project.getProjectType() == "PySide":
+            if self.project.getProjectType() in ("PySide", "PySide2"):
                 pyqtSignatureFormat = '@Slot({0})'
             else:
                 pyqtSignatureFormat = '@pyqtSlot({0})'
--- a/Project/Project.py	Tue May 15 18:25:26 2018 +0200
+++ b/Project/Project.py	Tue May 15 19:39:46 2018 +0200
@@ -284,17 +284,28 @@
             "JavaScript": ["Other"],
         }
         
-        pyside2, pyside3 = Utilities.checkPyside()
-        if pyside2 or pyside3:
+        pyside_py2, pyside_py3 = Utilities.checkPyside("1")
+        if pyside_py2 or pyside_py3:
             self.__projectTypes["PySide"] = self.tr("PySide GUI")
             self.__projectTypes["PySideC"] = self.tr("PySide Console")
-            if pyside2:
+            if pyside_py2:
                 self.__projectProgLanguages["Python2"].extend(
                     ["PySide", "PySideC"])
-            if pyside3:
+            if pyside_py3:
                 self.__projectProgLanguages["Python3"].extend(
                     ["PySide", "PySideC"])
         
+        pyside2_py2, pyside2_py3 = Utilities.checkPyside("2")
+        if pyside2_py2 or pyside2_py3:
+            self.__projectTypes["PySide2"] = self.tr("PySide2 GUI")
+            self.__projectTypes["PySide2C"] = self.tr("PySide2 Console")
+            if pyside2_py2:
+                self.__projectProgLanguages["Python2"].extend(
+                    ["PySide2", "PySide2C"])
+            if pyside2_py3:
+                self.__projectProgLanguages["Python3"].extend(
+                    ["PySide2", "PySide2C"])
+        
     def getProjectTypes(self, progLanguage=""):
         """
         Public method to get the list of supported project types.
@@ -575,21 +586,24 @@
         
         # Forms
         if self.pdata["PROJECTTYPE"] in ["Qt4", "PyQt5",
-                                         "E6Plugin", "PySide"]:
+                                         "E6Plugin", "PySide",
+                                         "PySide2"]:
             self.pdata["FILETYPES"]["*.ui"] = "FORMS"
         
         # Resources
         if self.pdata["PROJECTTYPE"] in ["Qt4", "Qt4C",
                                          "E6Plugin",
                                          "PyQt5", "PyQt5C",
-                                         "PySide", "PySideC"]:
+                                         "PySide", "PySideC",
+                                         "PySide2", "PySide2C"]:
             self.pdata["FILETYPES"]["*.qrc"] = "RESOURCES"
         
         # Translations
         if self.pdata["PROJECTTYPE"] in ["Qt4", "Qt4C",
                                          "E6Plugin",
                                          "PyQt5", "PyQt5C",
-                                         "PySide", "PySideC"]:
+                                         "PySide", "PySideC",
+                                         "PySide2", "PySide2C"]:
             self.pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS"
             self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS"
         
@@ -613,7 +627,8 @@
         if self.pdata["PROJECTTYPE"] in ["Qt4", "Qt4C",
                                          "E6Plugin",
                                          "PyQt5", "PyQt5C",
-                                         "PySide", "PySideC"]:
+                                         "PySide", "PySideC",
+                                         "PySide2", "PySide2C"]:
             if "*.ts" not in self.pdata["FILETYPES"]:
                 self.pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS"
             if "*.qm" not in self.pdata["FILETYPES"]:
@@ -1337,7 +1352,7 @@
             lang = dlg.getSelectedLanguage()
             if self.pdata["PROJECTTYPE"] in \
                     ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                     "PySide", "PySideC"]:
+                     "PySide", "PySideC", "PySide2", "PySide2C"]:
                 langFile = self.pdata["TRANSLATIONPATTERN"]\
                     .replace("%language%", lang)
                 self.appendFile(langFile)
--- a/Project/ProjectFormsBrowser.py	Tue May 15 18:25:26 2018 +0200
+++ b/Project/ProjectFormsBrowser.py	Tue May 15 19:39:46 2018 +0200
@@ -126,7 +126,7 @@
         
         self.menu = QMenu(self)
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
             self.menu.addAction(
                 self.tr('Compile form'), self.__compileForm)
             self.menu.addAction(
@@ -181,7 +181,7 @@
         self.menuActions.append(act)
         self.menu.addSeparator()
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
             self.menu.addAction(self.tr('New form...'), self.__newForm)
         else:
             if self.hooks["newForm"] is not None:
@@ -204,7 +204,7 @@
 
         self.backMenu = QMenu(self)
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"] or \
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"] or \
                 self.hooks["compileAllForms"] is not None:
             self.backMenu.addAction(
                 self.tr('Compile all forms'), self.__compileAllForms)
@@ -231,7 +231,7 @@
         # create the menu for multiple selected files
         self.multiMenu = QMenu(self)
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
             act = self.multiMenu.addAction(
                 self.tr('Compile forms'), self.__compileSelectedForms)
             self.multiMenu.addSeparator()
@@ -273,7 +273,7 @@
 
         self.dirMenu = QMenu(self)
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
             self.dirMenu.addAction(
                 self.tr('Compile all forms'), self.__compileAllForms)
             self.dirMenu.addSeparator()
@@ -293,7 +293,7 @@
         self.dirMenuActions.append(act)
         self.dirMenu.addSeparator()
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
             self.dirMenu.addAction(self.tr('New form...'), self.__newForm)
         else:
             if self.hooks["newForm"] is not None:
@@ -318,7 +318,7 @@
         
         self.dirMultiMenu = QMenu(self)
         if self.project.getProjectType() in \
-                ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
             self.dirMultiMenu.addAction(
                 self.tr('Compile all forms'), self.__compileAllForms)
             self.dirMultiMenu.addSeparator()
@@ -536,7 +536,7 @@
             self.hooks["newForm"](path)
         else:
             if self.project.getProjectType() in \
-                    ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+                    ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
                 self.__newUiForm(path)
         
     def __newUiForm(self, path):
@@ -637,7 +637,7 @@
     def __readStdout(self):
         """
         Private slot to handle the readyReadStandardOutput signal of the
-        pyuic4/pyuic5/pyside-uic/rbuic4 process.
+        pyuic4/pyuic5/pyside-uic/pyside2-uic/rbuic4 process.
         """
         if self.compileProc is None:
             return
@@ -650,7 +650,7 @@
     def __readStderr(self):
         """
         Private slot to handle the readyReadStandardError signal of the
-        pyuic4/pyuic5/pyside-uic/rbuic4 process.
+        pyuic4/pyuic5/pyside-uic/pyside2-uic/rbuic4 process.
         """
         if self.compileProc is None:
             return
@@ -759,7 +759,8 @@
                         'pyuic5', ["py3uic5", "py2uic5"])
             elif self.project.getProjectType() == "PySide":
                 self.uicompiler = \
-                    Utilities.generatePySideToolPath('pyside-uic')
+                    Utilities.generatePySideToolPath('pyside-uic', "1")
+            # TODO: add entry for PySide2
             else:
                 return None
         elif self.project.getProjectLanguage() == "Ruby":
@@ -932,7 +933,7 @@
             self.hooks["compileChangedForms"](self.project.pdata["FORMS"])
         else:
             if self.project.getProjectType() not in \
-               ["Qt4", "PyQt5", "E6Plugin", "PySide"]:
+               ["Qt4", "PyQt5", "E6Plugin", "PySide", "PySide2"]:
                 # ignore the request for non Qt GUI projects
                 return
             
--- a/Project/ProjectResourcesBrowser.py	Tue May 15 18:25:26 2018 +0200
+++ b/Project/ProjectResourcesBrowser.py	Tue May 15 19:39:46 2018 +0200
@@ -84,7 +84,7 @@
         self.menu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             self.menu.addAction(
                 self.tr('Compile resource'),
                 self.__compileResource)
@@ -120,7 +120,7 @@
         self.menu.addSeparator()
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             self.menu.addAction(
                 self.tr('New resource...'), self.__newResource)
         else:
@@ -148,7 +148,7 @@
         self.backMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             self.backMenu.addAction(
                 self.tr('Compile all resources'),
                 self.__compileAllResources)
@@ -186,7 +186,7 @@
         self.multiMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             act = self.multiMenu.addAction(
                 self.tr('Compile resources'),
                 self.__compileSelectedResources)
@@ -218,7 +218,7 @@
         self.dirMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             self.dirMenu.addAction(
                 self.tr('Compile all resources'),
                 self.__compileAllResources)
@@ -259,7 +259,7 @@
         self.dirMultiMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             self.dirMultiMenu.addAction(
                 self.tr('Compile all resources'),
                 self.__compileAllResources)
@@ -527,7 +527,7 @@
     def __readStdout(self):
         """
         Private slot to handle the readyReadStandardOutput signal of the
-        pyrcc4/pyrcc5/pyside-rcc/rbrcc process.
+        pyrcc4/pyrcc5/pyside-rcc/pyside2-rcc/rbrcc process.
         """
         if self.compileProc is None:
             return
@@ -541,7 +541,7 @@
     def __readStderr(self):
         """
         Private slot to handle the readyReadStandardError signal of the
-        pyrcc4/pyrcc5/pyside-rcc/rbrcc process.
+        pyrcc4/pyrcc5/pyside-rcc/pyside2-rcc/rbrcc process.
         """
         if self.compileProc is None:
             return
@@ -651,12 +651,13 @@
                     self.rccCompiler = Utilities.generatePyQtToolPath('pyrcc5')
             elif self.project.getProjectType() in ["PySide", "PySideC"]:
                 self.rccCompiler = Utilities.generatePySideToolPath(
-                    'pyside-rcc')
+                    'pyside-rcc', "1")
                 if self.project.getProjectLanguage() in \
                         ["Python", "Python2"]:
                     args.append("-py2")
                 else:
                     args.append("-py3")
+            # TODO: add entry for PySide2
             else:
                 return None
         elif self.project.getProjectLanguage() == "Ruby":
--- a/Project/ProjectTranslationsBrowser.py	Tue May 15 18:25:26 2018 +0200
+++ b/Project/ProjectTranslationsBrowser.py	Tue May 15 19:39:46 2018 +0200
@@ -107,7 +107,7 @@
         self.menu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             act = self.menu.addAction(
                 self.tr('Generate translation'), self.__generateSelected)
             self.tsMenuActions.append(act)
@@ -234,7 +234,7 @@
         self.backMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             act = self.backMenu.addAction(
                 self.tr('Generate all translations'),
                 self.__generateAll)
@@ -295,7 +295,7 @@
         self.multiMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             act = self.multiMenu.addAction(
                 self.tr('Generate translations'),
                 self.__generateSelected)
@@ -379,7 +379,7 @@
         self.dirMenu = QMenu(self)
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             act = self.dirMenu.addAction(
                 self.tr('Generate all translations'),
                 self.__generateAll)
@@ -497,7 +497,7 @@
         """
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             tsFiles = 0
             qmFiles = 0
             itmList = self.getSelectedItems()
@@ -539,7 +539,7 @@
         """
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             tsFiles = 0
             qmFiles = 0
             itmList = self.getSelectedItems()
@@ -579,7 +579,7 @@
         """
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             if self.pylupdateProcRunning:
                 for act in self.tsprocDirMenuActions:
                     act.setEnabled(False)
@@ -599,7 +599,7 @@
         """
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             if self.pylupdateProcRunning:
                 for act in self.tsprocBackMenuActions:
                     act.setEnabled(False)
@@ -869,7 +869,7 @@
     def __readStderrLupdate(self, proc):
         """
         Private slot to handle the readyReadStandardError signal of the
-        pylupdate4/pylupdate5/pyside-lupdate process.
+        pylupdate4/pylupdate5/pyside-lupdate/pyside2-lupdate process.
         
         @param proc reference to the process
         @type QProcess
@@ -1027,7 +1027,9 @@
             else:
                 self.pylupdate = Utilities.generatePyQtToolPath('pylupdate5')
         elif self.project.getProjectType() in ["PySide", "PySideC"]:
-            self.pylupdate = Utilities.generatePySideToolPath('pyside-lupdate')
+            self.pylupdate = Utilities.generatePySideToolPath(
+                'pyside-lupdate', "1")
+        # TODO: add entry for PySide2
         else:
             return
 
@@ -1201,7 +1203,7 @@
         
         if self.project.getProjectType() in \
                 ["Qt4", "Qt4C", "PyQt5", "PyQt5C", "E6Plugin",
-                 "PySide", "PySideC"]:
+                 "PySide", "PySideC", "PySide2", "PySideC2"]:
             lrelease = os.path.join(
                 Utilities.getQtBinariesPath(),
                 Utilities.generateQtToolName("lrelease"))
--- 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 == "":
--- a/Utilities/PySideImporter.py	Tue May 15 18:25:26 2018 +0200
+++ b/Utilities/PySideImporter.py	Tue May 15 19:39:46 2018 +0200
@@ -4,16 +4,31 @@
 #
 
 """
-Module to check for the presence of PySide by importing it.
+Module to check for the presence of PySide/PySide2 by importing it.
 """
 
 import sys
 
 if __name__ == "__main__":
-    try:
-        import PySide       # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
-        ret = 0
-    except ImportError:
+    pySideVariant = "2"
+    if len(sys.argv) == 2:
+        pySideVariant = sys.argv[1].replace("-", "")
+    
+    if pySideVariant == "1":
+        try:
+            import PySide       # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
+            ret = 0
+        except ImportError:
+            ret = 1
+    
+    elif pySideVariant == "2":
+        try:
+            import PySide2       # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
+            ret = 0
+        except ImportError:
+            ret = 1
+    
+    else:
         ret = 1
     
     sys.exit(ret)
--- a/Utilities/__init__.py	Tue May 15 18:25:26 2018 +0200
+++ b/Utilities/__init__.py	Tue May 15 19:39:46 2018 +0200
@@ -1748,21 +1748,27 @@
     return exe
 
 ###############################################################################
-# PySide utility functions below
+# PySide/PySide2 utility functions below
 ###############################################################################
 
 
-def generatePySideToolPath(toolname):
+def generatePySideToolPath(toolname, variant="2"):
     """
-    Module function to generate the executable path for a PySide tool.
+    Module function to generate the executable path for a PySide/PySide2 tool.
     
-    @param toolname base name of the tool (string)
-    @return the PySide tool path with extension (string)
+    @param toolname base name of the tool
+    @type str
+    @param variant indicator for the PySide variant
+    @type str
+    @return the PySide/PySide2 tool path with extension
+    @rtype str
     """
+    assert variant in ("1", "2")
+    
     if isWindowsPlatform():
-        pysideInterpreter = checkPyside()
+        pysideInterpreters = checkPyside(variant)
         interpreter = sys.version_info[0] - 2
-        hasPyside = pysideInterpreter[interpreter]
+        hasPyside = pysideInterpreters[interpreter]
         # if it isn't the internal interpreter, it has to be the external one
         if not hasPyside:
             interpreter = not interpreter
@@ -1772,22 +1778,38 @@
         else:
             prefix = os.path.dirname(
                 Preferences.getDebugger("PythonInterpreter"))
-        if toolname == "pyside-uic":
+        # TODO: check this on Windows
+        if toolname in ["pyside-uic", "pyside2-uic"]:
             return os.path.join(prefix, "Scripts", toolname + '.exe')
         else:
-            return os.path.join(prefix, "Lib", "site-packages", "PySide",
-                                toolname + ".exe")
+            return os.path.join(
+                prefix, "Lib", "site-packages",
+                "PySide{0}".format("" if variant == "1" else variant),
+                toolname + ".exe")
     else:
-        return toolname
+        if variant == "1":
+            return toolname
+        
+        elif toolname == "pyside2-uic":
+            return toolname
+        else:
+            import distutils.sysconfig
+            return os.path.join(distutils.sysconfig.get_python_lib(True),
+                                "PySide2", toolname)
 
 
-def checkPyside():
+def checkPyside(variant="2"):
     """
-    Module function to check the presence of PySide.
+    Module function to check the presence of PySide/PySide2.
     
-    @return list of two flags indicating the presence of PySide for Python2
-        and PySide for Python3 (boolean, boolean)
+    @param variant indicator for the PySide variant
+    @type str
+    @return list of two flags indicating the presence of PySide/PySide2 for
+        Python2 and PySide/PySide2 for Python3
+    @rtype tuple of (bool, bool)
     """
+    assert variant in ("1", "2")
+    
     pysideInformation = []
     for interpreterName in ["PythonInterpreter", "Python3Interpreter"]:
         interpreter = Preferences.getDebugger(interpreterName)
@@ -1797,7 +1819,7 @@
             hasPyside = False
             checker = os.path.join(getConfig('ericDir'),
                                    "Utilities", "PySideImporter.py")
-            args = [checker]
+            args = [checker, "-" + variant]
             proc = QProcess()
             proc.setProcessChannelMode(QProcess.MergedChannels)
             proc.start(interpreter, args)

eric ide

mercurial