remove gratuitous "ToolTip"s

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=874244
This commit is contained in:
Aaron J. Seigo 2008-10-21 01:33:32 +00:00
parent 70abf9ff86
commit 7abb5164a5
4 changed files with 30 additions and 42 deletions

View File

@ -300,7 +300,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
data.mainText = i18n("Unable to load the widget");
data.subText = reason;
data.image = KIcon("dialog-error").pixmap(IconSize(KIconLoader::Desktop));
Plasma::ToolTipManager::self()->setToolTipContent(failureIcon, data);
Plasma::ToolTipManager::self()->setContent(failureIcon, data);
setLayout(failureLayout);
resize(300, 250);

View File

@ -45,8 +45,7 @@ class ToolTipPrivate
imageLabel(0),
preview(0),
windowToPreview(0),
source(s),
isActivated(true)
source(s)
{ }
QLabel *label;
@ -55,7 +54,6 @@ class ToolTipPrivate
WId windowToPreview;
PanelSvg *background;
QObject *source;
bool isActivated;
};
void ToolTip::showEvent(QShowEvent *e)
@ -140,16 +138,6 @@ void ToolTip::prepareShowing(bool cueUpdate)
resize(sizeHint());
}
void ToolTip::setActivated(bool value)
{
d->isActivated = value;
}
bool ToolTip::isActivated()
{
return d->isActivated;
}
void ToolTip::resizeEvent(QResizeEvent *e)
{
QWidget::resizeEvent(e);

View File

@ -132,14 +132,14 @@ ToolTipManager::~ToolTipManager()
delete d;
}
void ToolTipManager::showToolTip(QGraphicsWidget *widget)
void ToolTipManager::show(QGraphicsWidget *widget)
{
if (!d->tooltips.contains(widget)) {
return;
}
if (d->currentWidget) {
hideToolTip(d->currentWidget);
hide(d->currentWidget);
}
d->hideTimer->stop();
@ -156,7 +156,7 @@ void ToolTipManager::showToolTip(QGraphicsWidget *widget)
}
}
bool ToolTipManager::isToolTipVisible(QGraphicsWidget *widget) const
bool ToolTipManager::isVisible(QGraphicsWidget *widget) const
{
ToolTip *tooltip = d->tooltips.value(widget);
if (tooltip) {
@ -166,14 +166,14 @@ bool ToolTipManager::isToolTipVisible(QGraphicsWidget *widget) const
}
}
void ToolTipManager::delayedHideToolTip()
void ToolTipManager::delayedHide()
{
d->showTimer->stop(); // stop the timer to show the tooltip
d->delayedHide = true;
d->hideTimer->start(250);
}
void ToolTipManager::hideToolTip(QGraphicsWidget *widget)
void ToolTipManager::hide(QGraphicsWidget *widget)
{
ToolTip *tooltip = d->tooltips.value(widget);
if (tooltip) {
@ -210,7 +210,7 @@ void ToolTipManager::unregisterWidget(QGraphicsWidget *widget)
}
}
void ToolTipManager::setToolTipContent(QGraphicsWidget *widget, const ToolTipContent &data)
void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &data)
{
registerWidget(widget);
@ -309,6 +309,7 @@ void ToolTipManagerPrivate::showToolTip()
// give the object a chance for delayed loading of the tip
QMetaObject::invokeMethod(currentWidget, "toolTipAboutToShow");
tooltip = tooltips.value(currentWidget);
kDebug() << "attempt to make one ... we gots" << tooltip;
if (tooltip) {
justCreated = true;
} else {
@ -317,14 +318,12 @@ void ToolTipManagerPrivate::showToolTip()
}
}
if (tooltip->isActivated()) {
tooltip->setVisible(false);
//kDebug() << "about to show" << justCreated;
tooltip->prepareShowing(!justCreated);
tooltip->move(popupPosition(currentWidget, tooltip->size()));
isShown = true; //ToolTip is visible
tooltip->setVisible(true);
}
tooltip->setVisible(false);
//kDebug() << "about to show" << justCreated;
tooltip->prepareShowing(!justCreated);
tooltip->move(popupPosition(currentWidget, tooltip->size()));
isShown = true; //ToolTip is visible
tooltip->setVisible(true);
}
bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
@ -338,7 +337,7 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
case QEvent::GraphicsSceneHoverMove:
// If the tooltip isn't visible, run through showing the tooltip again
// so that it only becomes visible after a stationary hover
if (Plasma::ToolTipManager::self()->isToolTipVisible(widget)) {
if (Plasma::ToolTipManager::self()->isVisible(widget)) {
break;
}
@ -361,19 +360,19 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
// initialized, in which case view() will return 0.
QGraphicsView *parentView = viewFor(widget);
if (parentView) {
showToolTip(widget);
show(widget);
}
break;
}
case QEvent::GraphicsSceneHoverLeave:
delayedHideToolTip();
delayedHide();
break;
case QEvent::GraphicsSceneMousePress:
case QEvent::GraphicsSceneWheel:
hideToolTip(widget);
hide(widget);
default:
break;

