*
[groove] / qmaemo5rotator.h
1 #ifndef QMAEMO5ROTATOR_H
2 #define QMAEMO5ROTATOR_H
3 //----------
4 // Provides a means of WORKING automatic rotation for Maemo 5 apps. (The default Qt solution is buggy.)
5 //----------
6 #include <X11/extensions/Xrandr.h>
7 #include <X11/Xlib.h>
8 #include <Qt>
9 #include <QtGui>
10 #include <QtCore>
11
12 class QMaemo5Rotator : private QObject
13 {
14
15     Q_OBJECT
16
17 public:
18
19     enum RotationBehavior
20     {
21         AutomaticBehavior = 0,
22         LandscapeBehavior = 1,
23         PortraitBehavior = 2
24     };
25     enum direction
26     {
27         up = RR_Rotate_180,
28         down = RR_Rotate_0,
29         right = RR_Rotate_90,
30         left = RR_Rotate_270
31     };
32
33     enum Orientation
34     {
35         LandscapeOrientation = 0,
36         PortraitOrientation = 1
37     };
38
39 private:
40
41     bool isSetUp;
42     RotationBehavior _currentBehavior;
43     Orientation _currentOrientation;
44     static bool setRotation(direction);
45
46 public:
47
48     explicit QMaemo5Rotator(RotationBehavior behavior = LandscapeBehavior, QWidget *parent = NULL);
49     ~QMaemo5Rotator();
50
51     const RotationBehavior currentBehavior();
52     const Orientation currentOrientation();
53     void setCurrentBehavior(RotationBehavior value);
54     void setCurrentOrientation(Orientation value);
55     void test();
56
57 private slots:
58
59     void on_orientation_changed(const QString& newOrienation);
60
61 signals:
62
63     void orientationChanged(Orientation orientation);
64
65 };
66 #endif // QMAEMO5ROTATOR_H