Fixed remaining issues with PyQt5 compatibility.
This commit is contained in:
parent
7c463a136f
commit
5b106d2231
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
.idea/
|
.idea/
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -1232,8 +1232,14 @@ class CodeEdit(QtWidgets.QPlainTextEdit):
|
||||||
self._foreground = QtGui.QColor('black')
|
self._foreground = QtGui.QColor('black')
|
||||||
self._whitespaces_foreground = QtGui.QColor('light gray')
|
self._whitespaces_foreground = QtGui.QColor('light gray')
|
||||||
app = QtWidgets.QApplication.instance()
|
app = QtWidgets.QApplication.instance()
|
||||||
|
# Qt5 compatibility
|
||||||
|
try:
|
||||||
self._sel_background = app.palette().highlight().color()
|
self._sel_background = app.palette().highlight().color()
|
||||||
self._sel_foreground = app.palette().highlightedText().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_size = 10
|
||||||
self.font_name = ""
|
self.font_name = ""
|
||||||
|
|
||||||
|
@ -1269,7 +1275,13 @@ class CodeEdit(QtWidgets.QPlainTextEdit):
|
||||||
self.setFont(QtGui.QFont(self._font_family,
|
self.setFont(QtGui.QFont(self._font_family,
|
||||||
self._font_size + self._zoom_level))
|
self._font_size + self._zoom_level))
|
||||||
flg_stylesheet = hasattr(self, '_flg_stylesheet')
|
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
|
self._flg_stylesheet = True
|
||||||
# On Window, if the application once had a stylesheet, we must
|
# On Window, if the application once had a stylesheet, we must
|
||||||
# keep on using a stylesheet otherwise strange colors appear
|
# keep on using a stylesheet otherwise strange colors appear
|
||||||
|
|
|
@ -84,8 +84,18 @@ class Panel(QtWidgets.QWidget, Mode):
|
||||||
"""
|
"""
|
||||||
Mode.on_install(self, editor)
|
Mode.on_install(self, editor)
|
||||||
self.setParent(editor)
|
self.setParent(editor)
|
||||||
|
# Qt5 compatibility
|
||||||
|
try:
|
||||||
self.setPalette(QtWidgets.QApplication.instance().palette())
|
self.setPalette(QtWidgets.QApplication.instance().palette())
|
||||||
|
except:
|
||||||
|
self.setPalette(QtGui.QGuiApplication.palette())
|
||||||
|
|
||||||
|
# Qt5 compatibility
|
||||||
|
try:
|
||||||
self.setFont(QtWidgets.QApplication.instance().font())
|
self.setFont(QtWidgets.QApplication.instance().font())
|
||||||
|
except:
|
||||||
|
self.setFont(QtGui.QGuiApplication.font())
|
||||||
|
|
||||||
self.editor.panels.refresh()
|
self.editor.panels.refresh()
|
||||||
self._background_brush = QtGui.QBrush(QtGui.QColor(
|
self._background_brush = QtGui.QBrush(QtGui.QColor(
|
||||||
self.palette().window().color()))
|
self.palette().window().color()))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user