author | sandman <sandman> | 2002-10-13 16:12:08 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-13 16:12:08 (UTC) |
commit | 467451d6d19a2cf5245afa2d219b7d2b1cd008f5 (patch) (unidiff) | |
tree | 8c59b58615a817377c0ae1db10a4093387fdaa77 | |
parent | 92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982 (diff) | |
download | opie-467451d6d19a2cf5245afa2d219b7d2b1cd008f5.zip opie-467451d6d19a2cf5245afa2d219b7d2b1cd008f5.tar.gz opie-467451d6d19a2cf5245afa2d219b7d2b1cd008f5.tar.bz2 |
- added qcop "QPE/System" "setDisplayState(int)" to toggle the LCD on/off
- removed qcop "QPE/Desktop" "home()" -- this is now handled via
qcop "QPE/Application/qpe" "raise()"
- renamed qcop "QPE/Desktop" "suspend()" to qcop "QPE/System" "suspend()"
-rw-r--r-- | core/launcher/desktop.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 6ee7132..0e60839 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -147,66 +147,68 @@ void DesktopPowerAlerter::alert( const QString &text, int priority ) | |||
147 | 147 | ||
148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
149 | { | 149 | { |
150 | QMessageBox::hideEvent( e ); | 150 | QMessageBox::hideEvent( e ); |
151 | alertCount = 0; | 151 | alertCount = 0; |
152 | currentPriority = INT_MAX; | 152 | currentPriority = INT_MAX; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | class QPEScreenSaver : public QWSScreenSaver | 156 | class QPEScreenSaver : public QWSScreenSaver |
157 | { | 157 | { |
158 | private: | 158 | private: |
159 | int LcdOn; | 159 | int LcdOn; |
160 | 160 | ||
161 | public: | 161 | public: |
162 | QPEScreenSaver() | 162 | QPEScreenSaver() |
163 | { | 163 | { |
164 | m_disable_suspend = 100; | 164 | m_disable_suspend = 100; |
165 | m_enable_dim = false; | 165 | m_enable_dim = false; |
166 | m_enable_lightoff = false; | 166 | m_enable_lightoff = false; |
167 | m_enable_onlylcdoff = false; | 167 | m_enable_onlylcdoff = false; |
168 | 168 | ||
169 | m_lcd_status = true; | 169 | m_lcd_status = true; |
170 | 170 | ||
171 | m_backlight_bright = -1; | 171 | m_backlight_bright = -1; |
172 | m_backlight_forcedoff = false; | 172 | m_backlight_forcedoff = false; |
173 | 173 | ||
174 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 174 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
175 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 175 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
176 | } | 176 | } |
177 | void restore() | 177 | void restore() |
178 | { | 178 | { |
179 | if ( !m_lcd_status ) // We must have turned it off | 179 | if ( !m_lcd_status ) { // We must have turned it off |
180 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 180 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
181 | m_lcd_status = true; | ||
182 | } | ||
181 | 183 | ||
182 | setBacklight ( -3 ); | 184 | setBacklight ( -3 ); |
183 | } | 185 | } |
184 | bool save( int level ) | 186 | bool save( int level ) |
185 | { | 187 | { |
186 | switch ( level ) { | 188 | switch ( level ) { |
187 | case 0: | 189 | case 0: |
188 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 190 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
189 | if ( backlight() > 1 ) | 191 | if ( backlight() > 1 ) |
190 | setBacklight( 1 ); // lowest non-off | 192 | setBacklight( 1 ); // lowest non-off |
191 | } | 193 | } |
192 | return true; | 194 | return true; |
193 | break; | 195 | break; |
194 | case 1: | 196 | case 1: |
195 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 197 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
196 | setBacklight( 0 ); // off | 198 | setBacklight( 0 ); // off |
197 | } | 199 | } |
198 | return true; | 200 | return true; |
199 | break; | 201 | break; |
200 | case 2: | 202 | case 2: |
201 | if ( m_enable_onlylcdoff ) { | 203 | if ( m_enable_onlylcdoff ) { |
202 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 204 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
203 | m_lcd_status = false; | 205 | m_lcd_status = false; |
204 | return true; | 206 | return true; |
205 | } | 207 | } |
206 | else // We're going to suspend the whole machine | 208 | else // We're going to suspend the whole machine |
207 | { | 209 | { |
208 | if ( ( m_disable_suspend > 2 ) && | 210 | if ( ( m_disable_suspend > 2 ) && |
209 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | 211 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && |
210 | ( !Network::networkOnline ( ) ) ) { | 212 | ( !Network::networkOnline ( ) ) ) { |
211 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 213 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
212 | return true; | 214 | return true; |
@@ -274,64 +276,72 @@ public: | |||
274 | if ( m_backlight_bright == -1 ) { | 276 | if ( m_backlight_bright == -1 ) { |
275 | // Read from config | 277 | // Read from config |
276 | Config config ( "qpe" ); | 278 | Config config ( "qpe" ); |
277 | config. setGroup ( "Screensaver" ); | 279 | config. setGroup ( "Screensaver" ); |
278 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 280 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); |
279 | } | 281 | } |
280 | return m_backlight_bright; | 282 | return m_backlight_bright; |
281 | } | 283 | } |
282 | 284 | ||
283 | void setBacklight ( int bright ) | 285 | void setBacklight ( int bright ) |
284 | { | 286 | { |
285 | if ( bright == -3 ) { | 287 | if ( bright == -3 ) { |
286 | // Forced on | 288 | // Forced on |
287 | m_backlight_forcedoff = false; | 289 | m_backlight_forcedoff = false; |
288 | bright = -1; | 290 | bright = -1; |
289 | } | 291 | } |
290 | if ( m_backlight_forcedoff && bright != -2 ) | 292 | if ( m_backlight_forcedoff && bright != -2 ) |
291 | return ; | 293 | return ; |
292 | if ( bright == -2 ) { | 294 | if ( bright == -2 ) { |
293 | // Toggle between off and on | 295 | // Toggle between off and on |
294 | bright = m_backlight_bright ? 0 : -1; | 296 | bright = m_backlight_bright ? 0 : -1; |
295 | m_backlight_forcedoff = !bright; | 297 | m_backlight_forcedoff = !bright; |
296 | } | 298 | } |
297 | 299 | ||
298 | m_backlight_bright = bright; | 300 | m_backlight_bright = bright; |
299 | 301 | ||
300 | bright = backlight ( ); | 302 | bright = backlight ( ); |
301 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 303 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
302 | 304 | ||
303 | m_backlight_bright = bright; | 305 | m_backlight_bright = bright; |
304 | } | 306 | } |
305 | 307 | ||
308 | void setDisplayState ( bool on ) | ||
309 | { | ||
310 | if ( m_lcd_status != on ) { | ||
311 | ODevice::inst ( ) -> setDisplayStatus ( on ); | ||
312 | m_lcd_status = on; | ||
313 | } | ||
314 | } | ||
315 | |||
306 | private: | 316 | private: |
307 | int m_disable_suspend; | 317 | int m_disable_suspend; |
308 | bool m_enable_dim; | 318 | bool m_enable_dim; |
309 | bool m_enable_lightoff; | 319 | bool m_enable_lightoff; |
310 | bool m_enable_onlylcdoff; | 320 | bool m_enable_onlylcdoff; |
311 | 321 | ||
312 | bool m_lcd_status; | 322 | bool m_lcd_status; |
313 | 323 | ||
314 | int m_backlight_bright; | 324 | int m_backlight_bright; |
315 | bool m_backlight_forcedoff; | 325 | bool m_backlight_forcedoff; |
316 | }; | 326 | }; |
317 | 327 | ||
318 | 328 | ||
319 | void DesktopApplication::switchLCD ( bool on ) | 329 | void DesktopApplication::switchLCD ( bool on ) |
320 | { | 330 | { |
321 | if ( qApp ) { | 331 | if ( qApp ) { |
322 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 332 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
323 | 333 | ||
324 | if ( dapp-> m_screensaver ) { | 334 | if ( dapp-> m_screensaver ) { |
325 | if ( on ) | 335 | if ( on ) |
326 | dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); | 336 | dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); |
327 | else | 337 | else |
328 | dapp-> m_screensaver-> save ( 1 ); | 338 | dapp-> m_screensaver-> save ( 1 ); |
329 | 339 | ||
330 | } | 340 | } |
331 | } | 341 | } |
332 | } | 342 | } |
333 | 343 | ||
334 | 344 | ||
335 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 345 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
336 | : QPEApplication( argc, argv, appType ) | 346 | : QPEApplication( argc, argv, appType ) |
337 | { | 347 | { |
@@ -348,99 +358,101 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | |||
348 | 358 | ||
349 | channel = new QCopChannel( "QPE/System", this ); | 359 | channel = new QCopChannel( "QPE/System", this ); |
350 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 360 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
351 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 361 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
352 | 362 | ||
353 | m_screensaver = new QPEScreenSaver; | 363 | m_screensaver = new QPEScreenSaver; |
354 | 364 | ||
355 | m_screensaver-> setInterval ( -1 ); | 365 | m_screensaver-> setInterval ( -1 ); |
356 | QWSServer::setScreenSaver( m_screensaver ); | 366 | QWSServer::setScreenSaver( m_screensaver ); |
357 | } | 367 | } |
358 | 368 | ||
359 | 369 | ||
360 | DesktopApplication::~DesktopApplication() | 370 | DesktopApplication::~DesktopApplication() |
361 | { | 371 | { |
362 | delete ps; | 372 | delete ps; |
363 | delete pa; | 373 | delete pa; |
364 | } | 374 | } |
365 | 375 | ||
366 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 376 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
367 | { | 377 | { |
368 | #ifdef Q_WS_QWS | 378 | #ifdef Q_WS_QWS |
369 | QDataStream stream( data, IO_ReadOnly ); | 379 | QDataStream stream( data, IO_ReadOnly ); |
370 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 380 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
371 | int k; | 381 | int k; |
372 | QString c, m; | 382 | QString c, m; |
373 | stream >> k; | 383 | stream >> k; |
374 | stream >> c; | 384 | stream >> c; |
375 | stream >> m; | 385 | stream >> m; |
376 | 386 | ||
377 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 387 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
378 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 388 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
379 | } | 389 | } |
380 | else if ( msg == "suspend()" ) { | ||
381 | emit power(); | ||
382 | } | ||
383 | else if ( msg == "home()" ) { | ||
384 | qpedesktop-> home ( ); | ||
385 | } | ||
386 | #endif | 390 | #endif |
387 | } | 391 | } |
388 | 392 | ||
389 | 393 | ||
390 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 394 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
391 | { | 395 | { |
392 | #ifdef Q_WS_QWS | 396 | #ifdef Q_WS_QWS |
393 | QDataStream stream ( data, IO_ReadOnly ); | 397 | QDataStream stream ( data, IO_ReadOnly ); |
394 | 398 | ||
395 | if ( msg == "setScreenSaverInterval(int)" ) { | 399 | if ( msg == "setScreenSaverInterval(int)" ) { |
396 | int time; | 400 | int time; |
397 | stream >> time; | 401 | stream >> time; |
398 | m_screensaver-> setInterval( time ); | 402 | m_screensaver-> setInterval( time ); |
399 | } | 403 | } |
400 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 404 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
401 | int t1, t2, t3; | 405 | int t1, t2, t3; |
402 | stream >> t1 >> t2 >> t3; | 406 | stream >> t1 >> t2 >> t3; |
403 | m_screensaver-> setIntervals( t1, t2, t3 ); | 407 | m_screensaver-> setIntervals( t1, t2, t3 ); |
404 | } | 408 | } |
405 | else if ( msg == "setBacklight(int)" ) { | 409 | else if ( msg == "setBacklight(int)" ) { |
406 | int bright; | 410 | int bright; |
407 | stream >> bright; | 411 | stream >> bright; |
408 | m_screensaver-> setBacklight( bright ); | 412 | m_screensaver-> setBacklight( bright ); |
409 | } | 413 | } |
410 | else if ( msg == "setScreenSaverMode(int)" ) { | 414 | else if ( msg == "setScreenSaverMode(int)" ) { |
411 | int mode; | 415 | int mode; |
412 | stream >> mode; | 416 | stream >> mode; |
413 | m_screensaver-> setMode ( mode ); | 417 | m_screensaver-> setMode ( mode ); |
414 | } | 418 | } |
419 | else if ( msg == "setDisplayState(int)" ) { | ||
420 | int state; | ||
421 | stream >> state; | ||
422 | m_screensaver-> setDisplayState ( state != 0 ); | ||
423 | } | ||
424 | else if ( msg == "suspend()" ) { | ||
425 | emit power(); | ||
426 | } | ||
415 | #endif | 427 | #endif |
416 | } | 428 | } |
417 | 429 | ||
418 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 430 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
419 | 431 | ||
420 | #ifdef Q_WS_QWS | 432 | #ifdef Q_WS_QWS |
421 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 433 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
422 | { | 434 | { |
423 | qpedesktop->checkMemory(); | 435 | qpedesktop->checkMemory(); |
424 | 436 | ||
425 | if ( e->type == QWSEvent::Key ) { | 437 | if ( e->type == QWSEvent::Key ) { |
426 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 438 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
427 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 439 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
428 | return TRUE; | 440 | return TRUE; |
429 | bool press = ke->simpleData.is_press; | 441 | bool press = ke->simpleData.is_press; |
430 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 442 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
431 | 443 | ||
432 | /* | 444 | /* |
433 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 445 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
434 | when user presses key, unless keyboard has been requested from app. | 446 | when user presses key, unless keyboard has been requested from app. |
435 | will not send multiple repeats if user holds key | 447 | will not send multiple repeats if user holds key |
436 | i.e. one shot | 448 | i.e. one shot |
437 | */ | 449 | */ |
438 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | 450 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
439 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | 451 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
440 | KeyRegisterList::Iterator it; | 452 | KeyRegisterList::Iterator it; |
441 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 453 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
442 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | 454 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
443 | if ( press ) | 455 | if ( press ) |
444 | qDebug( "press" ); | 456 | qDebug( "press" ); |
445 | else | 457 | else |
446 | qDebug( "release" ); | 458 | qDebug( "release" ); |
@@ -599,64 +611,66 @@ Desktop::Desktop() : | |||
599 | 611 | ||
600 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 612 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
601 | 613 | ||
602 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 614 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
603 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 615 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
604 | 616 | ||
605 | int displayw = qApp->desktop() ->width(); | 617 | int displayw = qApp->desktop() ->width(); |
606 | int displayh = qApp->desktop() ->height(); | 618 | int displayh = qApp->desktop() ->height(); |
607 | 619 | ||
608 | 620 | ||
609 | QSize sz = tb->sizeHint(); | 621 | QSize sz = tb->sizeHint(); |
610 | 622 | ||
611 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 623 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
612 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 624 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
613 | 625 | ||
614 | tb->show(); | 626 | tb->show(); |
615 | launcher->showMaximized(); | 627 | launcher->showMaximized(); |
616 | launcher->show(); | 628 | launcher->show(); |
617 | launcher->raise(); | 629 | launcher->raise(); |
618 | #if defined(QPE_HAVE_MEMALERTER) | 630 | #if defined(QPE_HAVE_MEMALERTER) |
619 | 631 | ||
620 | initMemalerter(); | 632 | initMemalerter(); |
621 | #endif | 633 | #endif |
622 | // start services | 634 | // start services |
623 | startTransferServer(); | 635 | startTransferServer(); |
624 | ( void ) new IrServer( this ); | 636 | ( void ) new IrServer( this ); |
625 | rereadVolumes(); | 637 | rereadVolumes(); |
626 | 638 | ||
627 | packageSlave = new PackageSlave( this ); | 639 | packageSlave = new PackageSlave( this ); |
628 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | 640 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); |
629 | 641 | ||
630 | qApp->installEventFilter( this ); | 642 | qApp->installEventFilter( this ); |
643 | |||
644 | qApp-> setMainWidget ( launcher ); | ||
631 | } | 645 | } |
632 | 646 | ||
633 | void Desktop::show() | 647 | void Desktop::show() |
634 | { | 648 | { |
635 | login( TRUE ); | 649 | login( TRUE ); |
636 | QWidget::show(); | 650 | QWidget::show(); |
637 | } | 651 | } |
638 | 652 | ||
639 | Desktop::~Desktop() | 653 | Desktop::~Desktop() |
640 | { | 654 | { |
641 | delete launcher; | 655 | delete launcher; |
642 | delete tb; | 656 | delete tb; |
643 | delete qcopBridge; | 657 | delete qcopBridge; |
644 | delete transferServer; | 658 | delete transferServer; |
645 | } | 659 | } |
646 | 660 | ||
647 | bool Desktop::recoverMemory() | 661 | bool Desktop::recoverMemory() |
648 | { | 662 | { |
649 | return tb->recoverMemory(); | 663 | return tb->recoverMemory(); |
650 | } | 664 | } |
651 | 665 | ||
652 | void Desktop::checkMemory() | 666 | void Desktop::checkMemory() |
653 | { | 667 | { |
654 | #if defined(QPE_HAVE_MEMALERTER) | 668 | #if defined(QPE_HAVE_MEMALERTER) |
655 | static bool ignoreNormal = FALSE; | 669 | static bool ignoreNormal = FALSE; |
656 | static bool existingMessage = FALSE; | 670 | static bool existingMessage = FALSE; |
657 | 671 | ||
658 | if ( existingMessage ) | 672 | if ( existingMessage ) |
659 | return ; // don't show a second message while still on first | 673 | return ; // don't show a second message while still on first |
660 | 674 | ||
661 | existingMessage = TRUE; | 675 | existingMessage = TRUE; |
662 | switch ( memstate ) { | 676 | switch ( memstate ) { |