Added more changes to make eric6 usable with PyQt4 as well.

Sat, 13 Sep 2014 16:13:52 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 13 Sep 2014 16:13:52 +0200
changeset 3778
0c5bc18da740
parent 3777
0c47cbb5b199
child 3779
573d5f26bc47

Added more changes to make eric6 usable with PyQt4 as well.

E5Gui/E5FileDialog.py file | annotate | diff | comparison | revisions
E5Gui/E5MapWidget.py file | annotate | diff | comparison | revisions
E5Gui/E5SideBar.py file | annotate | diff | comparison | revisions
E5Gui/E5TabWidget.py file | annotate | diff | comparison | revisions
Globals/__init__.py file | annotate | diff | comparison | revisions
Graphics/PixmapDiagram.py file | annotate | diff | comparison | revisions
Graphics/SvgDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLGraphicsView.py file | annotate | diff | comparison | revisions
Helpviewer/Download/DownloadItem.py file | annotate | diff | comparison | revisions
Helpviewer/HelpBrowserWV.py file | annotate | diff | comparison | revisions
IconEditor/IconEditorWindow.py file | annotate | diff | comparison | revisions
Network/IRC/IrcMessageEdit.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
QScintilla/Shell.py file | annotate | diff | comparison | revisions
Snapshot/SnapWidget.py file | annotate | diff | comparison | revisions
Tools/UIPreviewer.py file | annotate | diff | comparison | revisions
compileUiFiles.py file | annotate | diff | comparison | revisions
eric6_api.py file | annotate | diff | comparison | revisions
eric6_compare.py file | annotate | diff | comparison | revisions
eric6_configure.py file | annotate | diff | comparison | revisions
eric6_diff.py file | annotate | diff | comparison | revisions
eric6_doc.py file | annotate | diff | comparison | revisions
eric6_editor.py file | annotate | diff | comparison | revisions
eric6_iconeditor.py file | annotate | diff | comparison | revisions
eric6_plugininstall.py file | annotate | diff | comparison | revisions
eric6_pluginrepository.py file | annotate | diff | comparison | revisions
eric6_pluginuninstall.py file | annotate | diff | comparison | revisions
eric6_qregexp.py file | annotate | diff | comparison | revisions
eric6_qregularexpression.py file | annotate | diff | comparison | revisions
eric6_re.py file | annotate | diff | comparison | revisions
eric6_snap.py file | annotate | diff | comparison | revisions
eric6_sqlbrowser.py file | annotate | diff | comparison | revisions
eric6_tray.py file | annotate | diff | comparison | revisions
eric6_trpreviewer.py file | annotate | diff | comparison | revisions
eric6_uipreviewer.py file | annotate | diff | comparison | revisions
eric6_unittest.py file | annotate | diff | comparison | revisions
eric6_webbrowser.py file | annotate | diff | comparison | revisions
install.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5FileDialog.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/E5Gui/E5FileDialog.py	Sat Sep 13 16:13:52 2014 +0200
@@ -10,6 +10,7 @@
 
 from __future__ import unicode_literals
 
+from PyQt5.QtCore import qVersion
 from PyQt5.QtWidgets import QFileDialog
 
 import Globals
@@ -59,8 +60,12 @@
     """
     if Globals.isLinuxPlatform():
         options |= QFileDialog.DontUseNativeDialog
-    return QFileDialog.getOpenFileName(parent, caption, directory,
-                                       filter, "", options)[0]
+    if qVersion() >= "5.0.0":
+        return QFileDialog.getOpenFileName(
+            parent, caption, directory, filter, "", options)[0]
+    else:
+        return QFileDialog.getOpenFileName(
+            parent, caption, directory, filter, options)
 
 
 def getOpenFileNameAndFilter(parent=None, caption="", directory="",
@@ -81,8 +86,12 @@
     if Globals.isLinuxPlatform():
         options |= QFileDialog.DontUseNativeDialog
     newfilter = __reorderFilter(filter, initialFilter)
-    return QFileDialog.getOpenFileName(parent, caption, directory, newfilter,
-                                       initialFilter, options)
+    if qVersion() >= "5.0.0":
+        return QFileDialog.getOpenFileName(
+            parent, caption, directory, newfilter, initialFilter, options)
+    else:
+        return QFileDialog.getOpenFileNameAndFilter(
+            parent, caption, directory, newfilter, initialFilter, options)
 
 
 def getOpenFileNames(parent=None, caption="", directory="",
@@ -99,8 +108,12 @@
     """
     if Globals.isLinuxPlatform():
         options |= QFileDialog.DontUseNativeDialog
