mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-04-22 06:02:03 +02:00
windows: add support for system theme
Use registry "HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion /Themes/Personalize/AppsUseLightTheme" to check if system theme is supported and if it is dark or light. Removes "EnableDarkTheme" in favor of "AppTheme". Requires Windows SDK version 10.0.18362.0 to build with system theme support. Note: This does not watch for changes in system theme in runtime as the support for it requires Windows Runtime version 10.0.10240.0. GitLab: #723 Change-Id: Ice8f7936a90535f47dc1870d4f18215e062684ba
This commit is contained in:
parent
4b6c4b8a48
commit
956b7f7da5
6 changed files with 90 additions and 27 deletions
|
@ -164,7 +164,7 @@ Only 64-bit MSVC build can be compiled.
|
||||||
|
|
||||||
| | SDK | Toolset | MFC |
|
| | SDK | Toolset | MFC |
|
||||||
| ------------ | ------------ | ------- | ------ |
|
| ------------ | ------------ | ------- | ------ |
|
||||||
| Requirement: | 10.0.16299.0 | V142 | latest |
|
| Requirement: | 10.0.18362.0 | V142 | latest |
|
||||||
|
|
||||||
- Install Qt Vs Tools under extensions, and configure msvc2017_64 path under Qt Options. _See the Qt notes below._
|
- Install Qt Vs Tools under extensions, and configure msvc2017_64 path under Qt Options. _See the Qt notes below._
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ Only 64-bit MSVC build can be compiled.
|
||||||
```
|
```
|
||||||
|
|
||||||
> **SDK and Toolset** Note:
|
> **SDK and Toolset** Note:
|
||||||
> Jami can be build with more rencents Windows SDK and Toolset than the ones specified in the table above. However, if your have another version than SDK 10.0.16299.0 and/or Toolset v142 installed, you need to identify it according to the example below.
|
> Jami can be build with more recent Windows SDK and Toolset than the ones specified in the table above. However, if your have another version than SDK 10.0.18362.0 and/or Toolset v142 installed, you need to identify it according to the example below. For the SDK, you still need to have the required version in addition to the one you chose.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python build.py --install --sdk <your-sdk-version> --toolset <your-toolset-version>
|
python build.py --install --sdk <your-sdk-version> --toolset <your-toolset-version>
|
||||||
|
|
2
build.py
2
build.py
|
@ -32,7 +32,7 @@ OSX_DISTRIBUTION_NAME = "osx"
|
||||||
WIN32_DISTRIBUTION_NAME = "win32"
|
WIN32_DISTRIBUTION_NAME = "win32"
|
||||||
|
|
||||||
# vs vars
|
# vs vars
|
||||||
win_sdk_default = '10.0.16299.0'
|
win_sdk_default = '10.0.18362.0'
|
||||||
win_toolset_default = '142'
|
win_toolset_default = '142'
|
||||||
|
|
||||||
APT_BASED_DISTROS = [
|
APT_BASED_DISTROS = [
|
||||||
|
|
|
@ -210,10 +210,13 @@ def build(config_str, qtver, tests=False):
|
||||||
daemon_dir = os.path.dirname(repo_root_dir) + '\\daemon'
|
daemon_dir = os.path.dirname(repo_root_dir) + '\\daemon'
|
||||||
daemon_bin_dir = daemon_dir + '\\build\\x64\\ReleaseLib_win32\\bin'
|
daemon_bin_dir = daemon_dir + '\\build\\x64\\ReleaseLib_win32\\bin'
|
||||||
|
|
||||||
|
# We need to update the minimum SDK version to be able to
|
||||||
|
# build with system theme support
|
||||||
cmake_options = [
|
cmake_options = [
|
||||||
'-DCMAKE_PREFIX_PATH=' + qt_dir,
|
'-DCMAKE_PREFIX_PATH=' + qt_dir,
|
||||||
'-DCMAKE_INSTALL_PREFIX=' + daemon_bin_dir,
|
'-DCMAKE_INSTALL_PREFIX=' + daemon_bin_dir,
|
||||||
'-DLIBJAMI_INCLUDE_DIR=' + daemon_dir + '\\src\\jami'
|
'-DLIBJAMI_INCLUDE_DIR=' + daemon_dir + '\\src\\jami',
|
||||||
|
'-DCMAKE_SYSTEM_VERSION=10.0.18362.0'
|
||||||
]
|
]
|
||||||
if tests:
|
if tests:
|
||||||
cmake_options.append('-DENABLE_TESTS=true')
|
cmake_options.append('-DENABLE_TESTS=true')
|
||||||
|
|
|
@ -42,7 +42,6 @@ extern const QString defaultDownloadPath;
|
||||||
X(AcceptTransferBelow, 20) \
|
X(AcceptTransferBelow, 20) \
|
||||||
X(AutoAcceptFiles, true) \
|
X(AutoAcceptFiles, true) \
|
||||||
X(DisplayHyperlinkPreviews, true) \
|
X(DisplayHyperlinkPreviews, true) \
|
||||||
X(EnableDarkTheme, false) \
|
|
||||||
X(AppTheme, "System") \
|
X(AppTheme, "System") \
|
||||||
X(BaseZoom, 1.0) \
|
X(BaseZoom, 1.0) \
|
||||||
X(ParticipantsSide, false) \
|
X(ParticipantsSide, false) \
|
||||||
|
|
|
@ -599,6 +599,43 @@ settingsCallback(GSettings* self, gchar* key, gpointer user_data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>)
|
||||||
|
bool
|
||||||
|
readAppsUseLightThemeRegistry(bool getValue)
|
||||||
|
{
|
||||||
|
auto returnValue = true;
|
||||||
|
HKEY hKey;
|
||||||
|
auto lResult
|
||||||
|
= RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
|
TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"),
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&hKey);
|
||||||
|
|
||||||
|
if (lResult != ERROR_SUCCESS) {
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwBufferSize(sizeof(DWORD));
|
||||||
|
DWORD nResult(0);
|
||||||
|
LONG nError = ::RegQueryValueExW(hKey,
|
||||||
|
TEXT("AppsUseLightTheme"),
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
reinterpret_cast<LPBYTE>(&nResult),
|
||||||
|
&dwBufferSize);
|
||||||
|
if (nError != ERROR_SUCCESS) {
|
||||||
|
returnValue = false;
|
||||||
|
} else if (getValue) {
|
||||||
|
returnValue = !nResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
UtilsAdapter::isSystemThemeDark()
|
UtilsAdapter::isSystemThemeDark()
|
||||||
{
|
{
|
||||||
|
@ -636,15 +673,18 @@ UtilsAdapter::isSystemThemeDark()
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
qWarning("System theme detection is not implemented");
|
#if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>)
|
||||||
|
return readAppsUseLightThemeRegistry(true);
|
||||||
|
#else
|
||||||
|
qWarning("System theme detection is not implemented or is not supported");
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif // WIN32
|
||||||
|
#endif // __has_include(<gio/gio.h>)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
UtilsAdapter::useApplicationTheme()
|
UtilsAdapter::useApplicationTheme()
|
||||||
{
|
{
|
||||||
if (hasNativeDarkTheme()) {
|
|
||||||
QString theme = getAppValue(Settings::Key::AppTheme).toString();
|
QString theme = getAppValue(Settings::Key::AppTheme).toString();
|
||||||
if (theme == "Dark")
|
if (theme == "Dark")
|
||||||
return true;
|
return true;
|
||||||
|
@ -652,7 +692,18 @@ UtilsAdapter::useApplicationTheme()
|
||||||
return false;
|
return false;
|
||||||
return isSystemThemeDark();
|
return isSystemThemeDark();
|
||||||
}
|
}
|
||||||
bool enableDark = getAppValue(Settings::Key::EnableDarkTheme).toBool();
|
|
||||||
setAppValue(Settings::Key::AppTheme, enableDark ? "Dark" : "Light");
|
|
||||||
return enableDark;
|
bool
|
||||||
|
UtilsAdapter::hasNativeDarkTheme() const
|
||||||
|
{
|
||||||
|
#if __has_include(<gio/gio.h>)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
#if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>)
|
||||||
|
return readAppsUseLightThemeRegistry(false);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
|
@ -33,11 +33,28 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>)
|
||||||
|
#include <winrt/Windows.Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class QClipboard;
|
class QClipboard;
|
||||||
class SystemTray;
|
class SystemTray;
|
||||||
|
|
||||||
#define LOGSLIMIT 10000
|
#define LOGSLIMIT 10000
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>)
|
||||||
|
/**
|
||||||
|
* @brief Read if "AppsUseLightTheme" registry exists and its value
|
||||||
|
*
|
||||||
|
* @param getValue false to check if registry exists;
|
||||||
|
*
|
||||||
|
* @param getValue true if want the registry value.
|
||||||
|
* @return if getValue is true, returns if the native theme is Dark (defaults to false).
|
||||||
|
*/
|
||||||
|
bool readAppsUseLightThemeRegistry(bool getValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
class UtilsAdapter final : public QmlAdapterBase
|
class UtilsAdapter final : public QmlAdapterBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -112,14 +129,7 @@ public:
|
||||||
const QString& uri);
|
const QString& uri);
|
||||||
Q_INVOKABLE bool luma(const QColor& color) const;
|
Q_INVOKABLE bool luma(const QColor& color) const;
|
||||||
Q_INVOKABLE bool useApplicationTheme();
|
Q_INVOKABLE bool useApplicationTheme();
|
||||||
Q_INVOKABLE bool hasNativeDarkTheme() const
|
Q_INVOKABLE bool hasNativeDarkTheme() const;
|
||||||
{
|
|
||||||
#if __has_include(<gio/gio.h>)
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void debugMessageReceived(const QString& message);
|
void debugMessageReceived(const QString& message);
|
||||||
|
|
Loading…
Add table
Reference in a new issue