summaryrefslogtreecommitdiff
path: root/declarativewatchwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'declarativewatchwrapper.cpp')
-rw-r--r--declarativewatchwrapper.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/declarativewatchwrapper.cpp b/declarativewatchwrapper.cpp
index 127b6d6..384a29d 100644
--- a/declarativewatchwrapper.cpp
+++ b/declarativewatchwrapper.cpp
@@ -5,7 +5,7 @@
using namespace sowatch;
DeclarativeWatchWrapper::DeclarativeWatchWrapper(Watch* watch, QObject *parent) :
- QObject(parent), _watch(watch)
+ QObject(parent), _watch(watch), _active(false)
{
}
@@ -15,15 +15,28 @@ QString DeclarativeWatchWrapper::model() const
return _watch->model();
}
+bool DeclarativeWatchWrapper::active() const
+{
+ return _active;
+}
+
void DeclarativeWatchWrapper::activate()
{
- connect(_watch, SIGNAL(buttonPressed(int)), this, SIGNAL(buttonPressed(int)));
- connect(_watch, SIGNAL(buttonReleased(int)), this, SIGNAL(buttonReleased(int)));
+ if (!_active) {
+ connect(_watch, SIGNAL(buttonPressed(int)), this, SIGNAL(buttonPressed(int)));
+ connect(_watch, SIGNAL(buttonReleased(int)), this, SIGNAL(buttonReleased(int)));
+ _active = true;
+ emit activeChanged();
+ }
}
void DeclarativeWatchWrapper::deactivate()
{
- disconnect(this, SIGNAL(buttonPressed(int)));
- disconnect(this, SIGNAL(buttonReleased(int)));
+ if (_active) {
+ disconnect(this, SIGNAL(buttonPressed(int)));
+ disconnect(this, SIGNAL(buttonReleased(int)));
+ _active = false;
+ emit activeChanged();
+ }
}