-rw-r--r-- | libopie/oclickablelabel.h | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/libopie/oclickablelabel.h b/libopie/oclickablelabel.h index f65c440..4b6dcbc 100644 --- a/libopie/oclickablelabel.h +++ b/libopie/oclickablelabel.h | |||
@@ -1,30 +1,53 @@ | |||
1 | #ifndef CLICKABLELABEL | 1 | #ifndef CLICKABLELABEL |
2 | #define CLICKABLELABEL | 2 | #define CLICKABLELABEL |
3 | 3 | ||
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | 5 | ||
6 | class OClickableLabel: public QLabel | 6 | /** |
7 | * This class is a special QLabel which can behave | ||
8 | * as a QPushButton or QToggleButton. | ||
9 | * The reason to use a clickable is if you want to save space | ||
10 | * or you want to skip the border of a normal button | ||
11 | * | ||
12 | * <pre> | ||
13 | * QLabel* lbl = new OClickableLabel( parent, "PushLabel" ); | ||
14 | * lbl->setPixmap( "config" ); | ||
15 | * QWhatsThis::add( lbl, tr("Click here to do something") ); | ||
16 | * </pre> | ||
17 | * | ||
18 | * @short A Label behaving as button | ||
19 | * @author Hakan Ardo, Maximillian Reiß ( harlekin@handhelds.org ) | ||
20 | * @see QLabel | ||
21 | * @see QPushButton | ||
22 | * @see QToggleButton | ||
23 | * @version 1.0 | ||
24 | */ | ||
25 | |||
26 | class OClickableLabel: public QLabel | ||
7 | { | 27 | { |
8 | Q_OBJECT | 28 | Q_OBJECT |
9 | public: | 29 | public: |
10 | OClickableLabel(QWidget* parent = 0, const char* name = 0, | 30 | OClickableLabel(QWidget* parent = 0, const char* name = 0, |
11 | WFlags fl = 0); | 31 | WFlags fl = 0); |
12 | void setToggleButton(bool t); | 32 | void setToggleButton(bool t); |
33 | |||
13 | protected: | 34 | protected: |
14 | void mousePressEvent( QMouseEvent *e ); | 35 | void mousePressEvent( QMouseEvent *e ); |
15 | void mouseReleaseEvent( QMouseEvent *e ); | 36 | void mouseReleaseEvent( QMouseEvent *e ); |
16 | void mouseMoveEvent( QMouseEvent *e ); | 37 | void mouseMoveEvent( QMouseEvent *e ); |
38 | |||
17 | public slots: | 39 | public slots: |
18 | void setOn(bool on); | 40 | void setOn(bool on); |
19 | signals: | 41 | signals: |
20 | void clicked(); | 42 | void clicked(); |
21 | void toggled(bool on); | 43 | void toggled(bool on); |
22 | private: | 44 | private: |
23 | bool isToggle; | 45 | bool isToggle : 1; |
24 | bool isDown; | 46 | bool isDown : 1; |
47 | bool textInverted : 1; | ||
48 | |||
25 | void showState(bool on); | 49 | void showState(bool on); |
26 | bool textInverted; | ||
27 | void setInverted(bool on); | 50 | void setInverted(bool on); |
28 | }; | 51 | }; |
29 | 52 | ||
30 | #endif | 53 | #endif |