summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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 @@
+#include "clickablelabel.h"
+
+ClickableLabel::ClickableLabel(QWidget* parent = 0,
+ const char* name = 0,
+ WFlags fl = 0) :
+ QLabel(parent,name,fl)
+{
+ setFrameShape(NoFrame);
+ setFrameShadow(Sunken);
+}
+
+void ClickableLabel::mousePressEvent( QMouseEvent *e ) {
+ setFrameShape(Panel);
+ repaint();
+}
+
+void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
+ setFrameShape(NoFrame);
+ repaint();
+ if (rect().contains(e->pos())) {
+ emit clicked();
+ }
+}
+
+void ClickableLabel::mouseMoveEvent( QMouseEvent *e ) {
+ if (rect().contains(e->pos())) {
+ setFrameShape(Panel);
+ } else {
+ setFrameShape(NoFrame);
+ }
+}
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 @@
+#ifndef CLICKABLELABEL
+#define CLICKABLELABEL
+
+#include <qlabel.h>
+
+class ClickableLabel: public QLabel
+{
+ Q_OBJECT
+public:
+ ClickableLabel(QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
+ protected:
+ void mousePressEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+ void mouseMoveEvent( QMouseEvent *e );
+ signals:
+ void clicked();
+};
+
+#endif