Difference between revisions of "Development/Tutorials/PortToKStatusNotifierItem"

Jump to: navigation, search
(Created page with 'Here is a list of changes to make to your application so that it can take advantage of the new KStatusNotifierItem (KSNI) class, available since KDE 4.4. == Initialization == *...')
 
(Initialization)
Line 4: Line 4:
  
 
* KSNI constructor takes a QObject, not a QWidget
 
* KSNI constructor takes a QObject, not a QWidget
* Be sure to set your  
+
* Be sure to set the category of your application with setCategory()
  
* Signals:
+
== Signals ==
  * activated() becomes activateRequested(bool active, QPoint pos)
+
* activated() becomes activateRequested(bool active, QPoint pos)
 +
* Plasma systemtray will emit secondaryActivateRequested() when a user middle-click on the icon (other implementations may not support this though)
  
 
== Icons ==
 
== Icons ==

Revision as of 18:30, 25 February 2010

Here is a list of changes to make to your application so that it can take advantage of the new KStatusNotifierItem (KSNI) class, available since KDE 4.4.

Contents

Initialization

  • KSNI constructor takes a QObject, not a QWidget
  • Be sure to set the category of your application with setCategory()

Signals

  • activated() becomes activateRequested(bool active, QPoint pos)
  • Plasma systemtray will emit secondaryActivateRequested() when a user middle-click on the icon (other implementations may not support this though)

Icons

Icons can be passed as a QString or as a QPixmap. Note that both must go through D-Bus, so for performance reasons, pass icons by name whenever possible.

  • setIcon() becomes either setIconByName(QString) or setIconByPixmap(QPixmap)

Tooltip

A KSNI tooltip is made of an icon, a title and a subtitle (which may contain some limited markup). This means you have to replace your call to setToolTip(QString) with calls to:

  • setToolTipIconByName(QString) or setToolTipIconByPixmap()
  • setToolTipTitle(QString)
  • setToolTipSubTitle(QString)

show() -> setStatus(KStatusNotifierItem::Active) hide() -> setStatus(KStatusNotifierItem::Passive)

Misc

  • There is no equivalent for the convenience static loadIcon(QString) function. You have to replace it with KIconLoader::global()->loadIcon(name, KIconLoader::Panel)

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal