Several GUI fixes
[pierogi] / pirapplication.cpp
1 #include "pirapplication.h"
2
3 #include <QWidget>
4 #include <X11/Xlib.h>
5 #include <X11/Xatom.h>
6 #include <QX11Info>
7
8 PIRApplication::PIRApplication(
9   int &argc,
10   char **argv)
11   : QApplication(argc, argv)
12 {
13 }
14
15
16 void PIRApplication::setupRockerSwitch(QWidget *window)
17 {
18   // free the rocker switch from the volume controls:
19   unsigned long val = 1;
20
21   Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", 0);
22
23   XChangeProperty( 
24     QX11Info::display(),
25     window->winId(),
26     atom,
27     XA_INTEGER,
28     32,
29     PropModeReplace,
30     (unsigned char *) &val,
31     1);
32 }
33
34
35 bool PIRApplication::x11EventFilter(
36   XEvent *event)
37 {
38   // Return true means we will consume the event here; return false means
39   // letting the event continue to be passed up the chain.
40
41   if (event->type == KeyPress)
42   {
43     // Function key 7 (keycode 73) or "Zoom Out" button will go up.
44     // Function key 8 (keycode 74) or "Zoom In" button will go down.
45     if (
46       event->xkey.keycode == 73 ||
47       event->xkey.keycode == QKeySequence::ZoomOut)
48     {
49       emit decreaseRockerPressed();
50       return true;
51     }
52     else if (
53       event->xkey.keycode == 74 ||
54       event->xkey.keycode == QKeySequence::ZoomIn)
55     {
56       emit increaseRockerPressed();
57       return true;
58     }
59   }
60
61   return false;
62 }