mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +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)):
|
||||
"""
|
||||
Generates a QPixmap preview for given theme.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
If theme is a filename, the result is cached.
|
||||
"""
|
||||
|
||||
|
||||
# Checking whether theme is a string or dict
|
||||
if type(theme) == str and os.path.exists(theme):
|
||||
# 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.drawRect(QRect(w, h, w * 4, h * 5))
|
||||
painter.end()
|
||||
|
||||
|
||||
# If theme is a themefile, we keep it in cache
|
||||
if fromFile:
|
||||
_thumbCache[theme] = [themeDatas, px]
|
||||
|
@ -265,7 +265,8 @@ def setThemeEditorDatas(editor, themeDatas, pixmap, screenRect):
|
|||
)
|
||||
|
||||
editor._fromTheme = True
|
||||
|
||||
editor._themeData = themeDatas
|
||||
editor.highlighter.updateColorScheme()
|
||||
|
||||
def addThemePreviewText(pixmap, themeDatas, screenRect):
|
||||
# Text
|
||||
|
|
|
@ -47,16 +47,29 @@ class BasicHighlighter(QSyntaxHighlighter):
|
|||
# Reading user settings
|
||||
opt = settings.textEditor
|
||||
|
||||
self.defaultTextColor = QColor(opt["fontColor"])
|
||||
self.backgroundColor = (QColor(opt["background"])
|
||||
if not opt["backgroundTransparent"]
|
||||
else QColor(S.window))
|
||||
self.markupColor = F.mixColors(self.defaultTextColor,
|
||||
self.backgroundColor,
|
||||
.3)
|
||||
self.linkColor = QColor(S.link)
|
||||
self.spellingErrorColor = QColor(opt["misspelled"])
|
||||
self._defaultCharFormat.setForeground(QBrush(self.defaultTextColor))
|
||||
if not self.editor._fromTheme or not self.editor._themeData:
|
||||
|
||||
self.defaultTextColor = QColor(opt["fontColor"])
|
||||
self.backgroundColor = (QColor(opt["background"])
|
||||
if not opt["backgroundTransparent"]
|
||||
else QColor(S.window))
|
||||
self.markupColor = F.mixColors(self.defaultTextColor,
|
||||
self.backgroundColor,
|
||||
.3)
|
||||
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:
|
||||
self.rehighlight()
|
||||
|
|
|
@ -174,22 +174,33 @@ class MarkdownHighlighter(BasicHighlighter):
|
|||
|
||||
def defaultTheme(self):
|
||||
|
||||
# Colors
|
||||
# Base Colors
|
||||
background = self.backgroundColor
|
||||
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)
|
||||
highlightedTextDark = QColor(S.highlightedTextDark)
|
||||
highlightedTextLight = QColor(S.highlightedTextLight)
|
||||
highlight = QColor(S.highlight)
|
||||
listToken = F.mixColors(highlight, background, .4)
|
||||
|
||||
link = self.linkColor
|
||||
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 = {
|
||||
"markup": markup}
|
||||
|
||||
|
@ -211,10 +222,6 @@ class MarkdownHighlighter(BasicHighlighter):
|
|||
#"super":True,
|
||||
#"sub":True
|
||||
|
||||
titleColor = QColor(S.highlightedTextDark)
|
||||
# titleColor = highlight
|
||||
titleMarkupColor = F.mixColors(titleColor, background, .3)
|
||||
|
||||
for i in MTT.TITLES:
|
||||
theme[i] = {
|
||||
"formatMarkup":True,
|
||||
|
|
|
@ -38,6 +38,7 @@ class textEditView(QTextEdit):
|
|||
self.setAcceptRichText(False)
|
||||
# When setting up a theme, this becomes true.
|
||||
self._fromTheme = False
|
||||
self._themeData = None
|
||||
|
||||
self.spellcheck = spellcheck
|
||||
self.currentDict = dict if dict else settings.dict
|
||||
|
|
Loading…
Reference in a new issue