author | llornkcor <llornkcor> | 2002-07-13 13:53:02 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-13 13:53:02 (UTC) |
commit | c86efeae9e7f7f63dca633f630b571019a5c71b6 (patch) (unidiff) | |
tree | 550d7806331d476cd432cc64309a0901d9fcc185 | |
parent | 4b524c21f63087d44b0a908bd791ec6e470c7238 (diff) | |
download | opie-c86efeae9e7f7f63dca633f630b571019a5c71b6.zip opie-c86efeae9e7f7f63dca633f630b571019a5c71b6.tar.gz opie-c86efeae9e7f7f63dca633f630b571019a5c71b6.tar.bz2 |
try to fix QPE/Desktop keyRegister from sending on false signals
-rw-r--r-- | core/launcher/desktop.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 541b4be..e58b08c 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -80,257 +80,257 @@ static int loggedin=0; | |||
80 | static void login(bool at_poweron) | 80 | static void login(bool at_poweron) |
81 | { | 81 | { |
82 | if ( !loggedin ) { | 82 | if ( !loggedin ) { |
83 | Global::terminateBuiltin("calibrate"); | 83 | Global::terminateBuiltin("calibrate"); |
84 | Password::authenticate(at_poweron); | 84 | Password::authenticate(at_poweron); |
85 | loggedin=1; | 85 | loggedin=1; |
86 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 86 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | bool Desktop::screenLocked() | 90 | bool Desktop::screenLocked() |
91 | { | 91 | { |
92 | return loggedin == 0; | 92 | return loggedin == 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /* | 95 | /* |
96 | Priority is number of alerts that are needed to pop up | 96 | Priority is number of alerts that are needed to pop up |
97 | alert. | 97 | alert. |
98 | */ | 98 | */ |
99 | class DesktopPowerAlerter : public QMessageBox | 99 | class DesktopPowerAlerter : public QMessageBox |
100 | { | 100 | { |
101 | public: | 101 | public: |
102 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 102 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
103 | : QMessageBox( tr("Battery Status"), "Low Battery", | 103 | : QMessageBox( tr("Battery Status"), "Low Battery", |
104 | QMessageBox::Critical, | 104 | QMessageBox::Critical, |
105 | QMessageBox::Ok | QMessageBox::Default, | 105 | QMessageBox::Ok | QMessageBox::Default, |
106 | QMessageBox::NoButton, QMessageBox::NoButton, | 106 | QMessageBox::NoButton, QMessageBox::NoButton, |
107 | parent, name, FALSE ) | 107 | parent, name, FALSE ) |
108 | { | 108 | { |
109 | currentPriority = INT_MAX; | 109 | currentPriority = INT_MAX; |
110 | alertCount = 0; | 110 | alertCount = 0; |
111 | } | 111 | } |
112 | 112 | ||
113 | void alert( const QString &text, int priority ); | 113 | void alert( const QString &text, int priority ); |
114 | void hideEvent( QHideEvent * ); | 114 | void hideEvent( QHideEvent * ); |
115 | private: | 115 | private: |
116 | int currentPriority; | 116 | int currentPriority; |
117 | int alertCount; | 117 | int alertCount; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 120 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
121 | { | 121 | { |
122 | alertCount++; | 122 | alertCount++; |
123 | if ( alertCount < priority ) | 123 | if ( alertCount < priority ) |
124 | return; | 124 | return; |
125 | if ( priority > currentPriority ) | 125 | if ( priority > currentPriority ) |
126 | return; | 126 | return; |
127 | currentPriority = priority; | 127 | currentPriority = priority; |
128 | setText( text ); | 128 | setText( text ); |
129 | show(); | 129 | show(); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 133 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
134 | { | 134 | { |
135 | QMessageBox::hideEvent( e ); | 135 | QMessageBox::hideEvent( e ); |
136 | alertCount = 0; | 136 | alertCount = 0; |
137 | currentPriority = INT_MAX; | 137 | currentPriority = INT_MAX; |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 142 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
143 | : QPEApplication( argc, argv, appType ) | 143 | : QPEApplication( argc, argv, appType ) |
144 | { | 144 | { |
145 | 145 | ||
146 | QTimer *t = new QTimer( this ); | 146 | QTimer *t = new QTimer( this ); |
147 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 147 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); |
148 | t->start( 10000 ); | 148 | t->start( 10000 ); |
149 | ps = new PowerStatus; | 149 | ps = new PowerStatus; |
150 | pa = new DesktopPowerAlerter( 0 ); | 150 | pa = new DesktopPowerAlerter( 0 ); |
151 | 151 | ||
152 | channel = new QCopChannel( "QPE/Desktop", this ); | 152 | channel = new QCopChannel( "QPE/Desktop", this ); |
153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | DesktopApplication::~DesktopApplication() | 158 | DesktopApplication::~DesktopApplication() |
159 | { | 159 | { |
160 | delete ps; | 160 | delete ps; |
161 | delete pa; | 161 | delete pa; |
162 | } | 162 | } |
163 | 163 | ||
164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
165 | { | 165 | { |
166 | QDataStream stream( data, IO_ReadOnly ); | 166 | QDataStream stream( data, IO_ReadOnly ); |
167 | if (msg == "keyRegister(int key, QString channel, QString message)") | 167 | if (msg == "keyRegister(int key, QString channel, QString message)") |
168 | { | 168 | { |
169 | int k; | 169 | int k; |
170 | QString c, m; | 170 | QString c, m; |
171 | stream >> k; | 171 | stream >> k; |
172 | stream >> c; | 172 | stream >> c; |
173 | stream >> m; | 173 | stream >> m; |
174 | 174 | ||
175 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); | 175 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); |
176 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 176 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
177 | } | 177 | } |
178 | else if (msg == "suspend()"){ | 178 | else if (msg == "suspend()"){ |
179 | emit power(); | 179 | emit power(); |
180 | } | 180 | } |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
185 | 185 | ||
186 | #ifdef Q_WS_QWS | 186 | #ifdef Q_WS_QWS |
187 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 187 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
188 | { | 188 | { |
189 | qpedesktop->checkMemory(); | 189 | qpedesktop->checkMemory(); |
190 | 190 | ||
191 | if ( e->type == QWSEvent::Key ) { | 191 | if ( e->type == QWSEvent::Key ) { |
192 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 192 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
193 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 193 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
194 | return TRUE; | 194 | return TRUE; |
195 | bool press = ke->simpleData.is_press; | 195 | bool press = ke->simpleData.is_press; |
196 | bool autoRepeat= ke->simpleData.is_auto_repeat; | 196 | bool autoRepeat= ke->simpleData.is_auto_repeat; |
197 | 197 | ||
198 | /* | 198 | /* |
199 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 199 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
200 | when user presses key, unless keyboard has been requested from app. | 200 | when user presses key, unless keyboard has been requested from app. |
201 | will not send multiple repeats if user holds key | 201 | will not send multiple repeats if user holds key |
202 | i.e. one shot | 202 | i.e. one shot |
203 | 203 | ||
204 | */ | 204 | */ |
205 | if (!keyRegisterList.isEmpty()) { | 205 | if (!keyRegisterList.isEmpty()) { |
206 | KeyRegisterList::Iterator it; | 206 | KeyRegisterList::Iterator it; |
207 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 207 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
208 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed()) { | 208 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { |
209 | if(press) qDebug("press"); else qDebug("release"); | 209 | if(press) qDebug("press"); else qDebug("release"); |
210 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 210 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | if ( !keyboardGrabbed() ) { | 215 | if ( !keyboardGrabbed() ) { |
216 | if ( ke->simpleData.keycode == Key_F9 ) { | 216 | if ( ke->simpleData.keycode == Key_F9 ) { |
217 | if ( press ) emit datebook(); | 217 | if ( press ) emit datebook(); |
218 | return TRUE; | 218 | return TRUE; |
219 | } | 219 | } |
220 | if ( ke->simpleData.keycode == Key_F10 ) { | 220 | if ( ke->simpleData.keycode == Key_F10 ) { |
221 | if ( !press && cardSendTimer ) { | 221 | if ( !press && cardSendTimer ) { |
222 | emit contacts(); | 222 | emit contacts(); |
223 | delete cardSendTimer; | 223 | delete cardSendTimer; |
224 | } else if ( press ) { | 224 | } else if ( press ) { |
225 | cardSendTimer = new QTimer(); | 225 | cardSendTimer = new QTimer(); |
226 | cardSendTimer->start( 2000, TRUE ); | 226 | cardSendTimer->start( 2000, TRUE ); |
227 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 227 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
228 | } | 228 | } |
229 | return TRUE; | 229 | return TRUE; |
230 | } | 230 | } |
231 | /* menu key now opens application menu/toolbar | 231 | /* menu key now opens application menu/toolbar |
232 | if ( ke->simpleData.keycode == Key_F11 ) { | 232 | if ( ke->simpleData.keycode == Key_F11 ) { |
233 | if ( press ) emit menu(); | 233 | if ( press ) emit menu(); |
234 | return TRUE; | 234 | return TRUE; |
235 | } | 235 | } |
236 | */ | 236 | */ |
237 | if ( ke->simpleData.keycode == Key_F12 ) { | 237 | if ( ke->simpleData.keycode == Key_F12 ) { |
238 | while( activePopupWidget() ) | 238 | while( activePopupWidget() ) |
239 | activePopupWidget()->close(); | 239 | activePopupWidget()->close(); |
240 | if ( press ) emit launch(); | 240 | if ( press ) emit launch(); |
241 | return TRUE; | 241 | return TRUE; |
242 | } | 242 | } |
243 | if ( ke->simpleData.keycode == Key_F13 ) { | 243 | if ( ke->simpleData.keycode == Key_F13 ) { |
244 | if ( press ) emit email(); | 244 | if ( press ) emit email(); |
245 | return TRUE; | 245 | return TRUE; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | if ( ke->simpleData.keycode == Key_F34 ) { | 249 | if ( ke->simpleData.keycode == Key_F34 ) { |
250 | if ( press ) emit power(); | 250 | if ( press ) emit power(); |
251 | return TRUE; | 251 | return TRUE; |
252 | } | 252 | } |
253 | // This was used for the iPAQ PowerButton | 253 | // This was used for the iPAQ PowerButton |
254 | // See main.cpp for new KeyboardFilter | 254 | // See main.cpp for new KeyboardFilter |
255 | // | 255 | // |
256 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 256 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
257 | // if ( press ) emit power(); | 257 | // if ( press ) emit power(); |
258 | // return TRUE; | 258 | // return TRUE; |
259 | // } | 259 | // } |
260 | if ( ke->simpleData.keycode == Key_F35 ) { | 260 | if ( ke->simpleData.keycode == Key_F35 ) { |
261 | if ( press ) emit backlight(); | 261 | if ( press ) emit backlight(); |
262 | return TRUE; | 262 | return TRUE; |
263 | } | 263 | } |
264 | if ( ke->simpleData.keycode == Key_F32 ) { | 264 | if ( ke->simpleData.keycode == Key_F32 ) { |
265 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 265 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
266 | return TRUE; | 266 | return TRUE; |
267 | } | 267 | } |
268 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 268 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
269 | if ( press ) emit symbol(); | 269 | if ( press ) emit symbol(); |
270 | return TRUE; | 270 | return TRUE; |
271 | } | 271 | } |
272 | if ( ke->simpleData.keycode == Key_NumLock ) { | 272 | if ( ke->simpleData.keycode == Key_NumLock ) { |
273 | if ( press ) emit numLockStateToggle(); | 273 | if ( press ) emit numLockStateToggle(); |
274 | } | 274 | } |
275 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 275 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
276 | if ( press ) emit capsLockStateToggle(); | 276 | if ( press ) emit capsLockStateToggle(); |
277 | } | 277 | } |
278 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) | 278 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) |
279 | qpedesktop->keyClick(); | 279 | qpedesktop->keyClick(); |
280 | } else { | 280 | } else { |
281 | if ( e->type == QWSEvent::Mouse ) { | 281 | if ( e->type == QWSEvent::Mouse ) { |
282 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 282 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
283 | static bool up = TRUE; | 283 | static bool up = TRUE; |
284 | if ( me->simpleData.state&LeftButton ) { | 284 | if ( me->simpleData.state&LeftButton ) { |
285 | if ( up ) { | 285 | if ( up ) { |
286 | up = FALSE; | 286 | up = FALSE; |
287 | qpedesktop->screenClick(); | 287 | qpedesktop->screenClick(); |
288 | } | 288 | } |
289 | } else { | 289 | } else { |
290 | up = TRUE; | 290 | up = TRUE; |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | return QPEApplication::qwsEventFilter( e ); | 295 | return QPEApplication::qwsEventFilter( e ); |
296 | } | 296 | } |
297 | #endif | 297 | #endif |
298 | 298 | ||
299 | void DesktopApplication::psTimeout() | 299 | void DesktopApplication::psTimeout() |
300 | { | 300 | { |
301 | qpedesktop->checkMemory(); // in case no events are being generated | 301 | qpedesktop->checkMemory(); // in case no events are being generated |
302 | 302 | ||
303 | *ps = PowerStatusManager::readStatus(); | 303 | *ps = PowerStatusManager::readStatus(); |
304 | 304 | ||
305 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 305 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
306 | pa->alert( tr( "Battery is running very low." ), 6 ); | 306 | pa->alert( tr( "Battery is running very low." ), 6 ); |
307 | } | 307 | } |
308 | 308 | ||
309 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 309 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
310 | pa->alert( tr( "Battery level is critical!\n" | 310 | pa->alert( tr( "Battery level is critical!\n" |
311 | "Keep power off until power restored!" ), 1 ); | 311 | "Keep power off until power restored!" ), 1 ); |
312 | } | 312 | } |
313 | 313 | ||
314 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 314 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
315 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 315 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | void DesktopApplication::sendCard() | 320 | void DesktopApplication::sendCard() |
321 | { | 321 | { |
322 | delete cardSendTimer; | 322 | delete cardSendTimer; |
323 | cardSendTimer = 0; | 323 | cardSendTimer = 0; |
324 | QString card = getenv("HOME"); | 324 | QString card = getenv("HOME"); |
325 | card += "/Applications/addressbook/businesscard.vcf"; | 325 | card += "/Applications/addressbook/businesscard.vcf"; |
326 | 326 | ||
327 | if ( QFile::exists( card ) ) { | 327 | if ( QFile::exists( card ) ) { |
328 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); | 328 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); |
329 | QString mimetype = "text/x-vCard"; | 329 | QString mimetype = "text/x-vCard"; |
330 | e << tr("business card") << card << mimetype; | 330 | e << tr("business card") << card << mimetype; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | #if defined(QPE_HAVE_MEMALERTER) | 334 | #if defined(QPE_HAVE_MEMALERTER) |
335 | QPE_MEMALERTER_IMPL | 335 | QPE_MEMALERTER_IMPL |
336 | #endif | 336 | #endif |