From dbab60d064cc188c1de7a487e39d575b50925aae Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 25 Oct 2020 10:57:20 +0100 Subject: [PATCH] Properly update document colours when switching syntax theme --- nw/gui/doceditor.py | 11 ++++++++--- nw/gui/docviewer.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index a24a1f4e..79d84c1d 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -206,11 +206,16 @@ class GuiDocEditor(QTextEdit): theFont.setPointSize(self.mainConf.textSize) self.setFont(theFont) - docPalette = self.palette() - docPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) + mainPalette = self.palette() + mainPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) + mainPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack)) + mainPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) + self.setPalette(mainPalette) + + docPalette = self.viewport().palette() docPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack)) docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) - self.setPalette(docPalette) + self.viewport().setPalette(docPalette) # Set default text margins cM = self.mainConf.getTextMargin() diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 636c4637..8fcea123 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -112,11 +112,16 @@ class GuiDocViewer(QTextBrowser): theFont.setPointSize(self.mainConf.textSize) self.setFont(theFont) - docPalette = self.palette() - docPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) + mainPalette = self.palette() + mainPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack)) + mainPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack)) + mainPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) + self.setPalette(mainPalette) + + docPalette = self.viewport().palette() docPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack)) docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) - self.setPalette(docPalette) + self.viewport().setPalette(docPalette) self.qDocument.setDocumentMargin(0) theOpt = QTextOption()