Major reorganisation of themes, and added a few more syntax themes
This commit is contained in:
+13
-7
@@ -17,7 +17,7 @@ from time import time
|
|||||||
|
|
||||||
from PyQt5.QtCore import Qt, QTimer, QSizeF
|
from PyQt5.QtCore import Qt, QTimer, QSizeF
|
||||||
from PyQt5.QtWidgets import QTextEdit, QAction, QMenu, QShortcut
|
from PyQt5.QtWidgets import QTextEdit, QAction, QMenu, QShortcut
|
||||||
from PyQt5.QtGui import QTextCursor, QTextOption, QIcon, QKeySequence, QFont
|
from PyQt5.QtGui import QTextCursor, QTextOption, QIcon, QKeySequence, QFont, QColor, QPalette
|
||||||
|
|
||||||
from nw.project.document import NWDoc
|
from nw.project.document import NWDoc
|
||||||
from nw.gui.dochighlight import GuiDocHighlighter
|
from nw.gui.dochighlight import GuiDocHighlighter
|
||||||
@@ -37,8 +37,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
# Class Variables
|
# Class Variables
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theParent = theParent
|
|
||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
|
self.theParent = theParent
|
||||||
|
self.theTheme = theParent.theTheme
|
||||||
self.docChanged = False
|
self.docChanged = False
|
||||||
self.spellCheck = False
|
self.spellCheck = False
|
||||||
self.nwDocument = NWDoc(self.theProject, self.theParent)
|
self.nwDocument = NWDoc(self.theProject, self.theParent)
|
||||||
@@ -132,6 +133,11 @@ class GuiDocEditor(QTextEdit):
|
|||||||
theFont.setPointSize(self.mainConf.textSize)
|
theFont.setPointSize(self.mainConf.textSize)
|
||||||
self.setFont(theFont)
|
self.setFont(theFont)
|
||||||
|
|
||||||
|
docPalette = self.palette()
|
||||||
|
docPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack))
|
||||||
|
docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
|
||||||
|
self.setPalette(docPalette)
|
||||||
|
|
||||||
# Set text fixed width, or alternatively, just margins
|
# Set text fixed width, or alternatively, just margins
|
||||||
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
|
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
|
||||||
|
|
||||||
@@ -249,11 +255,11 @@ class GuiDocEditor(QTextEdit):
|
|||||||
tM = int((wW - sW - tW)/2)
|
tM = int((wW - sW - tW)/2)
|
||||||
if tM < 0:
|
if tM < 0:
|
||||||
tM = 0
|
tM = 0
|
||||||
# print(wW, tW, dW, sW, tM)
|
docFormat = self.qDocument.rootFrame().frameFormat()
|
||||||
self.setViewportMargins(tM,0,tM,0)
|
docFormat.setLeftMargin(tM)
|
||||||
self.qDocument.setTextWidth(tW)
|
docFormat.setRightMargin(tM)
|
||||||
else:
|
self.qDocument.rootFrame().setFrameFormat(docFormat)
|
||||||
self.setViewportMargins(0,0,0,0)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def docAction(self, theAction):
|
def docAction(self, theAction):
|
||||||
|
|||||||
+1
-1
@@ -360,7 +360,7 @@ class GuiDocTree(QTreeWidget):
|
|||||||
newItem.setText(self.C_FLAGS, "")
|
newItem.setText(self.C_FLAGS, "")
|
||||||
newItem.setText(self.C_HANDLE, tHandle)
|
newItem.setText(self.C_HANDLE, tHandle)
|
||||||
|
|
||||||
newItem.setForeground(self.C_COUNT,QColor(*self.theParent.theTheme.treeWCount))
|
# newItem.setForeground(self.C_COUNT,QColor(*self.theParent.theTheme.treeWCount))
|
||||||
newItem.setTextAlignment(self.C_COUNT,Qt.AlignRight)
|
newItem.setTextAlignment(self.C_COUNT,Qt.AlignRight)
|
||||||
newItem.setFont(self.C_FLAGS,self.fontFlags)
|
newItem.setFont(self.C_FLAGS,self.fontFlags)
|
||||||
|
|
||||||
|
|||||||
+65
-49
@@ -15,7 +15,7 @@ import nw
|
|||||||
|
|
||||||
from PyQt5.QtCore import Qt, QUrl
|
from PyQt5.QtCore import Qt, QUrl
|
||||||
from PyQt5.QtWidgets import QTextBrowser
|
from PyQt5.QtWidgets import QTextBrowser
|
||||||
from PyQt5.QtGui import QTextOption, QFont
|
from PyQt5.QtGui import QTextOption, QFont, QPalette, QColor
|
||||||
|
|
||||||
from nw.convert.tokenizer import Tokenizer
|
from nw.convert.tokenizer import Tokenizer
|
||||||
from nw.convert.tohtml import ToHtml
|
from nw.convert.tohtml import ToHtml
|
||||||
@@ -37,57 +37,14 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
self.theTheme = theParent.theTheme
|
self.theTheme = theParent.theTheme
|
||||||
self.theHandle = None
|
self.theHandle = None
|
||||||
|
|
||||||
self.theQDoc = self.document()
|
self.qDocument = self.document()
|
||||||
self.theQDoc.setDefaultStyleSheet((
|
|
||||||
"body {{"
|
|
||||||
" font-size: {textSize}pt;"
|
|
||||||
" color: rgb({tColR},{tColG},{tColB});"
|
|
||||||
"}}\n"
|
|
||||||
"h1, h2, h3, h4 {{"
|
|
||||||
" color: rgb({hColR},{hColG},{hColB});"
|
|
||||||
"}}\n"
|
|
||||||
"a {{"
|
|
||||||
" color: rgb({aColR},{aColG},{aColB});"
|
|
||||||
"}}\n"
|
|
||||||
"pre {{"
|
|
||||||
" color: rgb({cColR},{cColG},{cColB});"
|
|
||||||
" font-size: {preSize}pt;"
|
|
||||||
"}}\n"
|
|
||||||
"mark {{"
|
|
||||||
" color: rgb({eColR},{eColG},{eColB});"
|
|
||||||
"}}\n"
|
|
||||||
"table {{"
|
|
||||||
" margin: 10px 0px;"
|
|
||||||
"}}\n"
|
|
||||||
"td {{"
|
|
||||||
" padding: 0px 4px;"
|
|
||||||
"}}\n"
|
|
||||||
).format(
|
|
||||||
textSize = self.mainConf.textSize,
|
|
||||||
preSize = self.mainConf.textSize*0.9,
|
|
||||||
tColR = self.theTheme.colText[0],
|
|
||||||
tColG = self.theTheme.colText[1],
|
|
||||||
tColB = self.theTheme.colText[2],
|
|
||||||
hColR = self.theTheme.colHead[0],
|
|
||||||
hColG = self.theTheme.colHead[1],
|
|
||||||
hColB = self.theTheme.colHead[2],
|
|
||||||
cColR = self.theTheme.colComm[0],
|
|
||||||
cColG = self.theTheme.colComm[1],
|
|
||||||
cColB = self.theTheme.colComm[2],
|
|
||||||
eColR = self.theTheme.colEmph[0],
|
|
||||||
eColG = self.theTheme.colEmph[1],
|
|
||||||
eColB = self.theTheme.colEmph[2],
|
|
||||||
aColR = self.theTheme.colLink[0],
|
|
||||||
aColG = self.theTheme.colLink[1],
|
|
||||||
aColB = self.theTheme.colLink[2],
|
|
||||||
))
|
|
||||||
self.setMinimumWidth(300)
|
self.setMinimumWidth(300)
|
||||||
self.initViewer()
|
self.initViewer()
|
||||||
|
|
||||||
theOpt = QTextOption()
|
theOpt = QTextOption()
|
||||||
if self.mainConf.doJustify:
|
if self.mainConf.doJustify:
|
||||||
theOpt.setAlignment(Qt.AlignJustify)
|
theOpt.setAlignment(Qt.AlignJustify)
|
||||||
self.theQDoc.setDefaultTextOption(theOpt)
|
self.qDocument.setDefaultTextOption(theOpt)
|
||||||
|
|
||||||
logger.debug("DocViewer initialisation complete")
|
logger.debug("DocViewer initialisation complete")
|
||||||
|
|
||||||
@@ -102,20 +59,27 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
"""Set editor settings from main config.
|
"""Set editor settings from main config.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self._makeStyleSheet()
|
||||||
|
|
||||||
# Set Font
|
# Set Font
|
||||||
theFont = QFont()
|
theFont = QFont()
|
||||||
if self.mainConf.textFont is None:
|
if self.mainConf.textFont is None:
|
||||||
# If none is defined, set the default back to config
|
# If none is defined, set the default back to config
|
||||||
self.mainConf.textFont = self.theQDoc.defaultFont().family()
|
self.mainConf.textFont = self.qDocument.defaultFont().family()
|
||||||
theFont.setFamily(self.mainConf.textFont)
|
theFont.setFamily(self.mainConf.textFont)
|
||||||
theFont.setPointSize(self.mainConf.textSize)
|
theFont.setPointSize(self.mainConf.textSize)
|
||||||
self.setFont(theFont)
|
self.setFont(theFont)
|
||||||
|
|
||||||
self.theQDoc.setDocumentMargin(self.mainConf.textMargin)
|
docPalette = self.palette()
|
||||||
|
docPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack))
|
||||||
|
docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
|
||||||
|
self.setPalette(docPalette)
|
||||||
|
|
||||||
|
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
|
||||||
theOpt = QTextOption()
|
theOpt = QTextOption()
|
||||||
if self.mainConf.doJustify:
|
if self.mainConf.doJustify:
|
||||||
theOpt.setAlignment(Qt.AlignJustify)
|
theOpt.setAlignment(Qt.AlignJustify)
|
||||||
self.theQDoc.setDefaultTextOption(theOpt)
|
self.qDocument.setDefaultTextOption(theOpt)
|
||||||
|
|
||||||
# If we have a document open, we should reload it in case the font changed
|
# If we have a document open, we should reload it in case the font changed
|
||||||
if self.theHandle is not None:
|
if self.theHandle is not None:
|
||||||
@@ -162,4 +126,56 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
##
|
||||||
|
# Internal Functions
|
||||||
|
##
|
||||||
|
|
||||||
|
def _makeStyleSheet(self):
|
||||||
|
|
||||||
|
self.qDocument.setDefaultStyleSheet((
|
||||||
|
"body {{"
|
||||||
|
" font-size: {textSize}pt;"
|
||||||
|
" color: rgb({tColR},{tColG},{tColB});"
|
||||||
|
"}}\n"
|
||||||
|
"h1, h2, h3, h4 {{"
|
||||||
|
" color: rgb({hColR},{hColG},{hColB});"
|
||||||
|
"}}\n"
|
||||||
|
"a {{"
|
||||||
|
" color: rgb({aColR},{aColG},{aColB});"
|
||||||
|
"}}\n"
|
||||||
|
"pre {{"
|
||||||
|
" color: rgb({cColR},{cColG},{cColB});"
|
||||||
|
" font-size: {preSize}pt;"
|
||||||
|
"}}\n"
|
||||||
|
"mark {{"
|
||||||
|
" color: rgb({eColR},{eColG},{eColB});"
|
||||||
|
"}}\n"
|
||||||
|
"table {{"
|
||||||
|
" margin: 10px 0px;"
|
||||||
|
"}}\n"
|
||||||
|
"td {{"
|
||||||
|
" padding: 0px 4px;"
|
||||||
|
"}}\n"
|
||||||
|
).format(
|
||||||
|
textSize = self.mainConf.textSize,
|
||||||
|
preSize = self.mainConf.textSize*0.9,
|
||||||
|
tColR = self.theTheme.colText[0],
|
||||||
|
tColG = self.theTheme.colText[1],
|
||||||
|
tColB = self.theTheme.colText[2],
|
||||||
|
hColR = self.theTheme.colHead[0],
|
||||||
|
hColG = self.theTheme.colHead[1],
|
||||||
|
hColB = self.theTheme.colHead[2],
|
||||||
|
cColR = self.theTheme.colComm[0],
|
||||||
|
cColG = self.theTheme.colComm[1],
|
||||||
|
cColB = self.theTheme.colComm[2],
|
||||||
|
eColR = self.theTheme.colEmph[0],
|
||||||
|
eColG = self.theTheme.colEmph[1],
|
||||||
|
eColB = self.theTheme.colEmph[2],
|
||||||
|
aColR = self.theTheme.colLink[0],
|
||||||
|
aColG = self.theTheme.colLink[1],
|
||||||
|
aColB = self.theTheme.colLink[2],
|
||||||
|
))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
# END Class GuiDocViewer
|
# END Class GuiDocViewer
|
||||||
|
|||||||
+19
-4
@@ -104,8 +104,8 @@ class GuiMainMenu(QMenuBar):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _showAbout(self):
|
def _showAbout(self):
|
||||||
msgBox = QMessageBox()
|
listPrefix = " • "
|
||||||
msgBox.about(self.theParent, "About %s" % nw.__package__, (
|
aboutMsg = (
|
||||||
"<h3>About {name:s}</h3>"
|
"<h3>About {name:s}</h3>"
|
||||||
"<p>Version: {version:s}<br>Release Date: {date:s}</p>"
|
"<p>Version: {version:s}<br>Release Date: {date:s}</p>"
|
||||||
"<p>{name:s} is a markdown-like text editor designed for organising and writing novels. "
|
"<p>{name:s} is a markdown-like text editor designed for organising and writing novels. "
|
||||||
@@ -121,8 +121,23 @@ class GuiMainMenu(QMenuBar):
|
|||||||
date = nw.__date__,
|
date = nw.__date__,
|
||||||
copyright = nw.__copyright__,
|
copyright = nw.__copyright__,
|
||||||
website = nw.__url__,
|
website = nw.__url__,
|
||||||
credits = "".join([" • %s<br/>" % x for x in nw.__credits__]),
|
credits = "<br/>".join(["%s%s" % (listPrefix, x) for x in nw.__credits__]),
|
||||||
))
|
)
|
||||||
|
theTheme = self.theParent.theTheme
|
||||||
|
if theTheme.themeCredit != "" or theTheme.syntaxCredit != "":
|
||||||
|
aboutMsg += "<h4>GUI Theme and Syntax Highlighting</h4>"
|
||||||
|
aboutMsg += "<p>"
|
||||||
|
if theTheme.themeCredit != "":
|
||||||
|
aboutMsg += "%s%s by %s<br/>" % (
|
||||||
|
listPrefix, theTheme.themeName, theTheme.themeCredit
|
||||||
|
)
|
||||||
|
if theTheme.syntaxCredit != "":
|
||||||
|
aboutMsg += "%s%s by %s<br/>" % (
|
||||||
|
listPrefix, theTheme.syntaxName, theTheme.syntaxCredit
|
||||||
|
)
|
||||||
|
aboutMsg += "</p>"
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
msgBox.about(self.theParent, "About %s" % nw.__package__, aboutMsg)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _showAboutQt(self):
|
def _showAboutQt(self):
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class GuiMain(QMainWindow):
|
|||||||
self.resize(*self.mainConf.winGeometry)
|
self.resize(*self.mainConf.winGeometry)
|
||||||
self._setWindowTitle()
|
self._setWindowTitle()
|
||||||
self.setWindowIcon(QIcon(path.join(self.mainConf.appRoot, nwFiles.APP_ICON)))
|
self.setWindowIcon(QIcon(path.join(self.mainConf.appRoot, nwFiles.APP_ICON)))
|
||||||
self.theTheme.updateTheme()
|
|
||||||
|
|
||||||
# Main GUI Elements
|
# Main GUI Elements
|
||||||
self.statusBar = GuiMainStatus(self)
|
self.statusBar = GuiMainStatus(self)
|
||||||
@@ -114,9 +113,6 @@ class GuiMain(QMainWindow):
|
|||||||
self.setStatusBar(self.statusBar)
|
self.setStatusBar(self.statusBar)
|
||||||
self.statusBar.showMessage("Ready")
|
self.statusBar.showMessage("Ready")
|
||||||
|
|
||||||
# Load Theme StyleSheet
|
|
||||||
self.setStyleSheet(self.theTheme.cssData)
|
|
||||||
|
|
||||||
# Set Up Autosaving Project Timer
|
# Set Up Autosaving Project Timer
|
||||||
self.asProjTimer = QTimer()
|
self.asProjTimer = QTimer()
|
||||||
self.asProjTimer.timeout.connect(self._autoSaveProject)
|
self.asProjTimer.timeout.connect(self._autoSaveProject)
|
||||||
|
|||||||
+120
-47
@@ -16,6 +16,9 @@ import nw
|
|||||||
|
|
||||||
from os import path, listdir
|
from os import path, listdir
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import qApp
|
||||||
|
from PyQt5.QtGui import QPalette, QColor
|
||||||
|
|
||||||
from nw.enum import nwAlert
|
from nw.enum import nwAlert
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -24,48 +27,60 @@ class Theme:
|
|||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
|
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.guiPath = "gui"
|
self.guiPalette = QPalette()
|
||||||
self.syntaxPath = "syntax"
|
self.guiPath = "gui"
|
||||||
self.cssName = "styles.css"
|
self.syntaxPath = "syntax"
|
||||||
self.confName = "theme.conf"
|
self.cssName = "style.qss"
|
||||||
self.themeList = []
|
self.confName = "theme.conf"
|
||||||
self.syntaxList = []
|
self.themeList = []
|
||||||
|
self.syntaxList = []
|
||||||
|
|
||||||
# Loaded Theme Settings
|
# Loaded Theme Settings
|
||||||
|
|
||||||
## Main
|
## Theme
|
||||||
self.themeName = "No Name"
|
self.themeName = ""
|
||||||
|
self.themeAuthor = ""
|
||||||
## Syntax
|
self.themeCredit = ""
|
||||||
self.colText = [ 0, 0, 0]
|
self.themeUrl = ""
|
||||||
self.colLink = [ 0, 0, 0]
|
|
||||||
self.colHead = [ 0, 0, 0]
|
|
||||||
self.colHeadH = [ 0, 0, 0]
|
|
||||||
self.colEmph = [ 0, 0, 0]
|
|
||||||
self.colDialN = [ 0, 0, 0]
|
|
||||||
self.colDialD = [ 0, 0, 0]
|
|
||||||
self.colDialS = [ 0, 0, 0]
|
|
||||||
self.colComm = [ 0, 0, 0]
|
|
||||||
self.colKey = [ 0, 0, 0]
|
|
||||||
self.colVal = [ 0, 0, 0]
|
|
||||||
self.colSpell = [ 0, 0, 0]
|
|
||||||
self.colTagErr = [ 0, 0, 0]
|
|
||||||
self.colRepTag = [ 0, 0, 0]
|
|
||||||
|
|
||||||
## GUI
|
## GUI
|
||||||
self.treeWCount = [ 0, 0, 0]
|
self.treeWCount = [ 0, 0, 0]
|
||||||
self.statNone = [120,120,120]
|
self.statNone = [120,120,120]
|
||||||
self.statUnsaved = [120,120, 40]
|
self.statUnsaved = [120,120, 40]
|
||||||
self.statSaved = [ 40,120, 0]
|
self.statSaved = [ 40,120, 0]
|
||||||
|
|
||||||
|
# Loaded Syntax Settings
|
||||||
|
|
||||||
|
## Main
|
||||||
|
self.syntaxName = ""
|
||||||
|
self.syntaxAuthor = ""
|
||||||
|
self.syntaxCredit = ""
|
||||||
|
self.syntaxUrl = ""
|
||||||
|
|
||||||
|
## Colours
|
||||||
|
self.colBack = [255,255,255]
|
||||||
|
self.colText = [ 0, 0, 0]
|
||||||
|
self.colLink = [ 0, 0, 0]
|
||||||
|
self.colHead = [ 0, 0, 0]
|
||||||
|
self.colHeadH = [ 0, 0, 0]
|
||||||
|
self.colEmph = [ 0, 0, 0]
|
||||||
|
self.colDialN = [ 0, 0, 0]
|
||||||
|
self.colDialD = [ 0, 0, 0]
|
||||||
|
self.colDialS = [ 0, 0, 0]
|
||||||
|
self.colComm = [ 0, 0, 0]
|
||||||
|
self.colKey = [ 0, 0, 0]
|
||||||
|
self.colVal = [ 0, 0, 0]
|
||||||
|
self.colSpell = [ 0, 0, 0]
|
||||||
|
self.colTagErr = [ 0, 0, 0]
|
||||||
|
self.colRepTag = [ 0, 0, 0]
|
||||||
|
|
||||||
# Changeable Settings
|
# Changeable Settings
|
||||||
self.guiTheme = None
|
self.guiTheme = None
|
||||||
self.guiSyntax = None
|
self.guiSyntax = None
|
||||||
self.themeRoot = None
|
self.themeRoot = None
|
||||||
self.cssFile = None
|
self.cssFile = None
|
||||||
self.cssData = ""
|
|
||||||
|
|
||||||
self.updateTheme()
|
self.updateTheme()
|
||||||
|
|
||||||
@@ -85,8 +100,6 @@ class Theme:
|
|||||||
self.confFile = path.join(self.themePath,self.confName)
|
self.confFile = path.join(self.themePath,self.confName)
|
||||||
self.cssFile = path.join(self.themePath,self.cssName)
|
self.cssFile = path.join(self.themePath,self.cssName)
|
||||||
|
|
||||||
print(self.guiSyntax)
|
|
||||||
|
|
||||||
self.loadTheme()
|
self.loadTheme()
|
||||||
self.loadSyntax()
|
self.loadSyntax()
|
||||||
|
|
||||||
@@ -97,14 +110,57 @@ class Theme:
|
|||||||
logger.debug("Loading theme files")
|
logger.debug("Loading theme files")
|
||||||
|
|
||||||
# CSS File
|
# CSS File
|
||||||
|
cssData = ""
|
||||||
try:
|
try:
|
||||||
if path.isfile(self.cssFile):
|
if path.isfile(self.cssFile):
|
||||||
with open(self.cssFile,mode="r") as inFile:
|
with open(self.cssFile,mode="r") as inFile:
|
||||||
self.cssData = inFile.read()
|
cssData = inFile.read()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Could not load theme css file")
|
logger.error("Could not load theme css file")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Config File
|
||||||
|
confParser = configparser.ConfigParser()
|
||||||
|
try:
|
||||||
|
confParser.read_file(open(self.confFile))
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Could not load theme settings from: %s" % self.confFile)
|
||||||
|
return False
|
||||||
|
|
||||||
|
## Main
|
||||||
|
cnfSec = "Main"
|
||||||
|
if confParser.has_section(cnfSec):
|
||||||
|
self.themeName = self._parseLine(confParser,cnfSec,"name", "")
|
||||||
|
self.themeAuthor = self._parseLine(confParser,cnfSec,"author","")
|
||||||
|
self.themeCredit = self._parseLine(confParser,cnfSec,"credit","")
|
||||||
|
self.themeUrl = self._parseLine(confParser,cnfSec,"url", "")
|
||||||
|
|
||||||
|
## Palette
|
||||||
|
cnfSec = "Palette"
|
||||||
|
if confParser.has_section(cnfSec):
|
||||||
|
self._setPalette(confParser,cnfSec,"window", QPalette.Window)
|
||||||
|
self._setPalette(confParser,cnfSec,"windowtext", QPalette.WindowText)
|
||||||
|
self._setPalette(confParser,cnfSec,"base", QPalette.Base)
|
||||||
|
self._setPalette(confParser,cnfSec,"alternatebase",QPalette.AlternateBase)
|
||||||
|
self._setPalette(confParser,cnfSec,"text", QPalette.Text)
|
||||||
|
self._setPalette(confParser,cnfSec,"tooltipbase", QPalette.ToolTipBase)
|
||||||
|
self._setPalette(confParser,cnfSec,"tooltiptext", QPalette.ToolTipText)
|
||||||
|
self._setPalette(confParser,cnfSec,"button", QPalette.Button)
|
||||||
|
self._setPalette(confParser,cnfSec,"buttontext", QPalette.ButtonText)
|
||||||
|
self._setPalette(confParser,cnfSec,"brighttext", QPalette.BrightText)
|
||||||
|
|
||||||
|
## GUI
|
||||||
|
cnfSec = "GUI"
|
||||||
|
if confParser.has_section(cnfSec):
|
||||||
|
self.treeWCount = self._loadColour(confParser,cnfSec,"treewordcount")
|
||||||
|
self.statNone = self._loadColour(confParser,cnfSec,"statusnone")
|
||||||
|
self.statUnsaved = self._loadColour(confParser,cnfSec,"statusunsaved")
|
||||||
|
self.statSaved = self._loadColour(confParser,cnfSec,"statussaved")
|
||||||
|
|
||||||
|
# Apply Styles
|
||||||
|
qApp.setStyleSheet(cssData)
|
||||||
|
qApp.setPalette(self.guiPalette)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def loadSyntax(self):
|
def loadSyntax(self):
|
||||||
@@ -119,11 +175,15 @@ class Theme:
|
|||||||
## Main
|
## Main
|
||||||
cnfSec = "Main"
|
cnfSec = "Main"
|
||||||
if confParser.has_section(cnfSec):
|
if confParser.has_section(cnfSec):
|
||||||
self.themeName = confParser.get(cnfSec,"name")
|
self.syntaxName = self._parseLine(confParser,cnfSec,"name","")
|
||||||
|
self.syntaxAuthor = self._parseLine(confParser,cnfSec,"author","")
|
||||||
|
self.syntaxCredit = self._parseLine(confParser,cnfSec,"credit","")
|
||||||
|
self.syntaxUrl = self._parseLine(confParser,cnfSec,"url", "")
|
||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
cnfSec = "Syntax"
|
cnfSec = "Syntax"
|
||||||
if confParser.has_section(cnfSec):
|
if confParser.has_section(cnfSec):
|
||||||
|
self.colBack = self._loadColour(confParser,cnfSec,"background")
|
||||||
self.colText = self._loadColour(confParser,cnfSec,"text")
|
self.colText = self._loadColour(confParser,cnfSec,"text")
|
||||||
self.colLink = self._loadColour(confParser,cnfSec,"link")
|
self.colLink = self._loadColour(confParser,cnfSec,"link")
|
||||||
self.colHead = self._loadColour(confParser,cnfSec,"headertext")
|
self.colHead = self._loadColour(confParser,cnfSec,"headertext")
|
||||||
@@ -139,14 +199,6 @@ class Theme:
|
|||||||
self.colTagErr = self._loadColour(confParser,cnfSec,"tagerror")
|
self.colTagErr = self._loadColour(confParser,cnfSec,"tagerror")
|
||||||
self.colRepTag = self._loadColour(confParser,cnfSec,"replacetag")
|
self.colRepTag = self._loadColour(confParser,cnfSec,"replacetag")
|
||||||
|
|
||||||
## GUI
|
|
||||||
cnfSec = "GUI"
|
|
||||||
if confParser.has_section(cnfSec):
|
|
||||||
self.treeWCount = self._loadColour(confParser,cnfSec,"treewordcount")
|
|
||||||
self.statNone = self._loadColour(confParser,cnfSec,"statusnone")
|
|
||||||
self.statUnsaved = self._loadColour(confParser,cnfSec,"statusunsaved")
|
|
||||||
self.statSaved = self._loadColour(confParser,cnfSec,"statussaved")
|
|
||||||
|
|
||||||
logger.info("Loaded syntax colour theme '%s'" % self.guiSyntax)
|
logger.info("Loaded syntax colour theme '%s'" % self.guiSyntax)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -220,4 +272,25 @@ class Theme:
|
|||||||
outData = [0,0,0]
|
outData = [0,0,0]
|
||||||
return outData
|
return outData
|
||||||
|
|
||||||
|
def _setPalette(self, confParser, cnfSec, cnfName, paletteVal):
|
||||||
|
if confParser.has_option(cnfSec,cnfName):
|
||||||
|
inData = confParser.get(cnfSec,cnfName).split(",")
|
||||||
|
readCol = []
|
||||||
|
try:
|
||||||
|
readCol.append(int(inData[0]))
|
||||||
|
readCol.append(int(inData[1]))
|
||||||
|
readCol.append(int(inData[2]))
|
||||||
|
except:
|
||||||
|
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||||
|
return
|
||||||
|
if len(readCol) == 3:
|
||||||
|
self.guiPalette.setColor(paletteVal, QColor(*readCol))
|
||||||
|
return
|
||||||
|
|
||||||
|
def _parseLine(self, confParser, cnfSec, cnfName, cnfDefault):
|
||||||
|
if confParser.has_section(cnfSec):
|
||||||
|
if confParser.has_option(cnfSec, cnfName):
|
||||||
|
return confParser.get(cnfSec, cnfName)
|
||||||
|
return cnfDefault
|
||||||
|
|
||||||
# End Class Theme
|
# End Class Theme
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Default Theme: Dark
|
|
||||||
*/
|
|
||||||
|
|
||||||
* {
|
|
||||||
background-color: #999999;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextEdit {
|
|
||||||
background-color: #141414;
|
|
||||||
color: #c7cfd0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextBrowser {
|
|
||||||
background-color: #141414;
|
|
||||||
color: #c7cfd0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTreeView, QHeaderView {
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Default Theme: Light
|
||||||
|
*/
|
||||||
|
|
||||||
|
QTreeView, QHeaderView {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Default Theme: Light
|
|
||||||
*/
|
|
||||||
|
|
||||||
QTextEdit {
|
|
||||||
background-color: #ffffff;
|
|
||||||
color: #141414;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextBrowser {
|
|
||||||
background-color: #ffffff;
|
|
||||||
color: #141414;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTreeView, QHeaderView {
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
[Main]
|
[Main]
|
||||||
|
|
||||||
name = Default System Theme
|
name = Default System Theme
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Default Theme: Dark
|
||||||
|
*/
|
||||||
|
|
||||||
|
QTreeView, QHeaderView {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
[Main]
|
||||||
|
name = Default Dark Theme
|
||||||
|
author = Veronica Berglyd Olsen
|
||||||
|
credit = Veronica Berglyd Olsen
|
||||||
|
url = https://github.com/vkbo/novelWriter
|
||||||
|
|
||||||
|
[Palette]
|
||||||
|
window = 54, 54, 54
|
||||||
|
windowtext = 174, 174, 174
|
||||||
|
base = 62, 62, 62
|
||||||
|
alternatebase = 67, 67, 67
|
||||||
|
text = 174, 174, 174
|
||||||
|
tooltipbase = 255, 255, 192
|
||||||
|
tooltiptext = 21, 21, 13
|
||||||
|
button = 62, 62, 62
|
||||||
|
buttontext = 174, 174, 174
|
||||||
|
brighttext = 174, 174, 174
|
||||||
|
|
||||||
|
[GUI]
|
||||||
|
treewordcount = 197, 200, 198
|
||||||
|
statusnone = 150, 152, 150
|
||||||
|
statussaved = 39, 135, 78
|
||||||
|
statusunsaved = 138, 32, 32
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
name = Default Dark
|
name = Default Dark
|
||||||
|
|
||||||
[Syntax]
|
[Syntax]
|
||||||
|
background = 54, 54, 54
|
||||||
text = 199, 207, 208
|
text = 199, 207, 208
|
||||||
link = 184, 200, 0
|
link = 184, 200, 0
|
||||||
headertext = 0, 155, 200
|
headertext = 0, 155, 200
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
name = Default Light
|
name = Default Light
|
||||||
|
|
||||||
[Syntax]
|
[Syntax]
|
||||||
|
background = 255, 255, 255
|
||||||
text = 0, 0, 0
|
text = 0, 0, 0
|
||||||
link = 0, 0, 200
|
link = 0, 0, 200
|
||||||
headertext = 0, 100, 00
|
headertext = 0, 100, 00
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
##
|
||||||
|
# Theme: Tomorrow
|
||||||
|
# Source: https://github.com/chriskempson/tomorrow-theme
|
||||||
|
# Credit: Chris Kempson
|
||||||
|
##
|
||||||
|
# Colours:
|
||||||
|
# Background = 2d2d2d : 45, 45, 45
|
||||||
|
# Current Line = 393939 : 57, 57, 57
|
||||||
|
# Selection = 515151 : 81, 81, 81
|
||||||
|
# Foreground = cccccc : 204, 204, 204
|
||||||
|
# Comment = 999999 : 153, 153, 153
|
||||||
|
# Red = f2777a : 242, 119, 122
|
||||||
|
# Orange = f99157 : 249, 145, 57
|
||||||
|
# Yellow = ffcc66 : 255, 204, 102
|
||||||
|
# Green = 99cc99 : 153, 204, 153
|
||||||
|
# Aqua = 66cccc : 102, 204, 204
|
||||||
|
# Blue = 6699cc : 102, 153, 204
|
||||||
|
# Purple = cc99cc : 204, 153, 204
|
||||||
|
##
|
||||||
|
|
||||||
|
[Main]
|
||||||
|
name = Tomorrow
|
||||||
|
author = Veronica Berglyd Olsen
|
||||||
|
credit = Chris Kempson
|
||||||
|
url = https://github.com/chriskempson/tomorrow-theme
|
||||||
|
|
||||||
|
[Syntax]
|
||||||
|
background = 45, 45, 45
|
||||||
|
text = 204, 204, 204
|
||||||
|
link = 102, 153, 204
|
||||||
|
headertext = 102, 153, 204
|
||||||
|
headertag = 102, 153, 204
|
||||||
|
emphasis = 249, 145, 57
|
||||||
|
straightquotes = 242, 119, 122
|
||||||
|
doublequotes = 153, 204, 153
|
||||||
|
singlequotes = 255, 204, 102
|
||||||
|
hidden = 153, 153, 153
|
||||||
|
keyword = 242, 119, 122
|
||||||
|
value = 204, 153, 204
|
||||||
|
spellcheckline = 242, 119, 122
|
||||||
|
tagerror = 153, 204, 153
|
||||||
|
replacetag = 102, 204, 204
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
##
|
##
|
||||||
# Theme: Base16 Tomorrow Night
|
# Theme: Tomorrow Night
|
||||||
# Source: https://github.com/chriskempson/tomorrow-theme
|
# Source: https://github.com/chriskempson/tomorrow-theme
|
||||||
# Credit: Chris Kempson
|
# Credit: Chris Kempson
|
||||||
##
|
##
|
||||||
@@ -19,9 +19,13 @@
|
|||||||
##
|
##
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
name = Base16 Tomorrow Night
|
name = Tomorrow Night
|
||||||
|
author = Veronica Berglyd Olsen
|
||||||
|
credit = Chris Kempson
|
||||||
|
url = https://github.com/chriskempson/tomorrow-theme
|
||||||
|
|
||||||
[Syntax]
|
[Syntax]
|
||||||
|
background = 29, 31, 33
|
||||||
text = 197, 200, 198
|
text = 197, 200, 198
|
||||||
link = 129, 162, 190
|
link = 129, 162, 190
|
||||||
headertext = 129, 162, 190
|
headertext = 129, 162, 190
|
||||||
@@ -36,9 +40,3 @@ value = 178, 148, 187
|
|||||||
spellcheckline = 204, 102, 102
|
spellcheckline = 204, 102, 102
|
||||||
tagerror = 181, 189, 104
|
tagerror = 181, 189, 104
|
||||||
replacetag = 138, 190, 183
|
replacetag = 138, 190, 183
|
||||||
|
|
||||||
[GUI]
|
|
||||||
treewordcount = 197, 200, 198
|
|
||||||
statusnone = 150, 152, 150
|
|
||||||
statussaved = 39, 135, 78
|
|
||||||
statusunsaved = 138, 32, 32
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
##
|
||||||
|
# Theme: Tomorrow Night Eighties
|
||||||
|
# Source: https://github.com/chriskempson/tomorrow-theme
|
||||||
|
# Credit: Chris Kempson
|
||||||
|
##
|
||||||
|
# Colours:
|
||||||
|
# Background = 2d2d2d : 45, 45, 45
|
||||||
|
# Current Line = 393939 : 57, 57, 57
|
||||||
|
# Selection = 515151 : 81, 81, 81
|
||||||
|
# Foreground = cccccc : 204, 204, 204
|
||||||
|
# Comment = 999999 : 153, 153, 153
|
||||||
|
# Red = f2777a : 242, 119, 122
|
||||||
|
# Orange = f99157 : 249, 145, 57
|
||||||
|
# Yellow = ffcc66 : 255, 204, 102
|
||||||
|
# Green = 99cc99 : 153, 204, 153
|
||||||
|
# Aqua = 66cccc : 102, 204, 204
|
||||||
|
# Blue = 6699cc : 102, 153, 204
|
||||||
|
# Purple = cc99cc : 204, 153, 204
|
||||||
|
##
|
||||||
|
|
||||||
|
[Main]
|
||||||
|
name = Tomorrow Night Eighties
|
||||||
|
author = Veronica Berglyd Olsen
|
||||||
|
credit = Chris Kempson
|
||||||
|
url = https://github.com/chriskempson/tomorrow-theme
|
||||||
|
|
||||||
|
[Syntax]
|
||||||
|
background = 45, 45, 45
|
||||||
|
text = 204, 204, 204
|
||||||
|
link = 102, 153, 204
|
||||||
|
headertext = 102, 153, 204
|
||||||
|
headertag = 102, 153, 204
|
||||||
|
emphasis = 249, 145, 57
|
||||||
|
straightquotes = 242, 119, 122
|
||||||
|
doublequotes = 153, 204, 153
|
||||||
|
singlequotes = 255, 204, 102
|
||||||
|
hidden = 153, 153, 153
|
||||||
|
keyword = 242, 119, 122
|
||||||
|
value = 204, 153, 204
|
||||||
|
spellcheckline = 242, 119, 122
|
||||||
|
tagerror = 153, 204, 153
|
||||||
|
replacetag = 102, 204, 204
|
||||||
Reference in New Issue
Block a user