mark the exit row of the controls panel red on its chips instead of its label

This commit is contained in:
2026-08-07 19:52:51 +02:00
parent 365641feb7
commit 7a098edf72

View File

@@ -46,19 +46,20 @@ QWidget* makeRow(ControlAction action, const ControlContext& context, QWidget* p
layout->setSpacing(4); layout->setSpacing(4);
// Every badge is rendered from the binding the resolver matches, so a chip cannot // Every badge is rendered from the binding the resolver matches, so a chip cannot
// claim a key that does nothing (REQ-UI-CONTROLS-ACCURACY). // claim a key that does nothing (REQ-UI-CONTROLS-ACCURACY). The chips of the row
// that leaves the mode are the ones marked, not its label (REQ-UI-CONTROLS-CARD).
const bool exitsMode = (action == ControlAction::ExitMode);
const std::vector<ControlBinding> bindings = getControlActionBindings(action, context); const std::vector<ControlBinding> bindings = getControlActionBindings(action, context);
for (const ControlBinding& binding : bindings) for (const ControlBinding& binding : bindings)
{ {
QLabel* badge = new QLabel(getControlBindingBadge(binding), row); QLabel* badge = new QLabel(getControlBindingBadge(binding), row);
badge->setObjectName(QStringLiteral("controlBadge")); badge->setObjectName(exitsMode ? QStringLiteral("controlBadgeExit")
: QStringLiteral("controlBadge"));
layout->addWidget(badge); layout->addWidget(badge);
} }
QLabel* label = new QLabel(getControlActionLabel(action, context), row); QLabel* label = new QLabel(getControlActionLabel(action, context), row);
label->setObjectName(action == ControlAction::ExitMode label->setObjectName(QStringLiteral("controlLabel"));
? QStringLiteral("controlLabelExit")
: QStringLiteral("controlLabel"));
layout->addSpacing(4); layout->addSpacing(4);
layout->addWidget(label); layout->addWidget(label);
layout->addStretch(1); layout->addStretch(1);
@@ -100,9 +101,17 @@ ControlsPanel::ControlsPanel(const GameWorldView* view, QWidget* parent)
"QLabel#controlBadge { border: 1px solid palette(mid); border-radius: 3px;" "QLabel#controlBadge { border: 1px solid palette(mid); border-radius: 3px;"
" padding: 1px 5px; font-family: monospace; color: palette(text); }" " padding: 1px 5px; font-family: monospace; color: palette(text); }"
"QLabel#controlLabel { color: palette(text); }" "QLabel#controlLabel { color: palette(text); }"
// The row that leaves the mode reads differently from the ones that act within // The row that leaves the mode is marked on its chips rather than its label
// it (REQ-UI-CONTROLS-CARD). // (REQ-UI-CONTROLS-CARD): the label keeps the ordinary text color, so the row
"QLabel#controlLabelExit { color: palette(bright-text); }" // stays legible whatever the palette, and only the chips carry the warning.
//
// A literal red because there is no palette role for "destructive" -- the
// nearest, bright-text, is white by design, being meant for text over dark
// highlights, and was unreadable on this panel's chrome. This value reads on a
// light and a dark background alike. It is widget chrome, so like the rest of
// this stylesheet it is deliberately not a visuals.toml color.
"QLabel#controlBadgeExit { border: 1px solid #c0392b; border-radius: 3px;"
" padding: 1px 5px; font-family: monospace; color: #c0392b; }"
"QLabel#controlCaption { color: palette(mid); }")); "QLabel#controlCaption { color: palette(mid); }"));
QVBoxLayout* outerLayout = new QVBoxLayout(this); QVBoxLayout* outerLayout = new QVBoxLayout(this);