author | treke <treke> | 2003-12-09 03:25:26 (UTC) |
---|---|---|
committer | treke <treke> | 2003-12-09 03:25:26 (UTC) |
commit | 1440000b373d624956f7cbc693ac67e248b7bdb3 (patch) (unidiff) | |
tree | 9c6cc91452b7a4ae9b122908c23a2588dc31f28e | |
parent | 1538a521b674d2eff02b926c0d82fa6184dd99db (diff) | |
download | opie-1440000b373d624956f7cbc693ac67e248b7bdb3.zip opie-1440000b373d624956f7cbc693ac67e248b7bdb3.tar.gz opie-1440000b373d624956f7cbc693ac67e248b7bdb3.tar.bz2 |
Disabling the rotationw worked, but the code was horribly unobvious. Rewriting for clarity.
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index 0da2f0c..dd71cad 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,213 +1,213 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <, > . <= redistribute it and/or modify it under | 6 | .> <, > . <= redistribute it and/or modify it under |
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%+i> _;_. | 11 | .%+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. . .: details. | 18 | ++= -. . .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-= this library; see the file COPYING.LIB. | 22 | -- :-= this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
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> | 38 | #include <opie/odevice.h> |
39 | 39 | ||
40 | #include "rotate.h" | 40 | #include "rotate.h" |
41 | 41 | ||
42 | using namespace Opie; | 42 | using namespace Opie; |
43 | 43 | ||
44 | 44 | ||
45 | RotateApplet::RotateApplet ( ) | 45 | RotateApplet::RotateApplet ( ) |
46 | : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) | 46 | : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) |
47 | { | 47 | { |
48 | 48 | ||
49 | #if !defined(QT_NO_COP) | 49 | #if !defined(QT_NO_COP) |
50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); | 50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); |
51 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 51 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
52 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 52 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | } | 55 | } |
56 | 56 | ||
57 | RotateApplet::~RotateApplet ( ) | 57 | RotateApplet::~RotateApplet ( ) |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Qcop receive method. | 63 | * Qcop receive method. |
64 | */ | 64 | */ |
65 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { | 65 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { |
66 | QDataStream stream( data, IO_ReadOnly ); | 66 | QDataStream stream( data, IO_ReadOnly ); |
67 | if ( msg == "flip()" ) { | 67 | if ( msg == "flip()" ) { |
68 | activated ( ); | 68 | activated ( ); |
69 | } else if ( msg == "rotateDefault()") { | 69 | } else if ( msg == "rotateDefault()") { |
70 | rotateDefault(); | 70 | rotateDefault(); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | int RotateApplet::position ( ) const | 75 | int RotateApplet::position ( ) const |
76 | { | 76 | { |
77 | return 3; | 77 | return 3; |
78 | } | 78 | } |
79 | 79 | ||
80 | QString RotateApplet::name ( ) const | 80 | QString RotateApplet::name ( ) const |
81 | { | 81 | { |
82 | return tr( "Rotate shortcut" ); | 82 | return tr( "Rotate shortcut" ); |
83 | } | 83 | } |
84 | 84 | ||
85 | QString RotateApplet::text ( ) const | 85 | QString RotateApplet::text ( ) const |
86 | { | 86 | { |
87 | return tr( "Rotate" ); | 87 | return tr( "Rotate" ); |
88 | } | 88 | } |
89 | 89 | ||
90 | /*QString RotateApplet::tr( const char* s ) const | 90 | /*QString RotateApplet::tr( const char* s ) const |
91 | { | 91 | { |
92 | return qApp->translate( "RotateApplet", s, 0 ); | 92 | return qApp->translate( "RotateApplet", s, 0 ); |
93 | } | 93 | } |
94 | 94 | ||
95 | QString RotateApplet::tr( const char* s, const char* p ) const | 95 | QString RotateApplet::tr( const char* s, const char* p ) const |
96 | { | 96 | { |
97 | return qApp->translate( "RotateApplet", s, p ); | 97 | return qApp->translate( "RotateApplet", s, p ); |
98 | } | 98 | } |
99 | */ | 99 | */ |
100 | 100 | ||
101 | QIconSet RotateApplet::icon ( ) const | 101 | QIconSet RotateApplet::icon ( ) const |
102 | { | 102 | { |
103 | QPixmap pix; | 103 | QPixmap pix; |
104 | QImage img = Resource::loadImage ( "Rotation" ); | 104 | QImage img = Resource::loadImage ( "Rotation" ); |
105 | 105 | ||
106 | if ( !img. isNull ( )) | 106 | if ( !img. isNull ( )) |
107 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); | 107 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); |
108 | return pix; | 108 | return pix; |
109 | } | 109 | } |
110 | 110 | ||
111 | QPopupMenu *RotateApplet::popup ( QWidget * ) const | 111 | QPopupMenu *RotateApplet::popup ( QWidget * ) const |
112 | { | 112 | { |
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | void RotateApplet::rotateDefault ( ) | 116 | void RotateApplet::rotateDefault ( ) |
117 | { | 117 | { |
118 | 118 | ||
119 | int rot = ODevice::inst()->rotation(); | 119 | int rot = ODevice::inst()->rotation(); |
120 | 120 | ||
121 | switch (rot) { | 121 | switch (rot) { |
122 | case Rot0: | 122 | case Rot0: |
123 | rot=0; | 123 | rot=0; |
124 | break; | 124 | break; |
125 | case Rot90: | 125 | case Rot90: |
126 | rot=90; | 126 | rot=90; |
127 | break; | 127 | break; |
128 | case Rot180: | 128 | case Rot180: |
129 | rot=180; | 129 | rot=180; |
130 | break; | 130 | break; |
131 | case Rot270: | 131 | case Rot270: |
132 | rot=270; | 132 | rot=270; |
133 | break; | 133 | break; |
134 | default: | 134 | default: |
135 | rot=0; | 135 | rot=0; |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | Config cfg( "qpe" ); | 138 | Config cfg( "qpe" ); |
139 | cfg.setGroup( "Appearance" ); | 139 | cfg.setGroup( "Appearance" ); |
140 | 140 | ||
141 | bool rotateDisabled = cfg.readBoolEntry( "rotateEnabled",false ); | 141 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); |
142 | 142 | ||
143 | if (rotateDisabled == true) | 143 | if (rotateEnabled == false) |
144 | return; | 144 | return; |
145 | 145 | ||
146 | // hide inputs methods before rotation | 146 | // hide inputs methods before rotation |
147 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 147 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
148 | 148 | ||
149 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 149 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
150 | env << rot; | 150 | env << rot; |
151 | 151 | ||
152 | m_flipped = false; | 152 | m_flipped = false; |
153 | 153 | ||
154 | } | 154 | } |
155 | void RotateApplet::activated ( ) | 155 | void RotateApplet::activated ( ) |
156 | { | 156 | { |
157 | 157 | ||
158 | int defaultRotation = QPEApplication::defaultRotation(); | 158 | int defaultRotation = QPEApplication::defaultRotation(); |
159 | int newRotation = defaultRotation; | 159 | int newRotation = defaultRotation; |
160 | 160 | ||
161 | Config cfg( "qpe" ); | 161 | Config cfg( "qpe" ); |
162 | cfg.setGroup( "Appearance" ); | 162 | cfg.setGroup( "Appearance" ); |
163 | 163 | ||
164 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 164 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
165 | ODirection rot = CW; | 165 | ODirection rot = CW; |
166 | 166 | ||
167 | if (rotDirection == -1) { | 167 | if (rotDirection == -1) { |
168 | rot = ODevice::inst ( )-> direction ( ); | 168 | rot = ODevice::inst ( )-> direction ( ); |
169 | } else { | 169 | } else { |
170 | rot = (ODirection)rotDirection; | 170 | rot = (ODirection)rotDirection; |
171 | } | 171 | } |
172 | 172 | ||
173 | // hide inputs methods before rotation | 173 | // hide inputs methods before rotation |
174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
175 | 175 | ||
176 | if ( m_flipped ) { | 176 | if ( m_flipped ) { |
177 | // if flipped, flip back to the original state, | 177 | // if flipped, flip back to the original state, |
178 | // regardless of rotation direction | 178 | // regardless of rotation direction |
179 | newRotation = defaultRotation; | 179 | newRotation = defaultRotation; |
180 | } else { | 180 | } else { |
181 | if ( rot == CCW ) { | 181 | if ( rot == CCW ) { |
182 | newRotation = ( defaultRotation + 90 ) % 360; | 182 | newRotation = ( defaultRotation + 90 ) % 360; |
183 | } else if ( rot == CW ) { | 183 | } else if ( rot == CW ) { |
184 | newRotation = ( defaultRotation + 270 ) % 360; | 184 | newRotation = ( defaultRotation + 270 ) % 360; |
185 | } else if ( rot == Flip ) { | 185 | } else if ( rot == Flip ) { |
186 | newRotation = ( defaultRotation + 180 ) % 360; | 186 | newRotation = ( defaultRotation + 180 ) % 360; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 190 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
191 | env << newRotation; | 191 | env << newRotation; |
192 | 192 | ||
193 | m_flipped = !m_flipped; | 193 | m_flipped = !m_flipped; |
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
197 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 197 | QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
198 | { | 198 | { |
199 | *iface = 0; | 199 | *iface = 0; |
200 | if ( uuid == IID_QUnknown ) | 200 | if ( uuid == IID_QUnknown ) |
201 | *iface = this; | 201 | *iface = this; |
202 | else if ( uuid == IID_MenuApplet ) | 202 | else if ( uuid == IID_MenuApplet ) |
203 | *iface = this; | 203 | *iface = this; |
204 | 204 | ||
205 | if ( *iface ) | 205 | if ( *iface ) |
206 | (*iface)-> addRef ( ); | 206 | (*iface)-> addRef ( ); |
207 | return QS_OK; | 207 | return QS_OK; |
208 | } | 208 | } |
209 | 209 | ||
210 | Q_EXPORT_INTERFACE( ) | 210 | Q_EXPORT_INTERFACE( ) |
211 | { | 211 | { |
212 | Q_CREATE_INSTANCE( RotateApplet ) | 212 | Q_CREATE_INSTANCE( RotateApplet ) |
213 | } | 213 | } |