Merge pull request #1587 from irgolic/darkmode-example-property
app.dark_mode => app.property('darkMode')
This commit is contained in:
commit
d0d10ca512
@ -189,7 +189,7 @@ class PythonHighlighter(QSyntaxHighlighter):
|
|||||||
@property
|
@property
|
||||||
def styles(self):
|
def styles(self):
|
||||||
app = QtGui.QApplication.instance()
|
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):
|
def highlightBlock(self, text):
|
||||||
"""Apply syntax highlighting to the given block of text.
|
"""Apply syntax highlighting to the given block of text.
|
||||||
@ -310,7 +310,7 @@ class ExampleLoader(QtGui.QMainWindow):
|
|||||||
self.ui.codeView.setCurrentCharFormat(f)
|
self.ui.codeView.setCurrentCharFormat(f)
|
||||||
# finally, override application automatic detection
|
# finally, override application automatic detection
|
||||||
app = QtGui.QApplication.instance()
|
app = QtGui.QApplication.instance()
|
||||||
app.dark_mode = True
|
app.setProperty('darkMode', True)
|
||||||
|
|
||||||
def updateTheme(self):
|
def updateTheme(self):
|
||||||
self.hl = PythonHighlighter(self.ui.codeView.document())
|
self.hl = PythonHighlighter(self.ui.codeView.document())
|
||||||
|
@ -186,7 +186,7 @@ class PythonHighlighter(QSyntaxHighlighter):
|
|||||||
@property
|
@property
|
||||||
def styles(self):
|
def styles(self):
|
||||||
app = QtGui.QApplication.instance()
|
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):
|
def highlightBlock(self, text):
|
||||||
"""Apply syntax highlighting to the given block of text.
|
"""Apply syntax highlighting to the given block of text.
|
||||||
|
@ -468,19 +468,12 @@ class App(QtGui.QApplication):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(App, self).__init__(*args, **kwargs)
|
super(App, self).__init__(*args, **kwargs)
|
||||||
if QT_LIB in ['PyQt5', 'PySide2', 'PySide6']:
|
self.paletteChanged.connect(self.onPaletteChange)
|
||||||
# qt4 does not have paletteChanged signal!
|
|
||||||
self.paletteChanged.connect(self.onPaletteChange)
|
|
||||||
self.onPaletteChange(self.palette())
|
self.onPaletteChange(self.palette())
|
||||||
|
|
||||||
def onPaletteChange(self, palette):
|
def onPaletteChange(self, palette):
|
||||||
if QT_LIB in ['PyQt4', 'PySide']:
|
color = palette.base().color().name()
|
||||||
# Qt4 this is a QString
|
self.setProperty('darkMode', color.lower() != "#ffffff")
|
||||||
color = str(palette.base().color().name())
|
|
||||||
else:
|
|
||||||
# Qt5 has this as a str
|
|
||||||
color = palette.base().color().name()
|
|
||||||
self.dark_mode = color.lower() != "#ffffff"
|
|
||||||
|
|
||||||
QAPP = None
|
QAPP = None
|
||||||
def mkQApp(name=None):
|
def mkQApp(name=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user