9
+ − 1 #include "sys/win32/dark_theme.h"
2
+ − 2 #include <QOperatingSystemVersion>
9
+ − 3 #include <QSettings>
+ − 4
+ − 5 namespace win32 {
+ − 6
+ − 7 bool DarkThemeAvailable() {
+ − 8 // dark mode supported Windows 10 1809 10.0.17763 onward
+ − 9 // https://stackoverflow.com/questions/53501268/win10-dark-theme-how-to-use-in-winapi
+ − 10 if (QOperatingSystemVersion::current().majorVersion() == 10) {
+ − 11 return QOperatingSystemVersion::current().microVersion() >= 17763;
+ − 12 } else if (QOperatingSystemVersion::current().majorVersion() > 10) {
+ − 13 return true;
+ − 14 } else {
+ − 15 return false;
+ − 16 }
2
+ − 17 }
+ − 18
9
+ − 19 bool IsInDarkTheme() {
15
+ − 20 QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
+ − 21 QSettings::NativeFormat);
9
+ − 22 return settings.value("AppsUseLightTheme", 1).toInt() == 0;
2
+ − 23 }
9
+ − 24
+ − 25 } // namespace win32