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 VClickLabel.h 00013 ** \version $Id: VClickLabel.h 3735 2009-04-28 20:28:01Z edmanm $ 00014 ** \brief Custom widget to create a clickable label with both an image and text. 00015 */ 00016 00017 #ifndef _VCLICKLABEL_H 00018 #define _VCLICKLABEL_H 00019 00020 #include <QWidget> 00021 #include <QPixmap> 00022 #include <QMouseEvent> 00023 #include <QSize> 00024 00025 00026 class VClickLabel : public QWidget 00027 { 00028 Q_OBJECT 00029 00030 public: 00031 /** Default constructor. */ 00032 VClickLabel(QWidget *parent = 0); 00033 00034 /** Returns the current size hint for this widget's current contents. */ 00035 virtual QSize sizeHint() const; 00036 /** Returns the minimum size hint for this widget's current contents. */ 00037 virtual QSize minimumSizeHint() const; 00038 00039 /** Sets the label text to <b>text</b>. */ 00040 void setText(const QString &text); 00041 /** Sets the widget's image to <b>img</b>. */ 00042 void setPixmap(const QPixmap &img); 00043 00044 signals: 00045 /** Emitted when the widget is left-clicked. */ 00046 void clicked(); 00047 00048 protected: 00049 /** Overloaded paint event to draw a pixmap and a text label. */ 00050 virtual void paintEvent(QPaintEvent *e); 00051 /** Overloaded mouse event to catch left mouse button clicks. */ 00052 virtual void mouseReleaseEvent(QMouseEvent *e); 00053 00054 private: 00055 QString _text; /**< Text label to display in the widget. */ 00056 QPixmap _pixmap; /**< Image to display in the widget. */ 00057 }; 00058 00059 #endif 00060