Record which tooltip is being shown so that tooltip data updates don't change
which to another widget's tooltip. BUG: 154719 svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=754590
This commit is contained in:
parent
2e58716f0c
commit
f3e52b76cb
@ -34,6 +34,7 @@ class ToolTip::Private
|
|||||||
Private()
|
Private()
|
||||||
: label(0)
|
: label(0)
|
||||||
, imageLabel(0)
|
, imageLabel(0)
|
||||||
|
, currentWidget(0)
|
||||||
, isShown(false)
|
, isShown(false)
|
||||||
, showTimer(0)
|
, showTimer(0)
|
||||||
, hideTimer(0)
|
, hideTimer(0)
|
||||||
@ -41,6 +42,7 @@ class ToolTip::Private
|
|||||||
|
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
QLabel *imageLabel;
|
QLabel *imageLabel;
|
||||||
|
Plasma::Widget *currentWidget;
|
||||||
bool isShown;
|
bool isShown;
|
||||||
QTimer *showTimer;
|
QTimer *showTimer;
|
||||||
QTimer *hideTimer;
|
QTimer *hideTimer;
|
||||||
@ -58,9 +60,10 @@ ToolTip *ToolTip::instance()
|
|||||||
return &privateInstance->self;
|
return &privateInstance->self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::show(const QPoint &location, const Plasma::ToolTipData &data)
|
void ToolTip::show(const QPoint &location, Plasma::Widget *widget)
|
||||||
{
|
{
|
||||||
setData(data);
|
d->currentWidget = widget;
|
||||||
|
setData(widget->toolTip());
|
||||||
move(location.x(), location.y() - sizeHint().height());
|
move(location.x(), location.y() - sizeHint().height());
|
||||||
if (d->isShown) {
|
if (d->isShown) {
|
||||||
// Don't delay if the tooltip is already shown(i.e. moving from one task to another)
|
// Don't delay if the tooltip is already shown(i.e. moving from one task to another)
|
||||||
@ -68,14 +71,14 @@ void ToolTip::show(const QPoint &location, const Plasma::ToolTipData &data)
|
|||||||
// immediately show it again
|
// immediately show it again
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
d->showTimer->start(0);
|
d->showTimer->start(0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
d->showTimer->start(1000); //Shown after a one second delay.
|
d->showTimer->start(1000); //Shown after a one second delay.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::hide()
|
void ToolTip::hide()
|
||||||
{
|
{
|
||||||
|
d->currentWidget = 0;
|
||||||
d->showTimer->stop(); //Mouse out, stop the timer to show the tooltip
|
d->showTimer->stop(); //Mouse out, stop the timer to show the tooltip
|
||||||
if (!isVisible()) {
|
if (!isVisible()) {
|
||||||
d->isShown = false;
|
d->isShown = false;
|
||||||
@ -84,6 +87,11 @@ void ToolTip::hide()
|
|||||||
d->hideTimer->start(500); //500 ms delay before we are officially "gone" to allow for the time to move between widgets
|
d->hideTimer->start(500); //500 ms delay before we are officially "gone" to allow for the time to move between widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Plasma::Widget *ToolTip::currentWidget() const
|
||||||
|
{
|
||||||
|
return d->currentWidget;
|
||||||
|
}
|
||||||
|
|
||||||
//PRIVATE FUNCTIONS
|
//PRIVATE FUNCTIONS
|
||||||
void ToolTip::slotShowToolTip()
|
void ToolTip::slotShowToolTip()
|
||||||
{
|
{
|
||||||
|
@ -44,9 +44,11 @@ public:
|
|||||||
~ToolTip();
|
~ToolTip();
|
||||||
|
|
||||||
static ToolTip *instance();
|
static ToolTip *instance();
|
||||||
void show(const QPoint &location, const Plasma::ToolTipData &data);
|
void show(const QPoint &location, Plasma::Widget *widget);
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
|
Plasma::Widget *currentWidget() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotResetTimer();
|
void slotResetTimer();
|
||||||
void slotShowToolTip();
|
void slotShowToolTip();
|
||||||
|
@ -498,10 +498,10 @@ ToolTipData Widget::toolTip() const
|
|||||||
void Widget::setToolTip(const ToolTipData &tip)
|
void Widget::setToolTip(const ToolTipData &tip)
|
||||||
{
|
{
|
||||||
d->toolTip = tip;
|
d->toolTip = tip;
|
||||||
if (ToolTip::instance()->isVisible()) {
|
if (ToolTip::instance()->currentWidget() == this) {
|
||||||
QPoint viewPos = view()->mapFromScene(scenePos());
|
QPoint viewPos = view()->mapFromScene(scenePos());
|
||||||
QPoint globalPos = view()->mapToGlobal(viewPos);
|
QPoint globalPos = view()->mapToGlobal(viewPos);
|
||||||
ToolTip::instance()->show(globalPos, d->toolTip);
|
ToolTip::instance()->show(globalPos, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,10 +557,7 @@ void Widget::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
|
|||||||
|
|
||||||
return; //Nothing to show
|
return; //Nothing to show
|
||||||
}
|
}
|
||||||
if (view()->mouseGrabber()) {
|
|
||||||
return; // Someone has the mouse (eg. a context menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the mouse is in the widget's area at the time that it is being created
|
// If the mouse is in the widget's area at the time that it is being created
|
||||||
// the widget can receive a hover event before it is fully initialized, in
|
// the widget can receive a hover event before it is fully initialized, in
|
||||||
// which case view() will return 0.
|
// which case view() will return 0.
|
||||||
@ -570,9 +567,13 @@ void Widget::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parentView->mouseGrabber()) {
|
||||||
|
return; // Someone has the mouse (eg. a context menu)
|
||||||
|
}
|
||||||
|
|
||||||
QPoint viewPos = parentView->mapFromScene(scenePos());
|
QPoint viewPos = parentView->mapFromScene(scenePos());
|
||||||
QPoint globalPos = parentView->mapToGlobal(viewPos);
|
QPoint globalPos = parentView->mapToGlobal(viewPos);
|
||||||
ToolTip::instance()->show(globalPos, d->toolTip);
|
ToolTip::instance()->show(globalPos, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
void Widget::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||||
|
Loading…
Reference in New Issue
Block a user