com.trolltech.qt.gui
Class QSystemTrayIcon

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.core.QObject
                  extended by com.trolltech.qt.gui.QSystemTrayIcon
All Implemented Interfaces:
QtJambiInterface

public class QSystemTrayIcon
extends QObject

The QSystemTrayIcon class provides an icon for an application in the system tray. Modern operating systems usually provide a special area on the desktop, called the system tray or notification area, where long-running applications can display icons and short messages.


The QSystemTrayIcon class can be used on the following platforms: To check whether a system tray is present on the user's desktop, call the QSystemTrayIcon::isSystemTrayAvailable() static function.

To add a system tray entry, create a QSystemTrayIcon object, call setContextMenu() to provide a context menu for the icon, and call show() to make it visible in the system tray. Status notification messages ("balloon messages") can be displayed at any time using showMessage().

If the system tray is unavailable when a system tray icon is constructed, but becomes available later, QSystemTrayIcon will automatically add an entry for the application in the system tray if the icon is visible.

The activated() signal is emitted when the user activates the icon.

Only on X11, when a tooltip is requested, the QSystemTrayIcon receives a QHelpEvent of type QEvent::ToolTip . Additionally, the QSystemTrayIcon receives wheel events of type QEvent::Wheel . These are not supported on any other platform.

See also:
QDesktopServices, QDesktopWidget, Desktop Integration, and System Tray Icon Example.


Nested Class Summary
static class QSystemTrayIcon.ActivationReason
          This enum describes the reason the system tray was activated.
static class QSystemTrayIcon.MessageIcon
          This enum describes the icon that is shown when a balloon message is displayed.
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 QSignalEmitter.Signal1 activated
          This signal takes 1 generic argument(s).
 QSignalEmitter.Signal0 messageClicked
          This signal is emitted when the message displayed using showMessage() was clicked by the user.
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QSystemTrayIcon()
          Constructs a QSystemTrayIcon object with the given parent.
QSystemTrayIcon(QIcon icon)
          Constructs a QSystemTrayIcon object with the given icon and parent.
QSystemTrayIcon(QIcon icon, QObject parent)
          Constructs a QSystemTrayIcon object with the given icon and parent.
QSystemTrayIcon(QObject parent)
          Constructs a QSystemTrayIcon object with the given parent.
 
Method Summary
 QMenu contextMenu()
          Returns the current context menu for the system tray entry.
 QRect geometry()
          Returns the geometry of the system tray icon in screen coordinates.
 void hide()
          Hides the system tray entry.
 QIcon icon()
          This property holds the system tray icon.
static boolean isSystemTrayAvailable()
          Returns true if the system tray is available; otherwise returns false.
 boolean isVisible()
          This property holds whether the system tray entry is visible.
 void setContextMenu(QMenu menu)
          Sets the specified menu to be the context menu for the system tray icon.
 void setIcon(QIcon icon)
          This property holds the system tray icon.
 void setToolTip(java.lang.String tip)
          This property holds the tooltip for the system tray entry.
 void setVisible(boolean visible)
          This property holds whether the system tray entry is visible.
 void show()
          Shows the icon in the system tray.
 void showMessage(java.lang.String title, java.lang.String msg)
          Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint.
 void showMessage(java.lang.String title, java.lang.String msg, QSystemTrayIcon.MessageIcon icon)
          Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint.
 void showMessage(java.lang.String title, java.lang.String msg, QSystemTrayIcon.MessageIcon icon, int msecs)
          Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint.
static boolean supportsMessages()
          Returns true if the system tray supports balloon messages; otherwise returns false.
 java.lang.String toolTip()
          This property holds the tooltip for the system tray entry.
 
Methods inherited from class com.trolltech.qt.core.QObject
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

activated

public final QSignalEmitter.Signal1 activated

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QSystemTrayIcon$ActivationReason(named: reason)>:

This signal is emitted when the user activates the system tray icon. reason specifies the reason for activation. QSystemTrayIcon::ActivationReason enumerates the various reasons.

See also:
QSystemTrayIcon::ActivationReason .


messageClicked

public final QSignalEmitter.Signal0 messageClicked
This signal is emitted when the message displayed using showMessage() was clicked by the user.

Currently this signal is not sent on Mac OS X.

Note: We follow Microsoft Windows XP/Vista behavior, so the signal is also emitted when the user clicks on a tray icon with a balloon message displayed.

See also:
activated() .

Constructor Detail

QSystemTrayIcon

public QSystemTrayIcon()
Constructs a QSystemTrayIcon object with the given parent.

The icon is initially invisible.

See also:
visible.


QSystemTrayIcon

