win: fix the border color, take 2

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-12-19 17:39:36 +08:00
parent a381836ef7
commit 768ab6da4b
2 changed files with 21 additions and 12 deletions

View File

@ -56,11 +56,6 @@ jobs:
if: ${{ matrix.platform == 'windows-latest' }}
uses: ilammy/msvc-dev-cmd@v1
- name: Install Linux dependencies
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
sudo apt install -y libxcb1-dev libgtk-3-dev
- name: Build library with CMake
run: |
mkdir ci-test-build

View File

@ -718,8 +718,11 @@ QColor Utils::getDwmColorizationColor()
if (!registry.isValid()) {
return kDefaultDarkGrayColor;
}
const DWORD value = registry.value<DWORD>(kColorizationColor).value_or(0);
return QColor::fromRgba(value);
const QVariant value = registry.value(kColorizationColor);
if (!value.isValid()) {
return kDefaultDarkGrayColor;
}
return QColor::fromRgba(qvariant_cast<DWORD>(value));
};
if (!API_DWM_AVAILABLE(DwmGetColorizationColor)) {
return resultFromRegistry();
@ -1229,10 +1232,14 @@ QColor Utils::getFrameBorderColor(const bool active)
if (!WindowsVersionHelper::isWin10OrGreater()) {
return (active ? kDefaultBlackColor : kDefaultDarkGrayColor);
}
const bool dark = shouldAppsUseDarkMode();
if (active) {
return (isFrameBorderColorized() ? getDwmColorizationColor() : kDefaultTransparentColor);
if (isFrameBorderColorized()) {
return getDwmAccentColor();
}
return (dark ? kDefaultFrameBorderActiveColor : kDefaultTransparentColor);
} else {
return (shouldAppsUseDarkMode() ? kDefaultFrameBorderInactiveColorDark : kDefaultFrameBorderInactiveColorLight);
return (dark ? kDefaultFrameBorderInactiveColorDark : kDefaultFrameBorderInactiveColorLight);
}
}
@ -1901,14 +1908,21 @@ QColor Utils::getDwmAccentColor()
// so we'd better also do the same thing.
// There's no Windows API to get this value, so we can only read it
// directly from the registry.
const QColor alternative = getDwmColorizationColor();
const RegistryKey registry(RegistryRootKey::CurrentUser, dwmRegistryKey());
if (!registry.isValid()) {
return kDefaultDarkGrayColor;
return alternative;
}
const QVariant value = registry.value(kAccentColor);
if (!value.isValid()) {
return alternative;
}
const DWORD value = registry.value<DWORD>(kAccentColor).value_or(0);
// The retrieved value is in the #AABBGGRR format, we need to
// convert it to the #AARRGGBB format that Qt accepts.
const QColor abgr = QColor::fromRgba(value);
const QColor abgr = QColor::fromRgba(qvariant_cast<DWORD>(value));
if (!abgr.isValid()) {
return alternative;
}
return QColor(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha());
}