author | kergoth <kergoth> | 2003-04-18 22:17:38 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-18 22:17:38 (UTC) |
commit | 6e7112a3610c4e562f991ba6d6f33ca2fe0c605d (patch) (unidiff) | |
tree | ae90d7b8c36c49f109e3c2f231a119fc7fd5b799 /core/applets | |
parent | d0852e67c15c5a973b7bc7f7bee238a6fd00dee6 (diff) | |
download | opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.zip opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.gz opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.bz2 |
Make appearance and rotate applet use the new rotation method of odevice.
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index 04270f1..62567ed 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -26,26 +26,30 @@ | |||
26 | 26 | ||
27 | */ | 27 | */ |
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 <qpe/config.h> |
35 | #include <qiconset.h> | 35 | #include <qiconset.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | 37 | ||
38 | #include <opie/odevice.h> | ||
39 | |||
38 | #include "rotate.h" | 40 | #include "rotate.h" |
39 | 41 | ||
42 | using namespace Opie; | ||
43 | |||
40 | 44 | ||
41 | RotateApplet::RotateApplet ( ) | 45 | RotateApplet::RotateApplet ( ) |
42 | : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) | 46 | : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) |
43 | { | 47 | { |
44 | 48 | ||
45 | #if defined(Q_WS_QWS) | 49 | #if defined(Q_WS_QWS) |
46 | #if !defined(QT_NO_COP) | 50 | #if !defined(QT_NO_COP) |
47 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); | 51 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); |
48 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 52 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
49 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 53 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); |
50 | #endif | 54 | #endif |
51 | #endif | 55 | #endif |
@@ -104,46 +108,51 @@ QIconSet RotateApplet::icon ( ) const | |||
104 | return pix; | 108 | return pix; |
105 | } | 109 | } |
106 | 110 | ||
107 | QPopupMenu *RotateApplet::popup ( QWidget * ) const | 111 | QPopupMenu *RotateApplet::popup ( QWidget * ) const |
108 | { | 112 | { |
109 | return 0; | 113 | return 0; |
110 | } | 114 | } |
111 | 115 | ||
112 | void RotateApplet::activated ( ) | 116 | void RotateApplet::activated ( ) |
113 | { | 117 | { |
114 | 118 | ||
115 | int defaultRotation = QPEApplication::defaultRotation(); | 119 | int defaultRotation = QPEApplication::defaultRotation(); |
116 | 120 | int newRotation = defaultRotation; | |
117 | int newRotation; | ||
118 | 121 | ||
119 | Config cfg( "qpe" ); | 122 | Config cfg( "qpe" ); |
120 | cfg.setGroup( "Appearance" ); | 123 | cfg.setGroup( "Appearance" ); |
121 | 124 | ||
122 | // 0 -> 90° clockwise, 1 -> 90° counterclockwise | 125 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
123 | int rotDirection = cfg.readNumEntry( "rotatedir", 0 ); | 126 | ODirection rot = CW; |
127 | |||
128 | if (rotDirection == -1) { | ||
129 | rot = ODevice::inst ( )-> direction ( ); | ||
130 | } else { | ||
131 | rot = (ODirection)rotDirection; | ||
132 | } | ||
124 | 133 | ||
125 | // hide inputs methods before rotation | 134 | // hide inputs methods before rotation |
126 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 135 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
127 | 136 | ||
128 | if ( m_flipped ) { | 137 | if ( m_flipped ) { |
129 | // if flipped, flip back to the original state, | 138 | // if flipped, flip back to the original state, |
130 | // regardless of rotation direction | 139 | // regardless of rotation direction |
131 | newRotation = defaultRotation; | 140 | newRotation = defaultRotation; |
132 | } else { | 141 | } else { |
133 | if ( rotDirection == 1 ) { | 142 | if ( rot == CCW ) { |
134 | newRotation = ( defaultRotation + 90 ) % 360; | 143 | newRotation = ( defaultRotation + 90 ) % 360; |
135 | } else if ( rotDirection == 0 ) { | 144 | } else if ( rot == CW ) { |
136 | newRotation = ( defaultRotation + 270 ) % 360; | 145 | newRotation = ( defaultRotation + 270 ) % 360; |
137 | } else { | 146 | } else if ( rot == Flip ) { |
138 | newRotation = ( defaultRotation + 180 ) % 360; | 147 | newRotation = ( defaultRotation + 180 ) % 360; |
139 | } | 148 | } |
140 | } | 149 | } |
141 | 150 | ||
142 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 151 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
143 | env << newRotation; | 152 | env << newRotation; |
144 | 153 | ||
145 | m_flipped = !m_flipped; | 154 | m_flipped = !m_flipped; |
146 | } | 155 | } |
147 | 156 | ||
148 | 157 | ||
149 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 158 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
@@ -154,14 +163,12 @@ QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **if | |||
154 | else if ( uuid == IID_MenuApplet ) | 163 | else if ( uuid == IID_MenuApplet ) |
155 | *iface = this; | 164 | *iface = this; |
156 | 165 | ||
157 | if ( *iface ) | 166 | if ( *iface ) |
158 | (*iface)-> addRef ( ); | 167 | (*iface)-> addRef ( ); |
159 | return QS_OK; | 168 | return QS_OK; |
160 | } | 169 | } |
161 | 170 | ||
162 | Q_EXPORT_INTERFACE( ) | 171 | Q_EXPORT_INTERFACE( ) |
163 | { | 172 | { |
164 | Q_CREATE_INSTANCE( RotateApplet ) | 173 | Q_CREATE_INSTANCE( RotateApplet ) |
165 | } | 174 | } |
166 | |||
167 | |||