annotate src/gui/theme.cc @ 229:adc20fa321c1

theme: force Fusion style on platforms other than Win32 or OS X I was reluctant to do this, but most of the other styles just look like pure shite regardless of whether I force a stylesheet on them or not. KDE's style is actually hilariously bad paired with my stylesheet, so I've decided to also make the stylesheet Windows-specific as well, because that's really the only platform where it makes sense in the first place.
author Paper <paper@paper.us.eu.org>
date Wed, 10 Jan 2024 21:23:57 -0500
parents 01d259b9c89f
children 2f5a9247e501
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"
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include <QApplication>
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include <QFile>
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <QDebug>
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QTextStream>
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QStyleFactory>
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #ifdef MACOSX
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 # include "sys/osx/dark_theme.h"
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
10 #elif WIN32
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 # include "sys/win32/dark_theme.h"
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #endif
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13
229
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
14 /* 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
15 * 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
16 * 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
17 * 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
18 * 3. Windows dark mode support in Qt 6.5 (with Fusion) is completely unavoidable
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
19 * I think what I might end up doing is forcing the Fusion style on any platforms that isn't
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
20 * Windows or Mac. I'm not really fond of doing that, but it's the best way to achieve a "good"
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
21 * visual style without a substaintial amount of fucking around and subsequent finding out.
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
22 */
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 namespace Theme {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 Theme::Theme(Themes theme) {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 this->theme = theme;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
30 Themes Theme::GetTheme() const {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 return theme;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
34 bool Theme::IsInDarkTheme() const {
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 if (theme != Themes::OS)
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 return (theme == Themes::DARK);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 #ifdef MACOSX
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 if (osx::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 return osx::IsInDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 #elif defined(WIN32)
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 if (win32::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 return win32::IsInDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 #endif
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 return (theme == Themes::DARK);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 void Theme::SetToDarkTheme() {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 /* macOS >= 10.14 has its own global dark theme,
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 use it :) */
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
50 #ifdef MACOSX
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 if (osx::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 osx::SetToDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 else
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
54 #elif defined(WIN32)
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
55 if (win32::DarkThemeAvailable())
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
56 win32::SetTitleBarsToBlack(true);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 #endif
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 SetStyleSheet(Themes::DARK);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 void Theme::SetToLightTheme() {
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
62 #ifdef MACOSX
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 if (osx::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 osx::SetToLightTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 else
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
66 #elif defined(WIN32)
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
67 if (win32::DarkThemeAvailable())
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
68 win32::SetTitleBarsToBlack(false);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 #endif
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 SetStyleSheet(Themes::LIGHT);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
73 Themes Theme::GetCurrentOSTheme() const {
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
74 #ifdef MACOSX
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 if (osx::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 return osx::IsInDarkTheme() ? Themes::DARK : Themes::LIGHT;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 #elif defined(WIN32)
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 if (win32::DarkThemeAvailable())
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 return win32::IsInDarkTheme() ? Themes::DARK : Themes::LIGHT;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 #endif
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 /* Currently OS detection only supports Windows and macOS.
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 Please don't be shy if you're willing to port it to other OSes
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 (or desktop environments, or window managers) */
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 return Themes::LIGHT;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 /* this function is private, and should stay that way */
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 void Theme::SetStyleSheet(Themes theme) {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 switch (theme) {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 case Themes::DARK: {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 QColor darkGray(53, 53, 53);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 QColor gray(128, 128, 128);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 QColor black(25, 25, 25);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 QColor blue(42, 130, 218);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
96 QPalette pal(QApplication::style()->standardPalette());
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
97 pal.setColor(QPalette::Window, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
98 pal.setColor(QPalette::WindowText, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
99 pal.setColor(QPalette::Base, black);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
100 pal.setColor(QPalette::AlternateBase, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
101 pal.setColor(QPalette::ToolTipBase, blue);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
102 pal.setColor(QPalette::ToolTipText, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
103 pal.setColor(QPalette::Text, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
104 pal.setColor(QPalette::Button, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
105 pal.setColor(QPalette::ButtonText, Qt::white);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
106 pal.setColor(QPalette::Link, blue);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
107 pal.setColor(QPalette::Highlight, blue);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
108 pal.setColor(QPalette::HighlightedText, Qt::black);
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
110 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
111 pal.setColor(QPalette::Disabled, QPalette::ButtonText, gray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
112 pal.setColor(QPalette::Disabled, QPalette::WindowText, gray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
113 pal.setColor(QPalette::Disabled, QPalette::Text, gray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
114 pal.setColor(QPalette::Disabled, QPalette::Light, darkGray);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
115 qApp->setPalette(pal);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
116
229
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
117 #ifdef WIN32
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
118 /* This is a dark style sheet that makes things look
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
119 * marginally better on Windows.
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
120 *
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
121 * I'm very close to just giving up and 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
122 * everywhere.
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
123 */
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
124 QFile f(":dark.qss");
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
125 if (!f.exists())
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
126 break; // how?
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
127 f.open(QFile::ReadOnly | QFile::Text);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
128 QTextStream ts(&f);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
129 qApp->setStyleSheet(ts.readAll());
229
adc20fa321c1 theme: force Fusion style on platforms other than Win32 or OS X
Paper <paper@paper.us.eu.org>
parents: 183
diff changeset
130 #endif
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 default:
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
134 QPalette pal(QApplication::style()->standardPalette());
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
135 #ifdef WIN32 /* fuck you Qt 6 */
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
136 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
137 #endif
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
138 pal.setColor(QPalette::WindowText, Qt::black);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
139 pal.setColor(QPalette::ToolTipText, Qt::black);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
140 pal.setColor(QPalette::Text, Qt::black);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
141 pal.setColor(QPalette::ButtonText, Qt::black);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
142 qApp->setPalette(pal);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
143
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
144 qApp->setStyleSheet("");
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
149 void Theme::SetTheme(Themes theme) {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150 switch (theme) {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 case Themes::LIGHT:
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 SetToLightTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 case Themes::DARK:
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 SetToDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157 case Themes::OS:
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 if (GetCurrentOSTheme() == Themes::LIGHT)
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159 SetToLightTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 else
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 SetToDarkTheme();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 break;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164 this->theme = theme;
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 }
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
167 void Theme::RepaintCurrentTheme() {
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
168 Theme::SetTheme(theme);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
169 }
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
170
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 } // namespace DarkTheme