diff 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
line wrap: on
line diff
--- a/src/gui/theme.cc	Wed Jan 10 21:23:57 2024 -0500
+++ b/src/gui/theme.cc	Sat Jan 13 09:42:02 2024 -0500
@@ -16,9 +16,6 @@
  *   2. Some widgets, i.e. QTabWidget, QTabBar, etc., just completely IGNORE the QPalette setting
  *      on different platforms and the only way to fix it is by using Fusion
  *   3. Windows dark mode support in Qt 6.5 (with Fusion) is completely unavoidable
- * I think what I might end up doing is forcing the Fusion style on any platforms that isn't
- * Windows or Mac. I'm not really fond of doing that, but it's the best way to achieve a "good"
- * visual style without a substaintial amount of fucking around and subsequent finding out.
 */
 
 namespace Theme {
@@ -88,10 +85,10 @@
 void Theme::SetStyleSheet(Themes theme) {
 	switch (theme) {
 		case Themes::DARK: {
-			QColor darkGray(53, 53, 53);
-			QColor gray(128, 128, 128);
-			QColor black(25, 25, 25);
-			QColor blue(42, 130, 218);
+			const QColor darkGray(53, 53, 53);
+			const QColor gray(128, 128, 128);
+			const QColor black(25, 25, 25);
+			const QColor blue(42, 130, 218);
 
 			QPalette pal(QApplication::style()->standardPalette());
 			pal.setColor(QPalette::Window, darkGray);
@@ -115,22 +112,20 @@
 			qApp->setPalette(pal);
 
 #ifdef WIN32
-			/* This is a dark style sheet that makes things look
-			 * marginally better on Windows.
-			 *
-			 * I'm very close to just giving up and using Fusion
-			 * everywhere.
-			*/
-			QFile f(":dark.qss");
-			if (!f.exists())
-				break; // how?
-			f.open(QFile::ReadOnly | QFile::Text);
-			QTextStream ts(&f);
-			qApp->setStyleSheet(ts.readAll());
+			qApp->setStyleSheet([]{
+				QFile f(":/dark.qss");
+				if (!f.exists())
+					return QStringLiteral("");
+				f.open(QFile::ReadOnly | QFile::Text);
+				QTextStream ts(&f);
+				return ts.readAll();
+			}());
 #endif
 			break;
 		}
 		default:
+			/* this sucks, it relies on the standard palette which
+			 * may or may not be a dark style itself. */
 			QPalette pal(QApplication::style()->standardPalette());
 #ifdef WIN32 /* fuck you Qt 6 */
 			pal.setColor(QPalette::Window, QColor(0xF0, 0xF0, 0xF0));