Skip to content

Commit

Permalink
chore: keep consistent highlight color in different themes
Browse files Browse the repository at this point in the history
don't inverse color when color type is highlight

Log: keep consistent highlight color in dark/light themes
  • Loading branch information
wangfei committed Mar 22, 2024
1 parent 74e0716 commit d24dfe8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/private/dqmlglobalobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ bool DColor::isTypedColor() const noexcept
return data.color.type >= VARIANT_COLOR_TYPE_OFFSET;
}

quint8 DColor::type() const noexcept
{
return data.color.type;
}

static inline QPalette::ColorRole toPaletteColorRole(quint8 type)
{
auto color = static_cast<DColor::Type>(type - VARIANT_COLOR_TYPE_OFFSET);
Expand Down
1 change: 1 addition & 0 deletions src/private/dqmlglobalobject_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class DColor

[[nodiscard]] bool isValid() const noexcept;
[[nodiscard]] bool isTypedColor() const noexcept;
[[nodiscard]] quint8 type() const noexcept;

bool operator==(const DColor &c) const noexcept;
bool operator!=(const DColor &c) const noexcept;
Expand Down
4 changes: 3 additions & 1 deletion src/private/dquickcontrolpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,9 @@ QColor DQuickControlColorSelector::getColorOf(const DQuickControlPalette *palett
// create the dark color from the light theme
targetColor = getColor(palette, DQuickControlPalette::Light, familyIndex, stateIndex);
// inverse the color to dark
shouldInverseColor = true;
if (targetColor.type() != DColor::Highlight && targetColor.type() != DColor::HighlightedText) {
shouldInverseColor = true;
}
}
} while (false);

Expand Down

0 comments on commit d24dfe8

Please sign in to comment.