TrayIconImpl_qt.cpp

Go to the documentation of this file.
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_qt.cpp
00013 ** \version $Id: TrayIconImpl_qt.cpp 3735 2009-04-28 20:28:01Z edmanm $
00014 ** \brief Tray icon wrapper around Qt's QSystemTrayIcon implementation
00015 */
00016 
00017 #include "TrayIconImpl_qt.h"
00018 
00019 #include <QMouseEvent>
00020 
00021 
00022 /** Default constructor. */
00023 TrayIconImpl::TrayIconImpl(QObject *parent)
00024   : QSystemTrayIcon(parent)
00025 {
00026   connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
00027           this, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
00028 }
00029 
00030 /** Modify the tray icon's image to <b>iconFile</b>. */
00031 void
00032 TrayIconImpl::setIcon(const QString &iconFile)
00033 {
00034   QSystemTrayIcon::setIcon(QIcon(iconFile));
00035 }
00036 
00037 /** Called when the user interacts with the tray icon and propoagates
00038  * double-click events to the parent object. */
00039 void
00040 TrayIconImpl::onActivated(QSystemTrayIcon::ActivationReason reason)
00041 {
00042   if (reason == QSystemTrayIcon::DoubleClick) {
00043     /* Propagate the double-click to the parent class's event handler */
00044     event(new QMouseEvent(QEvent::MouseButtonDblClick, QPoint(), 
00045                           Qt::LeftButton, Qt::LeftButton, 
00046                           Qt::NoModifier));
00047   }
00048 }
00049 

Generated on 31 Mar 2010 for Vidalia by  doxygen 1.6.1