diff src/sys/win32/dark_theme.cc @ 81:9b2b41f83a5e

boring: mass rename to cc because this is a very unix-y project, it makes more sense to use the 'cc' extension
author Paper <mrpapersonic@gmail.com>
date Mon, 23 Oct 2023 12:07:27 -0400
parents src/sys/win32/dark_theme.cpp@6481c5aed3e1
children 6d8da6e64d61
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sys/win32/dark_theme.cc	Mon Oct 23 12:07:27 2023 -0400
@@ -0,0 +1,20 @@
+#include "sys/win32/dark_theme.h"
+#include <QOperatingSystemVersion>
+#include <QSettings>
+
+namespace win32 {
+
+bool DarkThemeAvailable() {
+	// dark mode supported Windows 10 1809 10.0.17763 onward
+	// https://stackoverflow.com/questions/53501268/win10-dark-theme-how-to-use-in-winapi
+	const auto& ver = QOperatingSystemVersion::current();
+	return (ver.majorVersion() > 10) ? true : (ver.majorVersion() == 10 && ver.microVersion() >= 17763);
+}
+
+bool IsInDarkTheme() {
+	QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
+	                   QSettings::NativeFormat);
+	return settings.value("AppsUseLightTheme", 1).toInt() == 0;
+}
+
+} // namespace win32