author | mickeyl <mickeyl> | 2004-01-12 19:38:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-12 19:38:37 (UTC) |
commit | 209e45790acd34ad85f8eaa103de20243f099e3e (patch) (unidiff) | |
tree | 980fccdea02e0aa8f9d52a857502c5dd1c87b151 | |
parent | 27e75f81eba7f5f7d267c2bac8f576cf7c9e2128 (diff) | |
download | opie-209e45790acd34ad85f8eaa103de20243f099e3e.zip opie-209e45790acd34ad85f8eaa103de20243f099e3e.tar.gz opie-209e45790acd34ad85f8eaa103de20243f099e3e.tar.bz2 |
nanoseconds are neither milliseconds nor microseconds
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index d8081a6..906063e 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,254 +1,254 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> | 4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> |
5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> | 5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This library is free software; you can | 8 | _;:, .> :=|. This library is free software; you can |
9 | .> <, > . <= redistribute it and/or modify it under | 9 | .> <, > . <= redistribute it and/or modify it under |
10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%+i> _;_. | 14 | .%+i> _;_. |
15 | .i_,=:_. -<s. This library is distributed in the hope that | 15 | .i_,=:_. -<s. This library is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. . .: details. | 21 | ++= -. . .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-= this library; see the file COPYING.LIB. | 25 | -- :-= this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "rotate.h" | 31 | #include "rotate.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie/odevice.h> | 34 | #include <opie/odevice.h> |
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | using namespace Opie; | 41 | using namespace Opie; |
42 | 42 | ||
43 | /* QT */ | 43 | /* QT */ |
44 | #include <qiconset.h> | 44 | #include <qiconset.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | 46 | ||
47 | #include <time.h> | 47 | #include <time.h> |
48 | 48 | ||
49 | RotateApplet::RotateApplet() | 49 | RotateApplet::RotateApplet() |
50 | :QObject( 0, "RotateApplet" ), ref( 0 ), m_flipped( false ) | 50 | :QObject( 0, "RotateApplet" ), ref( 0 ), m_flipped( false ) |
51 | { | 51 | { |
52 | 52 | ||
53 | #if !defined(QT_NO_COP) | 53 | #if !defined(QT_NO_COP) |
54 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); | 54 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); |
55 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 55 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
56 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 56 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | RotateApplet::~RotateApplet ( ) | 61 | RotateApplet::~RotateApplet ( ) |
62 | {} | 62 | {} |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Qcop receive method. | 65 | * Qcop receive method. |
66 | */ | 66 | */ |
67 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) | 67 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) |
68 | { | 68 | { |
69 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); | 69 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); |
70 | 70 | ||
71 | if ( ODevice::inst()->hasHingeSensor() ) | 71 | if ( ODevice::inst()->hasHingeSensor() ) |
72 | { | 72 | { |
73 | struct timespec interval; | 73 | struct timespec interval; |
74 | struct timespec remain; | 74 | struct timespec remain; |
75 | interval.tv_sec = 0; | 75 | interval.tv_sec = 0; |
76 | interval.tv_nsec = 600; | 76 | interval.tv_nsec = 600000; |
77 | ::nanosleep( &interval, &remain ); | 77 | ::nanosleep( &interval, &remain ); |
78 | OHingeStatus status = ODevice::inst()->readHingeSensor(); | 78 | OHingeStatus status = ODevice::inst()->readHingeSensor(); |
79 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); | 79 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); |
80 | 80 | ||
81 | Config cfg( "apm" ); | 81 | Config cfg( "apm" ); |
82 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); | 82 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); |
83 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); | 83 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); |
84 | 84 | ||
85 | if ( status == CASE_CLOSED ) | 85 | if ( status == CASE_CLOSED ) |
86 | { | 86 | { |
87 | switch ( action ) | 87 | switch ( action ) |
88 | { | 88 | { |
89 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; | 89 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; |
90 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; | 90 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; |
91 | default: /* IGNORE */ break; | 91 | default: /* IGNORE */ break; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | else /* status != CASE_CLOSED */ | 94 | else /* status != CASE_CLOSED */ |
95 | { | 95 | { |
96 | switch ( action ) | 96 | switch ( action ) |
97 | { | 97 | { |
98 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; | 98 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; |
99 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; | 99 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; |
100 | default: /* IGNORE */ break; | 100 | default: /* IGNORE */ break; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); | 103 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); |
104 | } | 104 | } |
105 | 105 | ||
106 | QDataStream stream( data, IO_ReadOnly ); | 106 | QDataStream stream( data, IO_ReadOnly ); |
107 | if ( msg == "flip()" ) | 107 | if ( msg == "flip()" ) |
108 | { | 108 | { |
109 | activated ( ); | 109 | activated ( ); |
110 | } | 110 | } |
111 | else if ( msg == "rotateDefault()") | 111 | else if ( msg == "rotateDefault()") |
112 | { | 112 | { |
113 | rotateDefault(); | 113 | rotateDefault(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | int RotateApplet::position() const | 117 | int RotateApplet::position() const |
118 | { | 118 | { |
119 | return 3; | 119 | return 3; |
120 | } | 120 | } |
121 | 121 | ||
122 | QString RotateApplet::name() const | 122 | QString RotateApplet::name() const |
123 | { | 123 | { |
124 | return tr( "Rotate shortcut" ); | 124 | return tr( "Rotate shortcut" ); |
125 | } | 125 | } |
126 | 126 | ||
127 | QString RotateApplet::text() const | 127 | QString RotateApplet::text() const |
128 | { | 128 | { |
129 | return tr( "Rotate" ); | 129 | return tr( "Rotate" ); |
130 | } | 130 | } |
131 | 131 | ||
132 | /*QString RotateApplet::tr( const char* s ) const | 132 | /*QString RotateApplet::tr( const char* s ) const |
133 | { | 133 | { |
134 | return qApp->translate( "RotateApplet", s, 0 ); | 134 | return qApp->translate( "RotateApplet", s, 0 ); |
135 | } | 135 | } |
136 | 136 | ||
137 | QString RotateApplet::tr( const char* s, const char* p ) const | 137 | QString RotateApplet::tr( const char* s, const char* p ) const |
138 | { | 138 | { |
139 | return qApp->translate( "RotateApplet", s, p ); | 139 | return qApp->translate( "RotateApplet", s, p ); |
140 | } | 140 | } |
141 | */ | 141 | */ |
142 | 142 | ||
143 | QIconSet RotateApplet::icon() const | 143 | QIconSet RotateApplet::icon() const |
144 | { | 144 | { |
145 | QPixmap pix; | 145 | QPixmap pix; |
146 | QImage img = Resource::loadImage( "Rotation" ); | 146 | QImage img = Resource::loadImage( "Rotation" ); |
147 | if ( !img.isNull() ) | 147 | if ( !img.isNull() ) |
148 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); | 148 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); |
149 | return pix; | 149 | return pix; |
150 | } | 150 | } |
151 | 151 | ||
152 | QPopupMenu* RotateApplet::popup(QWidget*) const | 152 | QPopupMenu* RotateApplet::popup(QWidget*) const |
153 | { | 153 | { |
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | void RotateApplet::rotateDefault() | 157 | void RotateApplet::rotateDefault() |
158 | { | 158 | { |
159 | int rot = ODevice::inst()->rotation(); | 159 | int rot = ODevice::inst()->rotation(); |
160 | 160 | ||
161 | switch (rot) | 161 | switch (rot) |
162 | { | 162 | { |
163 | case Rot0: rot=0; break; | 163 | case Rot0: rot=0; break; |
164 | case Rot90: rot=90; break; | 164 | case Rot90: rot=90; break; |
165 | case Rot180: rot=180; break; | 165 | case Rot180: rot=180; break; |
166 | case Rot270: rot=270; break; | 166 | case Rot270: rot=270; break; |
167 | default: rot=0; break; | 167 | default: rot=0; break; |
168 | } | 168 | } |
169 | 169 | ||
170 | Config cfg( "qpe" ); | 170 | Config cfg( "qpe" ); |
171 | cfg.setGroup( "Appearance" ); | 171 | cfg.setGroup( "Appearance" ); |
172 | 172 | ||
173 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); | 173 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); |
174 | 174 | ||
175 | if ( !rotateEnabled) return; | 175 | if ( !rotateEnabled) return; |
176 | 176 | ||
177 | // hide inputs methods before rotation | 177 | // hide inputs methods before rotation |
178 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 178 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
179 | 179 | ||
180 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 180 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
181 | env << rot; | 181 | env << rot; |
182 | 182 | ||
183 | m_flipped = false; | 183 | m_flipped = false; |
184 | 184 | ||
185 | } | 185 | } |
186 | void RotateApplet::activated() | 186 | void RotateApplet::activated() |
187 | { | 187 | { |
188 | int defaultRotation = QPEApplication::defaultRotation(); | 188 | int defaultRotation = QPEApplication::defaultRotation(); |
189 | int newRotation = defaultRotation; | 189 | int newRotation = defaultRotation; |
190 | 190 | ||
191 | Config cfg( "qpe" ); | 191 | Config cfg( "qpe" ); |
192 | cfg.setGroup( "Appearance" ); | 192 | cfg.setGroup( "Appearance" ); |
193 | 193 | ||
194 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 194 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
195 | ODirection rot = CW; | 195 | ODirection rot = CW; |
196 | 196 | ||
197 | if (rotDirection == -1) | 197 | if (rotDirection == -1) |
198 | { | 198 | { |
199 | rot = ODevice::inst()->direction(); | 199 | rot = ODevice::inst()->direction(); |
200 | } | 200 | } |
201 | else | 201 | else |
202 | { | 202 | { |
203 | rot = (ODirection) rotDirection; | 203 | rot = (ODirection) rotDirection; |
204 | } | 204 | } |
205 | 205 | ||
206 | // hide inputs methods before rotation | 206 | // hide inputs methods before rotation |
207 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 207 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
208 | 208 | ||
209 | if ( m_flipped ) | 209 | if ( m_flipped ) |
210 | { | 210 | { |
211 | // if flipped, flip back to the original state, | 211 | // if flipped, flip back to the original state, |
212 | // regardless of rotation direction | 212 | // regardless of rotation direction |
213 | newRotation = defaultRotation; | 213 | newRotation = defaultRotation; |
214 | } | 214 | } |
215 | else | 215 | else |
216 | { | 216 | { |
217 | if ( rot == CCW ) | 217 | if ( rot == CCW ) |
218 | { | 218 | { |
219 | newRotation = ( defaultRotation + 90 ) % 360; | 219 | newRotation = ( defaultRotation + 90 ) % 360; |
220 | } | 220 | } |
221 | else if ( rot == CW ) | 221 | else if ( rot == CW ) |
222 | { | 222 | { |
223 | newRotation = ( defaultRotation + 270 ) % 360; | 223 | newRotation = ( defaultRotation + 270 ) % 360; |
224 | } | 224 | } |
225 | else if ( rot == Flip ) | 225 | else if ( rot == Flip ) |
226 | { | 226 | { |
227 | newRotation = ( defaultRotation + 180 ) % 360; | 227 | newRotation = ( defaultRotation + 180 ) % 360; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 231 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
232 | env << newRotation; | 232 | env << newRotation; |
233 | 233 | ||
234 | m_flipped = !m_flipped; | 234 | m_flipped = !m_flipped; |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 238 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
239 | { | 239 | { |
240 | *iface = 0; | 240 | *iface = 0; |
241 | if ( uuid == IID_QUnknown ) | 241 | if ( uuid == IID_QUnknown ) |
242 | *iface = this; | 242 | *iface = this; |
243 | else if ( uuid == IID_MenuApplet ) | 243 | else if ( uuid == IID_MenuApplet ) |
244 | *iface = this; | 244 | *iface = this; |
245 | 245 | ||
246 | if ( *iface ) | 246 | if ( *iface ) |
247 | (*iface)->addRef(); | 247 | (*iface)->addRef(); |
248 | return QS_OK; | 248 | return QS_OK; |
249 | } | 249 | } |
250 | 250 | ||
251 | Q_EXPORT_INTERFACE() | 251 | Q_EXPORT_INTERFACE() |
252 | { | 252 | { |
253 | Q_CREATE_INSTANCE( RotateApplet ) | 253 | Q_CREATE_INSTANCE( RotateApplet ) |
254 | } | 254 | } |