• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

Plasma::ToolTipManager

Plasma::ToolTipManager Class Reference

Manages tooltips for QGraphicsWidgets in Plasma. More...

#include <Plasma/ToolTipManager>

Inheritance diagram for Plasma::ToolTipManager:
QObject

List of all members.

Public Types

enum  State { Activated = 0, Inhibited, Deactivated }

Public Member Functions

void clearContent (QGraphicsWidget *widget)
void hide (QGraphicsWidget *widget)
bool isVisible (QGraphicsWidget *widget) const
void registerWidget (QGraphicsWidget *widget)
void setContent (QGraphicsWidget *widget, const ToolTipContent &data)
void setState (ToolTipManager::State state)
void show (QGraphicsWidget *widget)
ToolTipManager::State state () const
void unregisterWidget (QGraphicsWidget *widget)

Static Public Member Functions

static ToolTipManager * self ()

Detailed Description

Manages tooltips for QGraphicsWidgets in Plasma.

If you want a widget to have a tooltip displayed when the mouse is hovered over it, you should do something like:

 // widget is a QGraphicsWidget*
 Plasma::ToolTipContent data;
 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()->setContent(widget, data);

Note that, since a Plasma::Applet is a QGraphicsWidget, you can use 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 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().

When a tooltip for a widget is about to be shown, the widget's toolTipAboutToShow slot will be invoked if it exists. Similarly, when a tooltip is hidden, the widget's toolTipHidden() slot will be invoked if it exists. This allows widgets to provide on-demand tooltip data.

Definition at line 68 of file tooltipmanager.h.


Member Enumeration Documentation

enum Plasma::ToolTipManager::State
Enumerator:
Activated 

< Will accept tooltip data and show tooltips

Inhibited 

< Will accept tooltip data, but not show tooltips

Deactivated 

< Will discard tooltip data, and not attempt to show them

Definition at line 73 of file tooltipmanager.h.


Member Function Documentation

void Plasma::ToolTipManager::clearContent ( QGraphicsWidget *  widget  ) 

Clears the tooltip data associated with this widget, but keeps the widget registered.

Definition at line 230 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::hide ( QGraphicsWidget *  widget  ) 

Hides the tooltip for a widget immediately.

Parameters:
widget the widget to hide the tooltip for

Definition at line 166 of file tooltipmanager.cpp.

bool Plasma::ToolTipManager::isVisible ( QGraphicsWidget *  widget  )  const

Find out whether the tooltip for a given widget is currently being displayed.

Parameters:
widget the widget to check the tooltip for
Returns:
true if the tooltip of the widget is currently displayed, false if not

Definition at line 154 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::registerWidget ( QGraphicsWidget *  widget  ) 

Registers a widget with the tooltip manager.

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.

This is useful for creating tooltip content on demand. You can 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 setContent().

If the widget also has a toolTipHidden slot, this will be called after the tooltip is hidden.

Parameters:
widget the desired widget

Definition at line 178 of file tooltipmanager.cpp.

ToolTipManager * Plasma::ToolTipManager::self (  )  [static]
Returns:
The singleton instance of the manager.

Definition at line 110 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::setContent ( QGraphicsWidget *  widget,
const ToolTipContent &  data 
)

Sets the content for the tooltip associated with a widget.

Note that this will register the widget with the ToolTipManager if necessary, so there is usually no need to call registerWidget().

Parameters:
widget the widget the tooltip should be associated with
data the content of the tooltip. If an empty Content is passed in, the tooltip content will be reset.

Definition at line 200 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::setState ( ToolTipManager::State  state  ) 

Sets the current state of the manager.

See also:
State
  • state the state to put the manager in

Definition at line 235 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::show ( QGraphicsWidget *  widget  ) 

Show the tooltip for a widget registered in the tooltip manager.

Parameters:
widget the widget for which the tooltip will be displayed

Definition at line 134 of file tooltipmanager.cpp.

ToolTipManager::State Plasma::ToolTipManager::state (  )  const
Returns:
the current state of the manager;
See also:
State

Definition at line 251 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::unregisterWidget ( QGraphicsWidget *  widget  ) 

Unregisters a widget from the tooltip manager.

This will free the memory used by the tooltip associated with the widget.

Parameters:
widget the desired widget to delete

Definition at line 190 of file tooltipmanager.cpp.


The documentation for this class was generated from the following files:
  • tooltipmanager.h
  • tooltipmanager.cpp

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal