Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
VClickLabel.h
Go to the documentation of this file.
1
/*
2
** This file is part of Vidalia, and is subject to the license terms in the
3
** LICENSE file, found in the top level directory of this distribution. If you
4
** did not receive the LICENSE file with this file, you may obtain it from the
5
** Vidalia source package distributed by the Vidalia Project at
6
** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7
** including this file, may be copied, modified, propagated, or distributed
8
** except according to the terms described in the LICENSE file.
9
*/
10
11
/*
12
** \file VClickLabel.h
13
** \brief Custom widget to create a clickable label with both an image and text.
14
*/
15
16
#ifndef _VCLICKLABEL_H
17
#define _VCLICKLABEL_H
18
19
#include <QWidget>
20
#include <QPixmap>
21
#include <QMouseEvent>
22
#include <QSize>
23
24
25
class
VClickLabel
:
public
QWidget
26
{
27
Q_OBJECT
28
29
public
:
30
/** Default constructor. */
31
VClickLabel
(QWidget *parent = 0);
32
33
/** Returns the current size hint for this widget's current contents. */
34
virtual
QSize
sizeHint
()
const
;
35
/** Returns the minimum size hint for this widget's current contents. */
36
virtual
QSize
minimumSizeHint
()
const
;
37
38
/** Sets the label text to <b>text</b>. */
39
void
setText
(
const
QString &
text
);
40
/** Sets the widget's image to <b>img</b>. */
41
void
setPixmap
(
const
QPixmap &img);
42
43
const
QString&
text
()
const
{
return
_text
; }
44
const
QPixmap&
pixmap
()
const
{
return
_pixmap
; }
45
46
Q_PROPERTY(QString text READ text WRITE setText USER
true
);
47
Q_PROPERTY(QPixmap
pixmap
READ
pixmap
WRITE setPixmap USER
true
);
48
49
public
slots:
50
/** Enables painting a different background color for this label */
51
void
enableFlashing
();
52
/** Disables the background color modification */
53
void
disableFlashing
();
54
55
signals:
56
/** Emitted when the widget is left-clicked. */
57
void
clicked
();
58
59
protected
:
60
/** Overloaded paint event to draw a pixmap and a text label. */
61
virtual
void
paintEvent
(QPaintEvent *e);
62
/** Overloaded mouse event to remember click state. */
63
virtual
void
mousePressEvent
(QMouseEvent * e);
64
/** Overloaded mouse event to catch left mouse button clicks. */
65
virtual
void
mouseReleaseEvent
(QMouseEvent *e);
66
67
private
:
68
QString
_text
;
/**< Text label to display in the widget. */
69
QPixmap
_pixmap
;
/**< Image to display in the widget. */
70
bool
_flashToggle
;
/**< Bool toggle for flashing the button. */
71
bool
_isPressed
;
/**< Remember if label is currently pressed. */
72
};
73
74
#endif
75
Generated on Thu Dec 6 2012 04:33:17 for Vidalia by
1.8.2