From 9ffb5e6a16f4f88547d716520ea1ad77dd775e19 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 8 Dec 2020 17:33:34 +0100 Subject: [PATCH] Add grey syntax themes and fix automatic update when changing them --- nw/assets/themes/syntax/default_light.conf | 2 +- nw/assets/themes/syntax/grey_dark.conf | 25 ++++++++++++++++++++++ nw/assets/themes/syntax/grey_light.conf | 25 ++++++++++++++++++++++ nw/gui/doceditor.py | 7 +++--- nw/gui/docviewer.py | 3 ++- 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 nw/assets/themes/syntax/grey_dark.conf create mode 100644 nw/assets/themes/syntax/grey_light.conf diff --git a/nw/assets/themes/syntax/default_light.conf b/nw/assets/themes/syntax/default_light.conf index 389ba6cb..908fd7cb 100644 --- a/nw/assets/themes/syntax/default_light.conf +++ b/nw/assets/themes/syntax/default_light.conf @@ -10,7 +10,7 @@ licenseurl = https://creativecommons.org/licenses/by-sa/4.0/ background = 255, 255, 255 text = 0, 0, 0 link = 0, 0, 200 -headertext = 0, 100, 00 +headertext = 0, 100, 0 headertag = 50, 100, 50 emphasis = 150, 110, 30 straightquotes = 200, 0, 0 diff --git a/nw/assets/themes/syntax/grey_dark.conf b/nw/assets/themes/syntax/grey_dark.conf new file mode 100644 index 00000000..a6bc0420 --- /dev/null +++ b/nw/assets/themes/syntax/grey_dark.conf @@ -0,0 +1,25 @@ +[Main] +name = Grey Dark +author = Veronica Berglyd Olsen +credit = Veronica Berglyd Olsen +url = https://github.com/vkbo/novelWriter +license = CC BY-SA 4.0 +licenseurl = https://creativecommons.org/licenses/by-sa/4.0/ + +[Syntax] +background = 54, 54, 54 +text = 200, 200, 200 +link = 200, 200, 200 +headertext = 225, 225, 225 +headertag = 225, 225, 225 +emphasis = 200, 200, 200 +straightquotes = 200, 200, 200 +doublequotes = 200, 200, 200 +singlequotes = 200, 200, 200 +hidden = 150, 150, 150 +keyword = 225, 225, 225 +value = 200, 200, 200 +spellcheckline = 200, 46, 0 +tagerror = 46, 200, 0 +replacetag = 225, 225, 225 +modifier = 225, 225, 225 diff --git a/nw/assets/themes/syntax/grey_light.conf b/nw/assets/themes/syntax/grey_light.conf new file mode 100644 index 00000000..a44593b4 --- /dev/null +++ b/nw/assets/themes/syntax/grey_light.conf @@ -0,0 +1,25 @@ +[Main] +name = Grey Light +author = Veronica Berglyd Olsen +credit = Veronica Berglyd Olsen +url = https://github.com/vkbo/novelWriter +license = CC BY-SA 4.0 +licenseurl = https://creativecommons.org/licenses/by-sa/4.0/ + +[Syntax] +background = 255, 255, 255 +text = 20, 20, 20 +link = 20, 20, 20 +headertext = 0, 0, 0 +headertag = 0, 0, 0 +emphasis = 20, 20, 20 +straightquotes = 20, 20, 20 +doublequotes = 20, 20, 20 +singlequotes = 20, 20, 20 +hidden = 100, 100, 100 +keyword = 0, 0, 0 +value = 20, 20, 20 +spellcheckline = 200, 0, 0 +tagerror = 0, 150, 0 +replacetag = 0, 0, 0 +modifier = 0, 0, 0 diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index d76623ce..48e44fbf 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -262,10 +262,10 @@ class GuiDocEditor(QTextEdit): # If we have a document open, we should reload it in case the # font changed, otherwise we just clear the editor entirely, # which makes it read only. - if self.theHandle is not None: - self.redrawText() - else: + if self.theHandle is None: self.clearEditor() + else: + self.redrawText() return True @@ -355,6 +355,7 @@ class GuiDocEditor(QTextEdit): """Redraw the text by marking the document content as "dirty". """ self.qDocument.markContentsDirty(0, self.qDocument.characterCount()) + self.updateDocMargins() return def replaceText(self, theText): diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index f3badad5..fab3b5ef 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -149,7 +149,7 @@ class GuiDocViewer(QTextBrowser): # If we have a document open, we should reload it in case the font changed if self.theHandle is not None: - self.redrawText() + self.reloadText() return True @@ -233,6 +233,7 @@ class GuiDocViewer(QTextBrowser): """Redraw the text by marking the document content as "dirty". """ self.qDocument.markContentsDirty(0, self.qDocument.characterCount()) + self.updateDocMargins() return def loadFromTag(self, theTag):