this is much clearer, does the same thing and has the benefit of being able to pre-emptively hide the tip in toolTipAboutToShow!

svn path=/trunk/KDE/kdelibs/; revision=903158
This commit is contained in:
Aaron J. Seigo 2008-12-30 02:04:35 +00:00
parent 014514e808
commit ea41519c3c
3 changed files with 6 additions and 25 deletions

View File

@ -241,12 +241,8 @@ void ToolTip::setContent(QObject *tipper, const ToolTipContent &data)
} }
} }
void ToolTip::prepareShowing(bool cueUpdate) void ToolTip::prepareShowing()
{ {
if (cueUpdate && d->source) {
QMetaObject::invokeMethod(d->source, "toolTipAboutToShow");
}
if (d->preview->windowId() != 0) { if (d->preview->windowId() != 0) {
// show/hide the preview area // show/hide the preview area
d->preview->show(); d->preview->show();

View File

@ -38,7 +38,7 @@ public:
~ToolTip(); ~ToolTip();
void setContent(QObject *tipper, const ToolTipContent &data); void setContent(QObject *tipper, const ToolTipContent &data);
void prepareShowing(bool cueUpdate); void prepareShowing();
void moveTo(const QPoint &to); void moveTo(const QPoint &to);
bool autohide() const; bool autohide() const;
void setDirection(Plasma::Direction); void setDirection(Plasma::Direction);

View File

@ -300,36 +300,21 @@ void ToolTipManagerPrivate::showToolTip()
return; return;
} }
QMetaObject::invokeMethod(currentWidget, "toolTipAboutToShow");
QHash<QGraphicsWidget *, ToolTipContent>::const_iterator tooltip = tooltips.constFind(currentWidget); QHash<QGraphicsWidget *, ToolTipContent>::const_iterator tooltip = tooltips.constFind(currentWidget);
if (tooltip == tooltips.constEnd()) {
return;
}
bool justCreated = false;
if (tooltip.value().isEmpty()) {
// give the object a chance for delayed loading of the tip
QMetaObject::invokeMethod(currentWidget, "toolTipAboutToShow");
tooltip = tooltips.constFind(currentWidget);
//kDebug() << "attempt to make one ... we gots" << tooltip.isEmpty();
if (tooltip == tooltips.constEnd() || tooltip.value().isEmpty()) { if (tooltip == tooltips.constEnd() || tooltip.value().isEmpty()) {
currentWidget = 0;
return; return;
} }
justCreated = true;
}
Containment *c = dynamic_cast<Containment *>(currentWidget->topLevelItem()); Containment *c = dynamic_cast<Containment *>(currentWidget->topLevelItem());
kDebug() << "about to show" << justCreated << (QObject*)c; //kDebug() << "about to show" << (QObject*)c;
if (c) { if (c) {
tipWidget->setDirection(Plasma::locationToDirection(c->location())); tipWidget->setDirection(Plasma::locationToDirection(c->location()));
} }
tipWidget->setContent(currentWidget, tooltip.value()); tipWidget->setContent(currentWidget, tooltip.value());
tipWidget->prepareShowing(!justCreated); tipWidget->prepareShowing();
tipWidget->moveTo(ToolTipManager::self()->m_corona->popupPosition(currentWidget, tipWidget->size())); tipWidget->moveTo(ToolTipManager::self()->m_corona->popupPosition(currentWidget, tipWidget->size()));
tipWidget->show(); tipWidget->show();
isShown = true; //ToolTip is visible isShown = true; //ToolTip is visible