Added dark tomorrow theme and separated gui theme from syntax

This commit is contained in:
Veronica K. B. Olsen
2019-06-15 15:24:29 +02:00
parent 4cb42339ce
commit 583e10adec
15 changed files with 239 additions and 91 deletions
+15 -2
View File
@@ -129,8 +129,19 @@ class GuiConfigEditGeneral(QWidget):
if themeIdx != -1:
self.guiLookTheme.setCurrentIndex(themeIdx)
self.guiLookForm.addWidget(QLabel("Theme"), 0, 0)
self.guiLookForm.addWidget(self.guiLookTheme, 0, 1)
self.guiLookSyntax = QComboBox()
self.guiLookSyntax.setMinimumWidth(200)
self.theSyntaxes = self.theParent.theTheme.listSyntax()
for syntaxFile, syntaxName in self.theSyntaxes:
self.guiLookSyntax.addItem(syntaxName, syntaxFile)
syntaxIdx = self.guiLookSyntax.findData(self.mainConf.guiSyntax)
if syntaxIdx != -1:
self.guiLookSyntax.setCurrentIndex(syntaxIdx)
self.guiLookForm.addWidget(QLabel("Theme"), 0, 0)
self.guiLookForm.addWidget(self.guiLookTheme, 0, 1)
self.guiLookForm.addWidget(QLabel("Syntax"), 1, 0)
self.guiLookForm.addWidget(self.guiLookSyntax, 1, 1)
# Spell Checking
self.spellLang = QGroupBox("Spell Checker", self)
@@ -188,6 +199,7 @@ class GuiConfigEditGeneral(QWidget):
needsRestart = False
guiTheme = self.guiLookTheme.currentData()
guiSyntax = self.guiLookSyntax.currentData()
spellLanguage = self.spellLangList.currentData()
autoSaveDoc = self.autoSaveDoc.value()
autoSaveProj = self.autoSaveProj.value()
@@ -196,6 +208,7 @@ class GuiConfigEditGeneral(QWidget):
needsRestart |= self.mainConf.guiTheme != guiTheme
self.mainConf.guiTheme = guiTheme
self.mainConf.guiSyntax = guiSyntax
self.mainConf.spellLanguage = spellLanguage
self.mainConf.autoSaveDoc = autoSaveDoc
self.mainConf.autoSaveProj = autoSaveProj
+6 -8
View File
@@ -134,7 +134,6 @@ class GuiDocEditor(QTextEdit):
# Set text fixed width, or alternatively, just margins
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
self.changeWidth()
# Also set the document text options for the document text flow
theOpt = QTextOption()
@@ -147,10 +146,13 @@ class GuiDocEditor(QTextEdit):
# 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.hLight.initHighlighter()
self.clearEditor()
self.loadText(tHandle)
self.hLight.initHighlighter()
self.hLight.rehighlight()
self.changeWidth()
return True
def loadText(self, tHandle):
@@ -220,18 +222,14 @@ class GuiDocEditor(QTextEdit):
def setSpellCheck(self, theMode):
self.spellCheck = theMode
self.hLight.setSpellCheck(theMode)
self.rehighlightDocument()
self.hLight.rehighlight()
return True
def updateSpellCheck(self):
if self.spellCheck:
self.rehighlightDocument()
self.hLight.rehighlight()
return True
def rehighlightDocument(self):
self.hLight.rehighlight()
return
##
# General Class Methods
##
+28 -12
View File
@@ -36,18 +36,18 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.hRules = []
self.hStyles = {}
self.colHead = QColor(*self.theTheme.colHead)
self.colHeadH = QColor(*self.theTheme.colHeadH)
self.colEmph = QColor(*self.theTheme.colEmph)
self.colDialN = QColor(*self.theTheme.colDialN)
self.colDialD = QColor(*self.theTheme.colDialD)
self.colDialS = QColor(*self.theTheme.colDialS)
self.colComm = QColor(*self.theTheme.colComm)
self.colKey = QColor(*self.theTheme.colKey)
self.colVal = QColor(*self.theTheme.colVal)
self.colSpell = QColor(*self.theTheme.colSpell)
self.colTagErr = QColor(*self.theTheme.colTagErr)
self.colRepTag = QColor(*self.theTheme.colRepTag)
self.colHead = QColor(0,0,0)
self.colHeadH = QColor(0,0,0)
self.colEmph = QColor(0,0,0)
self.colDialN = QColor(0,0,0)
self.colDialD = QColor(0,0,0)
self.colDialS = QColor(0,0,0)
self.colComm = QColor(0,0,0)
self.colKey = QColor(0,0,0)
self.colVal = QColor(0,0,0)
self.colSpell = QColor(0,0,0)
self.colTagErr = QColor(0,0,0)
self.colRepTag = QColor(0,0,0)
self.initHighlighter()
@@ -57,6 +57,21 @@ class GuiDocHighlighter(QSyntaxHighlighter):
def initHighlighter(self):
logger.debug("Setting up highlighting rules")
self.colHead = QColor(*self.theTheme.colHead)
self.colHeadH = QColor(*self.theTheme.colHeadH)
self.colEmph = QColor(*self.theTheme.colEmph)
self.colDialN = QColor(*self.theTheme.colDialN)
self.colDialD = QColor(*self.theTheme.colDialD)
self.colDialS = QColor(*self.theTheme.colDialS)
self.colComm = QColor(*self.theTheme.colComm)
self.colKey = QColor(*self.theTheme.colKey)
self.colVal = QColor(*self.theTheme.colVal)
self.colSpell = QColor(*self.theTheme.colSpell)
self.colTagErr = QColor(*self.theTheme.colTagErr)
self.colRepTag = QColor(*self.theTheme.colRepTag)
self.hStyles = {
"header1" : self._makeFormat(self.colHead, "bold",1.8),
"header2" : self._makeFormat(self.colHead, "bold",1.6),
@@ -80,6 +95,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
}
# Headers
self.hRules = []
self.hRules.append((
r"^(#{1}) (.*)[^\n]", {
0 : self.hStyles["header1"],
+1 -1
View File
@@ -360,7 +360,7 @@ class GuiDocTree(QTreeWidget):
newItem.setText(self.C_FLAGS, "")
newItem.setText(self.C_HANDLE, tHandle)
newItem.setForeground(self.C_COUNT,QColor(0,105,135))
newItem.setForeground(self.C_COUNT,QColor(*self.theParent.theTheme.treeWCount))
newItem.setTextAlignment(self.C_COUNT,Qt.AlignRight)
newItem.setFont(self.C_FLAGS,self.fontFlags)
+7 -5
View File
@@ -27,15 +27,17 @@ class GuiMainStatus(QStatusBar):
logger.debug("Initialising GuiMainStatus ...")
self.mainConf = nw.CONFIG
self.refTime = None
self.mainConf = nw.CONFIG
self.theParent = theParent
self.refTime = None
self.iconGrey = QPixmap(16,16)
self.iconGrey.fill(QColor(120,120,120))
self.iconYellow = QPixmap(16,16)
self.iconYellow.fill(QColor(120,120, 40))
self.iconGreen = QPixmap(16,16)
self.iconGreen.fill(QColor( 40,120, 0))
self.iconGrey.fill(QColor(*self.theParent.theTheme.statNone))
self.iconYellow.fill(QColor(*self.theParent.theTheme.statUnsaved))
self.iconGreen.fill(QColor(*self.theParent.theTheme.statSaved))
self.boxStats = QLabel()
self.boxStats.setToolTip("Project Word Count | Session Word Count")
+2 -1
View File
@@ -58,7 +58,7 @@ class GuiMain(QMainWindow):
self.resize(*self.mainConf.winGeometry)
self._setWindowTitle()
self.setWindowIcon(QIcon(path.join(self.mainConf.appRoot, nwFiles.APP_ICON)))
self.theTheme.loadTheme()
self.theTheme.updateTheme()
# Main GUI Elements
self.statusBar = GuiMainStatus(self)
@@ -467,6 +467,7 @@ class GuiMain(QMainWindow):
if dlgConf.exec_() == QDialog.Accepted:
logger.debug("Applying new preferences")
self.initMain()
self.theTheme.updateTheme()
self.docEditor.initEditor()
self.docViewer.initViewer()
return True