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 2362 2008-02-29 04:30:11Z 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 <QObject> 00021 #include <QString> 00022 #include <QMenu> 00023 #include <QMouseEvent> 00024 #include "config.h" 00025 00026 /* Include the correct tray icon implementation */ 00027 #if defined(Q_WS_MAC) 00028 #include "trayicon_mac.h" 00029 #else 00030 #include "trayicon_qt.h" 00031 #endif 00032 00033 00034 class TrayIcon : public TrayIconImpl 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 /** Balloon message status icons. */ 00040 enum BalloonMessageIcon { 00041 NoIcon = 0, 00042 Information, 00043 Warning, 00044 Critical 00045 }; 00046 00047 /** Default constructor. */ 00048 TrayIcon(QWidget *parent = 0); 00049 00050 /** Show the tray icon. */ 00051 void show(); 00052 /** Hide the tray icon. */ 00053 void hide(); 00054 /** Updates the icon image and tooltip. */ 00055 void update(const QString &iconFile, const QString &toolTip); 00056 /** Update the tray icon's tooltip. */ 00057 void setToolTip(const QString &toolTip); 00058 /** Update the tray icon's image. */ 00059 void setIcon(const QString &iconFile); 00060 /** Sets the context menu displayed when the tray icon is selected. */ 00061 void setContextMenu(QMenu *contextMenu); 00062 /** Displays a balloon message next to the tray icon. */ 00063 void showBalloonMessage(const QString &title, const QString &message, 00064 BalloonMessageIcon icon); 00065 00066 /** Returns true if the current platform and tray icon implementation 00067 * supports tray icons. */ 00068 static bool isTrayIconSupported(); 00069 /** Returns true if the current platform and tray icon implementation 00070 * supports tray icon balloon messages. */ 00071 static bool supportsBalloonMessages(); 00072 00073 signals: 00074 /** Emitted when the user double-clicks on the tray icon. */ 00075 void doubleClicked(); 00076 00077 protected: 00078 /** Override's QObject' event() method to catch mouse-related events. */ 00079 bool event(QEvent *); 00080 /** Respond to a mouse button being double-clicked. */ 00081 void mouseButtonDblClick(QMouseEvent *event); 00082 }; 00083 00084 #endif 00085