show a tooltip on click, and keep it up until the pointer leaves
One tooltip mechanism for the whole UI: a Tooltip popup plus a TooltipTrigger event filter, replacing every setToolTip call. Qt's own tooltip cannot do what REQ-UI-TOOLTIP-TRIGGER and REQ-UI-TOOLTIP-DISMISS ask for -- it times out, hides on the first mouse move, cannot be hovered and cannot be brought up by a click. A tooltip now appears the moment an element with no click action of its own is clicked, and it is placed with its top-left corner on the pointer, so the pointer can move onto the tooltip and hold it open. The pointer is polled while a tooltip is up rather than tracked through enter and leave events, whose order depends on which widget the pointer crosses first. The item chip's children become transparent to the mouse. They were taking the chip's enter and leave events, so its tooltip only ever appeared when the pointer rested on the chip's padding. The modal header's close button loses its "Close" tooltip: a close button in a header says that by being one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "InputMapper.h"
|
||||
#include "ItemIconCache.h"
|
||||
#include "Simulation.h"
|
||||
#include "TooltipTrigger.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -211,10 +212,12 @@ BuildButtonBar::BuildButtonBar(Simulation* sim, const GameConfig* config,
|
||||
btn->setCheckable(true);
|
||||
// The button face carries no name (REQ-UI-BUILD-COST), so the tooltip always
|
||||
// leads with it and adds the config description when there is one
|
||||
// (REQ-UI-BUILD-TOOLTIP).
|
||||
btn->setToolTip(def.tooltip
|
||||
// (REQ-UI-BUILD-TOOLTIP). Hover only: the click enters builder mode
|
||||
// (REQ-UI-TOOLTIP-TRIGGER).
|
||||
TooltipTrigger::attachText(*btn, def.tooltip
|
||||
? QStringLiteral("%1\n%2").arg(name, QString::fromStdString(*def.tooltip))
|
||||
: name);
|
||||
: name,
|
||||
TooltipTrigger::Trigger::HoverOnly);
|
||||
layout->addWidget(btn);
|
||||
|
||||
const int idx = static_cast<int>(m_buttons.size());
|
||||
@@ -253,7 +256,9 @@ BuildButtonBar::BuildButtonBar(Simulation* sim, const GameConfig* config,
|
||||
"block cost once removed; a construction site removed before it is built "
|
||||
"is refunded in full.")
|
||||
.arg(refundPercentage);
|
||||
m_deconstructButton->setToolTip(deconstructTooltip);
|
||||
// Hover only: the click toggles the mode (REQ-UI-TOOLTIP-TRIGGER).
|
||||
TooltipTrigger::attachText(*m_deconstructButton, deconstructTooltip,
|
||||
TooltipTrigger::Trigger::HoverOnly);
|
||||
layout->addWidget(m_deconstructButton);
|
||||
connect(m_deconstructButton, &QPushButton::clicked, this, [this]() {
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
|
||||
Reference in New Issue
Block a user