mark the exit row on its chips instead of its label
The label was painted palette(bright-text), which is not a destructive color at all: Qt has no such role, and bright-text is white by design, meant for text over dark highlights. On this panel's light chrome it was white on grey. The chips carry the warning now and the label keeps the ordinary text color, so the row stays legible whatever the palette and only the binding is marked -- which is what REQ-UI-CONTROLS-CARD asked for in the first place, and what the mockup shows. The red is a literal because no palette role means it, chosen to read on a light and a dark background alike, and it is widget chrome, so like the rest of this stylesheet it is deliberately not a visuals.toml color. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user