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