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