wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ThemeManager.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QColor>
11#include <QObject>
12#include <QPalette>
13
15
17enum class Theme { Light, Dark, System };
18
28{
29public:
30 // --- Theme Setup ---
31
33 void setTheme(const Theme theme);
34
35 // --- Members: Scene Colors ---
36
39
40 // --- Members: Selection Colors ---
41
44
45 // --- Members: Label Colors ---
46
48
49 // --- Members: Connection Colors ---
50
54 QColor m_connectionError = QColor(Qt::red);
56
57 // --- Members: Port Brush Colors ---
58
63
64 // --- Members: Port Pen Colors ---
65
70
71 // --- Members: Port Hover ---
72
74
75 // --- Members: Port Hover Label ---
76
79};
80
89class ThemeManager : public QObject
90{
91 Q_OBJECT
92
93public:
95 static ThemeManager &instance()
96 {
97 static ThemeManager instance;
98 return instance;
99 }
100
102 static QString themePath();
103
105 static Theme theme();
106
108 static const ThemeAttributes &attributes();
109
110 // --- Theme Management ---
111
113 static void setTheme(const Theme theme);
114
116 static Theme effectiveTheme();
117
118signals:
119 // --- Signals ---
120
123
124private:
125 // --- Lifecycle ---
126
127 explicit ThemeManager(QObject *parent = nullptr);
128
131 static Theme resolveSystemTheme();
132
134 void onSystemColorSchemeChanged();
135
136 // --- Members ---
137
138 Theme m_theme = Theme::System;
139 ThemeAttributes m_attributes;
140};
Custom QApplication subclass with exception handling and main-window access.
Theme
Enumeration of available application themes.
Contains all color attributes for a theme.
QColor m_connectionUnknown
QColor m_connectionInactive
QColor m_portHoverLabelText
QColor m_portInactivePen
QColor m_portHoverPort
QColor m_portHoverLabelBg
QColor m_connectionSelected
QColor m_portInactiveBrush
QColor m_portUnknownPen
QColor m_portUnknownBrush
QColor m_sceneBgBrush
QColor m_connectionActive
QColor m_connectionError
QColor m_portActivePen
QColor m_portErrorPen
QColor m_portActiveBrush
void setTheme(const Theme theme)
Applies theme colors to all color attributes in this object.
QColor m_selectionBrush
QColor m_selectionPen
QColor m_portErrorBrush
QColor m_graphicElementLabelColor
static Theme theme()
Returns the currently active theme.
static ThemeManager & instance()
Returns the singleton ThemeManager instance.
void themeChanged()
Emitted whenever the active theme changes.
static void setTheme(const Theme theme)
Switches the application to theme and emits themeChanged().
static Theme effectiveTheme()
Returns the effective theme (Light or Dark), resolving System to the OS preference.
static QString themePath()
Returns the resource path prefix for the current theme (e.g. "dark" or "light").
static const ThemeAttributes & attributes()
Returns the current ThemeAttributes color set.