-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 32 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.h | 2 |
2 files changed, 26 insertions, 8 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index e236cd1..4743388 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -28,22 +28,23 @@ | |||
28 | 28 | ||
29 | 29 | ||
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/config.h> | ||
34 | #include <qiconset.h> | 35 | #include <qiconset.h> |
35 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
36 | 37 | ||
37 | #include "rotate.h" | 38 | #include "rotate.h" |
38 | 39 | ||
39 | 40 | ||
40 | RotateApplet::RotateApplet ( ) | 41 | RotateApplet::RotateApplet ( ) |
41 | : QObject ( 0, "RotateApplet" ), ref ( 0 ) | 42 | : QObject ( 0, "RotateApplet" ), ref ( 0 ) |
42 | { | 43 | { |
43 | m_native = true; | 44 | m_flipped = false; |
44 | } | 45 | } |
45 | 46 | ||
46 | RotateApplet::~RotateApplet ( ) | 47 | RotateApplet::~RotateApplet ( ) |
47 | { | 48 | { |
48 | } | 49 | } |
49 | 50 | ||
@@ -89,31 +90,48 @@ QPopupMenu *RotateApplet::popup ( QWidget * ) const | |||
89 | 90 | ||
90 | void RotateApplet::activated ( ) | 91 | void RotateApplet::activated ( ) |
91 | { | 92 | { |
92 | int currentRotation = QPEApplication::defaultRotation(); | 93 | int currentRotation = QPEApplication::defaultRotation(); |
93 | 94 | ||
94 | int newRotation; | 95 | int newRotation; |
95 | if ( m_native == true ) { | ||
96 | 96 | ||
97 | Config cfg( "qpe" ); | ||
98 | cfg.setGroup( "Appearance" ); | ||
99 | |||
100 | // 0 -> 90° clockwise, 1 -> 90° counterclockwise | ||
101 | bool rotDirection = cfg.readBoolEntry( "rotatedir" ); | ||
102 | |||
103 | // hide inputs methods before rotation | ||
104 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | ||
105 | |||
106 | if ( m_flipped ) { | ||
107 | if ( rotDirection ) { | ||
108 | newRotation = currentRotation - 90; | ||
109 | if (newRotation <=0) newRotation = 270; | ||
110 | //ipaqs like the 36xx have the display rotated | ||
111 | // to 270 as default, and -90 is invalid => handle this here | ||
112 | } else { | ||
97 | newRotation = currentRotation + 90; | 113 | newRotation = currentRotation + 90; |
98 | if(newRotation >= 360) newRotation = 0;//ipaqs like the 36xx have the display | 114 | if(newRotation >= 360) newRotation = 0;//ipaqs like the 36xx have the display |
99 | //rotated to 270 as default, so 360 does nothing => handle this here | 115 | //rotated to 270 as default, so 360 does nothing => handle this here |
100 | 116 | } | |
117 | } else { | ||
118 | if ( rotDirection ) { | ||
119 | newRotation = currentRotation + 90; | ||
120 | if(newRotation >= 360) newRotation = 0; | ||
101 | } else { | 121 | } else { |
102 | newRotation = currentRotation - 90; | 122 | newRotation = currentRotation - 90; |
103 | if (newRotation <=0) newRotation = 270; | 123 | if (newRotation <=0) newRotation = 270; |
104 | //ipaqs like the 36xx have the display rotated | 124 | } |
105 | // to 270 as default, and -90 is invalid => handle this here | ||
106 | } | 125 | } |
107 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 126 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
108 | env << newRotation; | 127 | env << newRotation; |
109 | QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" ); | 128 | QCopEnvelope env2( "QPE/System", "setDefaultRotation(int)" ); |
110 | env2 << newRotation; | 129 | env2 << newRotation; |
111 | 130 | ||
112 | m_native = !m_native; | 131 | m_flipped = !m_flipped; |
113 | |||
114 | } | 132 | } |
115 | 133 | ||
116 | 134 | ||
117 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 135 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
118 | { | 136 | { |
119 | *iface = 0; | 137 | *iface = 0; |
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h index c4087f9..57f9040 100644 --- a/core/applets/rotateapplet/rotate.h +++ b/core/applets/rotateapplet/rotate.h | |||
@@ -51,11 +51,11 @@ public: | |||
51 | virtual QString tr( const char*, const char* ) const; | 51 | virtual QString tr( const char*, const char* ) const; |
52 | virtual QPopupMenu *popup ( QWidget *parent ) const; | 52 | virtual QPopupMenu *popup ( QWidget *parent ) const; |
53 | 53 | ||
54 | virtual void activated ( ); | 54 | virtual void activated ( ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | bool m_native; | 57 | bool m_flipped; |
58 | ulong ref; | 58 | ulong ref; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | #endif | 61 | #endif |