author | harlekin <harlekin> | 2002-03-11 15:01:41 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-11 15:01:41 (UTC) |
commit | cb57d1df6804ab3739f96ba1881ffc8110e3caa9 (patch) (unidiff) | |
tree | d6280a00f13e55183b0c35032d79cd27b4f1873d | |
parent | fbc69c770602ee58e1b2d31a60d7743abb10cc2c (diff) | |
download | opie-cb57d1df6804ab3739f96ba1881ffc8110e3caa9.zip opie-cb57d1df6804ab3739f96ba1881ffc8110e3caa9.tar.gz opie-cb57d1df6804ab3739f96ba1881ffc8110e3caa9.tar.bz2 |
clickable labels by ardo
-rw-r--r-- | core/pim/today/clickablelabel.cpp | 31 | ||||
-rw-r--r-- | core/pim/today/clickablelabel.h | 20 |
2 files changed, 51 insertions, 0 deletions
diff --git a/core/pim/today/clickablelabel.cpp b/core/pim/today/clickablelabel.cpp new file mode 100644 index 0000000..6912c34 --- a/dev/null +++ b/core/pim/today/clickablelabel.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #include "clickablelabel.h" | ||
2 | |||
3 | ClickableLabel::ClickableLabel(QWidget* parent = 0, | ||
4 | const char* name = 0, | ||
5 | WFlags fl = 0) : | ||
6 | QLabel(parent,name,fl) | ||
7 | { | ||
8 | setFrameShape(NoFrame); | ||
9 | setFrameShadow(Sunken); | ||
10 | } | ||
11 | |||
12 | void ClickableLabel::mousePressEvent( QMouseEvent *e ) { | ||
13 | setFrameShape(Panel); | ||
14 | repaint(); | ||
15 | } | ||
16 | |||
17 | void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { | ||
18 | setFrameShape(NoFrame); | ||
19 | repaint(); | ||
20 | if (rect().contains(e->pos())) { | ||
21 | emit clicked(); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | void ClickableLabel::mouseMoveEvent( QMouseEvent *e ) { | ||
26 | if (rect().contains(e->pos())) { | ||
27 | setFrameShape(Panel); | ||
28 | } else { | ||
29 | setFrameShape(NoFrame); | ||
30 | } | ||
31 | } | ||
diff --git a/core/pim/today/clickablelabel.h b/core/pim/today/clickablelabel.h new file mode 100644 index 0000000..b6d33ad --- a/dev/null +++ b/core/pim/today/clickablelabel.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef CLICKABLELABEL | ||
2 | #define CLICKABLELABEL | ||
3 | |||
4 | #include <qlabel.h> | ||
5 | |||
6 | class ClickableLabel: public QLabel | ||
7 | { | ||
8 | Q_OBJECT | ||
9 | public: | ||
10 | ClickableLabel(QWidget* parent = 0, const char* name = 0, | ||
11 | WFlags fl = 0); | ||
12 | protected: | ||
13 | void mousePressEvent( QMouseEvent *e ); | ||
14 | void mouseReleaseEvent( QMouseEvent *e ); | ||
15 | void mouseMoveEvent( QMouseEvent *e ); | ||
16 | signals: | ||
17 | void clicked(); | ||
18 | }; | ||
19 | |||
20 | #endif | ||