summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/clickablelabel.cpp31
-rw-r--r--core/pim/today/clickablelabel.h20
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
3ClickableLabel::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
12void ClickableLabel::mousePressEvent( QMouseEvent *e ) {
13 setFrameShape(Panel);
14 repaint();
15}
16
17void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
18 setFrameShape(NoFrame);
19 repaint();
20 if (rect().contains(e->pos())) {
21 emit clicked();
22 }
23}
24
25void 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
6class ClickableLabel: public QLabel
7{
8 Q_OBJECT
9public:
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