trayicon.h

Go to the documentation of this file.
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 1701 2007-04-09 03:12:06Z 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 : public TrayIconImpl
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051   /** Default constructor. */
00052   TrayIcon();
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   /** Sets the context menu displayed when the tray icon is selected. */
00065   void setContextMenu(QMenu *contextMenu);
00066   
00067 signals:
00068   /** Emitted when the user double-clicks on the tray icon. */
00069   void doubleClicked();
00070 
00071 protected:
00072   /** Override's QObject' event() method to catch mouse-related events. */
00073   bool event(QEvent *);
00074   /** Respond to a mouse button being pressed. */ 
00075   void mouseButtonPress(QMouseEvent *event);
00076   /** Respond to a mouse button being released. */
00077   void mouseButtonRelease(QMouseEvent *event);
00078   /** Respond to a mouse button being double-clicked. */
00079   void mouseButtonDblClick(QMouseEvent *event);
00080 
00081 private:
00082   QMenu* _contextMenu; /**< Menu to display when the tray icon is clicked. */
00083 };
00084 
00085 #endif
00086 

Generated on Wed Sep 5 15:49:28 2007 for Vidalia by  doxygen 1.5.3