game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
theme_manager.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/theme_manager.cpp
4// ==============================================================================
5// Implementation of ThemeManager - centralized theme management
6// ==============================================================================
7
8#include "theme_manager.h"
10
11#include <cmath>
12
13#include <QApplication>
14#include <QDir>
15#include <QFile>
16#include <QSettings>
17#include <QStandardPaths>
18#include <QStyle>
19#include <QStyleFactory>
20#include <QStyleHints>
21#include <QWidget>
22
23// ==============================================================================
24// Singleton Instance
25// ==============================================================================
26
32
34 : QObject(nullptr), currentThemeId_("auto") // Default to auto theme for best integration
35{
36 registerBuiltinThemes();
37
38 // Set initial effective colors from default theme
39 if (auto* theme = getTheme(currentThemeId_))
40 {
41 effectiveColors_ = theme->colors;
42 }
43
44 connectSystemThemeSignals();
45}
46
47// ==============================================================================
48// Initialization
49// ==============================================================================
50
52{
53 settingsController_ = settingsController;
55}
56
57// ==============================================================================
58// Theme Registration
59// ==============================================================================
60
61void ThemeManager::registerBuiltinThemes()
62{
63 // Auto theme first (follows system, auto-switches)
64 themes_[QStringLiteral("auto")] = createAutoTheme();
65
66 // System theme (follows OS palette)
67 themes_[QStringLiteral("system")] = createSystemTheme();
68
69 // Standard themes
70 themes_[QStringLiteral("standard-dark")] = createStandardDarkTheme();
71 themes_[QStringLiteral("standard-light")] = createStandardLightTheme();
72
73 // Specialty dark themes
74 themes_[QStringLiteral("cachyos-emerald")] = createCachyOSEmeraldTheme();
75 themes_[QStringLiteral("nord-dark")] = createNordDarkTheme();
76 themes_[QStringLiteral("dracula")] = createDraculaTheme();
77 themes_[QStringLiteral("catppuccin-mocha")] = createCatppuccinMochaTheme();
78 themes_[QStringLiteral("gruvbox-dark")] = createGruvboxDarkTheme();
79 themes_[QStringLiteral("tokyo-night")] = createTokyoNightTheme();
80
81 // Light themes
82 themes_[QStringLiteral("nord-light")] = createNordLightTheme();
83 themes_[QStringLiteral("catppuccin-latte")] = createCatppuccinLatteTheme();
84 themes_[QStringLiteral("gruvbox-light")] = createGruvboxLightTheme();
85 themes_[QStringLiteral("solarized-light")] = createSolarizedLightTheme();
86}
87
88// ==============================================================================
89// Theme Factory Methods
90// ==============================================================================
91
92// ==============================================================================
93// Auto Theme & System Signal Connection
94// ==============================================================================
95
96void ThemeManager::connectSystemThemeSignals()
97{
98#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
99 // Qt 6.5+ provides colorSchemeChanged signal on QStyleHints
100 if (QStyleHints* hints = QApplication::styleHints())
101 {
102 connect(hints, &QStyleHints::colorSchemeChanged, this,
103 &ThemeManager::onSystemColorSchemeChanged);
104 }
105#endif
106}
107
108void ThemeManager::onSystemColorSchemeChanged()
109{
110 if (!isAutoMode())
111 return;
112
113 // Recreate the auto theme with updated system colors
114 themes_[QStringLiteral("auto")] = createAutoTheme();
115 updateEffectiveColors();
116 refreshAllWidgetStyles();
117 emit themeChanged();
118}
119
120bool ThemeManager::isAutoMode() const
121{
122 return currentThemeId_ == QStringLiteral("auto");
123}
124
125QString ThemeManager::resolveAutoThemeId() const
126{
127#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
128 if (QStyleHints* hints = QApplication::styleHints())
129 {
130 Qt::ColorScheme scheme = hints->colorScheme();
131 if (scheme == Qt::ColorScheme::Dark)
132 return QStringLiteral("dark");
133 if (scheme == Qt::ColorScheme::Light)
134 return QStringLiteral("light");
135 }
136#endif
137 // Fallback: check QPalette brightness
138 return isSystemDarkMode() ? QStringLiteral("dark") : QStringLiteral("light");
139}
140
141Theme ThemeManager::createAutoTheme()
142{
143 // The auto theme detects system preference and builds colors accordingly
144 Theme theme;
145 theme.id = QStringLiteral("auto");
146 theme.displayName = QStringLiteral("Auto (System)");
147
148 bool isDark = false;
149
150#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
151 if (QStyleHints* hints = QApplication::styleHints())
152 {
153 Qt::ColorScheme scheme = hints->colorScheme();
154 if (scheme == Qt::ColorScheme::Dark)
155 isDark = true;
156 else if (scheme == Qt::ColorScheme::Light)
157 isDark = false;
158 else
159 isDark = isSystemDarkMode(); // Unknown scheme, fallback to palette check
160 }
161 else
162 {
163 isDark = isSystemDarkMode();
164 }
165#else
166 isDark = isSystemDarkMode();
167#endif
168
169 // Reuse the system theme logic which already handles dark/light based on palette
170 // But override the detection with our QStyleHints-based result
171 QPalette systemPalette = QApplication::palette();
172 ThemeColors& c = theme.colors;
173
174 if (isDark)
175 {
176 c.windowBackground = systemPalette.color(QPalette::Window);
177 c.panelBackground = systemPalette.color(QPalette::Base);
178
179 QColor altBase = systemPalette.color(QPalette::AlternateBase);
180 if (qAbs(altBase.lightness() - c.panelBackground.lightness()) < 10)
182 else
183 c.cardBackground = altBase;
184
187
188 // Use the brighter of WindowText/Text for primary, dimmer for secondary
189 {
190 QColor wt = systemPalette.color(QPalette::WindowText);
191 QColor tx = systemPalette.color(QPalette::Text);
192 if (tx.lightness() > wt.lightness())
193 {
194 c.textPrimary = tx;
195 c.textSecondary = wt;
196 }
197 else
198 {
199 c.textPrimary = wt;
200 c.textSecondary = tx;
201 }
202 // Ensure minimum brightness for dark themes (contrast guarantee)
203 if (c.textPrimary.lightness() < 180)
204 c.textPrimary =
205 QColor::fromHsl(c.textPrimary.hslHue(), c.textPrimary.hslSaturation(),
206 qMax(c.textPrimary.lightness(), 200));
207 if (c.textSecondary.lightness() < 140)
208 c.textSecondary =
209 QColor::fromHsl(c.textSecondary.hslHue(), c.textSecondary.hslSaturation(),
210 qMax(c.textSecondary.lightness(), 160));
211 }
212
213 QColor placeholder = systemPalette.color(QPalette::PlaceholderText);
214 c.textMuted = (placeholder.lightness() < 80) ? QColor(128, 128, 128) : placeholder;
215 c.textOnAccent = systemPalette.color(QPalette::HighlightedText);
216
217 theme.defaultAccent = systemPalette.color(QPalette::Highlight);
218 c.accent = theme.defaultAccent;
221
222 c.success = QColor("#4CAF50");
223 c.error = QColor("#ef5350");
224 c.warning = QColor("#ffb74d");
225 c.info = QColor("#4fc3f7");
226 c.favorite = QColor("#FFD700");
227
228 QColor midColor = systemPalette.color(QPalette::Mid);
229 if (qAbs(midColor.lightness() - c.panelBackground.lightness()) < 15)
231 else
232 c.border = midColor;
233 c.borderLight = darkenColor(c.border, 10);
234
238 }
239 else
240 {
241 c.windowBackground = systemPalette.color(QPalette::Window);
242 c.panelBackground = systemPalette.color(QPalette::Base);
243 c.cardBackground = QColor("#ffffff");
244 c.inputBackground = systemPalette.color(QPalette::Base);
245 c.hoverBackground = systemPalette.color(QPalette::Highlight).lighter(180);
246
247 c.textPrimary = systemPalette.color(QPalette::WindowText);
248 c.textSecondary = systemPalette.color(QPalette::Text);
249 c.textMuted = systemPalette.color(QPalette::PlaceholderText);
250 c.textOnAccent = systemPalette.color(QPalette::HighlightedText);
251
252 theme.defaultAccent = systemPalette.color(QPalette::Highlight);
253 c.accent = theme.defaultAccent;
254 c.accentHover = darkenColor(c.accent, 10);
256
257 c.success = QColor("#2e7d32");
258 c.error = QColor("#c62828");
259 c.warning = QColor("#f57c00");
260 c.info = QColor("#1976d2");
261 c.favorite = QColor("#ffc107");
262
263 c.border = systemPalette.color(QPalette::Mid);
264 c.borderLight = systemPalette.color(QPalette::Midlight);
265
269 }
270
271 return theme;
272}
273
274bool ThemeManager::isSystemDarkMode() const
275{
276 // Check system palette - if window color is dark, system is in dark mode
277 QPalette systemPalette = QApplication::palette();
278 QColor windowColor = systemPalette.color(QPalette::Window);
279 // Calculate luminance - if less than 128, it's dark
280 int luminance =
281 (windowColor.red() * 299 + windowColor.green() * 587 + windowColor.blue() * 114) / 1000;
282 return luminance < 128;
283}
284
285Theme ThemeManager::createSystemTheme()
286{
287 Theme theme;
288 theme.id = QStringLiteral("system");
289 theme.displayName = QStringLiteral("System (Follow OS)");
290
291 // Get system palette colors
292 QPalette systemPalette = QApplication::palette();
293
294 // Detect if system is in dark mode
295 bool isDark = isSystemDarkMode();
296
297 ThemeColors& c = theme.colors;
298
299 if (isDark)
300 {
301 // Dark mode - use system colors with sensible fallbacks
302 c.windowBackground = systemPalette.color(QPalette::Window);
303 c.panelBackground = systemPalette.color(QPalette::Base);
304
305 // Ensure card background has enough contrast from panel
306 QColor altBase = systemPalette.color(QPalette::AlternateBase);
307 // If AlternateBase is too similar to Base, lighten it slightly
308 if (qAbs(altBase.lightness() - c.panelBackground.lightness()) < 10)
309 {
311 }
312 else
313 {
314 c.cardBackground = altBase;
315 }
316
317 // Input background should be slightly lighter than card
320
321 // Use the brighter of WindowText/Text for primary, dimmer for secondary
322 {
323 QColor wt = systemPalette.color(QPalette::WindowText);
324 QColor tx = systemPalette.color(QPalette::Text);
325 if (tx.lightness() > wt.lightness())
326 {
327 c.textPrimary = tx;
328 c.textSecondary = wt;
329 }
330 else
331 {
332 c.textPrimary = wt;
333 c.textSecondary = tx;
334 }
335 // Ensure minimum brightness for dark themes (contrast guarantee)
336 if (c.textPrimary.lightness() < 180)
337 c.textPrimary =
338 QColor::fromHsl(c.textPrimary.hslHue(), c.textPrimary.hslSaturation(),
339 qMax(c.textPrimary.lightness(), 200));
340 if (c.textSecondary.lightness() < 140)
341 c.textSecondary =
342 QColor::fromHsl(c.textSecondary.hslHue(), c.textSecondary.hslSaturation(),
343 qMax(c.textSecondary.lightness(), 160));
344 }
345
346 // Ensure placeholder text has enough contrast
347 QColor placeholder = systemPalette.color(QPalette::PlaceholderText);
348 if (placeholder.lightness() < 80)
349 {
350 // Too dark for placeholder, use a lighter gray
351 c.textMuted = QColor(128, 128, 128);
352 }
353 else
354 {
355 c.textMuted = placeholder;
356 }
357 c.textOnAccent = systemPalette.color(QPalette::HighlightedText);
358
359 theme.defaultAccent = systemPalette.color(QPalette::Highlight);
360 c.accent = theme.defaultAccent;
363
364 // Brighter semantic colors for dark mode visibility
365 c.success = QColor("#4CAF50");
366 c.error = QColor("#ef5350");
367 c.warning = QColor("#ffb74d");
368 c.info = QColor("#4fc3f7");
369 c.favorite = QColor("#FFD700");
370
371 // Ensure border is visible against backgrounds
372 QColor midColor = systemPalette.color(QPalette::Mid);
373 if (qAbs(midColor.lightness() - c.panelBackground.lightness()) < 15)
374 {
376 }
377 else
378 {
379 c.border = midColor;
380 }
381 c.borderLight = darkenColor(c.border, 10);
382
386 }
387 else
388 {
389 // Light mode
390 c.windowBackground = systemPalette.color(QPalette::Window);
391 c.panelBackground = systemPalette.color(QPalette::Base);
392 c.cardBackground = QColor("#ffffff");
393 c.inputBackground = systemPalette.color(QPalette::Base);
394 c.hoverBackground = systemPalette.color(QPalette::Highlight).lighter(180);
395
396 c.textPrimary = systemPalette.color(QPalette::WindowText);
397 c.textSecondary = systemPalette.color(QPalette::Text);
398 c.textMuted = systemPalette.color(QPalette::PlaceholderText);
399 c.textOnAccent = systemPalette.color(QPalette::HighlightedText);
400
401 theme.defaultAccent = systemPalette.color(QPalette::Highlight);
402 c.accent = theme.defaultAccent;
403 c.accentHover = darkenColor(c.accent, 10);
405
406 c.success = QColor("#2e7d32");
407 c.error = QColor("#c62828");
408 c.warning = QColor("#f57c00");
409 c.info = QColor("#1976d2");
410 c.favorite = QColor("#ffc107");
411
412 c.border = systemPalette.color(QPalette::Mid);
413 c.borderLight = systemPalette.color(QPalette::Midlight);
414
418 }
419
420 return theme;
421}
422
423Theme ThemeManager::createStandardDarkTheme()
424{
425 Theme theme;
426 theme.id = QStringLiteral("standard-dark");
427 theme.displayName = QStringLiteral("Standard Dark");
428 theme.defaultAccent = QColor("#5294e2"); // Standard blue accent
429
430 ThemeColors& c = theme.colors;
431
432 // Classic dark theme backgrounds
433 c.windowBackground = QColor("#1e1e1e");
434 c.panelBackground = QColor("#252526");
435 c.cardBackground = QColor("#2d2d2d");
436 c.inputBackground = QColor("#3c3c3c");
437 c.hoverBackground = QColor("#404040");
438
439 // Text
440 c.textPrimary = QColor("#d4d4d4");
441 c.textSecondary = QColor("#a0a0a0");
442 c.textMuted = QColor("#6e6e6e");
443 c.textOnAccent = QColor("#ffffff");
444
445 // Accent
446 c.accent = theme.defaultAccent;
449
450 // Semantic colors
451 c.success = QColor("#4ec9b0");
452 c.error = QColor("#f14c4c");
453 c.warning = QColor("#cca700");
454 c.info = QColor("#3794ff");
455 c.favorite = QColor("#ffd700");
456
457 // Borders
458 c.border = QColor("#454545");
459 c.borderLight = QColor("#3c3c3c");
460
461 // Scrollbar
462 c.scrollbarTrack = QColor("#1e1e1e");
463 c.scrollbarThumb = QColor("#424242");
464 c.scrollbarThumbHover = QColor("#4f4f4f");
465
466 return theme;
467}
468
469Theme ThemeManager::createCachyOSEmeraldTheme()
470{
471 Theme theme;
472 theme.id = QStringLiteral("cachyos-emerald");
473 theme.displayName = QStringLiteral("CachyOS Emerald");
474 // CachyOS brand cyan/teal - matches the CachyOS logo and website
475 theme.defaultAccent = QColor("#0db1a8");
476
477 ThemeColors& c = theme.colors;
478
479 // Backgrounds - dark with slight cool undertone
480 c.windowBackground = QColor("#181a1b");
481 c.panelBackground = QColor("#1e2122");
482 c.cardBackground = QColor("#262a2b");
483 c.inputBackground = QColor("#2a2e30");
484 c.hoverBackground = QColor("#2f3537");
485
486 // Text - high contrast for readability
487 c.textPrimary = QColor("#e8eaeb");
488 c.textSecondary = QColor("#b0b5b8");
489 c.textMuted = QColor("#7a8185");
490 c.textOnAccent = QColor("#ffffff");
491
492 // Accent - CachyOS teal/cyan
493 c.accent = theme.defaultAccent;
494 c.accentHover = QColor("#15c9bf"); // Slightly brighter
495 c.accentPressed = QColor("#0a9a92"); // Slightly darker
496
497 // Semantic colors
498 c.success = QColor("#0db1a8"); // Match accent for consistency
499 c.error = QColor("#e05555"); // Softer red
500 c.warning = QColor("#e0a855"); // Warm amber
501 c.info = QColor("#55a8e0"); // Complementary blue
502 c.favorite = QColor("#e0c855"); // Gold/yellow
503
504 // Borders - subtle
505 c.border = QColor("#3a4042");
506 c.borderLight = QColor("#2a2e30");
507
508 // Scrollbar
509 c.scrollbarTrack = QColor("#1e2122");
510 c.scrollbarThumb = QColor("#3a4042");
511 c.scrollbarThumbHover = QColor("#4a5052");
512
513 return theme;
514}
515
516Theme ThemeManager::createNordDarkTheme()
517{
518 Theme theme;
519 theme.id = QStringLiteral("nord-dark");
520 theme.displayName = QStringLiteral("Nord Dark");
521 theme.defaultAccent = QColor("#88c0d0"); // Frost blue
522
523 ThemeColors& c = theme.colors;
524
525 // Nord Polar Night palette
526 c.windowBackground = QColor("#2e3440");
527 c.panelBackground = QColor("#3b4252");
528 c.cardBackground = QColor("#434c5e");
529 c.inputBackground = QColor("#4c566a");
530 c.hoverBackground = QColor("#4c566a");
531
532 // Nord Snow Storm
533 c.textPrimary = QColor("#eceff4");
534 c.textSecondary = QColor("#d8dee9");
535 c.textMuted = QColor("#a5b1c2");
536 c.textOnAccent = QColor("#2e3440");
537
538 // Accent
539 c.accent = theme.defaultAccent;
542
543 // Nord Aurora colors for semantic
544 c.success = QColor("#a3be8c");
545 c.error = QColor("#bf616a");
546 c.warning = QColor("#ebcb8b");
547 c.info = QColor("#81a1c1");
548 c.favorite = QColor("#ebcb8b");
549
550 // Borders
551 c.border = QColor("#4c566a");
552 c.borderLight = QColor("#434c5e");
553
554 // Scrollbar
555 c.scrollbarTrack = QColor("#3b4252");
556 c.scrollbarThumb = QColor("#4c566a");
557 c.scrollbarThumbHover = QColor("#5e6779");
558
559 return theme;
560}
561
562Theme ThemeManager::createDraculaTheme()
563{
564 Theme theme;
565 theme.id = QStringLiteral("dracula");
566 theme.displayName = QStringLiteral("Dracula");
567 theme.defaultAccent = QColor("#bd93f9"); // Purple
568
569 ThemeColors& c = theme.colors;
570
571 // Dracula background palette
572 c.windowBackground = QColor("#282a36");
573 c.panelBackground = QColor("#21222c");
574 c.cardBackground = QColor("#44475a");
575 c.inputBackground = QColor("#44475a");
576 c.hoverBackground = QColor("#6272a4");
577
578 // Text
579 c.textPrimary = QColor("#f8f8f2");
580 c.textSecondary = QColor("#bfbfb2");
581 c.textMuted = QColor("#6272a4");
582 c.textOnAccent = QColor("#282a36");
583
584 // Accent
585 c.accent = theme.defaultAccent;
588
589 // Dracula semantic colors
590 c.success = QColor("#50fa7b");
591 c.error = QColor("#ff5555");
592 c.warning = QColor("#ffb86c");
593 c.info = QColor("#8be9fd");
594 c.favorite = QColor("#f1fa8c");
595
596 // Borders
597 c.border = QColor("#6272a4");
598 c.borderLight = QColor("#44475a");
599
600 // Scrollbar
601 c.scrollbarTrack = QColor("#21222c");
602 c.scrollbarThumb = QColor("#44475a");
603 c.scrollbarThumbHover = QColor("#6272a4");
604
605 return theme;
606}
607
608Theme ThemeManager::createCatppuccinMochaTheme()
609{
610 Theme theme;
611 theme.id = QStringLiteral("catppuccin-mocha");
612 theme.displayName = QStringLiteral("Catppuccin Mocha");
613 theme.defaultAccent = QColor("#cba6f7"); // Mauve
614
615 ThemeColors& c = theme.colors;
616
617 // Catppuccin Mocha base colors
618 c.windowBackground = QColor("#1e1e2e");
619 c.panelBackground = QColor("#181825");
620 c.cardBackground = QColor("#313244");
621 c.inputBackground = QColor("#45475a");
622 c.hoverBackground = QColor("#585b70");
623
624 // Text
625 c.textPrimary = QColor("#cdd6f4");
626 c.textSecondary = QColor("#bac2de");
627 c.textMuted = QColor("#6c7086");
628 c.textOnAccent = QColor("#1e1e2e");
629
630 // Accent
631 c.accent = theme.defaultAccent;
634
635 // Catppuccin semantic colors
636 c.success = QColor("#a6e3a1");
637 c.error = QColor("#f38ba8");
638 c.warning = QColor("#fab387");
639 c.info = QColor("#89b4fa");
640 c.favorite = QColor("#f9e2af");
641
642 // Borders
643 c.border = QColor("#45475a");
644 c.borderLight = QColor("#313244");
645
646 // Scrollbar
647 c.scrollbarTrack = QColor("#181825");
648 c.scrollbarThumb = QColor("#45475a");
649 c.scrollbarThumbHover = QColor("#585b70");
650
651 return theme;
652}
653
654Theme ThemeManager::createGruvboxDarkTheme()
655{
656 Theme theme;
657 theme.id = QStringLiteral("gruvbox-dark");
658 theme.displayName = QStringLiteral("Gruvbox Dark");
659 theme.defaultAccent = QColor("#d79921"); // Yellow
660
661 ThemeColors& c = theme.colors;
662
663 // Gruvbox dark palette
664 c.windowBackground = QColor("#282828");
665 c.panelBackground = QColor("#1d2021");
666 c.cardBackground = QColor("#3c3836");
667 c.inputBackground = QColor("#504945");
668 c.hoverBackground = QColor("#665c54");
669
670 // Text
671 c.textPrimary = QColor("#ebdbb2");
672 c.textSecondary = QColor("#d5c4a1");
673 c.textMuted = QColor("#928374");
674 c.textOnAccent = QColor("#282828");
675
676 // Accent
677 c.accent = theme.defaultAccent;
680
681 // Gruvbox semantic colors
682 c.success = QColor("#b8bb26");
683 c.error = QColor("#fb4934");
684 c.warning = QColor("#fe8019");
685 c.info = QColor("#83a598");
686 c.favorite = QColor("#fabd2f");
687
688 // Borders
689 c.border = QColor("#504945");
690 c.borderLight = QColor("#3c3836");
691
692 // Scrollbar
693 c.scrollbarTrack = QColor("#1d2021");
694 c.scrollbarThumb = QColor("#504945");
695 c.scrollbarThumbHover = QColor("#665c54");
696
697 return theme;
698}
699
700Theme ThemeManager::createTokyoNightTheme()
701{
702 Theme theme;
703 theme.id = QStringLiteral("tokyo-night");
704 theme.displayName = QStringLiteral("Tokyo Night");
705 theme.defaultAccent = QColor("#7aa2f7"); // Blue
706
707 ThemeColors& c = theme.colors;
708
709 // Tokyo Night palette
710 c.windowBackground = QColor("#1a1b26");
711 c.panelBackground = QColor("#16161e");
712 c.cardBackground = QColor("#24283b");
713 c.inputBackground = QColor("#414868");
714 c.hoverBackground = QColor("#414868");
715
716 // Text
717 c.textPrimary = QColor("#c0caf5");
718 c.textSecondary = QColor("#a9b1d6");
719 c.textMuted = QColor("#565f89");
720 c.textOnAccent = QColor("#1a1b26");
721
722 // Accent
723 c.accent = theme.defaultAccent;
726
727 // Tokyo Night semantic colors
728 c.success = QColor("#9ece6a");
729 c.error = QColor("#f7768e");
730 c.warning = QColor("#e0af68");
731 c.info = QColor("#7dcfff");
732 c.favorite = QColor("#e0af68");
733
734 // Borders
735 c.border = QColor("#414868");
736 c.borderLight = QColor("#24283b");
737
738 // Scrollbar
739 c.scrollbarTrack = QColor("#16161e");
740 c.scrollbarThumb = QColor("#414868");
741 c.scrollbarThumbHover = QColor("#565f89");
742
743 return theme;
744}
745
746// ==============================================================================
747// Light Themes
748// ==============================================================================
749
750Theme ThemeManager::createStandardLightTheme()
751{
752 Theme theme;
753 theme.id = QStringLiteral("standard-light");
754 theme.displayName = QStringLiteral("Standard Light");
755 theme.defaultAccent = QColor("#0078d4"); // Microsoft-style blue
756
757 ThemeColors& c = theme.colors;
758
759 // Clean light backgrounds
760 c.windowBackground = QColor("#f5f5f5");
761 c.panelBackground = QColor("#ffffff");
762 c.cardBackground = QColor("#fafafa");
763 c.inputBackground = QColor("#ffffff");
764 c.hoverBackground = QColor("#e8e8e8");
765
766 // Dark text for contrast
767 c.textPrimary = QColor("#1a1a1a");
768 c.textSecondary = QColor("#444444");
769 c.textMuted = QColor("#888888");
770 c.textOnAccent = QColor("#ffffff");
771
772 // Accent
773 c.accent = theme.defaultAccent;
774 c.accentHover = darkenColor(c.accent, 10);
776
777 // Semantic colors (darker for light mode readability)
778 c.success = QColor("#107c10");
779 c.error = QColor("#d13438");
780 c.warning = QColor("#ca5010");
781 c.info = QColor("#0078d4");
782 c.favorite = QColor("#ffb900");
783
784 // Borders
785 c.border = QColor("#d1d1d1");
786 c.borderLight = QColor("#e5e5e5");
787
788 // Scrollbar
789 c.scrollbarTrack = QColor("#f0f0f0");
790 c.scrollbarThumb = QColor("#c1c1c1");
791 c.scrollbarThumbHover = QColor("#a1a1a1");
792
793 return theme;
794}
795
796Theme ThemeManager::createNordLightTheme()
797{
798 Theme theme;
799 theme.id = QStringLiteral("nord-light");
800 theme.displayName = QStringLiteral("Nord Light");
801 theme.defaultAccent = QColor("#5e81ac"); // Nord Frost darker blue
802
803 ThemeColors& c = theme.colors;
804
805 // Nord Snow Storm palette for backgrounds
806 c.windowBackground = QColor("#eceff4");
807 c.panelBackground = QColor("#e5e9f0");
808 c.cardBackground = QColor("#d8dee9");
809 c.inputBackground = QColor("#eceff4");
810 c.hoverBackground = QColor("#d8dee9");
811
812 // Nord Polar Night for text
813 c.textPrimary = QColor("#2e3440");
814 c.textSecondary = QColor("#3b4252");
815 c.textMuted = QColor("#4c566a");
816 c.textOnAccent = QColor("#eceff4");
817
818 // Accent
819 c.accent = theme.defaultAccent;
820 c.accentHover = darkenColor(c.accent, 10);
822
823 // Nord Aurora colors (adjusted for light bg)
824 c.success = QColor("#a3be8c");
825 c.error = QColor("#bf616a");
826 c.warning = QColor("#d08770");
827 c.info = QColor("#81a1c1");
828 c.favorite = QColor("#ebcb8b");
829
830 // Borders
831 c.border = QColor("#d8dee9");
832 c.borderLight = QColor("#e5e9f0");
833
834 // Scrollbar
835 c.scrollbarTrack = QColor("#e5e9f0");
836 c.scrollbarThumb = QColor("#b8c5d4");
837 c.scrollbarThumbHover = QColor("#9fb3c7");
838
839 return theme;
840}
841
842Theme ThemeManager::createCatppuccinLatteTheme()
843{
844 Theme theme;
845 theme.id = QStringLiteral("catppuccin-latte");
846 theme.displayName = QStringLiteral("Catppuccin Latte");
847 theme.defaultAccent = QColor("#8839ef"); // Mauve
848
849 ThemeColors& c = theme.colors;
850
851 // Catppuccin Latte base colors
852 c.windowBackground = QColor("#eff1f5"); // Base
853 c.panelBackground = QColor("#e6e9ef"); // Mantle
854 c.cardBackground = QColor("#dce0e8"); // Crust
855 c.inputBackground = QColor("#ccd0da"); // Surface0
856 c.hoverBackground = QColor("#bcc0cc"); // Surface1
857
858 // Text
859 c.textPrimary = QColor("#4c4f69"); // Text
860 c.textSecondary = QColor("#5c5f77"); // Subtext1
861 c.textMuted = QColor("#6c6f85"); // Subtext0
862 c.textOnAccent = QColor("#eff1f5");
863
864 // Accent
865 c.accent = theme.defaultAccent;
866 c.accentHover = darkenColor(c.accent, 10);
868
869 // Catppuccin Latte semantic colors
870 c.success = QColor("#40a02b"); // Green
871 c.error = QColor("#d20f39"); // Red
872 c.warning = QColor("#df8e1d"); // Yellow
873 c.info = QColor("#1e66f5"); // Blue
874 c.favorite = QColor("#df8e1d"); // Yellow
875
876 // Borders
877 c.border = QColor("#bcc0cc"); // Surface1
878 c.borderLight = QColor("#ccd0da"); // Surface0
879
880 // Scrollbar
881 c.scrollbarTrack = QColor("#e6e9ef");
882 c.scrollbarThumb = QColor("#acb0be"); // Surface2
883 c.scrollbarThumbHover = QColor("#9ca0b0"); // Overlay0
884
885 return theme;
886}
887
888Theme ThemeManager::createGruvboxLightTheme()
889{
890 Theme theme;
891 theme.id = QStringLiteral("gruvbox-light");
892 theme.displayName = QStringLiteral("Gruvbox Light");
893 theme.defaultAccent = QColor("#b57614"); // Yellow (dark variant for light bg)
894
895 ThemeColors& c = theme.colors;
896
897 // Gruvbox light palette
898 c.windowBackground = QColor("#fbf1c7"); // bg
899 c.panelBackground = QColor("#f9f5d7"); // bg0_h (hard)
900 c.cardBackground = QColor("#ebdbb2"); // bg1
901 c.inputBackground = QColor("#d5c4a1"); // bg2
902 c.hoverBackground = QColor("#bdae93"); // bg3
903
904 // Text (dark gruvbox colors)
905 c.textPrimary = QColor("#3c3836"); // fg
906 c.textSecondary = QColor("#504945"); // fg1
907 c.textMuted = QColor("#665c54"); // fg2
908 c.textOnAccent = QColor("#fbf1c7");
909
910 // Accent
911 c.accent = theme.defaultAccent;
912 c.accentHover = darkenColor(c.accent, 10);
914
915 // Gruvbox semantic colors (dark variants)
916 c.success = QColor("#79740e"); // Green
917 c.error = QColor("#9d0006"); // Red
918 c.warning = QColor("#b57614"); // Yellow
919 c.info = QColor("#076678"); // Blue
920 c.favorite = QColor("#b57614"); // Yellow
921
922 // Borders
923 c.border = QColor("#bdae93"); // bg3
924 c.borderLight = QColor("#d5c4a1"); // bg2
925
926 // Scrollbar
927 c.scrollbarTrack = QColor("#f9f5d7");
928 c.scrollbarThumb = QColor("#a89984"); // gray
929 c.scrollbarThumbHover = QColor("#928374"); // gray darker
930
931 return theme;
932}
933
934Theme ThemeManager::createSolarizedLightTheme()
935{
936 Theme theme;
937 theme.id = QStringLiteral("solarized-light");
938 theme.displayName = QStringLiteral("Solarized Light");
939 theme.defaultAccent = QColor("#268bd2"); // Blue
940
941 ThemeColors& c = theme.colors;
942
943 // Solarized light palette
944 c.windowBackground = QColor("#fdf6e3"); // base3
945 c.panelBackground = QColor("#eee8d5"); // base2
946 c.cardBackground = QColor("#fdf6e3"); // base3
947 c.inputBackground = QColor("#eee8d5"); // base2
948 c.hoverBackground = QColor("#d6d0bb"); // slightly darker
949
950 // Text
951 c.textPrimary = QColor("#657b83"); // base00
952 c.textSecondary = QColor("#586e75"); // base01
953 c.textMuted = QColor("#93a1a1"); // base1
954 c.textOnAccent = QColor("#fdf6e3");
955
956 // Accent
957 c.accent = theme.defaultAccent;
958 c.accentHover = darkenColor(c.accent, 10);
960
961 // Solarized accent colors
962 c.success = QColor("#859900"); // Green
963 c.error = QColor("#dc322f"); // Red
964 c.warning = QColor("#cb4b16"); // Orange
965 c.info = QColor("#268bd2"); // Blue
966 c.favorite = QColor("#b58900"); // Yellow
967
968 // Borders
969 c.border = QColor("#93a1a1"); // base1
970 c.borderLight = QColor("#eee8d5"); // base2
971
972 // Scrollbar
973 c.scrollbarTrack = QColor("#eee8d5");
974 c.scrollbarThumb = QColor("#93a1a1");
975 c.scrollbarThumbHover = QColor("#839496");
976
977 return theme;
978}
979
980// ==============================================================================
981// Theme Selection
982// ==============================================================================
983
984std::vector<QString> ThemeManager::getAvailableThemeIds() const
985{
986 // Return in a curated order: auto first, then system, then dark themes, then light themes
987 std::vector<QString> ids;
988 ids.reserve(themes_.size());
989
990 // Auto and system first
991 static const QString orderedIds[] = {
992 QStringLiteral("auto"),
993 QStringLiteral("system"),
994 QStringLiteral("standard-dark"),
995 QStringLiteral("standard-light"),
996 QStringLiteral("cachyos-emerald"),
997 QStringLiteral("nord-dark"),
998 QStringLiteral("dracula"),
999 QStringLiteral("catppuccin-mocha"),
1000 QStringLiteral("gruvbox-dark"),
1001 QStringLiteral("tokyo-night"),
1002 QStringLiteral("nord-light"),
1003 QStringLiteral("catppuccin-latte"),
1004 QStringLiteral("gruvbox-light"),
1005 QStringLiteral("solarized-light"),
1006 };
1007
1008 for (const auto& id : orderedIds)
1009 {
1010 if (themes_.find(id) != themes_.end())
1011 {
1012 ids.push_back(id);
1013 }
1014 }
1015
1016 // Add any remaining themes not in the ordered list
1017 for (const auto& [id, theme] : themes_)
1018 {
1019 if (std::find(ids.begin(), ids.end(), id) == ids.end())
1020 {
1021 ids.push_back(id);
1022 }
1023 }
1024
1025 return ids;
1026}
1027
1028const Theme* ThemeManager::getTheme(const QString& id) const
1029{
1030 auto it = themes_.find(id);
1031 if (it != themes_.end())
1032 {
1033 return &it->second;
1034 }
1035 return nullptr;
1036}
1037
1039{
1040 return getTheme(currentThemeId_);
1041}
1042
1044{
1045 return currentThemeId_;
1046}
1047
1048void ThemeManager::setTheme(const QString& themeId)
1049{
1050 if (themes_.find(themeId) == themes_.end())
1051 {
1052 return;
1053 }
1054
1055 if (currentThemeId_ != themeId)
1056 {
1057 currentThemeId_ = themeId;
1058 updateEffectiveColors();
1059 refreshAllWidgetStyles();
1060 emit themeChanged();
1061 }
1062}
1063
1064// ==============================================================================
1065// Accent Color Customization
1066// ==============================================================================
1067
1068void ThemeManager::setAccentColor(const QColor& color)
1069{
1070 if (color.isValid())
1071 {
1072 customAccentColor_ = color;
1073 useCustomAccent_ = true;
1074 updateEffectiveColors();
1075 refreshAllWidgetStyles();
1076 emit themeChanged();
1077 }
1078}
1079
1081{
1082 return effectiveColors_.accent;
1083}
1084
1086{
1087 return useCustomAccent_;
1088}
1089
1091{
1092 useCustomAccent_ = false;
1093 customAccentColor_ = QColor();
1094 updateEffectiveColors();
1095 refreshAllWidgetStyles();
1096 emit themeChanged();
1097}
1098
1099// ==============================================================================
1100// Color Access
1101// ==============================================================================
1102
1104{
1105 return effectiveColors_;
1106}
1107
1108// ==============================================================================
1109// Effective Colors Update
1110// ==============================================================================
1111
1112void ThemeManager::updateEffectiveColors()
1113{
1114 const Theme* theme = currentTheme();
1115 if (!theme)
1116 {
1117 return;
1118 }
1119
1120 // Start with theme's base colors
1121 effectiveColors_ = theme->colors;
1122
1123 // Apply custom accent if set
1124 if (useCustomAccent_ && customAccentColor_.isValid())
1125 {
1126 effectiveColors_.accent = customAccentColor_;
1127 effectiveColors_.accentHover = lightenColor(customAccentColor_, 15);
1128 effectiveColors_.accentPressed = darkenColor(customAccentColor_, 15);
1129 }
1130}
1131
1132void ThemeManager::refreshAllWidgetStyles()
1133{
1135
1136 // Force all widgets to update their styles
1137 for (QWidget* widget : QApplication::allWidgets())
1138 {
1139 widget->style()->unpolish(widget);
1140 widget->style()->polish(widget);
1141 widget->update();
1142 }
1143}
1144
1145// ==============================================================================
1146// Color Utilities
1147// ==============================================================================
1148
1149QColor ThemeManager::ensureContrast(const QColor& fg, const QColor& bg, int minDiff)
1150{
1151 // Ensure foreground has sufficient lightness difference from background
1152 int fgL = fg.lightness();
1153 int bgL = bg.lightness();
1154 int diff = qAbs(fgL - bgL);
1155 if (diff >= minDiff)
1156 return fg;
1157
1158 // Need more contrast — push fg away from bg
1159 int h, s, l, a;
1160 fg.getHsl(&h, &s, &l, &a);
1161 if (bgL < 128)
1162 {
1163 // Dark background: make fg lighter
1164 l = qMin(255, bgL + minDiff);
1165 }
1166 else
1167 {
1168 // Light background: make fg darker
1169 l = qMax(0, bgL - minDiff);
1170 }
1171 return QColor::fromHsl(h, s, l, a);
1172}
1173
1174QColor ThemeManager::lightenColor(const QColor& color, int amount)
1175{
1176 int h, s, l, a;
1177 color.getHsl(&h, &s, &l, &a);
1178 l = qMin(255, l + amount);
1179 return QColor::fromHsl(h, s, l, a);
1180}
1181
1182QColor ThemeManager::darkenColor(const QColor& color, int amount)
1183{
1184 int h, s, l, a;
1185 color.getHsl(&h, &s, &l, &a);
1186 l = qMax(0, l - amount);
1187 return QColor::fromHsl(h, s, l, a);
1188}
1189
1190// ==============================================================================
1191// Application Styling
1192// ==============================================================================
1193
1195{
1196 // Generate theme-aware indicator icons (checkmark/radio dot)
1197 generateIndicatorIcons();
1198
1199 // Apply scaled font to application
1200 qApp->setFont(applicationFont());
1201
1202 // Apply palette to application
1203 qApp->setPalette(buildPalette());
1204
1205 // Apply global stylesheet for widgets not covered by palette
1206 qApp->setStyleSheet(buildStyleSheet());
1207}
1208
1209void ThemeManager::generateIndicatorIcons()
1210{
1211 // Write SVG icons with current textOnAccent color for theme-aware checkbox/radio indicators
1212 QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
1213 QDir().mkpath(cacheDir);
1214
1215 const QString color = effectiveColors_.textOnAccent.name();
1216
1217 // Checkmark SVG
1218 checkmarkIconPath_ = cacheDir + "/checkmark.svg";
1219 QFile checkFile(checkmarkIconPath_);
1220 if (checkFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
1221 {
1222 checkFile.write(
1223 QString("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>"
1224 "<path d='M3.5 8.5L6.5 11.5L12.5 4.5' stroke='%1' stroke-width='2.5' "
1225 "stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>")
1226 .arg(color)
1227 .toUtf8());
1228 checkFile.close();
1229 }
1230
1231 // Radio dot SVG
1232 radioDotIconPath_ = cacheDir + "/radio_dot.svg";
1233 QFile radioFile(radioDotIconPath_);
1234 if (radioFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
1235 {
1236 radioFile.write(QString("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>"
1237 "<circle cx='8' cy='8' r='4' fill='%1'/></svg>")
1238 .arg(color)
1239 .toUtf8());
1240 radioFile.close();
1241 }
1242}
1243
1245{
1246 QPalette palette;
1247 const ThemeColors& c = effectiveColors_;
1248
1249 // Ensure text has sufficient contrast against its background
1250 QColor textOnWin = ensureContrast(c.textPrimary, c.windowBackground);
1251 QColor textOnBase = ensureContrast(c.textPrimary, c.panelBackground);
1252 QColor textOnBtn = ensureContrast(c.textPrimary, c.cardBackground);
1253
1254 // Window and general backgrounds
1255 palette.setColor(QPalette::Window, c.windowBackground);
1256 palette.setColor(QPalette::Base, c.panelBackground);
1257 palette.setColor(QPalette::AlternateBase, c.cardBackground);
1258 palette.setColor(QPalette::Button, c.cardBackground);
1259
1260 // Text colors — contrast-ensured against their respective backgrounds
1261 palette.setColor(QPalette::WindowText, textOnWin);
1262 palette.setColor(QPalette::Text, textOnBase);
1263 palette.setColor(QPalette::ButtonText, textOnBtn);
1264 palette.setColor(QPalette::BrightText, c.textOnAccent);
1265 palette.setColor(QPalette::PlaceholderText, c.textMuted);
1266
1267 // Highlights
1268 palette.setColor(QPalette::Highlight, c.accent);
1269 palette.setColor(QPalette::HighlightedText, c.textOnAccent);
1270
1271#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
1272 // QPalette::Accent was added in Qt 6.6. Widgets that care about a distinct
1273 // "accent" color (progress bars, switches, focus rings on some styles) read
1274 // this role in preference to Highlight. Setting it lets Plasma 6 / GNOME 48
1275 // respect our chosen accent while keeping Highlight for selection shading.
1276 palette.setColor(QPalette::Accent, c.accent);
1277#endif
1278
1279 // Links
1280 palette.setColor(QPalette::Link, c.info);
1281 palette.setColor(QPalette::LinkVisited, c.accent);
1282
1283 // Disabled state
1284 palette.setColor(QPalette::Disabled, QPalette::WindowText, c.textMuted);
1285 palette.setColor(QPalette::Disabled, QPalette::Text, c.textMuted);
1286 palette.setColor(QPalette::Disabled, QPalette::ButtonText, c.textMuted);
1287 palette.setColor(QPalette::Disabled, QPalette::Button, c.inputBackground);
1288
1289 // Tooltips
1290 palette.setColor(QPalette::ToolTipBase, c.cardBackground);
1291 palette.setColor(QPalette::ToolTipText, c.textPrimary);
1292
1293 return palette;
1294}
1295
1297{
1298 const ThemeColors& c = effectiveColors_;
1299
1300 // =========================================================================
1301 // Global stylesheet — modern, cohesive styling for all Qt widgets
1302 // =========================================================================
1303 // Color map:
1304 // %1 = scrollbarTrack (unused) %2 = scrollbarThumb
1305 // %3 = scrollbarThumbHover %4 = cardBackground
1306 // %5 = textPrimary %6 = border
1307 // %7 = accent %8 = inputBackground
1308 // %9 = panelBackground %10 = textSecondary
1309 // %11 = hoverBackground %12 = textOnAccent
1310 // %13 = accentHover %14 = borderLight
1311 // %15 = windowBackground %16 = textMuted
1312 // %17 = accentPressed %18 = success
1313 // %19 = error
1314 // =========================================================================
1315
1316 // Build accent color with alpha for selection backgrounds
1317 QColor accentFaded = c.accent;
1318 accentFaded.setAlpha(180); // Strong enough for readable contrast
1319 QString accentFadedStr = accentFaded.name(QColor::HexArgb);
1320
1321 // Ensure all text colors have sufficient contrast against their backgrounds
1322 QColor textOnCard = ensureContrast(c.textPrimary, c.cardBackground);
1323 QColor textSecOnCard = ensureContrast(c.textSecondary, c.cardBackground, 80);
1324
1325 return QString(
1326 // =================================================================
1327 // Reserved placeholders (must appear so chained .arg() doesn't skip)
1328 // %1=scrollbarTrack %17=accentPressed %18=success %19=error
1329 // =================================================================
1330 "/* %1 %17 %18 %19 */"
1331
1332 // =================================================================
1333 // Scrollbars — thin, rounded, transparent track
1334 // =================================================================
1335 "QScrollBar:vertical {"
1336 " background: transparent;"
1337 " width: 8px;"
1338 " margin: 0;"
1339 "}"
1340 "QScrollBar::handle:vertical {"
1341 " background: %2;"
1342 " min-height: 24px;"
1343 " border-radius: 4px;"
1344 " margin: 1px;"
1345 "}"
1346 "QScrollBar::handle:vertical:hover {"
1347 " background: %3;"
1348 "}"
1349 "QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {"
1350 " height: 0;"
1351 "}"
1352 "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
1353 " background: none;"
1354 "}"
1355 "QScrollBar:horizontal {"
1356 " background: transparent;"
1357 " height: 8px;"
1358 " margin: 0;"
1359 "}"
1360 "QScrollBar::handle:horizontal {"
1361 " background: %2;"
1362 " min-width: 24px;"
1363 " border-radius: 4px;"
1364 " margin: 1px;"
1365 "}"
1366 "QScrollBar::handle:horizontal:hover {"
1367 " background: %3;"
1368 "}"
1369 "QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {"
1370 " width: 0;"
1371 "}"
1372 "QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {"
1373 " background: none;"
1374 "}"
1375
1376 // =================================================================
1377 // Tooltips — elevated card with accent border
1378 // =================================================================
1379 "QToolTip {"
1380 " background-color: %4;"
1381 " color: %5;"
1382 " border: 1px solid %7;"
1383 " padding: 6px 10px;"
1384 " border-radius: 6px;"
1385 "}"
1386
1387 // =================================================================
1388 // Menus — rounded, padded, with smooth selection
1389 // =================================================================
1390 "QMenu {"
1391 " background-color: %4;"
1392 " border: 1px solid %14;"
1393 " border-radius: 8px;"
1394 " padding: 6px 4px;"
1395 "}"
1396 "QMenu::item {"
1397 " padding: 8px 32px 8px 16px;"
1398 " border-radius: 4px;"
1399 " margin: 1px 4px;"
1400 " color: %5;"
1401 "}"
1402 "QMenu::item:selected {"
1403 " background-color: %20;"
1404 " color: %12;"
1405 "}"
1406 "QMenu::item:checked {"
1407 " color: %5;"
1408 "}"
1409 "QMenu::item:checked:selected {"
1410 " color: %12;"
1411 "}"
1412 "QMenu::item:disabled {"
1413 " color: %16;"
1414 " background-color: transparent;"
1415 "}"
1416 "QMenu::indicator {"
1417 " width: 14px;"
1418 " height: 14px;"
1419 " margin-left: 6px;"
1420 "}"
1421 "QMenu::separator {"
1422 " height: 1px;"
1423 " background: %14;"
1424 " margin: 4px 10px;"
1425 "}"
1426 "QMenu::icon {"
1427 " padding-left: 8px;"
1428 "}"
1429
1430 // =================================================================
1431 // ComboBox — modern input with hover accent
1432 // =================================================================
1433 "QComboBox {"
1434 " background-color: %8;"
1435 " border: 1px solid %6;"
1436 " border-radius: 6px;"
1437 " padding: 5px 10px;"
1438 " color: %5;"
1439 " min-height: 20px;"
1440 "}"
1441 "QComboBox:hover {"
1442 " border-color: %7;"
1443 "}"
1444 "QComboBox:focus {"
1445 " border-color: %7;"
1446 "}"
1447 "QComboBox::drop-down {"
1448 " border: none;"
1449 " width: 24px;"
1450 " subcontrol-position: right center;"
1451 "}"
1452 "QComboBox QAbstractItemView {"
1453 " background-color: %4;"
1454 " color: %5;"
1455 " border: 1px solid %14;"
1456 " border-radius: 6px;"
1457 " padding: 4px;"
1458 " outline: none;"
1459 " selection-background-color: %20;"
1460 " selection-color: %12;"
1461 "}"
1462 "QComboBox QAbstractItemView::item {"
1463 " padding: 4px 8px;"
1464 " color: %5;"
1465 "}"
1466 "QComboBox QAbstractItemView::item:selected {"
1467 " color: %12;"
1468 "}"
1469
1470 // =================================================================
1471 // LineEdit — clean input field
1472 // =================================================================
1473 "QLineEdit {"
1474 " background-color: %8;"
1475 " border: 1px solid %6;"
1476 " border-radius: 6px;"
1477 " padding: 5px 10px;"
1478 " color: %5;"
1479 " selection-background-color: %7;"
1480 " selection-color: %12;"
1481 "}"
1482 "QLineEdit:focus {"
1483 " border-color: %7;"
1484 "}"
1485 "QLineEdit:disabled {"
1486 " color: %16;"
1487 " background-color: %15;"
1488 "}"
1489
1490 // =================================================================
1491 // SpinBox / DoubleSpinBox
1492 // =================================================================
1493 "QSpinBox, QDoubleSpinBox {"
1494 " background-color: %8;"
1495 " border: 1px solid %6;"
1496 " border-radius: 6px;"
1497 " padding: 5px 10px;"
1498 " color: %5;"
1499 "}"
1500 "QSpinBox:focus, QDoubleSpinBox:focus {"
1501 " border-color: %7;"
1502 "}"
1503 "QSpinBox::up-button, QDoubleSpinBox::up-button,"
1504 "QSpinBox::down-button, QDoubleSpinBox::down-button {"
1505 " border: none;"
1506 " width: 16px;"
1507 "}"
1508
1509 // =================================================================
1510 // TextEdit / PlainTextEdit
1511 // =================================================================
1512 "QTextEdit, QPlainTextEdit {"
1513 " background-color: %8;"
1514 " border: 1px solid %6;"
1515 " border-radius: 6px;"
1516 " padding: 6px;"
1517 " color: %5;"
1518 " selection-background-color: %7;"
1519 " selection-color: %12;"
1520 "}"
1521 "QTextEdit:focus, QPlainTextEdit:focus {"
1522 " border-color: %7;"
1523 "}"
1524
1525 // =================================================================
1526 // TabWidget — flat, underline-indicator style
1527 // =================================================================
1528 "QTabWidget::pane {"
1529 " border: 1px solid %14;"
1530 " border-top: none;"
1531 " background-color: %9;"
1532 "}"
1533 "QTabBar::tab {"
1534 " background-color: transparent;"
1535 " border: none;"
1536 " border-bottom: 2px solid transparent;"
1537 " padding: 9px 18px;"
1538 " margin-right: 2px;"
1539 " color: %10;"
1540 "}"
1541 "QTabBar::tab:selected {"
1542 " color: %7;"
1543 " border-bottom: 2px solid %7;"
1544 "}"
1545 "QTabBar::tab:hover:!selected {"
1546 " color: %5;"
1547 " border-bottom: 2px solid %14;"
1548 "}"
1549
1550 // =================================================================
1551 // GroupBox — accent left border, subtle header
1552 // =================================================================
1553 "QGroupBox {"
1554 " border: 1px solid %14;"
1555 " border-left: 3px solid %7;"
1556 " border-radius: 6px;"
1557 " margin-top: 16px;"
1558 " padding: 12px 8px 8px 8px;"
1559 " color: %5;"
1560 "}"
1561 "QGroupBox::title {"
1562 " subcontrol-origin: margin;"
1563 " left: 12px;"
1564 " padding: 0 6px;"
1565 " color: %7;"
1566 " font-weight: bold;"
1567 " font-size: 11px;"
1568 "}"
1569
1570 // =================================================================
1571 // CheckBox — accent-filled when checked
1572 // =================================================================
1573 "QCheckBox {"
1574 " color: %5;"
1575 " spacing: 8px;"
1576 "}"
1577 "QCheckBox::indicator {"
1578 " width: 18px;"
1579 " height: 18px;"
1580 " border: 2px solid %6;"
1581 " border-radius: 4px;"
1582 " background-color: %8;"
1583 "}"
1584 "QCheckBox::indicator:checked {"
1585 " background-color: %7;"
1586 " border-color: %7;"
1587 " image: url(" +
1588 checkmarkIconPath_ +
1589 ");"
1590 "}"
1591 "QCheckBox::indicator:hover {"
1592 " border-color: %7;"
1593 "}"
1594 "QCheckBox::indicator:disabled {"
1595 " background-color: %15;"
1596 " border-color: %14;"
1597 "}"
1598
1599 // =================================================================
1600 // RadioButton
1601 // =================================================================
1602 "QRadioButton {"
1603 " color: %5;"
1604 " spacing: 8px;"
1605 "}"
1606 "QRadioButton::indicator {"
1607 " width: 18px;"
1608 " height: 18px;"
1609 " border: 2px solid %6;"
1610 " border-radius: 9px;"
1611 " background-color: %8;"
1612 "}"
1613 "QRadioButton::indicator:checked {"
1614 " background-color: %7;"
1615 " border-color: %7;"
1616 " image: url(" +
1617 radioDotIconPath_ +
1618 ");"
1619 "}"
1620 "QRadioButton::indicator:hover {"
1621 " border-color: %7;"
1622 "}"
1623 "QRadioButton::indicator:disabled {"
1624 " background-color: %15;"
1625 " border-color: %14;"
1626 "}"
1627
1628 // =================================================================
1629 // ProgressBar — thin pill with accent chunk
1630 // =================================================================
1631 "QProgressBar {"
1632 " background-color: %8;"
1633 " border: none;"
1634 " border-radius: 4px;"
1635 " text-align: center;"
1636 " color: %5;"
1637 " max-height: 8px;"
1638 "}"
1639 "QProgressBar::chunk {"
1640 " background-color: %7;"
1641 " border-radius: 4px;"
1642 "}"
1643
1644 // =================================================================
1645 // Slider — modern track with accent handle
1646 // =================================================================
1647 "QSlider::groove:horizontal {"
1648 " background: %8;"
1649 " height: 4px;"
1650 " border-radius: 2px;"
1651 "}"
1652 "QSlider::handle:horizontal {"
1653 " background: %7;"
1654 " width: 16px;"
1655 " height: 16px;"
1656 " margin: -6px 0;"
1657 " border-radius: 8px;"
1658 " border: 2px solid %7;"
1659 "}"
1660 "QSlider::handle:horizontal:hover {"
1661 " background: %13;"
1662 " border-color: %13;"
1663 "}"
1664 "QSlider::sub-page:horizontal {"
1665 " background: %7;"
1666 " border-radius: 2px;"
1667 "}"
1668
1669 // =================================================================
1670 // PushButton — card surface with hover glow
1671 // =================================================================
1672 "QPushButton {"
1673 " background-color: %4;"
1674 " color: %5;"
1675 " border: 1px solid %6;"
1676 " border-radius: 6px;"
1677 " padding: 7px 16px;"
1678 " font-weight: 500;"
1679 "}"
1680 "QPushButton:hover {"
1681 " background-color: %11;"
1682 " border-color: %7;"
1683 "}"
1684 "QPushButton:pressed {"
1685 " background-color: %8;"
1686 " border-color: %7;"
1687 "}"
1688 "QPushButton:disabled {"
1689 " color: %16;"
1690 " background-color: %15;"
1691 " border-color: %14;"
1692 "}"
1693 "QPushButton:focus {"
1694 " outline: none;"
1695 " border-color: %7;"
1696 "}"
1697
1698 // =================================================================
1699 // ToolButton
1700 // =================================================================
1701 "QToolButton {"
1702 " border: 1px solid transparent;"
1703 " border-radius: 6px;"
1704 " padding: 4px;"
1705 "}"
1706 "QToolButton:hover {"
1707 " background-color: %11;"
1708 " border-color: %14;"
1709 "}"
1710 "QToolButton:pressed {"
1711 " background-color: %8;"
1712 "}"
1713 "QToolButton:focus {"
1714 " outline: none;"
1715 " border-color: %7;"
1716 "}"
1717
1718 // =================================================================
1719 // ScrollArea
1720 // =================================================================
1721 "QScrollArea {"
1722 " border: none;"
1723 " background: transparent;"
1724 "}"
1725
1726 // =================================================================
1727 // HeaderView (table/tree column headers)
1728 // =================================================================
1729 "QHeaderView::section {"
1730 " background-color: %9;"
1731 " color: %10;"
1732 " border: none;"
1733 " border-bottom: 2px solid %14;"
1734 " padding: 8px 10px;"
1735 " font-weight: bold;"
1736 " font-size: 11px;"
1737 " text-transform: uppercase;"
1738 "}"
1739 "QHeaderView::section:hover {"
1740 " color: %5;"
1741 " background-color: %11;"
1742 "}"
1743
1744 // =================================================================
1745 // TreeWidget / TreeView — modern selection & hover
1746 // =================================================================
1747 "QTreeView, QTreeWidget {"
1748 " background-color: %4;"
1749 " alternate-background-color: %9;"
1750 " border: 1px solid %14;"
1751 " border-radius: 6px;"
1752 " outline: none;"
1753 " selection-background-color: %20;"
1754 " selection-color: %5;"
1755 "}"
1756 "QTreeView::item, QTreeWidget::item {"
1757 " padding: 4px 8px;"
1758 " border-radius: 4px;"
1759 " margin: 1px 2px;"
1760 "}"
1761 "QTreeView::item:hover, QTreeWidget::item:hover {"
1762 " background-color: %11;"
1763 "}"
1764 "QTreeView::item:selected, QTreeWidget::item:selected {"
1765 " background-color: %20;"
1766 " color: %5;"
1767 "}"
1768
1769 // =================================================================
1770 // TableView / TableWidget
1771 // =================================================================
1772 "QTableView, QTableWidget {"
1773 " background-color: %4;"
1774 " alternate-background-color: %9;"
1775 " border: 1px solid %14;"
1776 " border-radius: 6px;"
1777 " gridline-color: %14;"
1778 " outline: none;"
1779 " selection-background-color: %20;"
1780 " selection-color: %5;"
1781 "}"
1782
1783 // =================================================================
1784 // ListView / ListWidget
1785 // =================================================================
1786 "QListView, QListWidget {"
1787 " background-color: %4;"
1788 " border: 1px solid %14;"
1789 " border-radius: 6px;"
1790 " outline: none;"
1791 "}"
1792 "QListView::item, QListWidget::item {"
1793 " border-radius: 4px;"
1794 " margin: 1px 2px;"
1795 "}"
1796 "QListView::item:hover, QListWidget::item:hover {"
1797 " background-color: %11;"
1798 "}"
1799 "QListView::item:selected, QListWidget::item:selected {"
1800 " background-color: %20;"
1801 " color: %5;"
1802 "}"
1803
1804 // =================================================================
1805 // Splitter — subtle handle with accent on hover
1806 // =================================================================
1807 "QSplitter::handle {"
1808 " background-color: %14;"
1809 "}"
1810 "QSplitter::handle:horizontal {"
1811 " width: 1px;"
1812 "}"
1813 "QSplitter::handle:vertical {"
1814 " height: 1px;"
1815 "}"
1816 "QSplitter::handle:hover {"
1817 " background-color: %7;"
1818 "}"
1819
1820 // =================================================================
1821 // Dialog base
1822 // =================================================================
1823 "QDialog {"
1824 " background-color: %15;"
1825 " color: %5;"
1826 "}"
1827 "QDialog QLabel {"
1828 " color: %5;"
1829 "}"
1830 "QDialog QGroupBox {"
1831 " color: %5;"
1832 "}"
1833
1834 // =================================================================
1835 // MessageBox
1836 // =================================================================
1837 "QMessageBox {"
1838 " background-color: %4;"
1839 " color: %5;"
1840 "}"
1841 "QMessageBox QLabel {"
1842 " color: %5;"
1843 " background-color: transparent;"
1844 "}"
1845 "QMessageBox QPushButton {"
1846 " background-color: %8;"
1847 " color: %5;"
1848 " border: 1px solid %6;"
1849 " border-radius: 4px;"
1850 " padding: 6px 16px;"
1851 " min-width: 70px;"
1852 "}"
1853 "QMessageBox QPushButton:hover {"
1854 " background-color: %11;"
1855 "}"
1856 "QMessageBox QPushButton:pressed {"
1857 " background-color: %7;"
1858 " color: %12;"
1859 "}"
1860
1861 // =================================================================
1862 // StatusBar
1863 // =================================================================
1864 "QStatusBar {"
1865 " background-color: %9;"
1866 " border-top: 1px solid %14;"
1867 " color: %10;"
1868 "}"
1869
1870 // =================================================================
1871 // Frame separator
1872 // =================================================================
1873 "QFrame[frameShape=\"4\"] {"
1874 " color: %14;"
1875 " max-height: 1px;"
1876 "}"
1877 "QFrame[frameShape=\"5\"] {"
1878 " color: %14;"
1879 " max-width: 1px;"
1880 "}"
1881
1882 // =================================================================
1883 // DialogButtonBox — accent OK, subtle Cancel
1884 // =================================================================
1885 "QDialogButtonBox QPushButton {"
1886 " min-width: 80px;"
1887 " padding: 7px 20px;"
1888 "}"
1889
1890 // =================================================================
1891 // Disabled text globally
1892 // =================================================================
1893 "QLabel:disabled {"
1894 " color: %16;"
1895 "}"
1896
1897 // =================================================================
1898 // Link-style labels
1899 // =================================================================
1900 "QLabel[link=\"true\"] {"
1901 " color: %7;"
1902 "}"
1903
1904 // =================================================================
1905 // Search/filter line edits — rounded pill shape
1906 // =================================================================
1907 "QLineEdit[placeholderText~=\"Search\"],"
1908 "QLineEdit[placeholderText~=\"search\"],"
1909 "QLineEdit[placeholderText~=\"Filter\"] {"
1910 " border-radius: 12px;"
1911 " padding: 5px 14px;"
1912 "}")
1913 .arg(c.scrollbarTrack.name()) // %1 (unused, kept for stability)
1914 .arg(c.scrollbarThumb.name()) // %2
1915 .arg(c.scrollbarThumbHover.name()) // %3
1916 .arg(c.cardBackground.name()) // %4
1917 .arg(textOnCard.name()) // %5 (textPrimary, contrast-ensured vs card)
1918 .arg(c.border.name()) // %6
1919 .arg(c.accent.name()) // %7
1920 .arg(c.inputBackground.name()) // %8
1921 .arg(c.panelBackground.name()) // %9
1922 .arg(textSecOnCard.name()) // %10 (textSecondary, contrast-ensured)
1923 .arg(c.hoverBackground.name()) // %11
1924 .arg(c.textOnAccent.name()) // %12
1925 .arg(c.accentHover.name()) // %13
1926 .arg(c.borderLight.name()) // %14
1927 .arg(c.windowBackground.name()) // %15
1928 .arg(textSecOnCard.name()) // %16 (disabled items — contrast-ensured)
1929 .arg(c.accentPressed.name()) // %17
1930 .arg(c.success.name()) // %18
1931 .arg(c.error.name()) // %19
1932 .arg(accentFadedStr); // %20 (accent with alpha for selections)
1933}
1934
1936{
1937 const ThemeColors& c = effectiveColors_;
1938
1939 // Ensure menu text has guaranteed contrast against menu background
1940 QColor menuText = ensureContrast(c.textPrimary, c.cardBackground);
1941 QColor menuDisabled = ensureContrast(c.textSecondary, c.cardBackground, 60);
1942
1943 QColor accentHighlight = c.accent;
1944 accentHighlight.setAlpha(180);
1945
1946 return QString("/* %2 */" // reserved placeholder (must appear so chained .arg() doesn't skip)
1947 "QMenu {"
1948 " background-color: %1;"
1949 " border: 1px solid %6;"
1950 " border-radius: 8px;"
1951 " padding: 6px 4px;"
1952 "}"
1953 "QMenu::item {"
1954 " padding: 8px 32px 8px 16px;"
1955 " border-radius: 4px;"
1956 " margin: 1px 4px;"
1957 " color: %3;"
1958 "}"
1959 "QMenu::item:selected {"
1960 " background-color: %4;"
1961 " color: %7;"
1962 "}"
1963 "QMenu::item:checked {"
1964 " color: %3;"
1965 "}"
1966 "QMenu::item:checked:selected {"
1967 " color: %7;"
1968 "}"
1969 "QMenu::item:disabled {"
1970 " color: %5;"
1971 " background-color: transparent;"
1972 "}"
1973 "QMenu::indicator {"
1974 " width: 14px;"
1975 " height: 14px;"
1976 " margin-left: 6px;"
1977 "}"
1978 "QMenu::separator {"
1979 " height: 1px;"
1980 " background: %6;"
1981 " margin: 4px 10px;"
1982 "}"
1983 "QMenu::icon {"
1984 " padding-left: 8px;"
1985 "}")
1986 .arg(c.cardBackground.name()) // %1
1987 .arg(c.border.name()) // %2 (unused)
1988 .arg(menuText.name()) // %3
1989 .arg(accentHighlight.name(QColor::HexArgb)) // %4
1990 .arg(menuDisabled.name()) // %5 (disabled items)
1991 .arg(c.borderLight.name()) // %6
1992 .arg(c.textOnAccent.name()); // %7 (selected text)
1993}
1994
1995void ThemeManager::styleMenu(QMenu* menu) const
1996{
1997 if (!menu)
1998 return;
1999
2000 const ThemeColors& c = effectiveColors_;
2001
2002 // Set stylesheet
2003 menu->setStyleSheet(menuStyleSheet());
2004
2005 // Also set palette directly as belt-and-suspenders for Wayland/KDE
2006 QColor menuText = ensureContrast(c.textPrimary, c.cardBackground);
2007 QPalette p = menu->palette();
2008 p.setColor(QPalette::Active, QPalette::WindowText, menuText);
2009 p.setColor(QPalette::Active, QPalette::Text, menuText);
2010 p.setColor(QPalette::Active, QPalette::ButtonText, menuText);
2011 p.setColor(QPalette::Active, QPalette::Window, c.cardBackground);
2012 p.setColor(QPalette::Active, QPalette::Base, c.cardBackground);
2013 p.setColor(QPalette::Active, QPalette::Highlight, c.accent);
2014 p.setColor(QPalette::Active, QPalette::HighlightedText, c.textOnAccent);
2015 p.setColor(QPalette::Inactive, QPalette::WindowText, menuText);
2016 p.setColor(QPalette::Inactive, QPalette::Text, menuText);
2017 p.setColor(QPalette::Inactive, QPalette::ButtonText, menuText);
2018 p.setColor(QPalette::Inactive, QPalette::Window, c.cardBackground);
2019 p.setColor(QPalette::Inactive, QPalette::Base, c.cardBackground);
2020 p.setColor(QPalette::Inactive, QPalette::Highlight, c.accent);
2021 p.setColor(QPalette::Inactive, QPalette::HighlightedText, c.textOnAccent);
2022 p.setColor(QPalette::Disabled, QPalette::WindowText, c.textMuted);
2023 p.setColor(QPalette::Disabled, QPalette::Text, c.textMuted);
2024 p.setColor(QPalette::Disabled, QPalette::ButtonText, c.textMuted);
2025 menu->setPalette(p);
2026}
2027
2028// ==============================================================================
2029// Persistence
2030// ==============================================================================
2031
2033{
2034 if (!settingsController_)
2035 {
2036 return;
2037 }
2038
2039 auto settings = settingsController_->getAppSettings();
2040 settings.themeId = currentThemeId_.toStdString();
2041 settings.customAccentColor = useCustomAccent_ ? customAccentColor_.name().toStdString() : "";
2042 settings.uiZoom = zoomLevel_;
2043 settings.fontFamily = fontFamily_.toStdString();
2044 settingsController_->setAppSettings(settings);
2045}
2046
2048{
2049 if (!settingsController_)
2050 {
2051 return;
2052 }
2053
2054 const auto& settings = settingsController_->getAppSettings();
2055
2056 // Load theme ID
2057 QString themeId = QString::fromStdString(settings.themeId);
2058
2059 // Check for first-run wizard theme override (wizard runs before settings controller exists)
2060 QSettings qSettings;
2061 QString wizardTheme = qSettings.value("app/wizardThemeId", "").toString();
2062 if (!wizardTheme.isEmpty())
2063 {
2064 // Use the wizard-selected theme and clear the override
2065 if (themes_.find(wizardTheme) != themes_.end())
2066 {
2067 themeId = wizardTheme;
2068 }
2069 qSettings.remove("app/wizardThemeId");
2070 }
2071
2072 if (themes_.find(themeId) != themes_.end())
2073 {
2074 currentThemeId_ = themeId;
2075 }
2076 else
2077 {
2078 currentThemeId_ = QStringLiteral("auto"); // Default to auto theme
2079 }
2080
2081 // Load custom accent
2082 if (!settings.customAccentColor.empty())
2083 {
2084 QColor color(QString::fromStdString(settings.customAccentColor));
2085 if (color.isValid())
2086 {
2087 customAccentColor_ = color;
2088 useCustomAccent_ = true;
2089 }
2090 }
2091
2092 // Load zoom and font settings
2093 zoomLevel_ = std::clamp(settings.uiZoom, 75, 150);
2094 fontFamily_ = QString::fromStdString(settings.fontFamily);
2095
2096 updateEffectiveColors();
2097}
2098
2099// ==============================================================================
2100// UI Scaling
2101// ==============================================================================
2102
2104{
2105 return zoomLevel_;
2106}
2107
2109{
2110 percent = std::clamp(percent, 75, 150);
2111 if (zoomLevel_ != percent)
2112 {
2113 zoomLevel_ = percent;
2115 emit zoomChanged();
2116 }
2117}
2118
2120{
2121 return fontFamily_;
2122}
2123
2124void ThemeManager::setFontFamily(const QString& family)
2125{
2126 if (fontFamily_ != family)
2127 {
2128 fontFamily_ = family;
2130 emit zoomChanged();
2131 }
2132}
2133
2134int ThemeManager::scaledFontSize(int baseSize) const
2135{
2136 // std::lround rounds half-away-from-zero correctly for both signs;
2137 // `static_cast<int>(x + 0.5)` truncates toward zero and silently
2138 // rounds negatives the wrong way (bugprone-incorrect-roundings).
2139 return static_cast<int>(std::lround(baseSize * zoomLevel_ / 100.0));
2140}
2141
2142int ThemeManager::scaledSize(int baseSize) const
2143{
2144 return static_cast<int>(std::lround(baseSize * zoomLevel_ / 100.0));
2145}
2146
2147QFont ThemeManager::scaledFont(const QFont& baseFont) const
2148{
2149 QFont font = baseFont;
2150
2151 // Apply custom font family if set
2152 if (!fontFamily_.isEmpty())
2153 {
2154 font.setFamily(fontFamily_);
2155 }
2156
2157 // Apply zoom scaling
2158 if (zoomLevel_ != 100)
2159 {
2160 int scaledSize = static_cast<int>(std::lround(font.pointSize() * zoomLevel_ / 100.0));
2161 font.setPointSize(std::max(6, scaledSize)); // Minimum 6pt
2162 }
2163
2164 return font;
2165}
2166
2168{
2169 QFont font = QApplication::font();
2170
2171 // Cache base font size on first call (baseFontSize_ is mutable)
2172 if (baseFontSize_ == 0)
2173 {
2174 baseFontSize_ = font.pointSize();
2175 if (baseFontSize_ <= 0)
2176 baseFontSize_ = 10; // Default fallback
2177 }
2178
2179 // Apply custom font family if set
2180 if (!fontFamily_.isEmpty())
2181 {
2182 font.setFamily(fontFamily_);
2183 }
2184
2185 // Apply zoom scaling
2186 int scaledSize = static_cast<int>(std::lround(baseFontSize_ * zoomLevel_ / 100.0));
2187 font.setPointSize(std::max(6, scaledSize));
2188
2189 return font;
2190}
static ThemeManager & instance()
void applyToApplication()
Apply current theme to the entire application.
QPalette buildPalette() const
Build QPalette from current theme.
static QColor ensureContrast(const QColor &fg, const QColor &bg, int minDiff=120)
Ensure foreground has sufficient contrast against background.
void resetAccentToDefault()
Reset accent to theme default.
static QColor darkenColor(const QColor &color, int amount)
Darken a color by decreasing its lightness.
QString currentThemeId() const
Get current theme ID.
QString buildStyleSheet() const
Build global stylesheet for widgets not covered by QPalette.
QString fontFamily() const
Get current font family (empty = system default).
bool hasCustomAccent() const
Check if using custom accent color.
void loadFromSettings()
Load theme settings from settings controller.
void styleMenu(QMenu *menu) const
Apply complete menu styling (stylesheet + palette) to a QMenu.
void setAccentColor(const QColor &color)
Set custom accent color (overrides theme default).
int scaledSize(int baseSize) const
Get scaled dimension for layouts/spacing.
void initialize(core::SettingsController *settingsController)
void setFontFamily(const QString &family)
Set font family.
void themeChanged()
Emitted when theme or accent color changes.
static QColor lightenColor(const QColor &color, int amount)
Lighten a color by increasing its lightness.
const Theme * getTheme(const QString &id) const
Get theme by ID (returns nullptr if not found).
void setZoomLevel(int percent)
Set zoom level (75-150).
int scaledFontSize(int baseSize) const
Get scaled font size for given base size.
QString menuStyleSheet() const
Get standalone menu stylesheet (for dynamically created menus).
int zoomLevel() const
Get current zoom level (75-150, default 100).
void setTheme(const QString &themeId)
Set active theme by ID.
void zoomChanged()
Emitted when zoom level or font changes.
const Theme * currentTheme() const
Get current theme.
const ThemeColors & colors() const
Get effective colors (with accent customization applied).
ThemeManager(const ThemeManager &)=delete
QFont scaledFont(const QFont &baseFont) const
Get scaled font (applies zoom + custom family if set).
std::vector< QString > getAvailableThemeIds() const
Get list of available theme IDs.
void saveToSettings()
Save theme settings to settings controller.
QColor accentColor() const
Get current accent color (custom or theme default).
QFont applicationFont() const
Get the base application font (with zoom and custom family applied).
QColor favorite
QColor panelBackground
QColor inputBackground
QColor borderLight
QColor cardBackground
QColor textSecondary
QColor scrollbarTrack
QColor textPrimary
QColor accentHover
QColor scrollbarThumbHover
QColor windowBackground
QColor scrollbarThumb
QColor textMuted
QColor hoverBackground
QColor accentPressed
QColor textOnAccent
ThemeColors colors
QString displayName
QString id
QColor defaultAccent