From abf654c5c519b7b62c998f203811bd1158624460 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 18 Mar 2008 01:39:28 +0000 Subject: [PATCH] have the tooltip inform the widget that it's about to tip so last second updates can be made, particularly nice for expensive tooltips svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=786834 --- widgets/tooltip.cpp | 1 + widgets/widget.cpp | 4 ++++ widgets/widget.h | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/widgets/tooltip.cpp b/widgets/tooltip.cpp index ae5cdd6d8..275c64a17 100644 --- a/widgets/tooltip.cpp +++ b/widgets/tooltip.cpp @@ -135,6 +135,7 @@ void ToolTip::showToolTip() return; } + d->currentWidget->updateToolTip(); setData(*d->currentWidget->toolTip()); if( d->windowToPreview != 0 ) { diff --git a/widgets/widget.cpp b/widgets/widget.cpp index 6f7c95112..8e5cb5a21 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -398,6 +398,10 @@ void Widget::setToolTip(const ToolTipData &tip) } } +void Widget::updateToolTip() +{ +} + void Widget::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(painter); diff --git a/widgets/widget.h b/widgets/widget.h index 09859f466..815e08118 100644 --- a/widgets/widget.h +++ b/widgets/widget.h @@ -277,7 +277,14 @@ public: * Setter for data shown in tooltip * @param data a ToolTip::Data object containing icon and text */ - void setToolTip( const ToolTipData &dt ); + void setToolTip(const ToolTipData &dt); + + /** + * Called when the tooltip data should be updated, e.g. right before + * a tooltip is shown. This allows tips that are more expensive to + * create ahead of time to be set at the last possible moment. + */ + virtual void updateToolTip(); /** * Recomended position for a popup window like a menu or a tooltip