00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file trayicon.h 00024 * \version $Id: trayicon.h 1238 2006-09-25 17:50:57Z edmanm $ 00025 * \brief Places an icon with context menu in the system notification area 00026 */ 00027 00028 #ifndef _TRAYICON_H 00029 #define _TRAYICON_H 00030 00031 #include <QObject> 00032 #include <QString> 00033 #include <QMenu> 00034 #include <QMouseEvent> 00035 00036 /* Include the correct tray icon implementation */ 00037 #if defined(Q_WS_WIN) 00038 #include "trayicon_win.h" 00039 #elif defined(Q_WS_X11) 00040 #include "trayicon_x11.h" 00041 #else 00042 #include "trayicon_mac.h" 00043 #endif 00044 00045 00046 class TrayIcon : private TrayIconImpl 00047 { 00048 Q_OBJECT 00049 00050 public: 00051 /** Constructor */ 00052 TrayIcon(const QString &iconFile, const QString &toolTip, QMenu *popupMenu = 0); 00053 00054 /** Show the tray icon. */ 00055 void show(); 00056 /** Hide the tray icon. */ 00057 void hide(); 00058 /** Updates the icon image and tooltip. */ 00059 void update(const QString &iconFile, const QString &toolTip); 00060 /** Update the tray icon's tooltip. */ 00061 void setToolTip(const QString &toolTip); 00062 /** Update the tray icon's image. */ 00063 void setIcon(const QString &iconFile); 00064 00065 signals: 00066 /** Emitted when the user double-clicks on the tray icon. */ 00067 void doubleClicked(); 00068 00069 protected: 00070 /** Override's QObject' event() method to catch mouse-related events. */ 00071 bool event(QEvent *); 00072 /** Respond to a mouse button being pressed. */ 00073 void mouseButtonPress(QMouseEvent *event); 00074 /** Respond to a mouse button being released. */ 00075 void mouseButtonRelease(QMouseEvent *event); 00076 /** Respond to a mouse button being double-clicked. */ 00077 void mouseButtonDblClick(QMouseEvent *event); 00078 00079 private: 00080 QMenu* _popupMenu; /**< Menu to display when the tray icon is clicked. */ 00081 }; 00082 00083 #endif 00084