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 TrayIconImpl_mac.h 00013 ** \version $Id: TrayIconImpl_mac.h 3735 2009-04-28 20:28:01Z edmanm $ 00014 ** \brief Tray icon implementation on OS X (Dock icon) 00015 */ 00016 00017 #ifndef _TRAYICON_MAC_H 00018 #define _TRAYICON_MAC_H 00019 00020 #include <QWidget> 00021 #include <QString> 00022 00023 #include <Carbon/Carbon.h> 00024 00025 00026 class TrayIconImpl : public QWidget 00027 { 00028 Q_OBJECT 00029 00030 protected: 00031 /** Default Constructor */ 00032 TrayIconImpl(QWidget *parent = 0); 00033 /** Destructor */ 00034 ~TrayIconImpl(); 00035 00036 /** Show the tray icon. */ 00037 void show(); 00038 /** Hide the tray icon. */ 00039 void hide(); 00040 /** Update the tray icon's image. */ 00041 void setIcon(const QString &iconFile); 00042 /** Update the tray icon's tooltip. */ 00043 void setToolTip(const QString &toolTip); 00044 00045 private: 00046 /** Load icon data from the given file and create a CGImageRef. */ 00047 CGImageRef createIconFromFile(FSSpec fileSpec); 00048 /** Create an icon from the given filename in the application bundle. */ 00049 CGImageRef createIcon(const QString &iconFile); 00050 /** Callback used by CGDataProviderCreateWithData(). */ 00051 static void releaseCallback(void *info, const void *data, size_t size); 00052 00053 CGImageRef _imageRef; /**< Tray icon image. */ 00054 bool _shown; /**< True if the dock icon is to be displayed. */ 00055 }; 00056 00057 #endif 00058