Fix #2085312 [Tweaks editor - improve contrast in dark mode](https://bugs.launchpad.net/calibre/+bug/2085312)

This commit is contained in:
Kovid Goyal 2024-10-22 09:58:46 +05:30
parent edefce2c78
commit 3855552c19
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -980,15 +980,16 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
baseFormat = QTextCharFormat() baseFormat = QTextCharFormat()
baseFormat.setFontFamilies(['monospace']) baseFormat.setFontFamilies(['monospace'])
p = QApplication.instance().palette() p = QApplication.instance().palette()
is_dark = QApplication.instance().is_dark_theme
for name, color, bold, italic in ( for name, color, bold, italic in (
("normal", None, False, False), ("normal", None, False, False),
("keyword", p.color(QPalette.ColorRole.Link).name(), True, False), ("keyword", p.color(QPalette.ColorRole.Link).name(), True, False),
("builtin", p.color(QPalette.ColorRole.Link).name(), False, False), ("builtin", p.color(QPalette.ColorRole.Link).name(), False, False),
("constant", p.color(QPalette.ColorRole.Link).name(), False, False), ("constant", p.color(QPalette.ColorRole.Link).name(), False, False),
("decorator", "#0000E0", False, False), ("decorator", "#0000E0", False, False),
("comment", "#007F00", False, True), ("comment", '#00c700' if is_dark else "#007F00", False, True),
("string", "#808000", False, False), ("string", '#b6b600' if is_dark else "#808000", False, False),
("number", "#924900", False, False), ("number", '#d96d00' if is_dark else "#924900", False, False),
("error", "#FF0000", False, False), ("error", "#FF0000", False, False),
("pyqt", "#50621A", False, False)): ("pyqt", "#50621A", False, False)):