mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-14 08:54:34 +12:00
Adds better fullscreen theme color integration
This commit is contained in:
parent
5f76a25f39
commit
7940cdb336
|
@ -89,13 +89,13 @@ def themeTextRect(themeDatas, screenRect):
|
||||||
def createThemePreview(theme, screenRect, size=QSize(200, 120)):
|
def createThemePreview(theme, screenRect, size=QSize(200, 120)):
|
||||||
"""
|
"""
|
||||||
Generates a QPixmap preview for given theme.
|
Generates a QPixmap preview for given theme.
|
||||||
|
|
||||||
Theme can be either a string containing the filename of the ini
|
Theme can be either a string containing the filename of the ini
|
||||||
file with the theme settings, or it can be a dict with the settings.
|
file with the theme settings, or it can be a dict with the settings.
|
||||||
|
|
||||||
If theme is a filename, the result is cached.
|
If theme is a filename, the result is cached.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Checking whether theme is a string or dict
|
# Checking whether theme is a string or dict
|
||||||
if type(theme) == str and os.path.exists(theme):
|
if type(theme) == str and os.path.exists(theme):
|
||||||
# Theme is the path to an ini file
|
# Theme is the path to an ini file
|
||||||
|
@ -126,7 +126,7 @@ def createThemePreview(theme, screenRect, size=QSize(200, 120)):
|
||||||
painter.setPen(Qt.white)
|
painter.setPen(Qt.white)
|
||||||
painter.drawRect(QRect(w, h, w * 4, h * 5))
|
painter.drawRect(QRect(w, h, w * 4, h * 5))
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
# If theme is a themefile, we keep it in cache
|
# If theme is a themefile, we keep it in cache
|
||||||
if fromFile:
|
if fromFile:
|
||||||
_thumbCache[theme] = [themeDatas, px]
|
_thumbCache[theme] = [themeDatas, px]
|
||||||
|
@ -265,7 +265,8 @@ def setThemeEditorDatas(editor, themeDatas, pixmap, screenRect):
|
||||||
)
|
)
|
||||||
|
|
||||||
editor._fromTheme = True
|
editor._fromTheme = True
|
||||||
|
editor._themeData = themeDatas
|
||||||
|
editor.highlighter.updateColorScheme()
|
||||||
|
|
||||||
def addThemePreviewText(pixmap, themeDatas, screenRect):
|
def addThemePreviewText(pixmap, themeDatas, screenRect):
|
||||||
# Text
|
# Text
|
||||||
|
|
|
@ -47,16 +47,29 @@ class BasicHighlighter(QSyntaxHighlighter):
|
||||||
# Reading user settings
|
# Reading user settings
|
||||||
opt = settings.textEditor
|
opt = settings.textEditor
|
||||||
|
|
||||||
self.defaultTextColor = QColor(opt["fontColor"])
|
if not self.editor._fromTheme or not self.editor._themeData:
|
||||||
self.backgroundColor = (QColor(opt["background"])
|
|
||||||
if not opt["backgroundTransparent"]
|
self.defaultTextColor = QColor(opt["fontColor"])
|
||||||
else QColor(S.window))
|
self.backgroundColor = (QColor(opt["background"])
|
||||||
self.markupColor = F.mixColors(self.defaultTextColor,
|
if not opt["backgroundTransparent"]
|
||||||
self.backgroundColor,
|
else QColor(S.window))
|
||||||
.3)
|
self.markupColor = F.mixColors(self.defaultTextColor,
|
||||||
self.linkColor = QColor(S.link)
|
self.backgroundColor,
|
||||||
self.spellingErrorColor = QColor(opt["misspelled"])
|
.3)
|
||||||
self._defaultCharFormat.setForeground(QBrush(self.defaultTextColor))
|
self.linkColor = QColor(S.link)
|
||||||
|
self.spellingErrorColor = QColor(opt["misspelled"])
|
||||||
|
self._defaultCharFormat.setForeground(QBrush(self.defaultTextColor))
|
||||||
|
|
||||||
|
# FullscreenEditor probably
|
||||||
|
else:
|
||||||
|
opt = self.editor._themeData
|
||||||
|
self.defaultTextColor = QColor(opt["Text/Color"])
|
||||||
|
self.backgroundColor = QColor(opt["Background/Color"])
|
||||||
|
self.markupColor = F.mixColors(self.defaultTextColor,
|
||||||
|
self.backgroundColor,
|
||||||
|
.3)
|
||||||
|
self.linkColor = QColor(S.link)
|
||||||
|
self.spellingErrorColor = QColor(opt["Text/Misspelled"])
|
||||||
|
|
||||||
if rehighlight:
|
if rehighlight:
|
||||||
self.rehighlight()
|
self.rehighlight()
|
||||||
|
|
|
@ -174,22 +174,33 @@ class MarkdownHighlighter(BasicHighlighter):
|
||||||
|
|
||||||
def defaultTheme(self):
|
def defaultTheme(self):
|
||||||
|
|
||||||
# Colors
|
# Base Colors
|
||||||
background = self.backgroundColor
|
background = self.backgroundColor
|
||||||
text = self.defaultTextColor
|
text = self.defaultTextColor
|
||||||
light = F.mixColors(text, background, .75)
|
|
||||||
markup = F.mixColors(text, background, .5)
|
|
||||||
veryLight = F.mixColors(text, background, .25)
|
|
||||||
|
|
||||||
highlightedText = QColor(S.highlightedText)
|
highlightedText = QColor(S.highlightedText)
|
||||||
highlightedTextDark = QColor(S.highlightedTextDark)
|
highlightedTextDark = QColor(S.highlightedTextDark)
|
||||||
highlightedTextLight = QColor(S.highlightedTextLight)
|
highlightedTextLight = QColor(S.highlightedTextLight)
|
||||||
highlight = QColor(S.highlight)
|
highlight = QColor(S.highlight)
|
||||||
listToken = F.mixColors(highlight, background, .4)
|
|
||||||
|
|
||||||
link = self.linkColor
|
link = self.linkColor
|
||||||
linkVisited = QColor(S.linkVisited)
|
linkVisited = QColor(S.linkVisited)
|
||||||
|
|
||||||
|
# titleColor = highlight
|
||||||
|
titleColor = QColor(S.highlightedTextDark)
|
||||||
|
|
||||||
|
# FullscreenEditor probably
|
||||||
|
if self.editor._fromTheme and self.editor._themeData:
|
||||||
|
text = QColor(self.editor._themeData["Text/Color"])
|
||||||
|
background = QColor(self.editor._themeData["Background/Color"])
|
||||||
|
titleColor = text
|
||||||
|
|
||||||
|
# Compositions
|
||||||
|
light = F.mixColors(text, background, .75)
|
||||||
|
markup = F.mixColors(text, background, .5)
|
||||||
|
veryLight = F.mixColors(text, background, .25)
|
||||||
|
listToken = F.mixColors(highlight, background, .4)
|
||||||
|
titleMarkupColor = F.mixColors(titleColor, background, .3)
|
||||||
|
|
||||||
|
|
||||||
theme = {
|
theme = {
|
||||||
"markup": markup}
|
"markup": markup}
|
||||||
|
|
||||||
|
@ -211,10 +222,6 @@ class MarkdownHighlighter(BasicHighlighter):
|
||||||
#"super":True,
|
#"super":True,
|
||||||
#"sub":True
|
#"sub":True
|
||||||
|
|
||||||
titleColor = QColor(S.highlightedTextDark)
|
|
||||||
# titleColor = highlight
|
|
||||||
titleMarkupColor = F.mixColors(titleColor, background, .3)
|
|
||||||
|
|
||||||
for i in MTT.TITLES:
|
for i in MTT.TITLES:
|
||||||
theme[i] = {
|
theme[i] = {
|
||||||
"formatMarkup":True,
|
"formatMarkup":True,
|
||||||
|
|
|
@ -38,6 +38,7 @@ class textEditView(QTextEdit):
|
||||||
self.setAcceptRichText(False)
|
self.setAcceptRichText(False)
|
||||||
# When setting up a theme, this becomes true.
|
# When setting up a theme, this becomes true.
|
||||||
self._fromTheme = False
|
self._fromTheme = False
|
||||||
|
self._themeData = None
|
||||||
|
|
||||||
self.spellcheck = spellcheck
|
self.spellcheck = spellcheck
|
||||||
self.currentDict = dict if dict else settings.dict
|
self.currentDict = dict if dict else settings.dict
|
||||||
|
|
Loading…
Reference in a new issue