Summary Files Commits Branches @commit @diff @stats
path: root / src / app.cpp
diff options
context:
space:
mode:
Commita79a11d22dcb1bb0cbe47874d7f8ff5d58f2271a (patch)
Author
 MageJohn <magejohnyjtp@gmail.com>
2019-02-18 23:34:31 +0000
Committer
 MageJohn <magejohnyjtp@gmail.com>
2019-02-18 23:34:31 +0000
Files37d3347671d5080a75c3c65c4be8a6b0b7e7d2ed /src/app.cpp
lead-a79a11d22dcb1bb0cbe47874d7f8ff5d58f2271a.tar
lead-a79a11d22dcb1bb0cbe47874d7f8ff5d58f2271a.tar.gz
lead-a79a11d22dcb1bb0cbe47874d7f8ff5d58f2271a.zip
Parentfe8218f49006190ee779a80173b5cf54eed1ca92 (diff)
Implement basic delay support
The ini file now has two entries for each corner, one for the action to be performed and one for the interval after which it will be performed if the mouse doesn't leave the hot corner/edge. This is a little inelegant, and I'd like to make the ini file nicer at some point.
1 files changed, 21 insertions, 9 deletions
-rw-r--r--src/app.cpp30
diff --git a/src/app.cpp b/src/app.cpp
index 0e3075a..1b63b72 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -30,6 +30,7 @@ SOFTWARE.
#include <QDebug>
#include <QScreen>
#include <QFileSystemWatcher>
+#include <QVariant>
#define SENSOR_WIDTH 5
#define SENSOR_HEIGHT 5
@@ -136,29 +137,40 @@ void
App::loadSensor(QScreen* screen, QString name, int x, int y, int w, int h)
{
- QString key = screen->name() + "/" + name;
+ QString action = screen->name() + "/" + name + "-" + "action";
+ QString interval = screen->name() + "/" + name + "-" + "interval";
+ if (!settings.contains(interval))
+ {
+ qDebug() << "App::loadSensor() interval for " << name << " not found; setting to 0";
+
+ // set default
+ settings.setValue(interval, QVariant(0));
+ }
- if (!settings.contains(key) )
+ if (!settings.contains(action))
{
- qDebug() << "App::loadSensor() key " << name << " not found";
+ qDebug() << "App::loadSensor() action for " << name << " not found; creating empty key";
- // restore missing key
- settings.setValue(key, QString());
+ // restore missing action
+ settings.setValue(action, QString());
return;
}
- if (settings.value(key).toString().isEmpty())
+ if (settings.value(action).toString().isEmpty())
{
- qDebug() << "App::loadSensor() key " << name << " is empty";
+ qDebug() << "App::loadSensor() action for " << name << " is empty";
return;
}
// create sensor and save in list so we can delete all sensors on delete
- sensors.append( new Sensor(x, y, w, h, settings.value(key).toString()) );
+ qDebug() << "App::loadSensor() action for " << name << " is " << settings.value(action).toString();
+ qDebug() << "App::loadSensor() interval for " << name << " is " << settings.value(interval).toInt();
+
+ sensors.append( new Sensor(x, y, w, h, settings.value(action).toString(), settings.value(interval).toInt()) );
}
-} // namespace \ No newline at end of file
+} // namespace