summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-11-20 14:11:45 (UTC)
committer mickeyl <mickeyl>2003-11-20 14:11:45 (UTC)
commitf43e28fe8f226039d96ebda4e6c4d26e4f3320ba (patch) (unidiff)
tree3a312c1333e53b0c674c3b1a682226dd80917f5c
parentae9e1ed9cc9e65c1ffb28f3b75ff499e18c6b31a (diff)
downloadopie-f43e28fe8f226039d96ebda4e6c4d26e4f3320ba.zip
opie-f43e28fe8f226039d96ebda4e6c4d26e4f3320ba.tar.gz
opie-f43e28fe8f226039d96ebda4e6c4d26e4f3320ba.tar.bz2
fix battery message box text wrapping
patch courtesy of Matthias Hentges - thanks.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/serverapp.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index 23a7f95..e8d49fd 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -276,206 +276,224 @@ void ServerApplication::switchLCD( bool on ) {
276 dapp-> m_screensaver-> setDisplayState ( true ); 276 dapp-> m_screensaver-> setDisplayState ( true );
277 dapp-> m_screensaver-> setBacklight ( -3 ); 277 dapp-> m_screensaver-> setBacklight ( -3 );
278 }else 278 }else
279 dapp-> m_screensaver-> setDisplayState ( false ); 279 dapp-> m_screensaver-> setDisplayState ( false );
280 280
281 281
282} 282}
283 283
284ServerApplication::ServerApplication( int& argc, char **argv, Type t ) 284ServerApplication::ServerApplication( int& argc, char **argv, Type t )
285 : QPEApplication( argc, argv, t ) 285 : QPEApplication( argc, argv, t )
286{ 286{
287 287
288 288
289 // We know we'll have lots of cached pixmaps due to App/DocLnks 289 // We know we'll have lots of cached pixmaps due to App/DocLnks
290 QPixmapCache::setCacheLimit(512); 290 QPixmapCache::setCacheLimit(512);
291 291
292 m_ps = new PowerStatus; 292 m_ps = new PowerStatus;
293 m_ps_last = new PowerStatus; 293 m_ps_last = new PowerStatus;
294 pa = new DesktopPowerAlerter( 0 ); 294 pa = new DesktopPowerAlerter( 0 );
295 295
296 m_apm_timer = new QTimer( this ); 296 m_apm_timer = new QTimer( this );
297 connect(m_apm_timer, SIGNAL( timeout() ), 297 connect(m_apm_timer, SIGNAL( timeout() ),
298 this, SLOT( apmTimeout() ) ); 298 this, SLOT( apmTimeout() ) );
299 299
300 reloadPowerWarnSettings(); 300 reloadPowerWarnSettings();
301 301
302 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 302 QCopChannel *channel = new QCopChannel( "QPE/System", this );
303 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), 303 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
304 this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); 304 this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) );
305 305
306 channel = new QCopChannel("QPE/Launcher", this ); 306 channel = new QCopChannel("QPE/Launcher", this );
307 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), 307 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
308 this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); 308 this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) );
309 309
310 m_screensaver = new OpieScreenSaver(); 310 m_screensaver = new OpieScreenSaver();
311 m_screensaver->setInterval( -1 ); 311 m_screensaver->setInterval( -1 );
312 QWSServer::setScreenSaver( m_screensaver ); 312 QWSServer::setScreenSaver( m_screensaver );
313 313
314 connect( qApp, SIGNAL( volumeChanged( bool ) ), 314 connect( qApp, SIGNAL( volumeChanged( bool ) ),
315 this, SLOT( rereadVolumes() ) ); 315 this, SLOT( rereadVolumes() ) );
316 316
317 317
318 /* ### PluginLoader libqtopia SafeMode */ 318 /* ### PluginLoader libqtopia SafeMode */
319#if 0 319#if 0
320 if ( PluginLoader::inSafeMode() ) 320 if ( PluginLoader::inSafeMode() )
321 QTimer::singleShot(500, this, SLOT(showSafeMode()) ); 321 QTimer::singleShot(500, this, SLOT(showSafeMode()) );
322 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); 322 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) );
323#endif 323#endif
324 324
325 kf = new KeyFilter(this); 325 kf = new KeyFilter(this);
326 326
327 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); 327 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) );
328 connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); 328 connect( kf, SIGNAL(power()), this, SIGNAL(power()) );
329 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); 329 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) );
330 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); 330 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol()));
331 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); 331 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle()));
332 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); 332 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle()));
333 connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), 333 connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)),
334 this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); 334 this,SIGNAL(activate(const Opie::ODeviceButton*,bool)));
335 335
336 336
337 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); 337 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) );
338 338
339 connect( this, SIGNAL(power() ), 339 connect( this, SIGNAL(power() ),
340 SLOT(togglePower() ) ); 340 SLOT(togglePower() ) );
341 341
342 rereadVolumes(); 342 rereadVolumes();
343 343
344 serverApp = this; 344 serverApp = this;
345 345
346 apmTimeout(); 346 apmTimeout();
347 grabKeyboard(); 347 grabKeyboard();
348 348
349 /* make sure the event filter is installed */ 349 /* make sure the event filter is installed */
350 const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); 350 const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 );
351} 351}
352 352
353 353
354ServerApplication::~ServerApplication() 354ServerApplication::~ServerApplication()
355{ 355{
356 ungrabKeyboard(); 356 ungrabKeyboard();
357 357
358 358
359 delete pa; 359 delete pa;
360 delete m_ps; 360 delete m_ps;
361 delete m_ps_last; 361 delete m_ps_last;
362} 362}
363 363
364void ServerApplication::apmTimeout() { 364void ServerApplication::apmTimeout() {
365 serverApp-> checkMemory( ); // in case no events are generated 365 serverApp-> checkMemory( ); // in case no events are generated
366 *m_ps_last = *m_ps; 366 *m_ps_last = *m_ps;
367 *m_ps = PowerStatusManager::readStatus(); 367 *m_ps = PowerStatusManager::readStatus();
368 368
369 if ( m_ps->acStatus() != m_ps_last-> acStatus() ) 369 if ( m_ps->acStatus() != m_ps_last-> acStatus() )
370 m_screensaver-> powerStatusChanged( *m_ps ); 370 m_screensaver-> powerStatusChanged( *m_ps );
371 371
372 if ( m_ps->acStatus() == PowerStatus::Online ) 372 if ( m_ps->acStatus() == PowerStatus::Online ) {
373 return; 373 return;
374 374 }
375
375 int bat = m_ps-> batteryPercentRemaining(); 376 int bat = m_ps-> batteryPercentRemaining();
376 377
377 if ( bat < m_ps_last-> batteryPercentRemaining() ) { 378 if ( bat < m_ps_last-> batteryPercentRemaining() ) {
378 if ( bat <= m_powerCritical ) 379 if ( bat <= m_powerCritical ) {
379 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 380 QMessageBox battlow(
380 else if ( bat <= m_powerVeryLow ) 381 tr("WARNING"),
381 pa->alert( tr( "Battery is running very low. "), 2 ); 382 tr("<p>The battery level is critical!"
383 "<p>Keep power off until AC is restored"),
384 QMessageBox::Warning,
385 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
386 0, QString::null, TRUE, WStyle_StaysOnTop);
387 battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
388 battlow.exec();
389 } else if ( bat <= m_powerVeryLow )
390 pa->alert( tr( "The battery is running very low. "), 2 );
382 } 391 }
383 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) 392
384 pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); 393 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) {
385 394 QMessageBox battlow(
395 tr("WARNING"),
396 tr("<p>The Back-up battery is very low"
397 "<p>Please charge the back-up battery"),
398 QMessageBox::Warning,
399 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
400 0, QString::null, TRUE, WStyle_StaysOnTop);
401 battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
402 battlow.exec();
403 }
386} 404}
387 405
388void ServerApplication::systemMessage( const QCString& msg, 406void ServerApplication::systemMessage( const QCString& msg,
389 const QByteArray& data ) { 407 const QByteArray& data ) {
390 QDataStream stream ( data, IO_ReadOnly ); 408 QDataStream stream ( data, IO_ReadOnly );
391 409
392 if ( msg == "setScreenSaverInterval(int)" ) { 410 if ( msg == "setScreenSaverInterval(int)" ) {
393 int time; 411 int time;
394 stream >> time; 412 stream >> time;
395 m_screensaver-> setInterval( time ); 413 m_screensaver-> setInterval( time );
396 } 414 }
397 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 415 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
398 int t1, t2, t3; 416 int t1, t2, t3;
399 stream >> t1 >> t2 >> t3; 417 stream >> t1 >> t2 >> t3;
400 m_screensaver-> setIntervals( t1, t2, t3 ); 418 m_screensaver-> setIntervals( t1, t2, t3 );
401 } 419 }
402 else if ( msg == "setBacklight(int)" ) { 420 else if ( msg == "setBacklight(int)" ) {
403 int bright; 421 int bright;
404 stream >> bright; 422 stream >> bright;
405 m_screensaver-> setBacklight( bright ); 423 m_screensaver-> setBacklight( bright );
406 } 424 }
407 else if ( msg == "setScreenSaverMode(int)" ) { 425 else if ( msg == "setScreenSaverMode(int)" ) {
408 int mode; 426 int mode;
409 stream >> mode; 427 stream >> mode;
410 m_screensaver-> setMode ( mode ); 428 m_screensaver-> setMode ( mode );
411 } 429 }
412 else if ( msg == "reloadPowerWarnSettings()" ) { 430 else if ( msg == "reloadPowerWarnSettings()" ) {
413 reloadPowerWarnSettings(); 431 reloadPowerWarnSettings();
414 } 432 }
415 else if ( msg == "setDisplayState(int)" ) { 433 else if ( msg == "setDisplayState(int)" ) {
416 int state; 434 int state;
417 stream >> state; 435 stream >> state;
418 m_screensaver-> setDisplayState ( state != 0 ); 436 m_screensaver-> setDisplayState ( state != 0 );
419 } 437 }
420 else if ( msg == "suspend()" ) { 438 else if ( msg == "suspend()" ) {
421 emit power(); 439 emit power();
422 } 440 }
423 else if ( msg == "sendBusinessCard()" ) { 441 else if ( msg == "sendBusinessCard()" ) {
424 QString card = ::getenv ( "HOME" ); 442 QString card = ::getenv ( "HOME" );
425 card += "/Applications/addressbook/businesscard.vcf"; 443 card += "/Applications/addressbook/businesscard.vcf";
426 444
427 if ( QFile::exists( card ) ) { 445 if ( QFile::exists( card ) ) {
428 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); 446 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
429 QString mimetype = "text/x-vCard"; 447 QString mimetype = "text/x-vCard";
430 e << tr( "business card" ) << card << mimetype; 448 e << tr( "business card" ) << card << mimetype;
431 } 449 }
432 } 450 }
433} 451}
434 452
435void ServerApplication::reloadPowerWarnSettings ( ) 453void ServerApplication::reloadPowerWarnSettings ( )
436{ 454{
437 Config cfg ( "apm" ); 455 Config cfg ( "apm" );
438 cfg. setGroup ( "Warnings" ); 456 cfg. setGroup ( "Warnings" );
439 457
440 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 458 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
441 459
442 m_apm_timer-> stop ( ); 460 m_apm_timer-> stop ( );
443 if ( iv ) 461 if ( iv )
444 m_apm_timer-> start ( iv ); 462 m_apm_timer-> start ( iv );
445 463
446 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 464 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
447 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 465 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
448} 466}
449 467
450void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 468void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data )
451{ 469{
452 QDataStream stream ( data, IO_ReadOnly ); 470 QDataStream stream ( data, IO_ReadOnly );
453 471
454 if ( msg == "deviceButton(int,int,int)" ) { 472 if ( msg == "deviceButton(int,int,int)" ) {
455 int keycode, press, autoRepeat; 473 int keycode, press, autoRepeat;
456 stream >> keycode >> press >> autoRepeat; 474 stream >> keycode >> press >> autoRepeat;
457 475
458 kf->checkButtonAction ( true, keycode, press, autoRepeat ); 476 kf->checkButtonAction ( true, keycode, press, autoRepeat );
459 } 477 }
460 else if ( msg == "keyRegister(int,QCString,QCString)" ) { 478 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
461 int k; 479 int k;
462 QCString c, m; 480 QCString c, m;
463 stream >> k >> c >> m; 481 stream >> k >> c >> m;
464 482
465 kf -> registerKey( QCopKeyRegister(k, c, m) ); 483 kf -> registerKey( QCopKeyRegister(k, c, m) );
466 } 484 }
467} 485}
468 486
469 487
470bool ServerApplication::screenLocked() 488bool ServerApplication::screenLocked()
471{ 489{
472 return loggedin == 0; 490 return loggedin == 0;
473} 491}
474 492
475void ServerApplication::login(bool at_poweron) 493void ServerApplication::login(bool at_poweron)
476{ 494{
477 if ( !loggedin ) { 495 if ( !loggedin ) {
478 Global::terminateBuiltin("calibrate"); // No tr 496 Global::terminateBuiltin("calibrate"); // No tr
479 Password::authenticate(at_poweron); 497 Password::authenticate(at_poweron);
480 loggedin=1; 498 loggedin=1;
481#ifndef QT_NO_COP 499#ifndef QT_NO_COP