mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 05:45:42 +03:00
Use existing fct for RegKeyQuery instead of redundant subroutine
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
parent
d6af025a46
commit
d60a216982
1 changed files with 7 additions and 26 deletions
|
@ -90,32 +90,13 @@ void setLaunchOnStartup_private(const QString &appName, const QString &guiName,
|
||||||
// TODO: Right now only detection on toggle/startup, not when windows theme is switched while nextcloud is running
|
// TODO: Right now only detection on toggle/startup, not when windows theme is switched while nextcloud is running
|
||||||
static inline bool hasDarkSystray_private()
|
static inline bool hasDarkSystray_private()
|
||||||
{
|
{
|
||||||
bool hasDarkSystray = true;
|
if(Utility::registryGetKeyValue( HKEY_CURRENT_USER,
|
||||||
// Open registry key first, continue only on success (may be legitimately absent in earlier windows versions)
|
"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
|
||||||
HKEY hKey;
|
"SystemUsesLightTheme" ) == 1) {
|
||||||
LONG lRes = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey);
|
return false;
|
||||||
|
}
|
||||||
// classical windows function - preserve buff size for DWORD, call ExW version, store regkey value in nResult
|
else {
|
||||||
if (lRes == ERROR_SUCCESS) {
|
return true;
|
||||||
DWORD dwBufferSize(sizeof(DWORD));
|
|
||||||
DWORD nResult(0);
|
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
|
|
||||||
LONG nError = ::RegQueryValueExW(hKey,
|
|
||||||
L"SystemUsesLightTheme",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
reinterpret_cast<LPBYTE>(&nResult),
|
|
||||||
&dwBufferSize);
|
|
||||||
|
|
||||||
// if RegQuery returned no error and light theme was found, change systray return value
|
|
||||||
if (nError == ERROR_SUCCESS && nResult == 1)
|
|
||||||
hasDarkSystray = false;
|
|
||||||
|
|
||||||
return hasDarkSystray;
|
|
||||||
} else {
|
|
||||||
// fallback to true if regkey could not be determined
|
|
||||||
return hasDarkSystray;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue