From 3488fd23c793db8fcd38f4ba34997ea4b0693146 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 23 Oct 2008 22:14:07 +0000 Subject: [PATCH] Small API adjustments of ToolTipManager as discussed with Aaron: * clearContent() is back, but no default value to setContent(); * delayedHide() is no more public. After all I didn't rename it and make it full of static methods because I noticed the following in the meantime: 1) register/unregister being still around, and passing the QGraphicsWidget* in most methods, effectively makes it a manager; 2) all managers in libplasma use the singleton pattern, so let's keep consistency. CCMAIL: aseigo@kde.org svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=875285 --- tooltipmanager.cpp | 17 ++++++++++++----- tooltipmanager.h | 13 +++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tooltipmanager.cpp b/tooltipmanager.cpp index 32522b596..5a70c47cc 100644 --- a/tooltipmanager.cpp +++ b/tooltipmanager.cpp @@ -81,6 +81,8 @@ public : void clearTips(); + void doDelayedHide(); + QGraphicsWidget *currentWidget; QTimer *showTimer; QTimer *hideTimer; @@ -171,11 +173,11 @@ bool ToolTipManager::isVisible(QGraphicsWidget *widget) const } } -void ToolTipManager::delayedHide() +void ToolTipManagerPrivate::doDelayedHide() { - d->showTimer->stop(); // stop the timer to show the tooltip - d->delayedHide = true; - d->hideTimer->start(250); + showTimer->stop(); // stop the timer to show the tooltip + delayedHide = true; + hideTimer->start(250); } void ToolTipManager::hide(QGraphicsWidget *widget) @@ -242,6 +244,11 @@ void ToolTipManager::setContent(QGraphicsWidget *widget, const Content &data) tooltip->updateTheme(); } +void ToolTipManager::clearContent(QGraphicsWidget *widget) +{ + setContent(widget, Content()); +} + void ToolTipManager::setState(ToolTipManager::State state) { d->state = state; @@ -409,7 +416,7 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event) } case QEvent::GraphicsSceneHoverLeave: - delayedHide(); + d->doDelayedHide(); break; case QEvent::GraphicsSceneMousePress: diff --git a/tooltipmanager.h b/tooltipmanager.h index 5d4941d2a..5dffaf624 100644 --- a/tooltipmanager.h +++ b/tooltipmanager.h @@ -120,11 +120,6 @@ public: */ bool isVisible(QGraphicsWidget *widget) const; - /** - * Hides the currently showing tooltip after a short amount of time. - */ - void delayedHide(); - /** * Hides the tooltip for a widget immediately. * @@ -172,7 +167,13 @@ public: * is passed in, the tooltip content will be reset. */ void setContent(QGraphicsWidget *widget, - const ToolTipManager::Content &data = ToolTipManager::Content()); + const ToolTipManager::Content &data); + + /** + * Clears the tooltip data associated with this widget, but keeps + * the widget registered. + */ + void clearContent(QGraphicsWidget *widget); /** * Sets the current state of the manager.