From 55b83d310010773983bda8b12f1adfba25d30231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 11 Dec 2024 17:01:03 +0100 Subject: [PATCH] Make sure the checkbox label remains readable when selected 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. --- src/tiled/propertiesview.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tiled/propertiesview.cpp b/src/tiled/propertiesview.cpp index 0c92c7df86..59b8da8feb 100644 --- a/src/tiled/propertiesview.cpp +++ b/src/tiled/propertiesview.cpp @@ -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) {