public QSystemTrayIcon(QObject parent)
Constructs a QSystemTrayIcon object with the given parent.

The icon is initially invisible.

See also:
visible.


QSystemTrayIcon

public QSystemTrayIcon(QIcon icon)
Constructs a QSystemTrayIcon object with the given icon and parent.

The icon is initially invisible.

See also:
visible.


QSystemTrayIcon

public QSystemTrayIcon(QIcon icon,
                       QObject parent)
Constructs a QSystemTrayIcon object with the given icon and parent.

The icon is initially invisible.

See also:
visible.

Method Detail

contextMenu

public final QMenu contextMenu()
Returns the current context menu for the system tray entry.

See also:
setContextMenu().


geometry

public final QRect geometry()
Returns the geometry of the system tray icon in screen coordinates.

See also:
visible.


hide

public final void hide()
Hides the system tray entry.

See also:
show(), and visible.


icon

public final QIcon icon()
This property holds the system tray icon. On Windows, the system tray icon size is 16x16; on X11, the preferred size is 22x22. The icon will be scaled to the appropriate size as necessary.


isVisible

public final boolean isVisible()
This property holds whether the system tray entry is visible. Setting this property to true or calling show() makes the system tray icon visible; setting this property to false or calling hide() hides it.


setContextMenu

public final void setContextMenu(QMenu menu)
Sets the specified menu to be the context menu for the system tray icon.

The menu will pop up when the user requests the context menu for the system tray icon by clicking the mouse button.

On Mac OS X, this is currenly converted to a NSMenu, so the aboutToHide() signal is not emitted.

Note: The system tray icon does not take ownership of the menu. You must ensure that it is deleted at the appropriate time by, for example, creating the menu with a suitable parent object.

See also:
contextMenu().


setIcon

public final void setIcon(QIcon icon)
This property holds the system tray icon. On Windows, the system tray icon size is 16x16; on X11, the preferred size is 22x22. The icon will be scaled to the appropriate size as necessary.


setToolTip

public final void setToolTip(java.lang.String tip)
This property holds the tooltip for the system tray entry. On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.


setVisible

public final void setVisible(boolean visible)
This property holds whether the system tray entry is visible. Setting this property to true or calling show() makes the system tray icon visible; setting this property to false or calling hide() hides it.


show

public final void show()
Shows the icon in the system tray.

See also:
hide(), and visible.


showMessage

public final void showMessage(java.lang.String title,
                              java.lang.String msg,
                              QSystemTrayIcon.MessageIcon icon)
Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint. title and message must be plain text strings.

Message can be clicked by the user; the messageClicked() signal will emitted when this occurs.

Note that display of messages are dependent on the system configuration and user preferences, and that messages may not appear at all. Hence, it should not be relied upon as the sole means for providing critical information.

On Windows, the millisecondsTimeoutHint is usually ignored by the system when the application has focus.

See also:
show(), and supportsMessages().


showMessage

public final void showMessage(java.lang.String title,
                              java.lang.String msg)
Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint. title and message must be plain text strings.

Message can be clicked by the user; the messageClicked() signal will emitted when this occurs.

Note that display of messages are dependent on the system configuration and user preferences, and that messages may not appear at all. Hence, it should not be relied upon as the sole means for providing critical information.

On Windows, the millisecondsTimeoutHint is usually ignored by the system when the application has focus.

See also:
show(), and supportsMessages().


showMessage

public final void showMessage(java.lang.String title,
                              java.lang.String msg,
                              QSystemTrayIcon.MessageIcon icon,
                              int msecs)
Shows a balloon message for the entry with the given title, message and icon for the time specified in millisecondsTimeoutHint. title and message must be plain text strings.

Message can be clicked by the user; the messageClicked() signal will emitted when this occurs.

Note that display of messages are dependent on the system configuration and user preferences, and that messages may not appear at all. Hence, it should not be relied upon as the sole means for providing critical information.

On Windows, the millisecondsTimeoutHint is usually ignored by the system when the application has focus.

See also:
show(), and supportsMessages().


toolTip

public final java.lang.String toolTip()
This property holds the tooltip for the system tray entry. On some systems, the tooltip's length is limited. The tooltip will be truncated if necessary.


isSystemTrayAvailable

public static boolean isSystemTrayAvailable()
Returns true if the system tray is available; otherwise returns false.

If the system tray is currently unavailable but becomes available later, QSystemTrayIcon will automatically add an entry in the system tray if it is visible.


supportsMessages

public static boolean supportsMessages()
Returns true if the system tray supports balloon messages; otherwise returns false.

See also:
showMessage().