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