Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).

Mon, 01 Oct 2012 19:44:40 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 01 Oct 2012 19:44:40 +0200
changeset 2084
d3f083dd0222
parent 2083
3005ae4463aa
child 2085
b4c1f0b6dac2

Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).

E5Gui/E5Application.py file | annotate | diff | comparison | revisions
E5Gui/E5LineEdit.py file | annotate | diff | comparison | revisions
E5Gui/E5ToolBarManager.py file | annotate | diff | comparison | revisions
Helpviewer/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py file | annotate | diff | comparison | revisions
Helpviewer/History/HistoryManager.py file | annotate | diff | comparison | revisions
Helpviewer/UrlBar/UrlBar.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
QScintilla/MiniEditor.py file | annotate | diff | comparison | revisions
QScintilla/QsciScintillaCompat.py file | annotate | diff | comparison | revisions
QScintilla/Shell.py file | annotate | diff | comparison | revisions
QScintilla/Terminal.py file | annotate | diff | comparison | revisions
Utilities/__init__.py file | annotate | diff | comparison | revisions
eric5.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5Application.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/E5Gui/E5Application.py	Mon Oct 01 19:44:40 2012 +0200
@@ -112,19 +112,5 @@
             return self.__pluginObjectRegistry[name][1]
         else:
             raise KeyError('Pluginobject "{0}" is not registered.'.format(name))
-        
-    @staticmethod
-    def palette():
-        """
-        Static method to get compatibility between Qt4 QApplication and
-        Qt5 QGuiApplication.
-        
-        @return reference to the global palette (QPalette)
-        """
-        try:
-            from PyQt4.QtGui import QGuiApplication
-            return QGuiApplication.palette()
-        except ImportError:
-            return QApplication.palette()
 
 e5App = QCoreApplication.instance
--- a/E5Gui/E5LineEdit.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/E5Gui/E5LineEdit.py	Mon Oct 01 19:44:40 2012 +0200
@@ -8,12 +8,8 @@
 """
 
 from PyQt4.QtCore import pyqtSignal, Qt, QEvent, qVersion
-from PyQt4.QtGui import QLineEdit, QStyle, QPainter, QPalette, \
+from PyQt4.QtGui import QLineEdit, QStyle, QPainter, QPalette, QStyleOptionFrameV2, \
     QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy
-try:
-    from PyQt4.QtGui import QStyleOptionFrameV2
-except ImportError:
-    from PyQt4.QtGui import QStyleOptionFrame as QStyleOptionFrameV2  # __IGNORE_WARNING__
 
 
 class SideWidget(QWidget):
--- a/E5Gui/E5ToolBarManager.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/E5Gui/E5ToolBarManager.py	Mon Oct 01 19:44:40 2012 +0200
@@ -10,6 +10,8 @@
 from PyQt4.QtCore import QObject, QByteArray, QDataStream, QIODevice
 from PyQt4.QtGui import QToolBar
 
+import Utilities
+
 
 class E5ToolBarManager(QObject):
     """
@@ -510,11 +512,11 @@
         
         toolBarCount = stream.readUInt16()
         for i in range(toolBarCount):
-            objectName = stream.readString().decode()
+            objectName = Utilities.readStringFromStream(stream)
             actionCount = stream.readUInt16()
             actions = []
             for j in range(actionCount):
-                actionName = stream.readString().decode()
+                actionName = Utilities.readStringFromStream(stream)
                 if actionName:
                     action = self.__findAction(actionName)
                     if action is not None:
@@ -533,12 +535,12 @@
         
         toolBarCount = stream.readUInt16()
         for i in range(toolBarCount):
-            objectName = stream.readString().decode()
-            toolBarTitle = stream.readString().decode()
+            objectName = Utilities.readStringFromStream(stream)
+            toolBarTitle = Utilities.readStringFromStream(stream)
             actionCount = stream.readUInt16()
             actions = []
             for j in range(actionCount):
-                actionName = stream.readString().decode()
+                actionName = Utilities.readStringFromStream(stream)
                 if actionName:
                     action = self.__findAction(actionName)
                     if action is not None:
