00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file TrayIcon.h 00013 ** \version $Id: TrayIcon.h 3737 2009-04-28 21:30:21Z edmanm $ 00014 ** \brief Places an icon with context menu in the system notification area 00015 */ 00016 00017 #ifndef _TRAYICON_H 00018 #define _TRAYICON_H 00019 00020 #include "config.h" 00021 00022 #include <QtGlobal> 00023 #if defined(Q_WS_MAC) 00024 #include "TrayIconImpl_mac.h" 00025 #else 00026 #include "TrayIconImpl_qt.h" 00027 #endif 00028 00029 #include <QObject> 00030 #include <QString> 00031 #include <QMenu> 00032 #include <QMouseEvent> 00033 00034 00035 class TrayIcon : public TrayIconImpl 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 /** Balloon message status icons. */ 00041 enum BalloonMessageIcon { 00042 NoIcon = 0, 00043 Information, 00044 Warning, 00045 Critical 00046 }; 00047 00048 /** Default constructor. */ 00049 TrayIcon(QWidget *parent = 0); 00050 00051 /** Show the tray icon. */ 00052 void show(); 00053 /** Hide the tray icon. */ 00054 void hide(); 00055 /** Updates the icon image and tooltip. */ 00056 void update(const QString &iconFile, const QString &toolTip); 00057 /** Update the tray icon's tooltip. */ 00058 void setToolTip(const QString &toolTip); 00059 /** Update the tray icon's image. */ 00060 void setIcon(const QString &iconFile); 00061 /** Sets the context menu displayed when the tray icon is selected. */ 00062 void setContextMenu(QMenu *contextMenu); 00063 /** Displays a balloon message next to the tray icon. */ 00064 void showBalloonMessage(const QString &title, const QString &message, 00065 BalloonMessageIcon icon); 00066 00067 /** Returns true if the current platform and tray icon implementation 00068 * supports tray icons. */ 00069 static bool isTrayIconSupported(); 00070 /** Returns true if the current platform and tray icon implementation 00071 * supports tray icon balloon messages. */ 00072 static bool supportsBalloonMessages(); 00073 00074 signals: 00075 /** Emitted when the user double-clicks on the tray icon. */ 00076 void doubleClicked(); 00077 00078 protected: 00079 /** Override's QObject' event() method to catch mouse-related events. */ 00080 bool event(QEvent *); 00081 /** Respond to a mouse button being double-clicked. */ 00082 void mouseButtonDblClick(QMouseEvent *event); 00083 }; 00084 00085 #endif 00086