From 358fc8ec6dfe9f76c2f8e6a9fd93e5a36a971583 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 24 Jun 2026 09:33:42 +0200 Subject: [PATCH] PMsrHighlighter tweak for Dark Color Schemes. Likely more work needs to be done (dynamic switching, etc.). --- src/musredit_qt6/musredit/PMsrHighlighter.cpp | 88 ++++++++++++++----- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/src/musredit_qt6/musredit/PMsrHighlighter.cpp b/src/musredit_qt6/musredit/PMsrHighlighter.cpp index 9b235e18..c4adbfda 100644 --- a/src/musredit_qt6/musredit/PMsrHighlighter.cpp +++ b/src/musredit_qt6/musredit/PMsrHighlighter.cpp @@ -30,6 +30,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include +#include +#include //as35 + #include "PMsrHighlighter.h" /** @@ -82,27 +86,69 @@ PMsrHighlighter::PMsrHighlighter(QTextDocument *parent) // ========================================================================= // Define the colour/styling for each keyword type. - - blockFormat.setForeground(tabOlive); // BLOCK keywords - theoryFormat.setForeground(tabGreen); // THEORY keywords - functionsFormat.setForeground(tabRed); // FUNCTION keywords - parFormat.setForeground(tabPink); // parX keywords - mapFormat.setForeground(tabOrange); // mapX keywords - funFormat.setForeground(tabPurple); // funX keywords - runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords - commandsFormat.setForeground(tabGreen); // COMMANDS keywords - fourierFormat.setForeground(tabGreen); // FOURIER keywords - plotFormat.setForeground(tabGreen); // PLOT keywords - optionsFormat.setForeground(tabRed); // keywords input options - infoFormat.setForeground(tabGray); // auto-printed information - boolFormat.setForeground(tabRed); // boolean strings - nullFormat.setForeground(tabRed); // null strings - dateFormat.setForeground(tabPink); // date & time strings - numberFormat.setForeground(tabBlue); // integer & float strings - commentFormat.setForeground(tabGray); // comments - commentFormat.setFontItalic(true); - titleFormat.setForeground(Qt::black); // title - // titleFormat.setBackground(tabGrayLight); + Qt::ColorScheme scheme = QGuiApplication::styleHints()->colorScheme(); + + if (scheme == Qt::ColorScheme::Light) { + blockFormat.setForeground(tabOlive); // BLOCK keywords + theoryFormat.setForeground(tabGreen); // THEORY keywords + functionsFormat.setForeground(tabRed); // FUNCTION keywords + parFormat.setForeground(tabPink); // parX keywords + mapFormat.setForeground(tabOrange); // mapX keywords + funFormat.setForeground(tabPurple); // funX keywords + runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords + commandsFormat.setForeground(tabGreen); // COMMANDS keywords + fourierFormat.setForeground(tabGreen); // FOURIER keywords + plotFormat.setForeground(tabGreen); // PLOT keywords + optionsFormat.setForeground(tabRed); // keywords input options + infoFormat.setForeground(tabGray); // auto-printed information + boolFormat.setForeground(tabRed); // boolean strings + nullFormat.setForeground(tabRed); // null strings + dateFormat.setForeground(tabPink); // date & time strings + numberFormat.setForeground(tabBlue); // integer & float strings + commentFormat.setForeground(tabGray); // comments + commentFormat.setFontItalic(true); + titleFormat.setForeground(Qt::black); // title + } else if (scheme == Qt::ColorScheme::Dark) { + blockFormat.setForeground(tabOlive); // BLOCK keywords + theoryFormat.setForeground(tabGreen); // THEORY keywords + functionsFormat.setForeground(tabRed); // FUNCTION keywords + parFormat.setForeground(tabPink); // parX keywords + mapFormat.setForeground(tabOrange); // mapX keywords + funFormat.setForeground(tabPurple); // funX keywords + runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords + commandsFormat.setForeground(tabGreen); // COMMANDS keywords + fourierFormat.setForeground(tabGreen); // FOURIER keywords + plotFormat.setForeground(tabGreen); // PLOT keywords + optionsFormat.setForeground(tabRed); // keywords input options + infoFormat.setForeground(tabGray); // auto-printed information + boolFormat.setForeground(tabRed); // boolean strings + nullFormat.setForeground(tabRed); // null strings + dateFormat.setForeground(tabPink); // date & time strings + numberFormat.setForeground(tabBlueLight); // integer & float strings + commentFormat.setForeground(tabGray); // comments + commentFormat.setFontItalic(true); + titleFormat.setForeground(Qt::white); // title + } else { // set it to Light for now + blockFormat.setForeground(tabOlive); // BLOCK keywords + theoryFormat.setForeground(tabGreen); // THEORY keywords + functionsFormat.setForeground(tabRed); // FUNCTION keywords + parFormat.setForeground(tabPink); // parX keywords + mapFormat.setForeground(tabOrange); // mapX keywords + funFormat.setForeground(tabPurple); // funX keywords + runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords + commandsFormat.setForeground(tabGreen); // COMMANDS keywords + fourierFormat.setForeground(tabGreen); // FOURIER keywords + plotFormat.setForeground(tabGreen); // PLOT keywords + optionsFormat.setForeground(tabRed); // keywords input options + infoFormat.setForeground(tabGray); // auto-printed information + boolFormat.setForeground(tabRed); // boolean strings + nullFormat.setForeground(tabRed); // null strings + dateFormat.setForeground(tabPink); // date & time strings + numberFormat.setForeground(tabBlue); // integer & float strings + commentFormat.setForeground(tabGray); // comments + commentFormat.setFontItalic(true); + titleFormat.setForeground(Qt::black); // title + } // ========================================================================= // BLOCK HEADERS