Advanced Settings Panel
[pierogi] / pirapplication.cpp
index 66d240a..44af66b 100644 (file)
@@ -4,11 +4,14 @@
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 #include <QX11Info>
+#include <QTimer>
+
 
 PIRApplication::PIRApplication(
   int &argc,
   char **argv)
-  : QApplication(argc, argv)
+  : QApplication(argc, argv),
+    changingKeyset(false)
 {
 }
 
@@ -40,22 +43,39 @@ bool PIRApplication::x11EventFilter(
 
   if (event->type == KeyPress)
   {
-    // Check for function key 7 (keycode 73) or for "Zoom Out" button:
+    // Function key 7 (keycode 73) or "Zoom Out" button will go up.
+    // Function key 8 (keycode 74) or "Zoom In" button will go down.
     if (
       event->xkey.keycode == 73 ||
       event->xkey.keycode == QKeySequence::ZoomOut)
     {
-      emit decreaseRockerPressed();
+      if (!changingKeyset)
+      {
+        changingKeyset = true;
+        QTimer::singleShot(500, this, SLOT(finishChangingKeyset()));
+        emit decreaseRockerPressed();
+      }
       return true;
     }
     else if (
       event->xkey.keycode == 74 ||
       event->xkey.keycode == QKeySequence::ZoomIn)
     {
-      emit increaseRockerPressed();
+      if (!changingKeyset)
+      {
+        changingKeyset = true;
+        QTimer::singleShot(500, this, SLOT(finishChangingKeyset()));
+        emit increaseRockerPressed();
+      }
       return true;
     }
   }
 
   return false;
 }
+
+
+void PIRApplication::finishChangingKeyset()
+{
+  changingKeyset = false;
+}