Summary Files Commits Branches @commit @diff @stats
path: root / src / app.cpp
diff options
context:
space:
mode:
Commita64ffe1153d7b637007c2dde8bd39c559c97a1fe (patch)
Author
 Alexis Maiquez Murcia <almamu@almamu.com>
2019-02-19 16:56:26 +0100
Committer
 Alexis Maiquez Murcia <almamu@almamu.com>
2019-02-19 16:56:26 +0100
Filesd1b7d773b093fd5f9e82d6ec7fdbc2437e40431a /src/app.cpp
lead-a64ffe1153d7b637007c2dde8bd39c559c97a1fe.tar
lead-a64ffe1153d7b637007c2dde8bd39c559c97a1fe.tar.gz
lead-a64ffe1153d7b637007c2dde8bd39c559c97a1fe.zip
Parent81aba56ae3ff565d5650ead18344c0d66ee62579 (diff)
Added support for sensor leaving events with delay support
Here delay means the time the mouse has to be in the sensor for the leave event to trigger the action Signed-off-by: Alexis Maiquez Murcia <almamu@almamu.com>
1 files changed, 35 insertions, 8 deletions
-rw-r--r--src/app.cpp43
diff --git a/src/app.cpp b/src/app.cpp
index 06f4daa..1dd94cc 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -143,29 +143,56 @@ App::loadSensor(QScreen* screen, QString name, int x, int y, int w, int h)
return;
}
- QString sensorName = settings.value (sensorNameKey).toString ();
- QString sensorAction = sensorName + "/action";
- QString sensorDelay = sensorName + "/delay";
+ QString sensorName = settings.value (sensorNameKey).toString ();
+ QString sensorEnterAction = sensorName + "/enterAction";
+ QString sensorExitAction = sensorName + "/exitAction";
+ QString sensorEnterDelay = sensorName + "/enterDelay";
+ QString sensorExitDelay = sensorName + "/exitDelay";
+ int emptyCount = 0;
if (sensorName.isEmpty () == true)
{
return;
}
- if (!settings.contains (sensorAction))
+ if (!settings.contains (sensorEnterAction))
{
- qDebug () << "App::loadSensor () sensor " << sensorName << " does not have action; ignoring...";
+ emptyCount ++;
+ }
+
+ if (!settings.contains (sensorExitAction))
+ {
+ emptyCount ++;
+ }
+
+ if (emptyCount == 2)
+ {
+ qDebug () << "App::loadSensor () sensor " << sensorName << " does not have any action in it, ignoring...";
return;
}
- if (!settings.contains (sensorDelay))
+ if (!settings.contains (sensorEnterDelay))
{
qDebug () << "App::loadSensor () sensor " << sensorName << " does not have delay; setting to 0";
- settings.setValue (sensorDelay, QVariant (0));
+ settings.setValue (sensorEnterDelay, QVariant (0));
+ }
+
+ if (!settings.contains (sensorExitDelay))
+ {
+ qDebug () << "App::loadSensor () sensor " << sensorName << " does not have exit delay; setting to 0";
+ settings.setValue (sensorExitDelay, QVariant (0));
}
qDebug () << "App::loadSensor () loaded sensor " << sensorName << " on screen " + screen->name();
- sensors.append (new Sensor (x, y, w, h, settings.value (sensorAction).toString (), settings.value (sensorDelay).toInt ()));
+ sensors.append (
+ new Sensor (
+ x, y, w, h,
+ settings.value (sensorEnterAction).toString (),
+ settings.value (sensorExitAction).toString (),
+ settings.value (sensorEnterDelay).toInt (),
+ settings.value (sensorExitDelay).toInt ()
+ )
+ );
}