• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Plasma

  • Plasma
  • ToolTipManager
Public Types | Signals | Public Member Functions | Static Public Member Functions

Plasma::ToolTipManager Class Reference

Manages tooltips for QGraphicsWidgets in Plasma. More...

#include <Plasma/ToolTipManager>

Inheritance diagram for Plasma::ToolTipManager:
Inheritance graph
[legend]

List of all members.

Public Types

enum  State { Activated = 0, Inhibited, Deactivated }

Signals

void linkActivated (const QString &anchor, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint &screenPos)
void windowPreviewActivated (WId window, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint &screenPos)

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 69 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 74 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 253 of file tooltipmanager.cpp.

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

Hides the tooltip for a widget immediately.

Parameters:
widgetthe widget to hide the tooltip for

Definition at line 182 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:
widgetthe widget to check the tooltip for
Returns:
true if the tooltip of the widget is currently displayed, false if not

Definition at line 164 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::linkActivated ( const QString &  anchor,
Qt::MouseButtons  buttons,
Qt::KeyboardModifiers  modifiers,
const QPoint &  screenPos 
) [signal]

This signal is emitted when a link in the tooltip is clicked.

  • anchor the achor text (e.g. url) that was clicked on
  • buttons the mouse buttons involved in the activation
  • modifiers the keyboard modifiers involved in the activation, if any
    Since:
    4.4
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:
widgetthe desired widget

Definition at line 194 of file tooltipmanager.cpp.

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

Definition at line 115 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:
widgetthe widget the tooltip should be associated with
datathe content of the tooltip. If an empty Content is passed in, the tooltip content will be reset.

Definition at line 216 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 258 of file tooltipmanager.cpp.

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

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

Parameters:
widgetthe widget for which the tooltip will be displayed

Definition at line 137 of file tooltipmanager.cpp.

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

Definition at line 274 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:
widgetthe desired widget to delete

Definition at line 206 of file tooltipmanager.cpp.

void Plasma::ToolTipManager::windowPreviewActivated ( WId  window,
Qt::MouseButtons  buttons,
Qt::KeyboardModifiers  modifiers,
const QPoint &  screenPos 
) [signal]

This signal is emitted when a window preview in the tooltip is clicked.

  • window the id of the window that was clicked
  • buttons the mouse buttons involved in the activation
  • modifiers the keyboard modifiers involved in the activation, if any
    Since:
    4.4

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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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