annotate src/sys/win32/dark_theme.cpp @ 15:cde8f67a7c7d

*: update, megacommit :)
author Paper <mrpapersonic@gmail.com>
date Tue, 19 Sep 2023 22:36:08 -0400
parents 5c0397762b53
children 6481c5aed3e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
1 #include "sys/win32/dark_theme.h"
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
2 #include <QOperatingSystemVersion>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
3 #include <QSettings>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
4
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
5 namespace win32 {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
6
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
7 bool DarkThemeAvailable() {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
8 // dark mode supported Windows 10 1809 10.0.17763 onward
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
9 // https://stackoverflow.com/questions/53501268/win10-dark-theme-how-to-use-in-winapi
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
10 if (QOperatingSystemVersion::current().majorVersion() == 10) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
11 return QOperatingSystemVersion::current().microVersion() >= 17763;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
12 } else if (QOperatingSystemVersion::current().majorVersion() > 10) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
13 return true;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
14 } else {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
15 return false;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
16 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
17 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
18
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
19 bool IsInDarkTheme() {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
20 QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
21 QSettings::NativeFormat);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
22 return settings.value("AppsUseLightTheme", 1).toInt() == 0;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
23 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
24
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
25 } // namespace win32