Mercurial > minori
comparison src/gui/theme.cc @ 230:2f5a9247e501
torrents: implement download button
erg
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Sat, 13 Jan 2024 09:42:02 -0500 |
| parents | adc20fa321c1 |
| children | ff0061e75f0f |
comparison
equal
deleted
inserted
replaced
| 229:adc20fa321c1 | 230:2f5a9247e501 |
|---|---|
| 14 /* Weird quirks of this implementation: | 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 * on different platforms and the only way to fix it is by using Fusion | 17 * on different platforms and the only way to fix it is by using Fusion |
| 18 * 3. 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 * I think what I might end up doing is forcing the Fusion style on any platforms that isn't | |
| 20 * Windows or Mac. I'm not really fond of doing that, but it's the best way to achieve a "good" | |
| 21 * visual style without a substaintial amount of fucking around and subsequent finding out. | |
| 22 */ | 19 */ |
| 23 | 20 |
| 24 namespace Theme { | 21 namespace Theme { |
| 25 | 22 |
| 26 Theme::Theme(Themes theme) { | 23 Theme::Theme(Themes theme) { |
| 86 | 83 |
| 87 /* this function is private, and should stay that way */ | 84 /* this function is private, and should stay that way */ |
| 88 void Theme::SetStyleSheet(Themes theme) { | 85 void Theme::SetStyleSheet(Themes theme) { |
| 89 switch (theme) { | 86 switch (theme) { |
| 90 case Themes::DARK: { | 87 case Themes::DARK: { |
| 91 QColor darkGray(53, 53, 53); | 88 const QColor darkGray(53, 53, 53); |
| 92 QColor gray(128, 128, 128); | 89 const QColor gray(128, 128, 128); |
| 93 QColor black(25, 25, 25); | 90 const QColor black(25, 25, 25); |
| 94 QColor blue(42, 130, 218); | 91 const QColor blue(42, 130, 218); |
| 95 | 92 |
| 96 QPalette pal(QApplication::style()->standardPalette()); | 93 QPalette pal(QApplication::style()->standardPalette()); |
| 97 pal.setColor(QPalette::Window, darkGray); | 94 pal.setColor(QPalette::Window, darkGray); |
| 98 pal.setColor(QPalette::WindowText, Qt::white); | 95 pal.setColor(QPalette::WindowText, Qt::white); |
| 99 pal.setColor(QPalette::Base, black); | 96 pal.setColor(QPalette::Base, black); |
| 113 pal.setColor(QPalette::Disabled, QPalette::Text, gray); | 110 pal.setColor(QPalette::Disabled, QPalette::Text, gray); |
| 114 pal.setColor(QPalette::Disabled, QPalette::Light, darkGray); | 111 pal.setColor(QPalette::Disabled, QPalette::Light, darkGray); |
| 115 qApp->setPalette(pal); | 112 qApp->setPalette(pal); |
| 116 | 113 |
| 117 #ifdef WIN32 | 114 #ifdef WIN32 |
| 118 /* This is a dark style sheet that makes things look | 115 qApp->setStyleSheet([]{ |
| 119 * marginally better on Windows. | 116 QFile f(":/dark.qss"); |
| 120 * | 117 if (!f.exists()) |
| 121 * I'm very close to just giving up and using Fusion | 118 return QStringLiteral(""); |
| 122 * everywhere. | 119 f.open(QFile::ReadOnly | QFile::Text); |
| 123 */ | 120 QTextStream ts(&f); |
| 124 QFile f(":dark.qss"); | 121 return ts.readAll(); |
| 125 if (!f.exists()) | 122 }()); |
| 126 break; // how? | |
| 127 f.open(QFile::ReadOnly | QFile::Text); | |
| 128 QTextStream ts(&f); | |
| 129 qApp->setStyleSheet(ts.readAll()); | |
| 130 #endif | 123 #endif |
| 131 break; | 124 break; |
| 132 } | 125 } |
| 133 default: | 126 default: |
| 127 /* this sucks, it relies on the standard palette which | |
| 128 * may or may not be a dark style itself. */ | |
| 134 QPalette pal(QApplication::style()->standardPalette()); | 129 QPalette pal(QApplication::style()->standardPalette()); |
| 135 #ifdef WIN32 /* fuck you Qt 6 */ | 130 #ifdef WIN32 /* fuck you Qt 6 */ |
| 136 pal.setColor(QPalette::Window, QColor(0xF0, 0xF0, 0xF0)); | 131 pal.setColor(QPalette::Window, QColor(0xF0, 0xF0, 0xF0)); |
| 137 #endif | 132 #endif |
| 138 pal.setColor(QPalette::WindowText, Qt::black); | 133 pal.setColor(QPalette::WindowText, Qt::black); |
