summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp161
-rw-r--r--core/launcher/desktop.h15
2 files changed, 129 insertions, 47 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index d2bd8ae..4926b97 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -152,85 +152,106 @@ void DesktopPowerAlerter::hideEvent( QHideEvent *e )
152 currentPriority = INT_MAX; 152 currentPriority = INT_MAX;
153} 153}
154 154
155class QPEScreenSaver : public QWSScreenSaver 155class QPEScreenSaver : public QWSScreenSaver
156{ 156{
157private: 157private:
158 int LcdOn; 158 int LcdOn;
159 159
160public: 160public:
161 QPEScreenSaver() 161 QPEScreenSaver()
162 { 162 {
163 m_disable_suspend = 100; 163 m_disable_suspend = 100;
164 m_enable_dim = false; 164 m_enable_dim = false;
165 m_enable_lightoff = false; 165 m_enable_lightoff = false;
166 m_enable_onlylcdoff = false; 166 m_enable_onlylcdoff = false;
167 167
168 m_disable_suspend_ac = 100;
169 m_enable_dim_ac = false;
170 m_enable_lightoff_ac = false;
171 m_enable_onlylcdoff_ac = false;
172
168 m_lcd_status = true; 173 m_lcd_status = true;
169 174
170 m_backlight_normal = -1; 175 m_backlight_normal = -1;
171 m_backlight_current = -1; 176 m_backlight_current = -1;
172 m_backlight_forcedoff = false; 177 m_backlight_forcedoff = false;
173 178
174 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 179 // 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 ); 180 ODevice::inst ( )-> setDisplayStatus ( true );
176 setBacklight ( -1 ); 181 setBacklight ( -1 );
177 } 182 }
178 void restore() 183 void restore()
179 { 184 {
180 if ( !m_lcd_status ) { // We must have turned it off 185 if ( !m_lcd_status ) { // We must have turned it off
181 ODevice::inst ( ) -> setDisplayStatus ( true ); 186 ODevice::inst ( ) -> setDisplayStatus ( true );
182 m_lcd_status = true; 187 m_lcd_status = true;
183 } 188 }
184 189
185 setBacklightInternal ( -1 ); 190 setBacklightInternal ( -1 );
186 } 191 }
187 bool save( int level ) 192 bool save( int level )
188 { 193 {
189 switch ( level ) { 194 bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online );
195
196 switch ( level ) {
190 case 0: 197 case 0:
191 if ( m_disable_suspend > 0 && m_enable_dim ) { 198
192 if ( m_backlight_current > 1 ) 199 if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) {
193 setBacklightInternal ( 1 ); // lowest non-off 200 if ( m_backlight_current > 1 )
194 } 201 setBacklight( 1 ); // lowest non-off
195 return true; 202 } else if ( m_disable_suspend > 0 && m_enable_dim ) {
196 break; 203 if ( m_backlight_current > 1 )
204 setBacklightInternal( 1 ); // lowest non-off
205 }
206 return true;
207 break;
197 case 1: 208 case 1:
198 if ( m_disable_suspend > 1 && m_enable_lightoff ) { 209
199 setBacklightInternal ( 0 ); // off 210 if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) {
200 } 211 setBacklightInternal( 0 ); // off
201 return true; 212 } else if ( m_disable_suspend > 1 && m_enable_lightoff ) {
202 break; 213 setBacklightInternal( 0 ); // off
203 case 2: 214 }
204 if ( m_enable_onlylcdoff ) {
205 ODevice::inst ( )-> setDisplayStatus ( false );
206 m_lcd_status = false;
207 return true; 215 return true;
208 } 216 break;
209 else // We're going to suspend the whole machine 217 case 2:
210 { 218 if ( m_enable_onlylcdoff_ac && onAC ) {
211 if ( ( m_disable_suspend > 2 ) && 219 ODevice::inst ( ) -> setDisplayStatus ( false );
212 ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && 220 m_lcd_status = false;
213 ( !Network::networkOnline ( ) ) ) { 221 return true;
214 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
215 return true;
216 } 222 }
217 } 223 else if ( m_enable_onlylcdoff ) {
218 break; 224 ODevice::inst ( ) -> setDisplayStatus ( false );
219 } 225 m_lcd_status = false;
220 return false; 226 return true;
227 }
228 else // We're going to suspend the whole machine
229 {
230 if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) {
231 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
232 return true;
233 }
234 if ( ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) {
235 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
236 return true;
237 }
238 }
239 break;
240 }
241 return false;
221 } 242 }
222 243
223private: 244private:
224 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) 245 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def )
225 { 246 {
226 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) 247 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 )
227 return 0; 248 return 0;
228 249
229 if ( interval < 0 ) { 250 if ( interval < 0 ) {
230 // Restore screen blanking and power saving state 251 // Restore screen blanking and power saving state
231 interval = config.readNumEntry( value, def ); 252 interval = config.readNumEntry( value, def );
232 } 253 }
233 return interval; 254 return interval;
234 } 255 }
235 256
236public: 257public:
@@ -247,125 +268,161 @@ public:
247 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 268 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
248 269
249 v [ 0 ] = QMAX( 1000 * i1, 100 ); 270 v [ 0 ] = QMAX( 1000 * i1, 100 );
250 v [ 1 ] = QMAX( 1000 * i2, 100 ); 271 v [ 1 ] = QMAX( 1000 * i2, 100 );
251 v [ 2 ] = QMAX( 1000 * i3, 100 ); 272 v [ 2 ] = QMAX( 1000 * i3, 100 );
252 v [ 3 ] = 0; 273 v [ 3 ] = 0;
253 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); 274 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false );
254 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); 275 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false );
255 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); 276 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 );
256 277
257 if ( !i1 && !i2 && !i3 ) 278 if ( !i1 && !i2 && !i3 )
258 QWSServer::setScreenSaverInterval( 0 ); 279 QWSServer::setScreenSaverInterval( 0 );
259 else 280 else
260 QWSServer::setScreenSaverIntervals( v ); 281 QWSServer::setScreenSaverIntervals( v );
261 } 282 }
262 283
284 void setIntervalsAC( int i1, int i2, int i3 )
285 {
286 Config config( "qpe" );
287 config.setGroup( "Screensaver" );
288
289 int v[ 4 ];
290 i1 = ssi( i1, config, "DimAC", "Interval_DimAC", 30 );
291 i2 = ssi( i2, config, "LightOffAC", "Interval_LightOffAC", 20 );
292 i3 = ssi( i3, config, "", "IntervalAC", 60 );
293
294 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
295
296 v [ 0 ] = QMAX( 1000 * i1, 100 );
297 v [ 1 ] = QMAX( 1000 * i2, 100 );
298 v [ 2 ] = QMAX( 1000 * i3, 100 );
299 v [ 3 ] = 0;
300 m_enable_dim_ac = ( ( i1 != 0 ) ? config.readNumEntry ( "DimAC", 1 ) : false );
301 m_enable_lightoff_ac = ( ( i2 != 0 ) ? config.readNumEntry ( "LightOffAC", 1 ) : false );
302 m_enable_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnlyAC", 0 );
303
304 if ( !i1 && !i2 && !i3 )
305 QWSServer::setScreenSaverInterval( 0 );
306 else
307 QWSServer::setScreenSaverIntervals( v );
308 }
309
263 void setInterval ( int interval ) 310 void setInterval ( int interval )
264 { 311 {
265 setIntervals ( -1, -1, interval ); 312 setIntervals ( -1, -1, interval );
266 } 313 }
267 314
268 void setMode ( int mode ) 315 void setMode ( int mode )
269 { 316 {
270 if ( mode > m_disable_suspend ) 317 if ( mode > m_disable_suspend )
271 setInterval( -1 ); 318 setInterval( -1 );
272 m_disable_suspend = mode; 319 m_disable_suspend = mode;
273 } 320 }
274 321
275 void setBacklight ( int bright ) 322 void setBacklight ( int bright )
276 { 323 {
277 // Read from config 324 // Read from config
278 Config config ( "qpe" ); 325 Config config ( "qpe" );
279 config. setGroup ( "Screensaver" ); 326 config. setGroup ( "Screensaver" );
280 m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); 327 m_backlight_normal = config. readNumEntry ( "Brightness", 255 );
281 328
282 setBacklightInternal ( bright ); 329 setBacklightInternal ( bright );
283 } 330 }
284 331
285private: 332private:
286 void setBacklightInternal ( int bright ) 333 void setBacklightInternal ( int bright )
287 { 334 {
288 if ( bright == -3 ) { 335 if ( bright == -3 ) {
289 // Forced on 336 // Forced on
290 m_backlight_forcedoff = false; 337 m_backlight_forcedoff = false;
291 bright = -1; 338 bright = -1;
292 } 339 }
293 if ( m_backlight_forcedoff && bright != -2 ) 340 if ( m_backlight_forcedoff && bright != -2 )
294 return ; 341 return ;
295 if ( bright == -2 ) { 342 if ( bright == -2 ) {
296 // Toggle between off and on 343 // Toggle between off and on
297 bright = m_backlight_current ? 0 : -1; 344 bright = m_backlight_current ? 0 : -1;
298 m_backlight_forcedoff = !bright; 345 m_backlight_forcedoff = !bright;
299 } 346 }
300 if ( bright == -1 ) 347 if ( bright == -1 )
301 bright = m_backlight_normal; 348 bright = m_backlight_normal;
302 349
303 if ( bright != m_backlight_current ) { 350 if ( bright != m_backlight_current ) {
304 ODevice::inst ( )-> setDisplayBrightness ( bright ); 351 ODevice::inst ( )-> setDisplayBrightness ( bright );
305 m_backlight_current = bright; 352 m_backlight_current = bright;
306 } 353 }
307 } 354 }
308 355
309public: 356public:
310 void setDisplayState ( bool on ) 357 void setDisplayState ( bool on )
311 { 358 {
312 if ( m_lcd_status != on ) { 359 if ( m_lcd_status != on ) {
313 ODevice::inst ( ) -> setDisplayStatus ( on ); 360 ODevice::inst ( ) -> setDisplayStatus ( on );
314 m_lcd_status = on; 361 m_lcd_status = on;
315 } 362 }
316 } 363 }
317 364
318private: 365private:
319 int m_disable_suspend; 366 int m_disable_suspend;
320 bool m_enable_dim; 367 bool m_enable_dim;
321 bool m_enable_lightoff; 368 bool m_enable_lightoff;
322 bool m_enable_onlylcdoff; 369 bool m_enable_onlylcdoff;
323 370
371 int m_disable_suspend_ac;
372 bool m_enable_dim_ac;
373 bool m_enable_lightoff_ac;
374 bool m_enable_onlylcdoff_ac;
375
324 bool m_lcd_status; 376 bool m_lcd_status;
325 377
326 int m_backlight_normal; 378 int m_backlight_normal;
327 int m_backlight_current; 379 int m_backlight_current;
328 bool m_backlight_forcedoff; 380 bool m_backlight_forcedoff;
329}; 381};
330 382
331void DesktopApplication::switchLCD ( bool on ) 383void DesktopApplication::switchLCD ( bool on )
332{ 384{
333 if ( qApp ) { 385 if ( qApp ) {
334 DesktopApplication *dapp = (DesktopApplication *) qApp; 386 DesktopApplication *dapp = (DesktopApplication *) qApp;
335 387
336 if ( dapp-> m_screensaver ) { 388 if ( dapp-> m_screensaver ) {
337 if ( on ) { 389 if ( on ) {
338 dapp-> m_screensaver-> setDisplayState ( true ); 390 dapp-> m_screensaver-> setDisplayState ( true );
339 dapp-> m_screensaver-> setBacklight ( -3 ); 391 dapp-> m_screensaver-> setBacklight ( -3 );
340 } 392 }
341 else { 393 else {
342 dapp-> m_screensaver-> setDisplayState ( false ); 394 dapp-> m_screensaver-> setDisplayState ( false );
343 } 395 }
344 } 396 }
345 } 397 }
346} 398}
347 399
348 400
349DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 401DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
350 : QPEApplication( argc, argv, appType ) 402 : QPEApplication( argc, argv, appType )
351{ 403{
352 404
353 QTimer * t = new QTimer( this ); 405 //FIXME, need also a method for setting different timer ( changed runtime )
354 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); 406 m_timer = new QTimer( this );
355 t->start( 10000 ); 407 connect( m_timer, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
408 Config cfg( "qpe" );
409 cfg.setGroup( "APM" );
410 m_timer->start( cfg.readNumEntry( "check_interval", 10000 ) );
411 m_powerVeryLow = cfg.readNumEntry( "power_verylow", 10 );
412 m_powerCritical = cfg.readNumEntry( "power_critical", 5 );
356 ps = new PowerStatus; 413 ps = new PowerStatus;
357 pa = new DesktopPowerAlerter( 0 ); 414 pa = new DesktopPowerAlerter( 0 );
358 415
359 channel = new QCopChannel( "QPE/Desktop", this ); 416 channel = new QCopChannel( "QPE/Desktop", this );
360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 417 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
361 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 418 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
362 419
363 channel = new QCopChannel( "QPE/System", this ); 420 channel = new QCopChannel( "QPE/System", this );
364 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 421 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
365 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 422 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
366 423
367 m_screensaver = new QPEScreenSaver; 424 m_screensaver = new QPEScreenSaver;
368 425
369 m_screensaver-> setInterval ( -1 ); 426 m_screensaver-> setInterval ( -1 );
370 QWSServer::setScreenSaver( m_screensaver ); 427 QWSServer::setScreenSaver( m_screensaver );
371} 428}
@@ -394,52 +451,70 @@ void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &
394 451
395 452
396void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 453void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
397{ 454{
398 QDataStream stream ( data, IO_ReadOnly ); 455 QDataStream stream ( data, IO_ReadOnly );
399 456
400 if ( msg == "setScreenSaverInterval(int)" ) { 457 if ( msg == "setScreenSaverInterval(int)" ) {
401 int time; 458 int time;
402 stream >> time; 459 stream >> time;
403 m_screensaver-> setInterval( time ); 460 m_screensaver-> setInterval( time );
404 } 461 }
405 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 462 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
406 int t1, t2, t3; 463 int t1, t2, t3;
407 stream >> t1 >> t2 >> t3; 464 stream >> t1 >> t2 >> t3;
408 m_screensaver-> setIntervals( t1, t2, t3 ); 465 m_screensaver-> setIntervals( t1, t2, t3 );
409 } 466 }
467 else if ( msg == "setScreenSaverIntervalsAC(int,int,int)" ) {
468 int t1, t2, t3;
469 stream >> t1 >> t2 >> t3;
470 m_screensaver-> setIntervalsAC( t1, t2, t3 );
471 }
410 else if ( msg == "setBacklight(int)" ) { 472 else if ( msg == "setBacklight(int)" ) {
411 int bright; 473 int bright;
412 stream >> bright; 474 stream >> bright;
413 m_screensaver-> setBacklight( bright ); 475 m_screensaver-> setBacklight( bright );
414 } 476 }
415 else if ( msg == "setScreenSaverMode(int)" ) { 477 else if ( msg == "setScreenSaverMode(int)" ) {
416 int mode; 478 int mode;
417 stream >> mode; 479 stream >> mode;
418 m_screensaver-> setMode ( mode ); 480 m_screensaver-> setMode ( mode );
419 } 481 }
482 else if ( msg == "reloadPowerWarnSettings()" ) {
483 reloadPowerWarnSettings();
484 }
420 else if ( msg == "setDisplayState(int)" ) { 485 else if ( msg == "setDisplayState(int)" ) {
421 int state; 486 int state;
422 stream >> state; 487 stream >> state;
423 m_screensaver-> setDisplayState ( state != 0 ); 488 m_screensaver-> setDisplayState ( state != 0 );
424 } 489 }
425 else if ( msg == "suspend()" ) { 490 else if ( msg == "suspend()" ) {
426 emit power(); 491 emit power();
427 } 492 }
428} 493}
429 494
495void DesktopApplication::reloadPowerWarnSettings() {
496 Config cfg( "apm" );
497 cfg.setGroup( "Warnings" );
498
499 m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) );
500 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
501 m_powerCritical = cfg.readNumEntry( "powervcritical", 5 );
502}
503
504
430enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 505enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
431 506
432#ifdef Q_WS_QWS 507#ifdef Q_WS_QWS
433bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 508bool DesktopApplication::qwsEventFilter( QWSEvent *e )
434{ 509{
435 qpedesktop->checkMemory(); 510 qpedesktop->checkMemory();
436 511
437 if ( e->type == QWSEvent::Key ) { 512 if ( e->type == QWSEvent::Key ) {
438 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 513 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
439 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 514 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
440 return TRUE; 515 return TRUE;
441 bool press = ke->simpleData.is_press; 516 bool press = ke->simpleData.is_press;
442 bool autoRepeat = ke->simpleData.is_auto_repeat; 517 bool autoRepeat = ke->simpleData.is_auto_repeat;
443 518
444 /* 519 /*
445 app that registers key/message to be sent back to the app, when it doesn't have focus, 520 app that registers key/message to be sent back to the app, when it doesn't have focus,
@@ -466,38 +541,38 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
466 if ( press ) 541 if ( press )
467 emit datebook(); 542 emit datebook();
468 return TRUE; 543 return TRUE;
469 } 544 }
470 if ( ke->simpleData.keycode == Key_F10 ) { 545 if ( ke->simpleData.keycode == Key_F10 ) {
471 if ( !press && cardSendTimer ) { 546 if ( !press && cardSendTimer ) {
472 emit contacts(); 547 emit contacts();
473 delete cardSendTimer; 548 delete cardSendTimer;
474 } 549 }
475 else if ( press ) { 550 else if ( press ) {
476 cardSendTimer = new QTimer(); 551 cardSendTimer = new QTimer();
477 cardSendTimer->start( 2000, TRUE ); 552 cardSendTimer->start( 2000, TRUE );
478 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 553 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
479 } 554 }
480 return TRUE; 555 return TRUE;
481 } 556 }
482// menu key now opens application menu/toolbar 557
483// if ( ke->simpleData.keycode == Key_F11 ) { 558// if ( ke->simpleData.keycode == Key_F11 ) {
484// if ( press ) emit menu(); 559// if ( press ) emit menu();
485// return TRUE; 560// return TRUE;
486// } 561// }
487 562
488 if ( ke->simpleData.keycode == Key_F12 ) { 563 if ( ke->simpleData.keycode == Key_F12 ) {
489 while ( activePopupWidget() ) 564 while ( activePopupWidget() )
490 activePopupWidget() ->close(); 565 activePopupWidget() ->close();
491 if ( press ) 566 if ( press )
492 emit launch(); 567 emit launch();
493 return TRUE; 568 return TRUE;
494 } 569 }
495 if ( ke->simpleData.keycode == Key_F13 ) { 570 if ( ke->simpleData.keycode == Key_F13 ) {
496 if ( press ) 571 if ( press )
497 emit email(); 572 emit email();
498 return TRUE; 573 return TRUE;
499 } 574 }
500 } 575 }
501 576
502 if ( ke->simpleData.keycode == Key_F34 ) { 577 if ( ke->simpleData.keycode == Key_F34 ) {
503 if ( press ) 578 if ( press )
@@ -550,39 +625,41 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
550 else { 625 else {
551 up = TRUE; 626 up = TRUE;
552 } 627 }
553 } 628 }
554 } 629 }
555 630
556 return QPEApplication::qwsEventFilter( e ); 631 return QPEApplication::qwsEventFilter( e );
557} 632}
558#endif 633#endif
559 634
560void DesktopApplication::psTimeout() 635void DesktopApplication::psTimeout()
561{ 636{
562 qpedesktop->checkMemory(); // in case no events are being generated 637 qpedesktop->checkMemory(); // in case no events are being generated
563 638
564 *ps = PowerStatusManager::readStatus(); 639 *ps = PowerStatusManager::readStatus();
565 640
566 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { 641 // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) {
567 pa->alert( tr( "Battery is running very low." ), 6 ); 642 if ( ( ps->batteryPercentRemaining() == m_powerVeryLow ) ) {
643 pa->alert( tr( "Battery is running very low." ), 6 );
568 } 644 }
569 645
570 if ( ps->batteryStatus() == PowerStatus::Critical ) { 646 // if ( ps->batteryStatus() == PowerStatus::Critical ) {
571 pa->alert( tr( "Battery level is critical!\n" 647 if ( ps->batteryPercentRemaining() == m_powerCritical ) {
572 "Keep power off until power restored!" ), 1 ); 648 pa->alert( tr( "Battery level is critical!\n"
649 "Keep power off until power restored!" ), 1 );
573 } 650 }
574 651
575 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 652 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
576 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 653 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
577 } 654 }
578} 655}
579 656
580 657
581void DesktopApplication::sendCard() 658void DesktopApplication::sendCard()
582{ 659{
583 delete cardSendTimer; 660 delete cardSendTimer;
584 cardSendTimer = 0; 661 cardSendTimer = 0;
585 QString card = getenv( "HOME" ); 662 QString card = getenv( "HOME" );
586 card += "/Applications/addressbook/businesscard.vcf"; 663 card += "/Applications/addressbook/businesscard.vcf";
587 664
588 if ( QFile::exists( card ) ) { 665 if ( QFile::exists( card ) ) {
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index 04c2f61..15d8ef7 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -67,37 +67,42 @@ protected:
67 67
68 bool qwsEventFilter( QWSEvent * ); 68 bool qwsEventFilter( QWSEvent * );
69#endif 69#endif
70 70
71 void shutdown(); 71 void shutdown();
72 void restart(); 72 void restart();
73 73
74public slots: 74public slots:
75 virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); 75 virtual void desktopMessage ( const QCString &msg, const QByteArray &data );
76 virtual void systemMessage ( const QCString &msg, const QByteArray &data ); 76 virtual void systemMessage ( const QCString &msg, const QByteArray &data );
77 77
78protected slots: 78protected slots:
79 void shutdown( ShutdownImpl::Type ); 79 void shutdown( ShutdownImpl::Type );
80 void psTimeout(); 80 void psTimeout();
81 void sendCard(); 81 void sendCard();
82private: 82private:
83 DesktopPowerAlerter *pa; 83 void reloadPowerWarnSettings();
84 PowerStatus *ps; 84 DesktopPowerAlerter *pa;
85 QTimer *cardSendTimer; 85 PowerStatus *ps;
86 QCopChannel *channel; 86 QTimer *cardSendTimer;
87 QPEScreenSaver *m_screensaver; 87 QCopChannel *channel;
88 QPEScreenSaver *m_screensaver;
89 QTimer * m_timer;
90 int m_powerVeryLow;
91 int m_powerCritical;
92
88}; 93};
89 94
90 95
91class Desktop : public QWidget 96class Desktop : public QWidget
92{ 97{
93 Q_OBJECT 98 Q_OBJECT
94public: 99public:
95 Desktop(); 100 Desktop();
96 ~Desktop(); 101 ~Desktop();
97 102
98 static bool screenLocked(); 103 static bool screenLocked();
99 104
100 void show(); 105 void show();
101 void checkMemory(); 106 void checkMemory();
102 107
103 void keyClick(); 108 void keyClick();