prevent calls to setContent prompted by tipAboutToShow called from showToolTip from messing around with the tip based on the current widget
BUG:194974 svn path=/trunk/KDE/kdelibs/; revision=976790
This commit is contained in:
parent
7be6cf3dfb
commit
980918d1cd
@ -54,8 +54,9 @@ namespace Plasma
|
|||||||
class ToolTipManagerPrivate
|
class ToolTipManagerPrivate
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ToolTipManagerPrivate()
|
ToolTipManagerPrivate(ToolTipManager *manager)
|
||||||
: currentWidget(0),
|
: q(manager),
|
||||||
|
currentWidget(0),
|
||||||
showTimer(0),
|
showTimer(0),
|
||||||
hideTimer(0),
|
hideTimer(0),
|
||||||
tipWidget(new ToolTip(0)),
|
tipWidget(new ToolTip(0)),
|
||||||
@ -84,6 +85,7 @@ public :
|
|||||||
void clearTips();
|
void clearTips();
|
||||||
void doDelayedHide();
|
void doDelayedHide();
|
||||||
|
|
||||||
|
ToolTipManager *q;
|
||||||
QGraphicsWidget *currentWidget;
|
QGraphicsWidget *currentWidget;
|
||||||
QTimer *showTimer;
|
QTimer *showTimer;
|
||||||
QTimer *hideTimer;
|
QTimer *hideTimer;
|
||||||
@ -112,7 +114,8 @@ ToolTipManager *ToolTipManager::self()
|
|||||||
|
|
||||||
ToolTipManager::ToolTipManager(QObject *parent)
|
ToolTipManager::ToolTipManager(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new ToolTipManagerPrivate)
|
d(new ToolTipManagerPrivate(this)),
|
||||||
|
m_corona(0)
|
||||||
{
|
{
|
||||||
d->showTimer = new QTimer(this);
|
d->showTimer = new QTimer(this);
|
||||||
d->showTimer->setSingleShot(true);
|
d->showTimer->setSingleShot(true);
|
||||||
@ -196,12 +199,12 @@ void ToolTipManager::unregisterWidget(QGraphicsWidget *widget)
|
|||||||
|
|
||||||
void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &data)
|
void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &data)
|
||||||
{
|
{
|
||||||
if (d->state == Deactivated) {
|
if (d->state == Deactivated || !widget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerWidget(widget);
|
registerWidget(widget);
|
||||||
d->tooltips[widget] = data;
|
d->tooltips.insert(widget, data);
|
||||||
|
|
||||||
if (d->currentWidget == widget) {
|
if (d->currentWidget == widget) {
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
@ -218,7 +221,9 @@ void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &d
|
|||||||
|
|
||||||
d->tipWidget->setContent(widget, data);
|
d->tipWidget->setContent(widget, data);
|
||||||
d->tipWidget->prepareShowing();
|
d->tipWidget->prepareShowing();
|
||||||
d->tipWidget->moveTo(m_corona->popupPosition(d->currentWidget, d->tipWidget->size()));
|
if (m_corona) {
|
||||||
|
d->tipWidget->moveTo(m_corona->popupPosition(widget, d->tipWidget->size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +272,7 @@ void ToolTipManagerPrivate::onWidgetDestroyed(QObject *object)
|
|||||||
|
|
||||||
void ToolTipManagerPrivate::removeWidget(QGraphicsWidget *w)
|
void ToolTipManagerPrivate::removeWidget(QGraphicsWidget *w)
|
||||||
{
|
{
|
||||||
// DO NOTE ACCESS w HERE!! IT MAY BE IN THE PROCESS OF DELETION!
|
// DO NOT ACCESS w HERE!! IT MAY BE IN THE PROCESS OF DELETION!
|
||||||
if (currentWidget == w) {
|
if (currentWidget == w) {
|
||||||
currentWidget = 0;
|
currentWidget = 0;
|
||||||
showTimer->stop(); // stop the timer to show the tooltip
|
showTimer->stop(); // stop the timer to show the tooltip
|
||||||
@ -311,7 +316,14 @@ void ToolTipManagerPrivate::showToolTip()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(currentWidget, "toolTipAboutToShow");
|
// toolTipAboutToShow may call into methods such as setContent which play
|
||||||
|
// with the current widget; so let's just pretend for a moment that we don't have
|
||||||
|
// a current widget
|
||||||
|
QGraphicsWidget *temp = currentWidget;
|
||||||
|
currentWidget = 0;
|
||||||
|
QMetaObject::invokeMethod(temp, "toolTipAboutToShow");
|
||||||
|
currentWidget = temp;
|
||||||
|
|
||||||
QHash<QGraphicsWidget *, ToolTipContent>::const_iterator tooltip = tooltips.constFind(currentWidget);
|
QHash<QGraphicsWidget *, ToolTipContent>::const_iterator tooltip = tooltips.constFind(currentWidget);
|
||||||
|
|
||||||
if (tooltip == tooltips.constEnd() || tooltip.value().isEmpty()) {
|
if (tooltip == tooltips.constEnd() || tooltip.value().isEmpty()) {
|
||||||
@ -326,7 +338,9 @@ void ToolTipManagerPrivate::showToolTip()
|
|||||||
|
|
||||||
tipWidget->setContent(currentWidget, tooltip.value());
|
tipWidget->setContent(currentWidget, tooltip.value());
|
||||||
tipWidget->prepareShowing();
|
tipWidget->prepareShowing();
|
||||||
tipWidget->moveTo(ToolTipManager::self()->m_corona->popupPosition(currentWidget, tipWidget->size()));
|
if (q->m_corona) {
|
||||||
|
tipWidget->moveTo(q->m_corona->popupPosition(currentWidget, tipWidget->size()));
|
||||||
|
}
|
||||||
tipWidget->show();
|
tipWidget->show();
|
||||||
isShown = true; //ToolTip is visible
|
isShown = true; //ToolTip is visible
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user