View File

@ -46,14 +46,14 @@ class Applet;
* data.mainText = i18n("My Title");
* data.subText = i18n("This is a little tooltip");
* data.image = KIcon("some-icon").pixmap(IconSize(KIconLoader::Desktop));
* Plasma::ToolTipManager::self()->setToolTipContent(widget, data);
* Plasma::ToolTipManager::self()->setContent(widget, data);
* @endcode
*
* Note that, since a Plasma::Applet is a QGraphicsWidget, you can use
* Plasma::ToolTipManager::self()->setToolTipContent(this, data); in the
* Plasma::ToolTipManager::self()->setContent(this, data); in the
* applet's init() method to set a tooltip for the whole applet.
*
* The tooltip will be registered automatically by setToolTipContent(). It will be
* The tooltip will be registered automatically by setContent(). It will be
* automatically unregistered when the associated widget is deleted, freeing the
* memory used by the tooltip, but you can manually unregister it at any time by
* calling unregisterWidget().
@ -103,7 +103,7 @@ public:
*
* @param widget the widget for which the tooltip will be displayed
*/
void showToolTip(QGraphicsWidget *widget);
void show(QGraphicsWidget *widget);
/**
* Find out whether the tooltip for a given widget is currently being displayed.
@ -112,24 +112,24 @@ public:
* @return true if the tooltip of the widget is currently displayed,
* false if not
*/
bool isToolTipVisible(QGraphicsWidget *widget) const;
bool isVisible(QGraphicsWidget *widget) const;
/**
* Hides the currently showing tooltip after a short amount of time.
*/
void delayedHideToolTip();
void delayedHide();
/**
* Hides the tooltip for a widget immediately.
*
* @param widget the widget to hide the tooltip for
*/
void hideToolTip(QGraphicsWidget *widget);
void hide(QGraphicsWidget *widget);
/**
* Registers a widget with the tooltip manager.
*
* Note that setToolTipContent() will register the widget if it
* Note that setContent() will register the widget if it
* has not already been registered, and so you do not normally
* need to use the method.
*
@ -137,7 +137,7 @@ public:
* register your widget with registerWidget(), then implement
* a slot named toolTipAboutToShow for the widget. This will be
* called before the tooltip is shown, allowing you to set the
* data with setToolTipContent().
* data with setContent().
*
* If the widget also has a toolTipHidden slot, this will be called
* after the tooltip is hidden.
@ -165,7 +165,8 @@ public:
* @param data the content of the tooltip. If an empty ToolTipContent
* is passed in, the tooltip content will be reset.
*/
void setToolTipContent(QGraphicsWidget *widget, const ToolTipContent &data);
void setContent(QGraphicsWidget *widget,
const ToolTipContent &data = ToolTipContent());
private:
/**