A few GUI tweaks

This commit is contained in:
Veronica K. B. Olsen
2019-06-15 22:19:52 +02:00
parent 6a6c0418ea
commit 21b7e882ac
4 changed files with 15 additions and 11 deletions
+7 -7
View File
@@ -59,6 +59,7 @@ class GuiDocEditor(QTextEdit):
# Core Elements
self.qDocument = self.document()
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
self.qDocument.contentsChange.connect(self._docChange)
if self.mainConf.spellTool == "enchant":
from nw.tools.spellenchant import NWSpellEnchant
@@ -90,7 +91,6 @@ class GuiDocEditor(QTextEdit):
self.wCounter = WordCounter(self)
self.wCounter.finished.connect(self._updateCounts)
self.clearEditor()
self.initEditor()
logger.debug("DocEditor initialisation complete")
@@ -138,7 +138,7 @@ class GuiDocEditor(QTextEdit):
docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
self.setPalette(docPalette)
# Set text fixed width, or alternatively, just margins
# Set default text margins
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
# Also set the document text options for the document text flow
@@ -149,15 +149,14 @@ class GuiDocEditor(QTextEdit):
theOpt.setAlignment(Qt.AlignJustify)
self.qDocument.setDefaultTextOption(theOpt)
self.hLight.initHighlighter()
# If we have a document open, we should reload it in case the font changed
if self.theHandle is not None:
tHandle = self.theHandle
self.clearEditor()
self.loadText(tHandle)
self.hLight.initHighlighter()
self.hLight.rehighlight()
self.changeWidth()
self.changeWidth()
return True
@@ -363,7 +362,8 @@ class GuiDocEditor(QTextEdit):
def _docChange(self, thePos, charsRemoved, charsAdded):
self.lastEdit = time()
self.setDocumentChanged(True)
if not self.docChanged:
self.setDocumentChanged(True)
if not self.wcTimer.isActive():
self.wcTimer.start()
if self.mainConf.doReplace and not self.hasSelection:
+2
View File
@@ -48,6 +48,7 @@ class GuiMain(QMainWindow):
def __init__(self):
QWidget.__init__(self)
logger.info("Starting %s" % nw.__package__)
logger.debug("Initialising GUI ...")
self.mainConf = nw.CONFIG
self.theTheme = Theme(self)
@@ -134,6 +135,7 @@ class GuiMain(QMainWindow):
self.initMain()
self.asProjTimer.start()
self.asDocTimer.start()
self.statusBar.clearStatus()
logger.debug("GUI initialisation complete")
+3 -1
View File
@@ -161,6 +161,8 @@ class Theme:
qApp.setStyleSheet(cssData)
qApp.setPalette(self.guiPalette)
logger.info("Loaded theme '%s'" % self.guiTheme)
return True
def loadSyntax(self):
@@ -199,7 +201,7 @@ class Theme:
self.colTagErr = self._loadColour(confParser,cnfSec,"tagerror")
self.colRepTag = self._loadColour(confParser,cnfSec,"replacetag")
logger.info("Loaded syntax colour theme '%s'" % self.guiSyntax)
logger.info("Loaded syntax theme '%s'" % self.guiSyntax)
return True