Skip to content

Commit

Permalink
Make sure the checkbox label remains readable when selected
Browse files Browse the repository at this point in the history
The QCommonStyle always uses the WindowText role when rendering a
checkbox label, so change the palette so that is picks up the
HighlightedText role when the property is selected.
  • Loading branch information
bjorn committed Dec 13, 2024
1 parent 8eb447e commit 754b2a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tiled/propertiesview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,16 @@ QWidget *BoolProperty::createEditor(QWidget *parent)
auto font = editor->font();
font.setBold(isModified());
editor->setFont(font);

// Make sure the label remains readable when selected
auto pal = QGuiApplication::palette();
if (isSelected())
pal.setBrush(QPalette::WindowText, pal.brush(QPalette::HighlightedText));
editor->setPalette(pal);
};
syncEditor();

connect(this, &Property::selectedChanged, editor, syncEditor);
connect(this, &Property::valueChanged, editor, syncEditor);
connect(this, &Property::modifiedChanged, editor, syncEditor);
connect(editor, &QCheckBox::toggled, this, [=](bool checked) {
Expand Down

0 comments on commit 754b2a5

Please sign in to comment.