Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamila Ayres <hello@camila.codes>2019-09-06 18:01:53 +0300
committerGitHub <noreply@github.com>2019-09-06 18:01:53 +0300
commitc4dfe576d0f6b43c682f792b85022051696773f9 (patch)
tree2e4cea6f3d17db76afd1fd79f717a0b423c2baf1
parentc3b270ba261764534d6cfdd6d12c012a4fe9660a (diff)
parent0841fe8dd3256e90c64c754a04de2ec23bb0b103 (diff)
Merge pull request #1399 from DominiqueFuchs/master
Integrated registry check on windows when hasDarkSystray is called.
-rw-r--r--src/common/utility_win.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/common/utility_win.cpp b/src/common/utility_win.cpp
index e3e4234e8..3706a4605 100644
--- a/src/common/utility_win.cpp
+++ b/src/common/utility_win.cpp
@@ -87,9 +87,36 @@ 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
static inline bool hasDarkSystray_private()
{
- return true;
+ bool hasDarkSystray = true;
+ // Open registry key first, continue only on success (may be legitimately absent in earlier windows versions)
+ HKEY hKey;
+ LONG lRes = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey);
+
+ // classical windows function - preserve buff size for DWORD, call ExW version, store regkey value in nResult
+ if (lRes == ERROR_SUCCESS) {
+ 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;
+ }
}
QVariant Utility::registryGetKeyValue(HKEY hRootKey, const QString &subKey, const QString &valueName)