trayicon.h

00001 /*
00002  * trayicon.h - system-independent trayicon class (adapted from Qt example)
00003  * Copyright (C) 2003  Justin Karneges
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 #ifndef CS_TRAYICON_H
00022 #define CS_TRAYICON_H
00023 
00024 #include <qwidget.h>
00025 #include <qimage.h>
00026 
00027 class QPopupMenu;
00028 
00029 class TrayIcon : public QWidget
00030 {
00031         Q_OBJECT
00032 
00033         Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
00034         Q_PROPERTY( QPixmap icon READ icon WRITE setIcon )
00035 
00036 public:
00037         TrayIcon( QWidget *parent = 0, const char *name = 0 );
00038         TrayIcon( const QPixmap &, const QString &, QPopupMenu *popup = 0, QWidget *parent = 0, const char *name = 0 );
00039         ~TrayIcon();
00040 
00041         // use WindowMaker dock mode.  ignored on non-X11 platforms
00042         void setWMDock(bool use) { v_isWMDock = use; }
00043         bool isWMDock() { return v_isWMDock; }
00044 
00045         // Set a popup menu to handle RMB
00046         void setPopup( QPopupMenu * );
00047         QPopupMenu* popup() const;
00048 
00049         QPixmap icon() const;
00050         QString toolTip() const;
00051 
00052         void gotCloseEvent();
00053 
00054 public slots:
00055         void setIcon( const QPixmap &icon );
00056         void setToolTip( const QString &tip );
00057 
00058         void show();
00059         void hide();
00060 
00061 signals:
00062         void clicked( const QPoint&, int);
00063         void doubleClicked( const QPoint& );
00064         void closed();
00065 
00066 protected:
00067         bool event( QEvent * );
00068         virtual void mouseMoveEvent( QMouseEvent *e );
00069         virtual void mousePressEvent( QMouseEvent *e );
00070         virtual void mouseReleaseEvent( QMouseEvent *e );
00071         virtual void mouseDoubleClickEvent( QMouseEvent *e );
00072 
00073         private:
00074         QPopupMenu *pop;
00075         QPixmap pm;
00076         QString tip;
00077         bool v_isWMDock;
00078 
00079         // system-dependant part
00080         class TrayIconPrivate;
00081         TrayIconPrivate *d;
00082         void sysInstall();
00083         void sysRemove();
00084         void sysUpdateIcon();
00085         void sysUpdateToolTip();
00086 };
00087 
00088 #endif // CS_TRAYICON_H

Generated on Mon Jun 5 10:20:48 2006 for Intelligence.kdevelop by  doxygen 1.4.6