summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-22 23:34:24 (UTC)
committer harlekin <harlekin>2002-10-22 23:34:24 (UTC)
commita4dccc9ce6de0bf75d11688b01f2cc010da3647e (patch) (side-by-side diff)
tree80c6c360b67bad9af77d79888bef97fa6feabc76
parente4297ff151693e07313ea036de91ad3c788c5e26 (diff)
downloadopie-a4dccc9ce6de0bf75d11688b01f2cc010da3647e.zip
opie-a4dccc9ce6de0bf75d11688b01f2cc010da3647e.tar.gz
opie-a4dccc9ce6de0bf75d11688b01f2cc010da3647e.tar.bz2
timer is now more separated from warnings
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/desktop.cpp37
-rw-r--r--core/launcher/desktop.h5
2 files changed, 27 insertions, 15 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
@@ -397,24 +397,24 @@ void DesktopApplication::switchLCD ( bool on )
}
}
DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
: QPEApplication( argc, argv, appType )
{
- //FIXME, need also a method for setting different timer ( changed runtime )
m_timer = new QTimer( this );
- connect( m_timer, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
- Config cfg( "qpe" );
- cfg.setGroup( "APM" );
- m_timer->start( cfg.readNumEntry( "check_interval", 10000 ) );
- m_powerVeryLow = cfg.readNumEntry( "power_verylow", 10 );
- m_powerCritical = cfg.readNumEntry( "power_critical", 5 );
+ connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) );
+ Config cfg( "apm" );
+ cfg.setGroup( "Warnings" );
+ m_timer->start( 5000 );
+ //cfg.readNumEntry( "checkinterval", 10000 )
+ m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
+ m_powerCritical = cfg.readNumEntry( "powercritical", 5 );
ps = new PowerStatus;
pa = new DesktopPowerAlerter( 0 );
channel = new QCopChannel( "QPE/Desktop", this );
connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
channel = new QCopChannel( "QPE/System", this );
@@ -491,17 +491,17 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray &
emit power();
}
}
void DesktopApplication::reloadPowerWarnSettings() {
Config cfg( "apm" );
cfg.setGroup( "Warnings" );
- m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) );
+ // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) );
m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
m_powerCritical = cfg.readNumEntry( "powervcritical", 5 );
}
enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
#ifdef Q_WS_QWS
@@ -627,38 +627,49 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
}
}
}
return QPEApplication::qwsEventFilter( e );
}
#endif
-void DesktopApplication::psTimeout()
+void DesktopApplication::psTimeout( int batRemaining )
{
- qpedesktop->checkMemory(); // in case no events are being generated
-
*ps = PowerStatusManager::readStatus();
+ // maybe now since its triggered by apm change there might be to few warnings
// if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) {
- if ( ( ps->batteryPercentRemaining() == m_powerVeryLow ) ) {
+ if ( ( batRemaining == m_powerVeryLow ) ) {
pa->alert( tr( "Battery is running very low." ), 6 );
}
// if ( ps->batteryStatus() == PowerStatus::Critical ) {
- if ( ps->batteryPercentRemaining() == m_powerCritical ) {
+ if ( batRemaining == m_powerCritical ) {
pa->alert( tr( "Battery level is critical!\n"
"Keep power off until power restored!" ), 1 );
}
if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
}
}
+void DesktopApplication::apmTimeout()
+{
+ qpedesktop->checkMemory(); // in case no events are being generated
+
+ *ps = PowerStatusManager::readStatus();
+
+ if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) {
+ // not very nice, since psTimeout parses the again
+ m_currentPowerLevel = ps->batteryPercentRemaining();
+ psTimeout( m_currentPowerLevel );
+ }
+}
void DesktopApplication::sendCard()
{
delete cardSendTimer;
cardSendTimer = 0;
QString card = getenv( "HOME" );
card += "/Applications/addressbook/businesscard.vcf";
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
@@ -72,29 +72,30 @@ protected:
void restart();
public slots:
virtual void desktopMessage ( const QCString &msg, const QByteArray &data );
virtual void systemMessage ( const QCString &msg, const QByteArray &data );
protected slots:
void shutdown( ShutdownImpl::Type );
- void psTimeout();
+ void psTimeout( int );
+ void apmTimeout();
void sendCard();
private:
void reloadPowerWarnSettings();
DesktopPowerAlerter *pa;
PowerStatus *ps;
QTimer *cardSendTimer;
QCopChannel *channel;
QPEScreenSaver *m_screensaver;
QTimer * m_timer;
int m_powerVeryLow;
int m_powerCritical;
-
+ int m_currentPowerLevel;
};
class Desktop : public QWidget
{
Q_OBJECT
public:
Desktop();