mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-19 12:22:23 +12:00
Adds better style colors of references
This commit is contained in:
parent
a334e8bd1b
commit
31dcc6d53a
|
@ -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.
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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!
|
||||
|
||||
|
|
Loading…
Reference in a new issue