A proximity sensor plugin, checks if something is close to the phone (the phones...
[shepherd:shepherd-plugins.git] / shepherd / triggers / sensors / proximity_sensor / proximity.h
1 #ifndef SHEPHERD_PROXIMITY_SENSOR_PLUGIN_HEADER
2 #define SHEPHERD_PROXIMITY_SENSOR_PLUGIN_HEADER
3
4 #include <QProximitySensor>
5 #include <QProximityFilter>
6
7 #include "interfaces.h"
8
9 QTM_USE_NAMESPACE
10
11 class ProximitySensorPlugin : public QObject,
12                               public QProximityFilter,
13                               public InputInterface,
14                               public InfoInterface,
15                               public TriggerInterface
16 {
17     Q_OBJECT
18     Q_INTERFACES(InputInterface)
19     Q_INTERFACES(InfoInterface)
20     Q_INTERFACES(TriggerInterface)
21
22     public:
23         ProximitySensorPlugin(QObject * parent = 0);
24         ~ProximitySensorPlugin();
25
26         // InfoInterface
27         QString name();
28         QString description();
29         QPixmap * pixmap();
30         void aboutPlugin();
31
32         // InputInterface
33         bool configure();
34         bool configure(QString);
35         const QVariantMap & config();
36
37         // TriggerInterface
38         void setConfig(const QVariantMap &);
39         bool eval();
40
41     private slots:
42         bool filter(QProximityReading *);
43     
44     signals:
45         // TriggerInterface
46         void stateChanged(bool);
47         void turnedTrue();
48         void turnedFalse();
49
50     private:
51         QProximitySensor * m_sensor;
52         QPixmap * pix;
53         bool somethingCloseLastEval;
54 };
55
56 #endif