annotate src/gui/theme.cc @ 351:c844f8bb87ce

gui/theme: add xsettings backend this also adds newly-necessary endianness methods in core/endian.h which just so happen to be constexpr as well
author Paper <paper@paper.us.eu.org>
date Sun, 14 Jul 2024 23:23:56 -0400
parents 91ac90a34003
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "core/config.h"
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/session.h"
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
3 #include "gui/theme.h"
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include <QApplication>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
5 #include <QDebug>
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QFile>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
7 #include <QStyleFactory>
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <QTextStream>
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
9 #include <QStyle>
291
9a88e1725fd2 *: refactor lots of stuff
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
10 #include <QtGlobal>
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #ifdef MACOSX
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 # include "sys/osx/dark_theme.h"
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
13 #elif defined(WIN32)
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 # include "sys/win32/dark_theme.h"
232
ff0061e75f0f theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
15 #else
ff0061e75f0f theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
16 # ifdef GLIB
ff0061e75f0f theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
17 # include "sys/glib/dark_theme.h"
ff0061e75f0f theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
18 # endif
351
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
19 # ifdef HAVE_XCB
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
20 # include "sys/x11/dark_theme.h"
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
21 # endif
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 #endif
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23
229
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
24 /* Weird quirks of this implementation:
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
25 * 1. Dark mode stuff in Qt changes a lot and Qt 5 and Qt 6 are massively different
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
26 * 2. Some widgets, i.e. QTabWidget, QTabBar, etc., just completely IGNORE the QPalette setting
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
27 * on different platforms and the only way to fix it is by using Fusion
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
28 * 3. Windows dark mode support in Qt 6.5 (with Fusion) is completely unavoidable
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
29 */
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 namespace Theme {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
33 ThemeManager::ThemeManager(Theme theme) {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 this->theme = theme;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
37 Theme ThemeManager::GetTheme() const {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 return theme;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
41 bool ThemeManager::IsInDarkTheme() const {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
42 switch (theme) {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
43 case Theme::Default:
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 #ifdef MACOSX
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
45 if (osx::DarkThemeAvailable())
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
46 return osx::IsInDarkTheme();
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 #elif defined(WIN32)
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
48 if (win32::DarkThemeAvailable())
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
49 return win32::IsInDarkTheme();
232
ff0061e75f0f theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
50 #else
351
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
51 # ifdef HAVE_XCB
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
52 if (x11::IsInDarkTheme())
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
53 return true;
232
ff0061e75f0f theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
54 # endif
351
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
55 # ifdef GLIB
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
56 if (glib::IsInDarkTheme())
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
57 return true;
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
58 # endif
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
59 break;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 #endif
351
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
61 default:
c844f8bb87ce gui/theme: add xsettings backend
Paper <paper@paper.us.eu.org>
parents: 305
diff changeset
62 break;
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
63 }
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
64 return (theme == Theme::Dark);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
67 void ThemeManager::SetToDarkTheme() {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 /* macOS >= 10.14 has its own global dark theme,
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 use it :) */
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
70 #ifdef MACOSX
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 if (osx::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 osx::SetToDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 else
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
74 #elif defined(WIN32)
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
75 if (win32::DarkThemeAvailable())
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
76 win32::SetTitleBarsToBlack(true);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 #endif
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
78 SetStyleSheet(Theme::Dark);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
81 void ThemeManager::SetToLightTheme() {
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
82 #ifdef MACOSX
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 if (osx::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 osx::SetToLightTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 else
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
86 #elif defined(WIN32)
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
87 if (win32::DarkThemeAvailable())
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
88 win32::SetTitleBarsToBlack(false);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 #endif
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
90 SetStyleSheet(Theme::Light);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
93 Theme ThemeManager::GetCurrentOSTheme() const {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
94 return IsInDarkTheme() ? Theme::Dark : Theme::Light;
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 /* this function is private, and should stay that way */
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
98 void ThemeManager::SetStyleSheet(Theme theme) {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 switch (theme) {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
100 case Theme::Dark: {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
101 const QColor darkGray(53, 53, 53);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
102 const QColor gray(128, 128, 128);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
103 const QColor black(25, 25, 25);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
104 const QColor blue(42, 130, 218);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105
305
91ac90a34003 core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
106 QPalette pal;
91ac90a34003 core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
107
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
108 pal.setColor(QPalette::Window, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
109 pal.setColor(QPalette::WindowText, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
110 pal.setColor(QPalette::Base, black);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
111 pal.setColor(QPalette::AlternateBase, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
112 pal.setColor(QPalette::ToolTipBase, blue);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
113 pal.setColor(QPalette::ToolTipText, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
114 pal.setColor(QPalette::Text, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
115 pal.setColor(QPalette::Button, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
116 pal.setColor(QPalette::ButtonText, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
117 pal.setColor(QPalette::Link, blue);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
118 pal.setColor(QPalette::Highlight, blue);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
119 pal.setColor(QPalette::HighlightedText, Qt::black);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
121 pal.setColor(QPalette::Active, QPalette::Button, gray.darker());
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
122 pal.setColor(QPalette::Disabled, QPalette::ButtonText, gray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
123 pal.setColor(QPalette::Disabled, QPalette::WindowText, gray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
124 pal.setColor(QPalette::Disabled, QPalette::Text, gray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
125 pal.setColor(QPalette::Disabled, QPalette::Light, darkGray);
305
91ac90a34003 core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
126
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
127 qApp->setPalette(pal);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
128
229
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
129 #ifdef WIN32
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
130 qApp->setStyleSheet([] {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
131 QFile f(":/dark.qss");
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
132 if (!f.exists())
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
133 return QStringLiteral("");
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
134 f.open(QFile::ReadOnly | QFile::Text);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
135 QTextStream ts(&f);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
136 return ts.readAll();
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 229
diff changeset
137 }());
229
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
138 #endif
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141 default:
305
91ac90a34003 core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents: 291
diff changeset
142 /* this sucks */
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
143 QPalette pal(QApplication::style()->standardPalette());
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
144 #ifdef WIN32 /* fuck you Qt 6 */
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
145 pal.setColor(QPalette::Window, QColor(0xF0, 0xF0, 0xF0));
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
146 #endif
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
147 qApp->setPalette(pal);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
148
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
149 qApp->setStyleSheet("");
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
154 void ThemeManager::SetTheme(Theme theme) {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 switch (theme) {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
156 case Theme::Light: SetToLightTheme(); break;
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
157 case Theme::Dark: SetToDarkTheme(); break;
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
158 case Theme::Default:
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
159 if (GetCurrentOSTheme() == Theme::Light)
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 SetToLightTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 else
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 SetToDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 this->theme = theme;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
168 void ThemeManager::RepaintCurrentTheme() {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
169 SetTheme(theme);
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
170 }
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
171
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
172 } // namespace Theme