From 94da52982d3d8e689aba62e6da44a575bec05117 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 8 Jun 2019 23:10:11 +0200 Subject: [PATCH] Obey justify option also in viewer --- nw/gui/docviewer.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 4f4aaa3d..65e20250 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -13,7 +13,9 @@ import logging import nw +from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QTextBrowser +from PyQt5.QtGui import QTextOption logger = logging.getLogger(__name__) @@ -29,17 +31,22 @@ class GuiDocViewer(QTextBrowser): self.theParent = theParent self.theTheme = theParent.theTheme - self.theDoc = self.document() - self.theDoc.setDefaultStyleSheet(( + self.theQDoc = self.document() + self.theQDoc.setDefaultStyleSheet(( "h1, h2, h3, h4 {{" " color: rgb({0},{1},{2});" "}}" ).format( *self.theTheme.colHead )) - self.theDoc.setDocumentMargin(self.mainConf.textMargin[0]) + self.theQDoc.setDocumentMargin(self.mainConf.textMargin[0]) self.setMinimumWidth(300) + theOpt = QTextOption() + if self.mainConf.doJustify: + theOpt.setAlignment(Qt.AlignJustify) + self.theQDoc.setDefaultTextOption(theOpt) + logger.debug("DocViewer initialisation complete") return