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:
@@ -19,6 +19,7 @@
|
||||
#include "Simulation.h"
|
||||
#include "SpeedChangeRequestedEvent.h"
|
||||
#include "Tick.h"
|
||||
#include "TooltipTrigger.h"
|
||||
|
||||
const double HeaderBar::kSpeeds[] = { 0.0, 0.5, 1.0, 2.0, 10.0 };
|
||||
const int HeaderBar::kSpeedCount = 5;
|
||||
@@ -34,18 +35,24 @@ HeaderBar::HeaderBar(const Simulation* sim, const GameConfig* config,
|
||||
layout->setSpacing(8);
|
||||
|
||||
m_timeLabel = new QLabel("00:00", this);
|
||||
// Both displays state a value and do nothing when clicked, so a click brings the
|
||||
// tooltip up at once rather than waiting the hover out (REQ-UI-TOOLTIP-TRIGGER).
|
||||
m_blocksLabel = new QLabel(this);
|
||||
if (config->world.buildingBlocksTooltip)
|
||||
{
|
||||
m_blocksLabel->setToolTip(
|
||||
QString::fromStdString(*config->world.buildingBlocksTooltip));
|
||||
TooltipTrigger::attachText(
|
||||
*m_blocksLabel,
|
||||
QString::fromStdString(*config->world.buildingBlocksTooltip),
|
||||
TooltipTrigger::Trigger::HoverAndClick);
|
||||
}
|
||||
updateBlocksLabel();
|
||||
m_artifactsLabel = new QLabel(tr("Artifacts: 0/?"), this);
|
||||
if (config->world.artifactTooltip)
|
||||
{
|
||||
m_artifactsLabel->setToolTip(
|
||||
QString::fromStdString(*config->world.artifactTooltip));
|
||||
TooltipTrigger::attachText(
|
||||
*m_artifactsLabel,
|
||||
QString::fromStdString(*config->world.artifactTooltip),
|
||||
TooltipTrigger::Trigger::HoverAndClick);
|
||||
}
|
||||
m_bossWaveLabel = new QLabel(tr("Boss Wave #1"), this);
|
||||
m_nextBossLabel = new QLabel(tr("Next boss: 5:00"), this);
|
||||
|
||||
Reference in New Issue
Block a user