From ae54e27ff66dc4d4e115104ce85b23d452d74c8d Mon Sep 17 00:00:00 2001 From: Rafael Irgolic Date: Thu, 18 Feb 2021 19:02:18 +0000 Subject: [PATCH 1/2] app.dark_mode => app.property('darkMode') --- examples/ExampleApp.py | 4 ++-- examples/syntax.py | 2 +- pyqtgraph/Qt.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ExampleApp.py b/examples/ExampleApp.py index 1175f264..458daf76 100644 --- a/examples/ExampleApp.py +++ b/examples/ExampleApp.py @@ -189,7 +189,7 @@ class PythonHighlighter(QSyntaxHighlighter): @property def styles(self): app = QtGui.QApplication.instance() - return DARK_STYLES if app.dark_mode else LIGHT_STYLES + return DARK_STYLES if app.property('darkMode') else LIGHT_STYLES def highlightBlock(self, text): """Apply syntax highlighting to the given block of text. @@ -310,7 +310,7 @@ class ExampleLoader(QtGui.QMainWindow): self.ui.codeView.setCurrentCharFormat(f) # finally, override application automatic detection app = QtGui.QApplication.instance() - app.dark_mode = True + app.setProperty('darkMode', True) def updateTheme(self): self.hl = PythonHighlighter(self.ui.codeView.document()) diff --git a/examples/syntax.py b/examples/syntax.py index 1079c128..2c547867 100644 --- a/examples/syntax.py +++ b/examples/syntax.py @@ -186,7 +186,7 @@ class PythonHighlighter(QSyntaxHighlighter): @property def styles(self): app = QtGui.QApplication.instance() - return DARK_STYLES if app.dark_mode else LIGHT_STYLES + return DARK_STYLES if app.property('darkMode') else LIGHT_STYLES def highlightBlock(self, text): """Apply syntax highlighting to the given block of text. diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 91c4d1b0..492604a1 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -480,7 +480,7 @@ class App(QtGui.QApplication): else: # Qt5 has this as a str color = palette.base().color().name() - self.dark_mode = color.lower() != "#ffffff" + self.setProperty('darkMode', color.lower() != "#ffffff") QAPP = None def mkQApp(name=None): From 6da60ccec8f8e2a095704e5068a6e4d3ac048def Mon Sep 17 00:00:00 2001 From: Rafael Irgolic Date: Thu, 18 Feb 2021 19:12:24 +0000 Subject: [PATCH 2/2] Qt: Remove some Qt4 shims --- pyqtgraph/Qt.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 492604a1..22971dba 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -468,18 +468,11 @@ class App(QtGui.QApplication): def __init__(self, *args, **kwargs): super(App, self).__init__(*args, **kwargs) - if QT_LIB in ['PyQt5', 'PySide2', 'PySide6']: - # qt4 does not have paletteChanged signal! - self.paletteChanged.connect(self.onPaletteChange) + self.paletteChanged.connect(self.onPaletteChange) self.onPaletteChange(self.palette()) def onPaletteChange(self, palette): - if QT_LIB in ['PyQt4', 'PySide']: - # Qt4 this is a QString - color = str(palette.base().color().name()) - else: - # Qt5 has this as a str - color = palette.base().color().name() + color = palette.base().color().name() self.setProperty('darkMode', color.lower() != "#ffffff") QAPP = None