Adds better style colors of references

This commit is contained in:
Olivier Keshavjee 2017-11-14 15:22:16 +01:00
parent a334e8bd1b
commit 31dcc6d53a
3 changed files with 22 additions and 12 deletions

View file

@ -9,12 +9,16 @@ import re
# A regex used to match references
from PyQt5.QtWidgets import qApp
from PyQt5.QtGui import QColor
from PyQt5.QtCore import Qt
from manuskript.enums import Outline
from manuskript.enums import Character
from manuskript.enums import Plot
from manuskript.enums import PlotStep
from manuskript.functions import mainWindow
from manuskript.functions import mainWindow, mixColors
from manuskript.ui import style as S
RegEx = r"{(\w):(\d+):?.*?}"
# A non-capturing regex used to identify references
@ -27,6 +31,12 @@ TextLetter = "T"
PlotLetter = "P"
WorldLetter = "W"
# Colors
TextHighlightColor = QColor(mixColors(QColor(Qt.blue).name(), S.window, .3))
CharacterHighlightColor = QColor(mixColors(QColor(Qt.yellow).name(), S.window, .3))
PlotHighlightColor = QColor(mixColors(QColor(Qt.red).name(), S.window, .3))
WorldHighlightColor = QColor(mixColors(QColor(Qt.green).name(), S.window, .3))
def plotReference(ID, searchable=False):
"""Takes the ID of a plot and returns a reference for that plot.

View file

@ -65,15 +65,15 @@ class basicHighlighter(QSyntaxHighlighter):
fmt = self.format(txt.start())
fmt.setFontFixedPitch(True)
fmt.setFontWeight(QFont.DemiBold)
fmt.setForeground(Qt.black) # or text becomes unreadable in some color scheme
if txt.group(1) == Ref.TextLetter:
fmt.setBackground(QBrush(QColor(Qt.blue).lighter(190)))
fmt.setBackground(QBrush(Ref.TextHighlightColor))
elif txt.group(1) == Ref.CharacterLetter:
fmt.setBackground(QBrush(QColor(Qt.yellow).lighter(170)))
fmt.setBackground(QBrush(Ref.CharacterHighlightColor))
elif txt.group(1) == Ref.PlotLetter:
fmt.setBackground(QBrush(QColor(Qt.red).lighter(170)))
fmt.setBackground(QBrush(Ref.PlotHighlightColor))
elif txt.group(1) == Ref.WorldLetter:
fmt.setBackground(QBrush(QColor(Qt.green).lighter(170)))
fmt.setBackground(QBrush(Ref.WorldHighlightColor))
self.setFormat(txt.start(),
txt.end() - txt.start(),

View file

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'manuskript/ui/importers/importer_ui.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
# Created by: PyQt5 UI code generator 5.9
#
# WARNING! All changes made in this file will be lost!