--- a/Helpviewer/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/Helpviewer/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py	Mon Oct 01 19:44:40 2012 +0200
@@ -9,11 +9,7 @@
 
 from PyQt4.QtCore import Qt, QSize, QRect
 from PyQt4.QtGui import QStyle, QStyledItemDelegate, QApplication, QFontMetrics, \
-    QPalette, QFont
-try:
-    from PyQt4.QtGui import QStyleOptionViewItemV4
-except ImportError:
-    from PyQt4.QtGui import QStyleOptionViewItem as QStyleOptionViewItemV4  # __IGNORE_WARNING__
+    QPalette, QFont, QStyleOptionViewItemV4
 
 import UI.PixmapCache
 import Globals
--- a/Helpviewer/History/HistoryManager.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/Helpviewer/History/HistoryManager.py	Mon Oct 01 19:44:40 2012 +0200
@@ -389,9 +389,9 @@
             if ver != HISTORY_VERSION:
                 continue
             itm = HistoryEntry()
-            itm.url = stream.readString().decode()
+            itm.url = Utilities.readStringFromStream(stream)
             stream >> itm.dateTime
-            itm.title = stream.readString().decode()
+            itm.title = Utilities.readStringFromStream(stream)
             
             if not itm.dateTime.isValid():
                 continue
