// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include class QChart; class QWidget; // The viewer's colour scheme: the light salmon one, or a dark indigo one. The View menu offers // System, Light and Dark; System follows the desktop where Qt can read it (Qt 6.5+) and is light // otherwise. A change applies at once: widgets that follow the palette repaint by themselves, and // the ones that put colours into stylesheets, icons or charts listen to ThemeNotifier. enum class ThemeChoice { System, Light, Dark }; ThemeChoice LoadThemeChoice(); void SetThemeChoice(ThemeChoice choice); // stores the choice and applies it // Sets the palette and starts following the desktop's scheme. Call once, after the Fusion style is // set and before any window is made. void InitTheme(); bool DarkTheme(); class ThemeNotifier : public QObject { Q_OBJECT public: static ThemeNotifier *Instance(); signals: void changed(); }; // Sets the widget's stylesheet from `style`, now and again after every theme change. void SetThemedStyleSheet(QWidget *widget, const std::function &style); // Colours that widgets put into their own stylesheets and drawings. QColor AccentTextColor(); // headings and headline values: navy on light, light blue on dark QColor IconInkColor(); // toolbar glyphs and flat toolbar-button text QString SliderStyle(); // the coral/navy sliders of the toolbars // The filled "hero" buttons and checked segments: navy on light, a lighter navy on dark, where the // light one would sink into the indigo panels. Hover is a shade darker/lighter respectively. QColor AccentFillColor(); QColor AccentFillHoverColor(); QString HeroButtonStyle(); // the filled push buttons (Analyze image / dataset, + Plot) QColor GuideLineColor(); // chart hover cross-hairs and guide lines // Chart series, one colour per run (index 0 is the primary line). Each is a light/dark pair of one // hue, as the accents are: navy then amber first, a pair that stays apart for colour-blind readers too. QColor PlotSeriesColor(int index); QColor PlotMarkerColor(); // the "current image" marker: the coral of the sliders QColor AlertTextColor(); // red text that must read on either background QColor CautionTextColor(); // amber text, likewise // Qt Charts do not follow the widget palette; this gives a chart the current scheme's colours. It // recolours the series too, so call it before adding series that carry colours of their own. void StyleChart(QChart *chart); // Tints the grid lines with the slider groove's colour (salmon on light, indigo on dark) and mutes the // dark theme's axis lines, where Qt's light grey competes with the data. Axes take the Qt theme's grid when they are // added, so call it after the axes are in place. void StyleChartAxes(QChart *chart);