-    return QFileDialog.getOpenFileNames(parent, caption, directory,
-                                        filter, "", options)[0]
+    if qVersion() >= "5.0.0":
+        return QFileDialog.getOpenFileNames(
+            parent, caption, directory, filter, "", options)[0]
+    else:
+        return QFileDialog.getOpenFileNames(
+            parent, caption, directory, filter, options)
 
 
 def getOpenFileNamesAndFilter(parent=None, caption="", directory="",
@@ -122,8 +135,12 @@
     if Globals.isLinuxPlatform():
         options |= QFileDialog.DontUseNativeDialog
     newfilter = __reorderFilter(filter, initialFilter)
-    return QFileDialog.getOpenFileNames(parent, caption, directory, newfilter,
-                                        initialFilter, options)
+    if qVersion() >= "5.0.0":
+        return QFileDialog.getOpenFileNames(
+            parent, caption, directory, newfilter, initialFilter, options)
+    else:
+        return QFileDialog.getOpenFileNamesAndFilter(
+            parent, caption, directory, newfilter, initialFilter, options)
 
 
 def getSaveFileName(parent=None, caption="", directory="",
@@ -140,8 +157,12 @@
     """
     if Globals.isLinuxPlatform():
         options |= QFileDialog.DontUseNativeDialog
-    return QFileDialog.getSaveFileName(parent, caption, directory,
-                                       filter, "", options)[0]
+    if qVersion() >= "5.0.0":
+        return QFileDialog.getSaveFileName(
+            parent, caption, directory, filter, "", options)[0]
+    else:
+        return QFileDialog.getSaveFileName(
+            parent, caption, directory, filter, options)
 
 
 def getSaveFileNameAndFilter(parent=None, caption="", directory="",
@@ -162,8 +183,12 @@
     if Globals.isLinuxPlatform():
         options |= QFileDialog.DontUseNativeDialog
     newfilter = __reorderFilter(filter, initialFilter)
-    return QFileDialog.getSaveFileName(parent, caption, directory, newfilter,
-                                       initialFilter, options)
+    if qVersion() >= "5.0.0":
+        return QFileDialog.getSaveFileName(
+            parent, caption, directory, newfilter, initialFilter, options)
+    else:
+        return QFileDialog.getSaveFileNameAndFilter(
+            parent, caption, directory, newfilter, initialFilter, options)
 
 
 def getExistingDirectory(parent=None, caption="",
--- a/E5Gui/E5MapWidget.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/E5Gui/E5MapWidget.py	Sat Sep 13 16:13:52 2014 +0200
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import Qt, QSize, QRect, QCoreApplication
+from PyQt5.QtCore import Qt, QSize, QRect, QCoreApplication, qVersion
 from PyQt5.QtGui import QColor, QBrush, QPainter
 from PyQt5.QtWidgets import QWidget, QAbstractScrollArea
 
@@ -219,10 +219,14 @@
         
         @param event reference to the wheel event (QWheelEvent)
         """
+        if qVersion() >= "5.0.0":
+            isVertical = event.angleDelta().x() == 0
+        else:
+            isVertical = event.orientation() == Qt.Vertical
         if self._master and \
             event.modifiers() == Qt.NoModifier and \
-                event.angleDelta().x() == 0:
-            # TODO: test angleDelte() with Mac Trackpad
+                isVertical:
+            # TODO: test angleDelta() with Mac Trackpad
             QCoreApplication.sendEvent(self._master.verticalScrollBar(), event)
     
     def calculateGeometry(self):
--- a/E5Gui/E5SideBar.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/E5Gui/E5SideBar.py	Sat Sep 13 16:13:52 2014 +0200
@@ -10,7 +10,7 @@
 from __future__ import unicode_literals
 
 from PyQt5.QtCore import QEvent, QSize, Qt, QByteArray, QDataStream, \
-    QIODevice, QTimer
+    QIODevice, QTimer, qVersion
 from PyQt5.QtWidgets import QTabBar, QWidget, QStackedWidget, QBoxLayout, \
     QToolButton, QSizePolicy
 
@@ -254,7 +254,11 @@
                 elif self.isMinimized():
                     self.expand()
             elif evt.type() == QEvent.Wheel:
-                if evt.angleDelta().y() > 0:
+                if qVersion() >= "5.0.0":
+                    delta = evt.angleDelta().y()
+                else:
+                    delta = evt.delta()
+                if delta > 0:
                     self.prevTab()
                 else:
                     self.nextTab()
--- a/E5Gui/E5TabWidget.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/E5Gui/E5TabWidget.py	Sat Sep 13 16:13:52 2014 +0200
@@ -9,7 +9,8 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal
+from PyQt5.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal, \
+    qVersion
 from PyQt5.QtGui import QDrag, QMovie
 from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication, QStyle, QLabel
 
@@ -35,7 +36,11 @@
         @param event reference to the wheel event (QWheelEvent)
         """
         try:
-            if event.angleDelta().y() > 0:
+            if qVersion() >= "5.0.0":
+                delta = event.angleDelta().y()
+            else:
+                delta = event.delta()
+            if delta > 0:
                 self._tabWidget.prevTab()
             else:
                 self._tabWidget.nextTab()
--- a/Globals/__init__.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Globals/__init__.py	Sat Sep 13 16:13:52 2014 +0200
@@ -94,9 +94,10 @@
     # always assume, that snapshots are good
     if "snapshot" not in pyqtVersion:
         # check for blacklisted versions
-        for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]:
+        pyqtVariant = "PyQt{0}".format(pyqtVersion[0])
+        for vers in BlackLists[pyqtVariant] + PlatformBlackLists[pyqtVariant]:
             if vers == pyqtVersion:
-                print('Sorry, PyQt5 version {0} is not compatible with eric6.'
+                print('Sorry, PyQt version {0} is not compatible with eric6.'
                       .format(vers))
                 print('Please install another version.')
                 return False
@@ -160,6 +161,7 @@
     return distutils.sysconfig.get_python_lib(True)
 
 
+# TODO: modify to also work with PyQt4
 def getPyQt5ModulesDirectory():
     """
     Function to determine the path to PyQt5's modules directory.
--- a/Graphics/PixmapDiagram.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Graphics/PixmapDiagram.py	Sat Sep 13 16:13:52 2014 +0200
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import Qt, QSize, QEvent
+from PyQt5.QtCore import Qt, QSize, QEvent, qVersion
 from PyQt5.QtGui import QPalette, QImage, QPixmap, QPainter, QFont, QColor
 from PyQt5.QtWidgets import QLabel, QSizePolicy, QScrollArea, QAction, QMenu, \
     QToolBar
@@ -187,7 +187,11 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if qVersion() >= "5.0.0":
+                delta = evt.angleDelta().y()
+            else:
+                delta = evt.delta()
+            if delta < 0:
                 self.__zoomOut()
             else:
                 self.__zoomIn()
--- a/Graphics/SvgDiagram.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Graphics/SvgDiagram.py	Sat Sep 13 16:13:52 2014 +0200
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import Qt, QSize, QEvent
+from PyQt5.QtCore import Qt, QSize, QEvent, qVersion
 from PyQt5.QtGui import QPalette, QPainter, QFont, QColor
 from PyQt5.QtWidgets import QSizePolicy, QScrollArea, QAction, QMenu, QToolBar
 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
@@ -157,7 +157,11 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if qVersion() >= "5.0.0":
+                delta = evt.angleDelta().y()
+            else:
+                delta = evt.delta()
+            if delta < 0:
                 self.__zoomOut()
             else:
                 self.__zoomIn()
--- a/Graphics/UMLGraphicsView.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Graphics/UMLGraphicsView.py	Sat Sep 13 16:13:52 2014 +0200
@@ -10,7 +10,7 @@
 from __future__ import unicode_literals
 
 from PyQt5.QtCore import pyqtSignal, Qt, QSignalMapper, QFileInfo, QEvent, \
-    QRectF
+    QRectF, qVersion
 from PyQt5.QtWidgets import QGraphicsView, QAction, QToolBar, QDialog
 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
 
@@ -601,7 +601,11 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if qVersion() >= "5.0.0":
+                delta = evt.angleDelta().y()
+            else:
+                delta = evt.delta()
+            if delta < 0:
                 self.zoomOut()
             else:
                 self.zoomIn()
--- a/Helpviewer/Download/DownloadItem.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Helpviewer/Download/DownloadItem.py	Sat Sep 13 16:13:52 2014 +0200
@@ -14,7 +14,7 @@
     pass
 
 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QTime, QFile, QFileInfo, \
-    QUrl, QIODevice, QCryptographicHash, QStandardPaths
+    QUrl, QIODevice, QCryptographicHash, PYQT_VERSION_STR
 from PyQt5.QtGui import QPalette, QDesktopServices
 from PyQt5.QtWidgets import QWidget, QStyle, QDialog
 from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
@@ -210,9 +210,16 @@
                 return
             
             self.__autoOpen = dlg.getAction() == "open"
-            fileName = QStandardPaths.storageLocation(
-                QStandardPaths.TempLocation) + \
-                '/' + QFileInfo(fileName).completeBaseName()
+            if PYQT_VERSION_STR >= "5.0.0":
+                from PyQt5.QtCore import QStandardPaths
+                tempLocation = QStandardPaths.storageLocation(
+                    QStandardPaths.TempLocation)
+            else:
+                from PyQt5.QtGui import QDesktopServices
+                tempLocation = QDesktopServices.storageLocation(
+                    QDesktopServices.TempLocation)
+            fileName = tempLocation + '/' + \
+                QFileInfo(fileName).completeBaseName()
         
         if ask and not self.__autoOpen and self.__requestFilename:
             self.__gettingFileName = True
--- a/Helpviewer/HelpBrowserWV.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Helpviewer/HelpBrowserWV.py	Sat Sep 13 16:13:52 2014 +0200
@@ -1726,8 +1726,12 @@
         
         @param evt reference to the wheel event (QWheelEvent)
         """
+        if qVersion() >= "5.0.0":
+            delta = evt.angleDelta().y()
+        else:
+            delta = evt.delta()
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if delta < 0:
                 self.zoomOut()
             else:
                 self.zoomIn()
@@ -1735,7 +1739,7 @@
             return
         
         if evt.modifiers() & Qt.ShiftModifier:
-            if evt.angleDelta().y() < 0:
+            if delta < 0:
                 self.backward()
             else:
                 self.forward()
--- a/IconEditor/IconEditorWindow.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/IconEditor/IconEditorWindow.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,7 +12,7 @@
 import os
 
 from PyQt5.QtCore import pyqtSignal, Qt, QSize, QSignalMapper, QFileInfo, \
-    QFile, QEvent
+    QFile, QEvent, qVersion
 from PyQt5.QtGui import QPalette, QImage, QImageReader, QImageWriter, \
     QKeySequence
 from PyQt5.QtWidgets import QScrollArea, QLabel, QDockWidget, QWhatsThis
@@ -1327,7 +1327,11 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if qVersion() >= "5.0.0":
+                delta = evt.angleDelta().y()
+            else:
+                delta = evt.delta()
+            if delta < 0:
                 self.__zoomOut()
             else:
                 self.__zoomIn()
--- a/Network/IRC/IrcMessageEdit.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Network/IRC/IrcMessageEdit.py	Sat Sep 13 16:13:52 2014 +0200
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import Qt
+from PyQt5.QtCore import Qt, qVersion
 
 from E5Gui.E5LineEdit import E5LineEdit, E5ClearableLineEdit
 
@@ -75,9 +75,13 @@
         
         @param evt reference to the wheel event (QWheelEvent)
         """
-        if evt.angleDelta().y() > 0:
+        if qVersion() >= "5.0.0":
+            delta = evt.angleDelta().y()
+        else:
+            delta = evt.delta()
+        if delta > 0:
             self.__getHistory(True)
-        elif evt.angleDelta().y() < 0:
+        elif delta < 0:
             self.__getHistory(False)
         
         super(IrcMessageEdit, self).wheelEvent(evt)
--- a/QScintilla/Editor.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/QScintilla/Editor.py	Sat Sep 13 16:13:52 2014 +0200
@@ -18,7 +18,7 @@
 import difflib
 
 from PyQt5.QtCore import QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, \
-    pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt
+    pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt, qVersion
 from PyQt5.QtGui import QCursor, QPalette, QFont, QPixmap, QPainter
 from PyQt5.QtWidgets import QLineEdit, QActionGroup, QDialog, QInputDialog, \
     QApplication, QMenu
@@ -6179,8 +6179,12 @@
         
         @param evt reference to the wheel event (QWheelEvent)
         """
+        if qVersion() >= "5.0.0":
+            delta = evt.angleDelta().y()
+        else:
+            delta = evt.delta()
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if delta < 0:
                 self.zoomOut()
             else:
                 self.zoomIn()
@@ -6188,7 +6192,7 @@
             return
         
         if evt.modifiers() & Qt.ShiftModifier:
-            if evt.angleDelta().y() < 0:
+            if delta < 0:
                 self.gotoMethodClass(False)
             else:
                 self.gotoMethodClass(True)
--- a/QScintilla/Shell.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/QScintilla/Shell.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,7 +12,7 @@
 import sys
 import re
 
-from PyQt5.QtCore import pyqtSignal, QFileInfo, Qt, QEvent
+from PyQt5.QtCore import pyqtSignal, QFileInfo, Qt, QEvent,  qVersion
 from PyQt5.QtGui import QClipboard, QPalette, QFont
 from PyQt5.QtWidgets import QDialog, QInputDialog, QApplication, QMenu, \
     QWidget, QHBoxLayout, QVBoxLayout, QShortcut
@@ -857,7 +857,11 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if evt.angleDelta().y() < 0:
+            if qVersion() >= "5.0.0":
+                delta = evt.angleDelta().y()
+            else:
+                delta = evt.delta()
+            if delta < 0:
                 self.zoomOut()
             else:
                 self.zoomIn()
--- a/Snapshot/SnapWidget.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Snapshot/SnapWidget.py	Sat Sep 13 16:13:52 2014 +0200
@@ -16,7 +16,7 @@
 import os
 
 from PyQt5.QtCore import pyqtSlot, QFile, QFileInfo, QTimer, QPoint, \
-    QMimeData, Qt, QEvent, QRegExp, qVersion, QStandardPaths
+    QMimeData, Qt, QEvent, QRegExp, qVersion, PYQT_VERSION_STR
 from PyQt5.QtGui import QImageWriter, QPixmap, QCursor, QDrag, QKeySequence
 from PyQt5.QtWidgets import QWidget, QApplication, QShortcut
 
@@ -75,12 +75,18 @@
             Preferences.Prefs.settings.value("Snapshot/Delay", 0))
         self.delaySpin.setValue(self.__delay)
         
+        if PYQT_VERSION_STR >= "5.0.0":
+            from PyQt5.QtCore import QStandardPaths
+            picturesLocation = QStandardPaths.writableLocation(
+                QStandardPaths.PicturesLocation)
+        else:
+            from PyQt5.QtGui import QDesktopServices
+            picturesLocation = QDesktopServices.storageLocation(
+                QDesktopServices.PicturesLocation)
         self.__filename = Preferences.Prefs.settings.value(
             "Snapshot/Filename",
-            os.path.join(
-                QStandardPaths.writableLocation(
-                    QStandardPaths.PicturesLocation),
-                self.tr("snapshot") + "1.png"))
+            os.path.join(picturesLocation,
+                         self.tr("snapshot") + "1.png"))
         
         self.__grabber = None
         self.__snapshot = QPixmap()
--- a/Tools/UIPreviewer.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/Tools/UIPreviewer.py	Sat Sep 13 16:13:52 2014 +0200
@@ -78,7 +78,7 @@
         self.styleCombo.setEditable(False)
         self.styleCombo.setToolTip(self.tr("Select the GUI Theme"))
         self.styleLayout.addWidget(self.styleCombo)
-        self.styleCombo.addItems(list(QStyleFactory().keys()))
+        self.styleCombo.addItems(sorted(QStyleFactory().keys()))
         currentStyle = Preferences.Prefs.settings.value('UIPreviewer/style')
         if currentStyle is not None:
             self.styleCombo.setCurrentIndex(int(currentStyle))
--- a/compileUiFiles.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/compileUiFiles.py	Sat Sep 13 16:13:52 2014 +0200
@@ -19,10 +19,25 @@
     """
     Compile the .ui files to Python sources.
     """                                                 # __IGNORE_WARNING__
+    # step 1: determine PyQt variant, preferring PyQt5
     try:
-        from PyQt5.uic import compileUiDir
+        import PyQt5        # __IGNORE_WARNING__
+        pyqtVariant = "PyQt5"
     except ImportError:
-        from PyQt5.uic import compileUi
+        import PyQt4    # __IGNORE_WARNING__
+        pyqtVariant = "PyQt4"
+    
+    # step 2: compile the UI files
+    try:
+        if pyqtVariant == "PyQt4":
+            from PyQt4.uic import compileUiDir
+        else:
+            from PyQt5.uic import compileUiDir
+    except ImportError:
+        if pyqtVariant == "PyQt4":
+            from PyQt4.uic import compileUi
+        else:
+            from PyQt5.uic import compileUi
         
         def compileUiDir(dir, recurse=False,            # __IGNORE_WARNING__
                          map=None, **compileUi_args):
--- a/eric6_api.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_api.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_compare.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_compare.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_configure.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_configure.py	Sat Sep 13 16:13:52 2014 +0200
@@ -11,6 +11,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_diff.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_diff.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_doc.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_doc.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_editor.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_editor.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_iconeditor.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_iconeditor.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_plugininstall.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_plugininstall.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,6 +12,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_pluginrepository.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_pluginrepository.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,6 +12,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_pluginuninstall.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_pluginuninstall.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,6 +12,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_qregexp.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_qregexp.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_qregularexpression.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_qregularexpression.py	Sat Sep 13 16:13:52 2014 +0200
@@ -14,6 +14,8 @@
 
 from __future__ import unicode_literals
 
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_re.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_re.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_snap.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_snap.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,6 +12,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_sqlbrowser.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_sqlbrowser.py	Sat Sep 13 16:13:52 2014 +0200
@@ -12,6 +12,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_tray.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_tray.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_trpreviewer.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_trpreviewer.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_uipreviewer.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_uipreviewer.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_unittest.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_unittest.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/eric6_webbrowser.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/eric6_webbrowser.py	Sat Sep 13 16:13:52 2014 +0200
@@ -13,6 +13,9 @@
 """
 
 from __future__ import unicode_literals
+
+import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
+
 try:  # Only for Py2
     import Utilities.compatibility_fixes     # __IGNORE_WARNING__
 except (ImportError):
--- a/install.py	Mon Sep 08 20:13:54 2014 +0200
+++ b/install.py	Sat Sep 13 16:13:52 2014 +0200
@@ -48,28 +48,33 @@
 macAppBundlePath = "/Applications"
 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
     sys.exec_prefix)
+pyqtVariant = ""
 
 # Define blacklisted versions of the prerequisites
 BlackLists = {
     "sip": ["4.11", "4.12.3"],
+    "PyQt4": [],
     "PyQt5": [],
     "QScintilla2": [],
 }
 PlatformsBlackLists = {
     "windows": {
         "sip": [],
+        "PyQt4": [],
         "PyQt5": [],
         "QScintilla2": [],
     },
     
     "linux": {
         "sip": [],
+        "PyQt4": [],
         "PyQt5": [],
         "QScintilla2": [],
     },
     
     "mac": {
         "sip": [],
+        "PyQt4": [],
         "PyQt5": [],
         "QScintilla2": [],
     },
@@ -166,12 +171,29 @@
     exit(rcode)
 
 
+def determinePyQtVariant():
+    """
+    Module function to determine the PyQt variant to be used.
+    """
+    global pyqtVariant
+    
+    try:
+        import PyQt5        # __IGNORE_WARNING__
+        pyqtVariant = "PyQt5"
+    except ImportError:
+        try:
+            import PyQt4    # __IGNORE_WARNING__
+            pyqtVariant = "PyQt4"
+        except ImportError:
+            pyqtVariant = ""
+
+
 def initGlobals():
     """
     Module function to set the values of globals that need more than a
     simple assignment.
     """
-    global platBinDir, modDir, pyModDir, apisDir
+    global platBinDir, modDir, pyModDir, apisDir, pyqtVariant
 
     if sys.platform.startswith("win"):
         platBinDir = sys.exec_prefix
@@ -183,13 +205,16 @@
     modDir = distutils.sysconfig.get_python_lib(True)
     pyModDir = modDir
     
-    pyqtDataDir = os.path.join(modDir, "PyQt5")
+    pyqtDataDir = os.path.join(modDir, pyqtVariant)
     if os.path.exists(os.path.join(pyqtDataDir, "qsci")):
         # it's the installer
         qtDataDir = pyqtDataDir
     else:
         try:
-            from PyQt5.QtCore import QLibraryInfo
+            if pyqtVariant == "PyQt4":
+                from PyQt4.QtCore import QLibraryInfo
+            else:
+                from PyQt5.QtCore import QLibraryInfo
             qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath)
         except ImportError:
             qtDataDir = None
@@ -930,30 +955,48 @@
         print('Please install it and try again.')
         exit(5)
     
-    try:
-        from PyQt5.QtCore import qVersion
-    except ImportError as msg:
-        print('Sorry, please install PyQt5.')
-        print('Error: {0}'.format(msg))
-        exit(1)
-    print("Found PyQt5")
+    if pyqtVariant == "PyQt4":
+        try:
+            from PyQt4.QtCore import qVersion
+        except ImportError as msg:
+            print('Sorry, please install PyQt5 or PyQt4.')
+            print('Error: {0}'.format(msg))
+            exit(1)
+        print("Found PyQt4")
+    else:
+        try:
+            from PyQt5.QtCore import qVersion
+        except ImportError as msg:
+            print('Sorry, please install PyQt5 or PyQt4.')
+            print('Error: {0}'.format(msg))
+            exit(1)
+        print("Found PyQt5")
     
     try:
-        from PyQt5 import Qsci      # __IGNORE_WARNING__
-
+        if pyqtVariant == "PyQt4":
+            from PyQt4 import Qsci      # __IGNORE_WARNING__
+        else:
+            from PyQt5 import Qsci      # __IGNORE_WARNING__
     except ImportError as msg:
         print("Sorry, please install QScintilla2 and")
-        print("its PyQt5 wrapper.")
+        print("its PyQt5/PyQt4 wrapper.")
         print('Error: {0}'.format(msg))
         exit(1)
     print("Found QScintilla2")
     
+    if pyqtVariant == "PyQt4":
+        impModulesList = [
+            "PyQt4.QtGui", "PyQt4.QtNetwork", "PyQt4.QtSql",
+            "PyQt4.QtSvg", "PyQt4.QtWebKit",
+        ]
+    else:
+        impModulesList = [
+            "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtPrintSupport",
+            "PyQt5.QtSql", "PyQt5.QtSvg", "PyQt5.QtWebKit",
+            "PyQt5.QtWebKitWidgets", "PyQt5.QtWidgets",
+        ]
     modulesOK = True
-    for impModule in [
-        "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtPrintSupport",
-        "PyQt5.QtSql", "PyQt5.QtSvg", "PyQt5.QtWebKit",
-        "PyQt5.QtWebKitWidgets", "PyQt5.QtWidgets",
-    ]:
+    for impModule in impModulesList:
         name = impModule.split(".")[1]
         try:
             __import__(impModule)
@@ -976,8 +1019,11 @@
     # check version of Qt
     qtMajor = int(qVersion().split('.')[0])
     qtMinor = int(qVersion().split('.')[1])
-    if qtMajor < 5 or (qtMajor == 3 and qtMinor < 6):
-        print('Sorry, you must have Qt version 5.3.0 or higher.')
+    if qtMajor < 4 or \
+        (qtMajor == 4 and qtMinor < 8) or \
+            (qtMajor == 5 and qtMinor < 3):
+        print('Sorry, you must have Qt version 4.8.0 or better or')
+        print('5.3.0 or better.')
         exit(2)
     print("Qt Version: {0}".format(qVersion()))
     
@@ -1010,7 +1056,10 @@
         pass
     
     # check version of PyQt
-    from PyQt5.QtCore import PYQT_VERSION_STR
+    if pyqtVariant == "PyQt4":
+        from PyQt4.QtCore import PYQT_VERSION_STR
+    else:
+        from PyQt5.QtCore import PYQT_VERSION_STR
     pyqtVersion = PYQT_VERSION_STR
     # always assume, that snapshots are new enough
     if "snapshot" not in pyqtVersion:
@@ -1020,21 +1069,27 @@
         maj = int(maj)
         min = int(min)
         pat = int(pat)
-        if maj < 5 or (maj == 5 and min < 3):
-            print('Sorry, you must have PyQt 5.3.0 or higher or'
+        if maj < 4 or \
+            (maj == 4 and min < 10) or \
+                (maj == 5 and min < 3):
+            print('Sorry, you must have PyQt 4.10.0 or better or')
+            print('PyQt 5.3.0 or better or'
                   ' a recent snapshot release.')
             exit(4)
         # check for blacklisted versions
-        for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]:
+        for vers in BlackLists[pyqtVariant] + PlatformBlackLists[pyqtVariant]:
             if vers == pyqtVersion:
-                print('Sorry, PyQt5 version {0} is not compatible with eric6.'
+                print('Sorry, PyQt version {0} is not compatible with eric6.'
                       .format(vers))
                 print('Please install another version.')
                 exit(4)
     print("PyQt Version: ", pyqtVersion)
     
     # check version of QScintilla
-    from PyQt5.Qsci import QSCINTILLA_VERSION_STR
+    if pyqtVariant == "PyQt4":
+        from PyQt4.Qsci import QSCINTILLA_VERSION_STR
+    else:
+        from PyQt5.Qsci import QSCINTILLA_VERSION_STR
     scintillaVersion = QSCINTILLA_VERSION_STR
     # always assume, that snapshots are new enough
     if "snapshot" not in scintillaVersion:
@@ -1062,15 +1117,22 @@
     print()
 
 
+# TODO: PyQt4
 def compileUiFiles():
     """
     Compile the .ui files to Python sources.
     """                                                 # __IGNORE_WARNING__
     global sourceDir
     try:
-        from PyQt5.uic import compileUiDir
+        if pyqtVariant == "PyQt4":
+            from PyQt4.uic import compileUiDir
+        else:
+            from PyQt5.uic import compileUiDir
     except ImportError:
-        from PyQt5.uic import compileUi
+        if pyqtVariant == "PyQt4":
+            from PyQt4.uic import compileUi
+        else:
+            from PyQt5.uic import compileUi
         
         def compileUiDir(dir, recurse=False,            # __IGNORE_WARNING__
                          map=None, **compileUi_args):
@@ -1175,7 +1237,8 @@
     
     if os.path.dirname(argv[0]):
         os.chdir(os.path.dirname(argv[0]))
-
+    
+    determinePyQtVariant()
     initGlobals()
 
     try:

eric ide

mercurial