forked from github_mirror/framelesshelper
win: fix the border color, take 2
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
a381836ef7
commit
768ab6da4b
|
@ -56,11 +56,6 @@ jobs:
|
||||||
if: ${{ matrix.platform == 'windows-latest' }}
|
if: ${{ matrix.platform == 'windows-latest' }}
|
||||||
uses: ilammy/msvc-dev-cmd@v1
|
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
|
- name: Build library with CMake
|
||||||
run: |
|
run: |
|
||||||
mkdir ci-test-build
|
mkdir ci-test-build
|
||||||
|
|
|
@ -718,8 +718,11 @@ QColor Utils::getDwmColorizationColor()
|
||||||
if (!registry.isValid()) {
|
if (!registry.isValid()) {
|
||||||
return kDefaultDarkGrayColor;
|
return kDefaultDarkGrayColor;
|
||||||
}
|
}
|
||||||
const DWORD value = registry.value<DWORD>(kColorizationColor).value_or(0);
|
const QVariant value = registry.value(kColorizationColor);
|
||||||
return QColor::fromRgba(value);
|
if (!value.isValid()) {
|
||||||
|
return kDefaultDarkGrayColor;
|
||||||
|
}
|
||||||
|
return QColor::fromRgba(qvariant_cast<DWORD>(value));
|
||||||
};
|
};
|
||||||
if (!API_DWM_AVAILABLE(DwmGetColorizationColor)) {
|
if (!API_DWM_AVAILABLE(DwmGetColorizationColor)) {
|
||||||
return resultFromRegistry();
|
return resultFromRegistry();
|
||||||
|
@ -1229,10 +1232,14 @@ QColor Utils::getFrameBorderColor(const bool active)
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
return (active ? kDefaultBlackColor : kDefaultDarkGrayColor);
|
return (active ? kDefaultBlackColor : kDefaultDarkGrayColor);
|
||||||
}
|
}
|
||||||
|
const bool dark = shouldAppsUseDarkMode();
|
||||||
if (active) {
|
if (active) {
|
||||||
return (isFrameBorderColorized() ? getDwmColorizationColor() : kDefaultTransparentColor);
|
if (isFrameBorderColorized()) {
|
||||||
|
return getDwmAccentColor();
|
||||||
|
}
|
||||||
|
return (dark ? kDefaultFrameBorderActiveColor : kDefaultTransparentColor);
|
||||||
} else {
|
} 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.
|
// so we'd better also do the same thing.
|
||||||
// There's no Windows API to get this value, so we can only read it
|
// There's no Windows API to get this value, so we can only read it
|
||||||
// directly from the registry.
|
// directly from the registry.
|
||||||
|
const QColor alternative = getDwmColorizationColor();
|
||||||
const RegistryKey registry(RegistryRootKey::CurrentUser, dwmRegistryKey());
|
const RegistryKey registry(RegistryRootKey::CurrentUser, dwmRegistryKey());
|
||||||
if (!registry.isValid()) {
|
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
|
// The retrieved value is in the #AABBGGRR format, we need to
|
||||||
// convert it to the #AARRGGBB format that Qt accepts.
|
// 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());
|
return QColor(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue