author | llornkcor <llornkcor> | 2002-10-10 13:31:57 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-10 13:31:57 (UTC) |
commit | c82a7868e0e2f8dc3e3d2b42629fc8d8efef05c7 (patch) (unidiff) | |
tree | 46c91fad5a5869d7ca146cf78c74a02d04eb083a | |
parent | 798474a96ae42503b9d73444d7a4c05d6af5bc10 (diff) | |
download | opie-c82a7868e0e2f8dc3e3d2b42629fc8d8efef05c7.zip opie-c82a7868e0e2f8dc3e3d2b42629fc8d8efef05c7.tar.gz opie-c82a7868e0e2f8dc3e3d2b42629fc8d8efef05c7.tar.bz2 |
enough memory again mesage is silly and annoying, and takes up memory in low memory situations
-rw-r--r-- | core/launcher/desktop.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 1a33b36..6ee7132 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -278,155 +278,155 @@ public: | |||
278 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 278 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); |
279 | } | 279 | } |
280 | return m_backlight_bright; | 280 | return m_backlight_bright; |
281 | } | 281 | } |
282 | 282 | ||
283 | void setBacklight ( int bright ) | 283 | void setBacklight ( int bright ) |
284 | { | 284 | { |
285 | if ( bright == -3 ) { | 285 | if ( bright == -3 ) { |
286 | // Forced on | 286 | // Forced on |
287 | m_backlight_forcedoff = false; | 287 | m_backlight_forcedoff = false; |
288 | bright = -1; | 288 | bright = -1; |
289 | } | 289 | } |
290 | if ( m_backlight_forcedoff && bright != -2 ) | 290 | if ( m_backlight_forcedoff && bright != -2 ) |
291 | return ; | 291 | return ; |
292 | if ( bright == -2 ) { | 292 | if ( bright == -2 ) { |
293 | // Toggle between off and on | 293 | // Toggle between off and on |
294 | bright = m_backlight_bright ? 0 : -1; | 294 | bright = m_backlight_bright ? 0 : -1; |
295 | m_backlight_forcedoff = !bright; | 295 | m_backlight_forcedoff = !bright; |
296 | } | 296 | } |
297 | 297 | ||
298 | m_backlight_bright = bright; | 298 | m_backlight_bright = bright; |
299 | 299 | ||
300 | bright = backlight ( ); | 300 | bright = backlight ( ); |
301 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 301 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
302 | 302 | ||
303 | m_backlight_bright = bright; | 303 | m_backlight_bright = bright; |
304 | } | 304 | } |
305 | 305 | ||
306 | private: | 306 | private: |
307 | int m_disable_suspend; | 307 | int m_disable_suspend; |
308 | bool m_enable_dim; | 308 | bool m_enable_dim; |
309 | bool m_enable_lightoff; | 309 | bool m_enable_lightoff; |
310 | bool m_enable_onlylcdoff; | 310 | bool m_enable_onlylcdoff; |
311 | 311 | ||
312 | bool m_lcd_status; | 312 | bool m_lcd_status; |
313 | 313 | ||
314 | int m_backlight_bright; | 314 | int m_backlight_bright; |
315 | bool m_backlight_forcedoff; | 315 | bool m_backlight_forcedoff; |
316 | }; | 316 | }; |
317 | 317 | ||
318 | 318 | ||
319 | void DesktopApplication::switchLCD ( bool on ) | 319 | void DesktopApplication::switchLCD ( bool on ) |
320 | { | 320 | { |
321 | if ( qApp ) { | 321 | if ( qApp ) { |
322 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 322 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
323 | 323 | ||
324 | if ( dapp-> m_screensaver ) { | 324 | if ( dapp-> m_screensaver ) { |
325 | if ( on ) | 325 | if ( on ) |
326 | dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); | 326 | dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); |
327 | else | 327 | else |
328 | dapp-> m_screensaver-> save ( 1 ); | 328 | dapp-> m_screensaver-> save ( 1 ); |
329 | 329 | ||
330 | } | 330 | } |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 335 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
336 | : QPEApplication( argc, argv, appType ) | 336 | : QPEApplication( argc, argv, appType ) |
337 | { | 337 | { |
338 | 338 | ||
339 | QTimer * t = new QTimer( this ); | 339 | QTimer * t = new QTimer( this ); |
340 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 340 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); |
341 | t->start( 10000 ); | 341 | t->start( 10000 ); |
342 | ps = new PowerStatus; | 342 | ps = new PowerStatus; |
343 | pa = new DesktopPowerAlerter( 0 ); | 343 | pa = new DesktopPowerAlerter( 0 ); |
344 | 344 | ||
345 | channel = new QCopChannel( "QPE/Desktop", this ); | 345 | channel = new QCopChannel( "QPE/Desktop", this ); |
346 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 346 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
347 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 347 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
348 | 348 | ||
349 | channel = new QCopChannel( "QPE/System", this ); | 349 | channel = new QCopChannel( "QPE/System", this ); |
350 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 350 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
351 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 351 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
352 | 352 | ||
353 | m_screensaver = new QPEScreenSaver; | 353 | m_screensaver = new QPEScreenSaver; |
354 | 354 | ||
355 | m_screensaver-> setInterval ( -1 ); | 355 | m_screensaver-> setInterval ( -1 ); |
356 | QWSServer::setScreenSaver( m_screensaver ); | 356 | QWSServer::setScreenSaver( m_screensaver ); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | DesktopApplication::~DesktopApplication() | 360 | DesktopApplication::~DesktopApplication() |
361 | { | 361 | { |
362 | delete ps; | 362 | delete ps; |
363 | delete pa; | 363 | delete pa; |
364 | } | 364 | } |
365 | 365 | ||
366 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 366 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
367 | { | 367 | { |
368 | #ifdef Q_WS_QWS | 368 | #ifdef Q_WS_QWS |
369 | QDataStream stream( data, IO_ReadOnly ); | 369 | QDataStream stream( data, IO_ReadOnly ); |
370 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 370 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
371 | int k; | 371 | int k; |
372 | QString c, m; | 372 | QString c, m; |
373 | stream >> k; | 373 | stream >> k; |
374 | stream >> c; | 374 | stream >> c; |
375 | stream >> m; | 375 | stream >> m; |
376 | 376 | ||
377 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 377 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
378 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 378 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
379 | } | 379 | } |
380 | else if ( msg == "suspend()" ) { | 380 | else if ( msg == "suspend()" ) { |
381 | emit power(); | 381 | emit power(); |
382 | } | 382 | } |
383 | else if ( msg == "home()" ) { | 383 | else if ( msg == "home()" ) { |
384 | qpedesktop-> home ( ); | 384 | qpedesktop-> home ( ); |
385 | } | 385 | } |
386 | #endif | 386 | #endif |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 390 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
391 | { | 391 | { |
392 | #ifdef Q_WS_QWS | 392 | #ifdef Q_WS_QWS |
393 | QDataStream stream ( data, IO_ReadOnly ); | 393 | QDataStream stream ( data, IO_ReadOnly ); |
394 | 394 | ||
395 | if ( msg == "setScreenSaverInterval(int)" ) { | 395 | if ( msg == "setScreenSaverInterval(int)" ) { |
396 | int time; | 396 | int time; |
397 | stream >> time; | 397 | stream >> time; |
398 | m_screensaver-> setInterval( time ); | 398 | m_screensaver-> setInterval( time ); |
399 | } | 399 | } |
400 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 400 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
401 | int t1, t2, t3; | 401 | int t1, t2, t3; |
402 | stream >> t1 >> t2 >> t3; | 402 | stream >> t1 >> t2 >> t3; |
403 | m_screensaver-> setIntervals( t1, t2, t3 ); | 403 | m_screensaver-> setIntervals( t1, t2, t3 ); |
404 | } | 404 | } |
405 | else if ( msg == "setBacklight(int)" ) { | 405 | else if ( msg == "setBacklight(int)" ) { |
406 | int bright; | 406 | int bright; |
407 | stream >> bright; | 407 | stream >> bright; |
408 | m_screensaver-> setBacklight( bright ); | 408 | m_screensaver-> setBacklight( bright ); |
409 | } | 409 | } |
410 | else if ( msg == "setScreenSaverMode(int)" ) { | 410 | else if ( msg == "setScreenSaverMode(int)" ) { |
411 | int mode; | 411 | int mode; |
412 | stream >> mode; | 412 | stream >> mode; |
413 | m_screensaver-> setMode ( mode ); | 413 | m_screensaver-> setMode ( mode ); |
414 | } | 414 | } |
415 | #endif | 415 | #endif |
416 | } | 416 | } |
417 | 417 | ||
418 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 418 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
419 | 419 | ||
420 | #ifdef Q_WS_QWS | 420 | #ifdef Q_WS_QWS |
421 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 421 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
422 | { | 422 | { |
423 | qpedesktop->checkMemory(); | 423 | qpedesktop->checkMemory(); |
424 | 424 | ||
425 | if ( e->type == QWSEvent::Key ) { | 425 | if ( e->type == QWSEvent::Key ) { |
426 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 426 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
427 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 427 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
428 | return TRUE; | 428 | return TRUE; |
429 | bool press = ke->simpleData.is_press; | 429 | bool press = ke->simpleData.is_press; |
430 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 430 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
431 | 431 | ||
432 | /* | 432 | /* |
@@ -630,151 +630,151 @@ Desktop::Desktop() : | |||
630 | qApp->installEventFilter( this ); | 630 | qApp->installEventFilter( this ); |
631 | } | 631 | } |
632 | 632 | ||
633 | void Desktop::show() | 633 | void Desktop::show() |
634 | { | 634 | { |
635 | login( TRUE ); | 635 | login( TRUE ); |
636 | QWidget::show(); | 636 | QWidget::show(); |
637 | } | 637 | } |
638 | 638 | ||
639 | Desktop::~Desktop() | 639 | Desktop::~Desktop() |
640 | { | 640 | { |
641 | delete launcher; | 641 | delete launcher; |
642 | delete tb; | 642 | delete tb; |
643 | delete qcopBridge; | 643 | delete qcopBridge; |
644 | delete transferServer; | 644 | delete transferServer; |
645 | } | 645 | } |
646 | 646 | ||
647 | bool Desktop::recoverMemory() | 647 | bool Desktop::recoverMemory() |
648 | { | 648 | { |
649 | return tb->recoverMemory(); | 649 | return tb->recoverMemory(); |
650 | } | 650 | } |
651 | 651 | ||
652 | void Desktop::checkMemory() | 652 | void Desktop::checkMemory() |
653 | { | 653 | { |
654 | #if defined(QPE_HAVE_MEMALERTER) | 654 | #if defined(QPE_HAVE_MEMALERTER) |
655 | static bool ignoreNormal = FALSE; | 655 | static bool ignoreNormal = FALSE; |
656 | static bool existingMessage = FALSE; | 656 | static bool existingMessage = FALSE; |
657 | 657 | ||
658 | if ( existingMessage ) | 658 | if ( existingMessage ) |
659 | return ; // don't show a second message while still on first | 659 | return ; // don't show a second message while still on first |
660 | 660 | ||
661 | existingMessage = TRUE; | 661 | existingMessage = TRUE; |
662 | switch ( memstate ) { | 662 | switch ( memstate ) { |
663 | case Unknown: | 663 | case Unknown: |
664 | break; | 664 | break; |
665 | case Low: | 665 | case Low: |
666 | memstate = Unknown; | 666 | memstate = Unknown; |
667 | if ( recoverMemory() ) | 667 | if ( recoverMemory() ) |
668 | ignoreNormal = TRUE; | 668 | ignoreNormal = TRUE; |
669 | else | 669 | else |
670 | QMessageBox::warning( 0 , "Memory Status", | 670 | QMessageBox::warning( 0 , "Memory Status", |
671 | "The memory smacks of shortage. \n" | 671 | "The memory smacks of shortage. \n" |
672 | "Please save data. " ); | 672 | "Please save data. " ); |
673 | break; | 673 | break; |
674 | case Normal: | 674 | case Normal: |
675 | memstate = Unknown; | 675 | memstate = Unknown; |
676 | if ( ignoreNormal ) | 676 | if ( ignoreNormal ) |
677 | ignoreNormal = FALSE; | 677 | ignoreNormal = FALSE; |
678 | else | 678 | // else |
679 | QMessageBox::information ( 0 , "Memory Status", | 679 | // QMessageBox::information ( 0 , "Memory Status", |
680 | "There is enough memory again." ); | 680 | // "There is enough memory again." ); |
681 | break; | 681 | break; |
682 | case VeryLow: | 682 | case VeryLow: |
683 | memstate = Unknown; | 683 | memstate = Unknown; |
684 | QMessageBox::critical( 0 , "Memory Status", | 684 | QMessageBox::critical( 0 , "Memory Status", |
685 | "The memory is very low. \n" | 685 | "The memory is very low. \n" |
686 | "Please end this application \n" | 686 | "Please end this application \n" |
687 | "immediately." ); | 687 | "immediately." ); |
688 | recoverMemory(); | 688 | recoverMemory(); |
689 | } | 689 | } |
690 | existingMessage = FALSE; | 690 | existingMessage = FALSE; |
691 | #endif | 691 | #endif |
692 | } | 692 | } |
693 | 693 | ||
694 | static bool isVisibleWindow( int wid ) | 694 | static bool isVisibleWindow( int wid ) |
695 | { | 695 | { |
696 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 696 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
697 | QWSWindow* w; | 697 | QWSWindow* w; |
698 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 698 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
699 | if ( w->winId() == wid ) | 699 | if ( w->winId() == wid ) |
700 | return !w->isFullyObscured(); | 700 | return !w->isFullyObscured(); |
701 | } | 701 | } |
702 | return FALSE; | 702 | return FALSE; |
703 | } | 703 | } |
704 | 704 | ||
705 | static bool hasVisibleWindow( const QString& clientname ) | 705 | static bool hasVisibleWindow( const QString& clientname ) |
706 | { | 706 | { |
707 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 707 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
708 | QWSWindow* w; | 708 | QWSWindow* w; |
709 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 709 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
710 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 710 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
711 | return TRUE; | 711 | return TRUE; |
712 | } | 712 | } |
713 | return FALSE; | 713 | return FALSE; |
714 | } | 714 | } |
715 | 715 | ||
716 | void Desktop::raiseLauncher() | 716 | void Desktop::raiseLauncher() |
717 | { | 717 | { |
718 | Config cfg( "qpe" ); //F12 'Home' | 718 | Config cfg( "qpe" ); //F12 'Home' |
719 | cfg.setGroup( "AppsKey" ); | 719 | cfg.setGroup( "AppsKey" ); |
720 | QString tempItem; | 720 | QString tempItem; |
721 | tempItem = cfg.readEntry( "Middle", "Home" ); | 721 | tempItem = cfg.readEntry( "Middle", "Home" ); |
722 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | 722 | if ( tempItem == "Home" || tempItem.isEmpty() ) { |
723 | home ( ); | 723 | home ( ); |
724 | } | 724 | } |
725 | else { | 725 | else { |
726 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 726 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
727 | e << tempItem; | 727 | e << tempItem; |
728 | } | 728 | } |
729 | } | 729 | } |
730 | 730 | ||
731 | void Desktop::home ( ) | 731 | void Desktop::home ( ) |
732 | { | 732 | { |
733 | if ( isVisibleWindow( launcher->winId() ) ) | 733 | if ( isVisibleWindow( launcher->winId() ) ) |
734 | launcher->nextView(); | 734 | launcher->nextView(); |
735 | else | 735 | else |
736 | launcher->raise(); | 736 | launcher->raise(); |
737 | } | 737 | } |
738 | 738 | ||
739 | void Desktop::executeOrModify( const QString& appLnkFile ) | 739 | void Desktop::executeOrModify( const QString& appLnkFile ) |
740 | { | 740 | { |
741 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 741 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
742 | if ( lnk.isValid() ) { | 742 | if ( lnk.isValid() ) { |
743 | QCString app = lnk.exec().utf8(); | 743 | QCString app = lnk.exec().utf8(); |
744 | Global::terminateBuiltin( "calibrate" ); | 744 | Global::terminateBuiltin( "calibrate" ); |
745 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 745 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
746 | // MRUList::addTask( &lnk ); | 746 | // MRUList::addTask( &lnk ); |
747 | if ( hasVisibleWindow( app ) ) | 747 | if ( hasVisibleWindow( app ) ) |
748 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 748 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
749 | else | 749 | else |
750 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 750 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
751 | } | 751 | } |
752 | else { | 752 | else { |
753 | lnk.execute(); | 753 | lnk.execute(); |
754 | } | 754 | } |
755 | } | 755 | } |
756 | } | 756 | } |
757 | 757 | ||
758 | void Desktop::raiseDatebook() | 758 | void Desktop::raiseDatebook() |
759 | { | 759 | { |
760 | Config cfg( "qpe" ); //F9 'Activity' | 760 | Config cfg( "qpe" ); //F9 'Activity' |
761 | cfg.setGroup( "AppsKey" ); | 761 | cfg.setGroup( "AppsKey" ); |
762 | QString tempItem; | 762 | QString tempItem; |
763 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 763 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
764 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 764 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
765 | tempItem = "datebook"; | 765 | tempItem = "datebook"; |
766 | } | 766 | } |
767 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 767 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
768 | e << tempItem; | 768 | e << tempItem; |
769 | } | 769 | } |
770 | 770 | ||
771 | void Desktop::raiseContacts() | 771 | void Desktop::raiseContacts() |
772 | { | 772 | { |
773 | Config cfg( "qpe" ); //F10, 'Contacts' | 773 | Config cfg( "qpe" ); //F10, 'Contacts' |
774 | cfg.setGroup( "AppsKey" ); | 774 | cfg.setGroup( "AppsKey" ); |
775 | QString tempItem; | 775 | QString tempItem; |
776 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 776 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
777 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 777 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
778 | tempItem = "addressbook"; | 778 | tempItem = "addressbook"; |
779 | } | 779 | } |
780 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 780 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |