Allow to get tooltips to popup instantly on hover

Add an "instant popup" property on ToolTipContent allowing to control
for a given tooltip to popup immediately when the corresponding widget
is hovered. The default is the usual behavior though.

The ToolTipManager behavior itself got adjusted to take care of the
instant popup flag.
This commit is contained in:
Kevin Ottens 2011-04-26 20:43:40 +02:00
parent 955137bf2f
commit 7fa4dff47b
3 changed files with 38 additions and 5 deletions

View File

@ -51,6 +51,7 @@ class ToolTipContentPrivate
public:
ToolTipContentPrivate()
: autohide(true),
instantPopup(false),
clickable(false),
highlightWindows(false)
{
@ -63,6 +64,7 @@ public:
QHash<QString, ToolTipResource> resources;
QWeakPointer<QGraphicsWidget> graphicsWidget;
bool autohide : 1;
bool instantPopup : 1;
bool clickable : 1;
bool highlightWindows : 1;
};
@ -200,6 +202,16 @@ bool ToolTipContent::autohide() const
return d->autohide;
}
void ToolTipContent::setInstantPopup(bool enabled)
{
d->instantPopup = enabled;
}
bool ToolTipContent::isInstantPopup() const
{
return d->instantPopup;
}
void ToolTipContent::addResource(ResourceType type, const QUrl &path, const QVariant &resource)
{
d->resources.insert(path.toString(), ToolTipResource(type, resource));

View File

@ -166,6 +166,22 @@ public:
*/
bool autohide() const;
/**
* Sets whether or not the tooltip should popup instantly when
* the widget is hovered, defaults to false.
*
* @since 4.7
*/
void setInstantPopup(bool enabled);
/**
* Whether or not the tooltip should popup instantly when
* the widget is hovered, defaults to false.
*
* @since 4.7
*/
bool isInstantPopup() const;
/**
* Adds a resource that can then be referenced from the text elements
* using rich text

View File

@ -140,12 +140,17 @@ void ToolTipManager::show(QGraphicsWidget *widget)
return;
}
qreal delay = 0.0;
ToolTipContent content = d->tooltips[widget];
if (!content.isInstantPopup()) {
KConfig config("plasmarc");
KConfigGroup cg(&config, "PlasmaToolTips");
qreal delay = cg.readEntry("Delay", qreal(0.7));
delay = cg.readEntry("Delay", qreal(0.7));
if (delay < 0) {
return;
}
}
d->hideTimer->stop();
d->delayedHide = false;