author | harlekin <harlekin> | 2002-10-22 23:34:24 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-22 23:34:24 (UTC) |
commit | a4dccc9ce6de0bf75d11688b01f2cc010da3647e (patch) (unidiff) | |
tree | 80c6c360b67bad9af77d79888bef97fa6feabc76 | |
parent | e4297ff151693e07313ea036de91ad3c788c5e26 (diff) | |
download | opie-a4dccc9ce6de0bf75d11688b01f2cc010da3647e.zip opie-a4dccc9ce6de0bf75d11688b01f2cc010da3647e.tar.gz opie-a4dccc9ce6de0bf75d11688b01f2cc010da3647e.tar.bz2 |
timer is now more separated from warnings
-rw-r--r-- | core/launcher/desktop.cpp | 37 | ||||
-rw-r--r-- | core/launcher/desktop.h | 23 |
2 files changed, 36 insertions, 24 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 4926b97..33bea36 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -403,12 +403,12 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | |||
403 | { | 403 | { |
404 | 404 | ||
405 | //FIXME, need also a method for setting different timer ( changed runtime ) | ||
406 | m_timer = new QTimer( this ); | 405 | m_timer = new QTimer( this ); |
407 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 406 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); |
408 | Config cfg( "qpe" ); | 407 | Config cfg( "apm" ); |
409 | cfg.setGroup( "APM" ); | 408 | cfg.setGroup( "Warnings" ); |
410 | m_timer->start( cfg.readNumEntry( "check_interval", 10000 ) ); | 409 | m_timer->start( 5000 ); |
411 | m_powerVeryLow = cfg.readNumEntry( "power_verylow", 10 ); | 410 | //cfg.readNumEntry( "checkinterval", 10000 ) |
412 | m_powerCritical = cfg.readNumEntry( "power_critical", 5 ); | 411 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
412 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); | ||
413 | ps = new PowerStatus; | 413 | ps = new PowerStatus; |
414 | pa = new DesktopPowerAlerter( 0 ); | 414 | pa = new DesktopPowerAlerter( 0 ); |
@@ -497,5 +497,5 @@ void DesktopApplication::reloadPowerWarnSettings() { | |||
497 | cfg.setGroup( "Warnings" ); | 497 | cfg.setGroup( "Warnings" ); |
498 | 498 | ||
499 | m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); | 499 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); |
500 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 500 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
501 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); | 501 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); |
@@ -633,17 +633,16 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
633 | #endif | 633 | #endif |
634 | 634 | ||
635 | void DesktopApplication::psTimeout() | 635 | void DesktopApplication::psTimeout( int batRemaining ) |
636 | { | 636 | { |
637 | qpedesktop->checkMemory(); // in case no events are being generated | ||
638 | |||
639 | *ps = PowerStatusManager::readStatus(); | 637 | *ps = PowerStatusManager::readStatus(); |
640 | 638 | ||
639 | // maybe now since its triggered by apm change there might be to few warnings | ||
641 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 640 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
642 | if ( ( ps->batteryPercentRemaining() == m_powerVeryLow ) ) { | 641 | if ( ( batRemaining == m_powerVeryLow ) ) { |
643 | pa->alert( tr( "Battery is running very low." ), 6 ); | 642 | pa->alert( tr( "Battery is running very low." ), 6 ); |
644 | } | 643 | } |
645 | 644 | ||
646 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { | 645 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { |
647 | if ( ps->batteryPercentRemaining() == m_powerCritical ) { | 646 | if ( batRemaining == m_powerCritical ) { |
648 | pa->alert( tr( "Battery level is critical!\n" | 647 | pa->alert( tr( "Battery level is critical!\n" |
649 | "Keep power off until power restored!" ), 1 ); | 648 | "Keep power off until power restored!" ), 1 ); |
@@ -655,4 +654,16 @@ void DesktopApplication::psTimeout() | |||
655 | } | 654 | } |
656 | 655 | ||
656 | void DesktopApplication::apmTimeout() | ||
657 | { | ||
658 | qpedesktop->checkMemory(); // in case no events are being generated | ||
659 | |||
660 | *ps = PowerStatusManager::readStatus(); | ||
661 | |||
662 | if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) { | ||
663 | // not very nice, since psTimeout parses the again | ||
664 | m_currentPowerLevel = ps->batteryPercentRemaining(); | ||
665 | psTimeout( m_currentPowerLevel ); | ||
666 | } | ||
667 | } | ||
657 | 668 | ||
658 | void DesktopApplication::sendCard() | 669 | void DesktopApplication::sendCard() |
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index 15d8ef7..8308811 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -78,17 +78,18 @@ public slots: | |||
78 | protected slots: | 78 | protected slots: |
79 | void shutdown( ShutdownImpl::Type ); | 79 | void shutdown( ShutdownImpl::Type ); |
80 | void psTimeout(); | 80 | void psTimeout( int ); |
81 | void apmTimeout(); | ||
81 | void sendCard(); | 82 | void sendCard(); |
82 | private: | 83 | private: |
83 | void reloadPowerWarnSettings(); | 84 | void reloadPowerWarnSettings(); |
84 | DesktopPowerAlerter *pa; | 85 | DesktopPowerAlerter *pa; |
85 | PowerStatus *ps; | 86 | PowerStatus *ps; |
86 | QTimer *cardSendTimer; | 87 | QTimer *cardSendTimer; |
87 | QCopChannel *channel; | 88 | QCopChannel *channel; |
88 | QPEScreenSaver *m_screensaver; | 89 | QPEScreenSaver *m_screensaver; |
89 | QTimer * m_timer; | 90 | QTimer * m_timer; |
90 | int m_powerVeryLow; | 91 | int m_powerVeryLow; |
91 | int m_powerCritical; | 92 | int m_powerCritical; |
92 | 93 | int m_currentPowerLevel; | |
93 | }; | 94 | }; |
94 | 95 | ||