Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 222:b9f111d84d95 | 229:adc20fa321c1 |
|---|---|
| 9 # include "sys/osx/dark_theme.h" | 9 # include "sys/osx/dark_theme.h" |
| 10 #elif WIN32 | 10 #elif WIN32 |
| 11 # include "sys/win32/dark_theme.h" | 11 # include "sys/win32/dark_theme.h" |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 /* This is, believe it or not, one of the hardest things I've implemented :/ | 14 /* Weird quirks of this implementation: |
| 15 1. Dark mode stuff in Qt changes a lot and Qt 5 and Qt 6 are massively different | 15 * 1. Dark mode stuff in Qt changes a lot and Qt 5 and Qt 6 are massively different |
| 16 2. Some widgets, i.e. QTabWidget, QTabBar, etc., just completely IGNORE the QPalette setting | 16 * 2. Some widgets, i.e. QTabWidget, QTabBar, etc., just completely IGNORE the QPalette setting |
| 17 3. I don't want to use the Fusion style on every single platform | 17 * on different platforms and the only way to fix it is by using Fusion |
| 18 4. Windows dark mode support in Qt 6.5 (with Fusion) is completely unavoidable | 18 * 3. Windows dark mode support in Qt 6.5 (with Fusion) is completely unavoidable |
| 19 (not a joke btw, it's retarded) | 19 * I think what I might end up doing is forcing the Fusion style on any platforms that isn't |
| 20 These four already make it really difficult, but along with that, I don't even remember if | 20 * Windows or Mac. I'm not really fond of doing that, but it's the best way to achieve a "good" |
| 21 OS X dark mode support even works still; I remember the background of some of the widgets | 21 * visual style without a substaintial amount of fucking around and subsequent finding out. |
| 22 would refuse to update for whatever reason. */ | 22 */ |
| 23 | 23 |
| 24 namespace Theme { | 24 namespace Theme { |
| 25 | 25 |
| 26 Theme::Theme(Themes theme) { | 26 Theme::Theme(Themes theme) { |
| 27 this->theme = theme; | 27 this->theme = theme; |
| 112 pal.setColor(QPalette::Disabled, QPalette::WindowText, gray); | 112 pal.setColor(QPalette::Disabled, QPalette::WindowText, gray); |
| 113 pal.setColor(QPalette::Disabled, QPalette::Text, gray); | 113 pal.setColor(QPalette::Disabled, QPalette::Text, gray); |
| 114 pal.setColor(QPalette::Disabled, QPalette::Light, darkGray); | 114 pal.setColor(QPalette::Disabled, QPalette::Light, darkGray); |
| 115 qApp->setPalette(pal); | 115 qApp->setPalette(pal); |
| 116 | 116 |
| 117 #ifdef WIN32 | |
| 118 /* This is a dark style sheet that makes things look | |
| 119 * marginally better on Windows. | |
| 120 * | |
| 121 * I'm very close to just giving up and using Fusion | |
| 122 * everywhere. | |
| 123 */ | |
| 117 QFile f(":dark.qss"); | 124 QFile f(":dark.qss"); |
| 118 if (!f.exists()) | 125 if (!f.exists()) |
| 119 break; // how? | 126 break; // how? |
| 120 f.open(QFile::ReadOnly | QFile::Text); | 127 f.open(QFile::ReadOnly | QFile::Text); |
| 121 QTextStream ts(&f); | 128 QTextStream ts(&f); |
| 122 qApp->setStyleSheet(ts.readAll()); | 129 qApp->setStyleSheet(ts.readAll()); |
| 130 #endif | |
| 123 break; | 131 break; |
| 124 } | 132 } |
| 125 default: | 133 default: |
| 126 QPalette pal(QApplication::style()->standardPalette()); | 134 QPalette pal(QApplication::style()->standardPalette()); |
| 127 #ifdef WIN32 /* fuck you Qt 6 */ | 135 #ifdef WIN32 /* fuck you Qt 6 */ |
