Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/private/dquickcontrolpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,17 @@ QColor DQuickControlColorSelector::getColorOf(const DQuickControlPalette *palett
colorValue = QColor(255 - r, 255 - g, 255 - b, a);
}

// items with inactive state should use inactive color, it likes dtkgui's generatePaletteColor_helper.
static const auto useInactiveColor = DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::UseInactiveColorGroup);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider whether static const is appropriate for useInactiveColor.

If the application's attribute can change at runtime, use a local variable instead to ensure the value is always current.

Suggested change
static const auto useInactiveColor = DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::UseInactiveColorGroup);
const auto useInactiveColor = DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::UseInactiveColorGroup);

if (useInactiveColor && state->controlState == DQMLGlobalObject::InactiveState) {
const auto &palette = DGuiApplicationHelper::standardPalette(state->controlTheme);
const auto &windowColor = palette.color(QPalette::Window);

QColor inactiveMaskColor = windowColor;
inactiveMaskColor.setAlphaF(state->controlTheme == DGuiApplicationHelper::DarkType ? 0.6 : 0.4);
colorValue = DGuiApplicationHelper::blendColor(colorValue, inactiveMaskColor);
}

return colorValue;
}

Expand Down
Loading