Fixed remaining issues with PyQt5 compatibility.

This commit is contained in:
Cathy Wright 2018-04-26 12:03:33 -04:00
parent 7c463a136f
commit 5b106d2231
3 changed files with 28 additions and 5 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.pyc
.idea/
.DS_Store

View File

@ -1232,8 +1232,14 @@ class CodeEdit(QtWidgets.QPlainTextEdit):
self._foreground = QtGui.QColor('black')
self._whitespaces_foreground = QtGui.QColor('light gray')
app = QtWidgets.QApplication.instance()
self._sel_background = app.palette().highlight().color()
self._sel_foreground = app.palette().highlightedText().color()
# Qt5 compatibility
try:
self._sel_background = app.palette().highlight().color()
self._sel_foreground = app.palette().highlightedText().color()
except:
palette = QtGui.QGuiApplication.palette()
self._sel_background = palette.highlight().color()
self._sel_foreground = palette.highlightedText().color()
self._font_size = 10
self.font_name = ""
@ -1269,7 +1275,13 @@ class CodeEdit(QtWidgets.QPlainTextEdit):
self.setFont(QtGui.QFont(self._font_family,
self._font_size + self._zoom_level))
flg_stylesheet = hasattr(self, '_flg_stylesheet')
if QtWidgets.QApplication.instance().styleSheet() or flg_stylesheet:
# Qt5 compatibility
try:
curStylesheet = QtWidgets.QApplication.instance().styleSheet()
except:
curStylesheet = None
if curStylesheet or flg_stylesheet:
self._flg_stylesheet = True
# On Window, if the application once had a stylesheet, we must
# keep on using a stylesheet otherwise strange colors appear

View File

@ -84,8 +84,18 @@ class Panel(QtWidgets.QWidget, Mode):
"""
Mode.on_install(self, editor)
self.setParent(editor)
self.setPalette(QtWidgets.QApplication.instance().palette())
self.setFont(QtWidgets.QApplication.instance().font())
# Qt5 compatibility
try:
self.setPalette(QtWidgets.QApplication.instance().palette())
except:
self.setPalette(QtGui.QGuiApplication.palette())
# Qt5 compatibility
try:
self.setFont(QtWidgets.QApplication.instance().font())
except:
self.setFont(QtGui.QGuiApplication.font())
self.editor.panels.refresh()
self._background_brush = QtGui.QBrush(QtGui.QColor(
self.palette().window().color()))