--- a/Helpviewer/UrlBar/UrlBar.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/Helpviewer/UrlBar/UrlBar.py	Mon Oct 01 19:44:40 2012 +0200
@@ -8,7 +8,7 @@
 """
 
 from PyQt4.QtCore import pyqtSlot, Qt, QPointF, QUrl, QDateTime, qVersion
-from PyQt4.QtGui import QColor, QPalette, QLinearGradient, QIcon, QDialog
+from PyQt4.QtGui import QColor, QPalette, QLinearGradient, QIcon, QDialog, QApplication
 try:
     from PyQt4.QtNetwork import QSslCertificate     # __IGNORE_EXCEPTION__
 except ImportError:
@@ -17,7 +17,6 @@
 
 from E5Gui.E5LineEdit import E5LineEdit
 from E5Gui.E5LineEditButton import E5LineEditButton
-from E5Gui.E5Application import E5Application
 
 import Helpviewer.HelpWindow
 
@@ -278,8 +277,8 @@
             backgroundColor = QColor(220, 220, 220)     # light gray
             foregroundColor = Qt.black
         else:
-            backgroundColor = E5Application.palette().color(QPalette.Base)
-            foregroundColor = E5Application.palette().color(QPalette.Text)
+            backgroundColor = QApplication.palette().color(QPalette.Base)
+            foregroundColor = QApplication.palette().color(QPalette.Text)
         
         if self.__browser is not None:
             p = self.palette()
@@ -300,7 +299,7 @@
                             backgroundColor = Preferences.getHelp("SaveUrlColor")
                     else:
                         backgroundColor = Preferences.getHelp("SaveUrlColor")
-                highlight = E5Application.palette().color(QPalette.Highlight)
+                highlight = QApplication.palette().color(QPalette.Highlight)
                 r = (highlight.red() + 2 * backgroundColor.red()) // 3
                 g = (highlight.green() + 2 * backgroundColor.green()) // 3
                 b = (highlight.blue() + 2 * backgroundColor.blue()) // 3
--- a/Preferences/__init__.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/Preferences/__init__.py	Mon Oct 01 19:44:40 2012 +0200
@@ -22,13 +22,12 @@
 
 from PyQt4.QtCore import QDir, QPoint, QLocale, QSettings, QFileInfo, QCoreApplication, \
     QByteArray, QSize, QUrl, Qt, QLibraryInfo
-from PyQt4.QtGui import QColor, QFont, QInputDialog, QPalette
+from PyQt4.QtGui import QColor, QFont, QInputDialog, QPalette, QApplication
 from PyQt4.QtNetwork import QNetworkRequest
 from PyQt4.QtWebKit import QWebSettings
 from PyQt4.Qsci import QsciScintilla
 
 from E5Gui import E5FileDialog
-from E5Gui.E5Application import E5Application
 
 from E5Network.E5Ftp import E5FtpProxyType
 
@@ -453,9 +452,9 @@
         "WhitespaceForeground": QColor(Qt.darkGray),
         "WhitespaceBackground": QColor(Qt.white),
         "EditAreaForeground":
-            E5Application.palette().color(QPalette.Active, QPalette.Base),
+            QApplication.palette().color(QPalette.Active, QPalette.Base),
         "EditAreaBackground":
-            E5Application.palette().color(QPalette.Active, QPalette.Text),
+            QApplication.palette().color(QPalette.Active, QPalette.Text),
     }
     
     editorOtherFontsDefaults = {
--- a/QScintilla/Editor.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/QScintilla/Editor.py	Mon Oct 01 19:44:40 2012 +0200
@@ -16,7 +16,7 @@
     QDialog, QAbstractPrintDialog, QInputDialog, QApplication, QMenu, QPalette, QFont
 from PyQt4.Qsci import QsciScintilla, QsciMacro, QsciStyledText
 
-from E5Gui.E5Application import e5App, E5Application
+from E5Gui.E5Application import e5App
 from E5Gui import E5FileDialog, E5MessageBox
 
 from . import Exporters
@@ -3681,7 +3681,7 @@
                 Preferences.getEditorColour("SelectionBackground"))
         else:
             self.setSelectionBackgroundColor(
-                E5Application.palette().color(QPalette.Highlight))
+                QApplication.palette().color(QPalette.Highlight))
         if Preferences.getEditor("ColourizeSelText"):
             self.resetSelectionForegroundColor()
         elif Preferences.getEditor("CustomSelectionColours"):
@@ -3689,7 +3689,7 @@
                 Preferences.getEditorColour("SelectionForeground"))
         else:
             self.setSelectionForegroundColor(
-                E5Application.palette().color(QPalette.HighlightedText))
+                QApplication.palette().color(QPalette.HighlightedText))
         self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
         self.setCaretForegroundColor(
             Preferences.getEditorColour("CaretForeground"))
--- a/QScintilla/MiniEditor.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/QScintilla/MiniEditor.py	Mon Oct 01 19:44:40 2012 +0200
@@ -19,7 +19,6 @@
 
 from E5Gui.E5Action import E5Action, createActionGroup
 from E5Gui import E5MessageBox, E5FileDialog
-from E5Gui.E5Application import E5Application
 
 from . import Lexers
 from .QsciScintillaCompat import QsciScintillaCompat
@@ -2166,7 +2165,7 @@
                 Preferences.getEditorColour("SelectionBackground"))
         else:
             self.__textEdit.setSelectionBackgroundColor(
-                E5Application.palette().color(QPalette.Highlight))
+                QApplication.palette().color(QPalette.Highlight))
         if Preferences.getEditor("ColourizeSelText"):
             self.__textEdit.resetSelectionForegroundColor()
         elif Preferences.getEditor("CustomSelectionColours"):
@@ -2174,7 +2173,7 @@
                 Preferences.getEditorColour("SelectionForeground"))
         else:
             self.__textEdit.setSelectionForegroundColor(
-                E5Application.palette().color(QPalette.HighlightedText))
+                QApplication.palette().color(QPalette.HighlightedText))
         self.__textEdit.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
         self.__textEdit.setCaretForegroundColor(
             Preferences.getEditorColour("CaretForeground"))
--- a/QScintilla/QsciScintillaCompat.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/QScintilla/QsciScintillaCompat.py	Mon Oct 01 19:44:40 2012 +0200
@@ -8,13 +8,11 @@
 """
 
 from PyQt4.QtCore import Qt
-from PyQt4.QtGui import QPalette, QColor
+from PyQt4.QtGui import QPalette, QColor, QApplication
 from PyQt4.Qsci import QsciScintilla, \
     QSCINTILLA_VERSION as QsciQSCINTILLA_VERSION, QSCINTILLA_VERSION_STR, \
     QsciScintillaBase
 
-from E5Gui.E5Application import E5Application
-
 ###############################################################################
 
 
