summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-11 15:01:41 (UTC)
committer harlekin <harlekin>2002-03-11 15:01:41 (UTC)
commitcb57d1df6804ab3739f96ba1881ffc8110e3caa9 (patch) (side-by-side diff)
treed6280a00f13e55183b0c35032d79cd27b4f1873d
parentfbc69c770602ee58e1b2d31a60d7743abb10cc2c (diff)
downloadopie-cb57d1df6804ab3739f96ba1881ffc8110e3caa9.zip
opie-cb57d1df6804ab3739f96ba1881ffc8110e3caa9.tar.gz
opie-cb57d1df6804ab3739f96ba1881ffc8110e3caa9.tar.bz2
clickable labels by ardo
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