Skip to content

Commit 0358b68

Browse files
committed
fix: skip inactive color when active and inactive colors are equal
When the inactive and active colors in QPalette are identical, the system should not apply inactive color processing to avoid unnecessary color calculations and potential visual inconsistencies. This change adds a check to bypass inactive color usage when the QPalette's inactive and active color groups are equal, ensuring more efficient rendering and consistent visual behavior. Log: Fixed an issue where inactive color processing was incorrectly applied when active and inactive colors were identical, improving rendering efficiency and visual consistency. Influence: 1. Test UI components with identical active and inactive QPalette colors to ensure they render correctly 2. Verify that components with different active/inactive colors still properly apply inactive colors when appropriate 3. Check performance impact when switching between color states 4. Test with various control types to ensure consistent behavior across the application 5. Verify that the fix doesn't break existing inactive state visual effects fix: 当QPalette中非活动色和活动色相同时跳过非活动色处理 当QPalette中的非活动色和活动色相同时,系统不应应用非活动色处理,以避免 不必要的颜色计算和潜在的视觉不一致。此更改添加了一个检查,当QPalette的非 活动色和活动色组相等时,跳过非活动色的使用,确保更高效的渲染和一致的视觉 行为。 Log: 修复了当活动色和非活动色相同时错误应用非活动色处理的问题,提高了渲 染效率和视觉一致性。 Influence: 1. 测试具有相同活动和非活动QPalette颜色的UI组件,确保它们正确渲染 2. 验证具有不同活动/非活动颜色的组件在适当时仍能正确应用非活动色 3. 检查在不同颜色状态之间切换时的性能影响 4. 测试各种控件类型,确保在整个应用程序中行为一致 5. 验证此修复不会破坏现有的非活动状态视觉效果 PMS: BUG-298841
1 parent 6307600 commit 0358b68

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/private/dquickcontrolpalette.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -844,7 +844,17 @@ QColor DQuickControlColorSelector::getColorOf(const DQuickControlPalette *palett
844844

845845
// items with inactive state should use inactive color, it likes dtkgui's generatePaletteColor_helper.
846846
static const auto useInactiveColor = DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::UseInactiveColorGroup);
847-
if (useInactiveColor && state->controlState == DQMLGlobalObject::InactiveState) {
847+
bool shouldBlendInactive = useInactiveColor && state->controlState == DQMLGlobalObject::InactiveState;
848+
if (shouldBlendInactive) {
849+
if (m_control) {
850+
// If the control's inactive palette is same as active palette, it means the control does not have a real
851+
// inactive state, we should not blend the color with inactive mask color, otherwise it will cause the
852+
// color looks like disabled and hard to recognize.
853+
const auto qpalette = _d_getControlPalette(m_control);
854+
shouldBlendInactive = !qpalette.isEqual(QPalette::Inactive, QPalette::Active);
855+
}
856+
}
857+
if (shouldBlendInactive) {
848858
const auto &palette = DGuiApplicationHelper::standardPalette(state->controlTheme);
849859
const auto &windowColor = palette.color(QPalette::Window);
850860

0 commit comments

Comments
 (0)