@@ -80,7 +78,7 @@
         """
         Public method to set the styles according the selected Qt style.
         """
-        palette = E5Application.palette()
+        palette = QApplication.palette()
         self.SendScintilla(QsciScintilla.SCI_STYLESETFORE,
             QsciScintilla.STYLE_DEFAULT, palette.color(QPalette.Text))
         self.SendScintilla(QsciScintilla.SCI_STYLESETBACK,
--- a/QScintilla/Shell.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/QScintilla/Shell.py	Mon Oct 01 19:44:40 2012 +0200
@@ -15,7 +15,7 @@
     QPalette, QFont, QWidget, QHBoxLayout, QVBoxLayout, QShortcut
 from PyQt4.Qsci import QsciScintilla
 
-from E5Gui.E5Application import e5App, E5Application
+from E5Gui.E5Application import e5App
 from E5Gui import E5MessageBox
 
 from . import Lexers
@@ -377,7 +377,7 @@
                 Preferences.getEditorColour("SelectionBackground"))
         else:
             self.setSelectionBackgroundColor(
-                E5Application.palette().color(QPalette.Highlight))
+                QApplication.palette().color(QPalette.Highlight))
         if Preferences.getEditor("ColourizeSelText"):
             self.resetSelectionForegroundColor()
         elif Preferences.getEditor("CustomSelectionColours"):
@@ -385,7 +385,7 @@
                 Preferences.getEditorColour("SelectionForeground"))
         else:
             self.setSelectionForegroundColor(
-                E5Application.palette().color(QPalette.HighlightedText))
+                QApplication.palette().color(QPalette.HighlightedText))
         self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
         self.setCaretForegroundColor(
             Preferences.getEditorColour("CaretForeground"))
--- a/QScintilla/Terminal.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/QScintilla/Terminal.py	Mon Oct 01 19:44:40 2012 +0200
@@ -17,7 +17,7 @@
     QWidget, QHBoxLayout, QShortcut
 from PyQt4.Qsci import QsciScintilla
 
-from E5Gui.E5Application import e5App, E5Application
+from E5Gui.E5Application import e5App
 
 from . import Lexers
 from .QsciScintillaCompat import QsciScintillaCompat
@@ -379,7 +379,7 @@
                 Preferences.getEditorColour("SelectionBackground"))
         else:
             self.setSelectionBackgroundColor(
-                E5Application.palette().color(QPalette.Highlight))
+                QApplication.palette().color(QPalette.Highlight))
         if Preferences.getEditor("ColourizeSelText"):
             self.resetSelectionForegroundColor()
         elif Preferences.getEditor("CustomSelectionColours"):
@@ -387,7 +387,7 @@
                 Preferences.getEditorColour("SelectionForeground"))
         else:
             self.setSelectionForegroundColor(
-                E5Application.palette().color(QPalette.HighlightedText))
+                QApplication.palette().color(QPalette.HighlightedText))
         self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
         self.setCaretForegroundColor(
             Preferences.getEditorColour("CaretForeground"))
--- a/Utilities/__init__.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/Utilities/__init__.py	Mon Oct 01 19:44:40 2012 +0200
@@ -373,6 +373,20 @@
     
     return str(buffer, encoding="utf-8", errors="ignore")
 
+
+def readStringFromStream(stream):
+    """
+    Module function to read a string from the given stream.
+    
+    @param stream data stream opened for reading (QDataStream)
+    @return string read from the stream (string)
+    """
+    data = stream.readString()
+    if data is None:
+        data = b""
+    return data.decode()
+
+
 _escape = re.compile("[&<>\"'\u0080-\uffff]")
 
 _escape_map = {
--- a/eric5.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/eric5.py	Mon Oct 01 19:44:40 2012 +0200
@@ -56,6 +56,7 @@
 from UI.Info import BugAddress
 from UI.SplashScreen import SplashScreen, NoneSplashScreen
 from E5Gui.E5SingleApplication import E5SingleApplicationClient
+##from E5Gui.E5Application import E5Application
 
 import Utilities
 from Utilities import Startup

eric ide

mercurial