Intercept light/dark modes transitions on MacOS.

This commit is contained in:
Gabriel Linder 2020-03-08 10:34:54 +01:00
parent 412698c8bb
commit d0b92349dd
No known key found for this signature in database
GPG Key ID: 5FA837672AC41AE3

View File

@ -44,8 +44,9 @@ class ExampleLoader(QtGui.QMainWindow):
self.codeBtn = QtGui.QPushButton('Run Edited Code') self.codeBtn = QtGui.QPushButton('Run Edited Code')
self.codeLayout = QtGui.QGridLayout() self.codeLayout = QtGui.QGridLayout()
self.ui.codeView.setLayout(self.codeLayout) self.ui.codeView.setLayout(self.codeLayout)
#self.simulate_black_mode()
self.hl = PythonHighlighter(self.ui.codeView.document()) self.hl = PythonHighlighter(self.ui.codeView.document())
app = QtGui.QApplication.instance()
app.paletteChanged.connect(self.updateTheme)
self.codeLayout.addItem(QtGui.QSpacerItem(100,100,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding), 0, 0) self.codeLayout.addItem(QtGui.QSpacerItem(100,100,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding), 0, 0)
self.codeLayout.addWidget(self.codeBtn, 1, 1) self.codeLayout.addWidget(self.codeBtn, 1, 1)
self.codeBtn.hide() self.codeBtn.hide()
@ -83,6 +84,9 @@ class ExampleLoader(QtGui.QMainWindow):
app = QtGui.QApplication.instance() app = QtGui.QApplication.instance()
app.dark_mode = True app.dark_mode = True
def updateTheme(self):
self.hl = PythonHighlighter(self.ui.codeView.document())
def populateTree(self, root, examples): def populateTree(self, root, examples):
for key, val in examples.items(): for key, val in examples.items():
item = QtGui.QTreeWidgetItem([key]) item = QtGui.QTreeWidgetItem([key])