author | simon <simon> | 2003-03-25 20:30:12 (UTC) |
---|---|---|
committer | simon <simon> | 2003-03-25 20:30:12 (UTC) |
commit | 3a4ee8d8a53ca17703b34f84e1a411056ee7e50f (patch) (unidiff) | |
tree | 6010cc8c464767725a7ab8b973428945dca62994 | |
parent | f7395e72a415322101ee3e22cb0e10b6bdf60a63 (diff) | |
download | opie-3a4ee8d8a53ca17703b34f84e1a411056ee7e50f.zip opie-3a4ee8d8a53ca17703b34f84e1a411056ee7e50f.tar.gz opie-3a4ee8d8a53ca17703b34f84e1a411056ee7e50f.tar.bz2 |
- keep an eye on resize events on the desktop widget, which are an
indication for things like life rotation. upon a resize re-layout things
(taskbar, tabs and maxwindow rect)
-rw-r--r-- | core/launcher/desktop.cpp | 31 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/launcher/taskbar.h | 3 |
3 files changed, 28 insertions, 8 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 86527f6..6def126 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -254,608 +254,625 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & | |||
254 | m_screensaver-> setInterval( time ); | 254 | m_screensaver-> setInterval( time ); |
255 | } | 255 | } |
256 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 256 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
257 | int t1, t2, t3; | 257 | int t1, t2, t3; |
258 | stream >> t1 >> t2 >> t3; | 258 | stream >> t1 >> t2 >> t3; |
259 | m_screensaver-> setIntervals( t1, t2, t3 ); | 259 | m_screensaver-> setIntervals( t1, t2, t3 ); |
260 | } | 260 | } |
261 | else if ( msg == "setBacklight(int)" ) { | 261 | else if ( msg == "setBacklight(int)" ) { |
262 | int bright; | 262 | int bright; |
263 | stream >> bright; | 263 | stream >> bright; |
264 | m_screensaver-> setBacklight( bright ); | 264 | m_screensaver-> setBacklight( bright ); |
265 | } | 265 | } |
266 | else if ( msg == "setScreenSaverMode(int)" ) { | 266 | else if ( msg == "setScreenSaverMode(int)" ) { |
267 | int mode; | 267 | int mode; |
268 | stream >> mode; | 268 | stream >> mode; |
269 | m_screensaver-> setMode ( mode ); | 269 | m_screensaver-> setMode ( mode ); |
270 | } | 270 | } |
271 | else if ( msg == "reloadPowerWarnSettings()" ) { | 271 | else if ( msg == "reloadPowerWarnSettings()" ) { |
272 | reloadPowerWarnSettings(); | 272 | reloadPowerWarnSettings(); |
273 | } | 273 | } |
274 | else if ( msg == "setDisplayState(int)" ) { | 274 | else if ( msg == "setDisplayState(int)" ) { |
275 | int state; | 275 | int state; |
276 | stream >> state; | 276 | stream >> state; |
277 | m_screensaver-> setDisplayState ( state != 0 ); | 277 | m_screensaver-> setDisplayState ( state != 0 ); |
278 | } | 278 | } |
279 | else if ( msg == "suspend()" ) { | 279 | else if ( msg == "suspend()" ) { |
280 | emit power(); | 280 | emit power(); |
281 | } | 281 | } |
282 | else if ( msg == "sendBusinessCard()" ) { | 282 | else if ( msg == "sendBusinessCard()" ) { |
283 | QString card = ::getenv ( "HOME" ); | 283 | QString card = ::getenv ( "HOME" ); |
284 | card += "/Applications/addressbook/businesscard.vcf"; | 284 | card += "/Applications/addressbook/businesscard.vcf"; |
285 | 285 | ||
286 | if ( QFile::exists( card ) ) { | 286 | if ( QFile::exists( card ) ) { |
287 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 287 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
288 | QString mimetype = "text/x-vCard"; | 288 | QString mimetype = "text/x-vCard"; |
289 | e << tr( "business card" ) << card << mimetype; | 289 | e << tr( "business card" ) << card << mimetype; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | void DesktopApplication::reloadPowerWarnSettings ( ) | 294 | void DesktopApplication::reloadPowerWarnSettings ( ) |
295 | { | 295 | { |
296 | Config cfg ( "apm" ); | 296 | Config cfg ( "apm" ); |
297 | cfg. setGroup ( "Warnings" ); | 297 | cfg. setGroup ( "Warnings" ); |
298 | 298 | ||
299 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 299 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
300 | 300 | ||
301 | m_apm_timer-> stop ( ); | 301 | m_apm_timer-> stop ( ); |
302 | if ( iv ) | 302 | if ( iv ) |
303 | m_apm_timer-> start ( iv ); | 303 | m_apm_timer-> start ( iv ); |
304 | 304 | ||
305 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 305 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
306 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 306 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 310 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
311 | 311 | ||
312 | 312 | ||
313 | void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 313 | void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
314 | { | 314 | { |
315 | QDataStream stream ( data, IO_ReadOnly ); | 315 | QDataStream stream ( data, IO_ReadOnly ); |
316 | 316 | ||
317 | if ( msg == "deviceButton(int,int,int)" ) { | 317 | if ( msg == "deviceButton(int,int,int)" ) { |
318 | int keycode, press, autoRepeat; | 318 | int keycode, press, autoRepeat; |
319 | stream >> keycode >> press >> autoRepeat; | 319 | stream >> keycode >> press >> autoRepeat; |
320 | 320 | ||
321 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); | 321 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); |
322 | 322 | ||
323 | if ( db ) | 323 | if ( db ) |
324 | checkButtonAction ( db, keycode, press, autoRepeat ); | 324 | checkButtonAction ( db, keycode, press, autoRepeat ); |
325 | } | 325 | } |
326 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 326 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
327 | int k; | 327 | int k; |
328 | QCString c, m; | 328 | QCString c, m; |
329 | stream >> k >> c >> m; | 329 | stream >> k >> c >> m; |
330 | 330 | ||
331 | keyRegisterList.append ( QCopKeyRegister ( k, c, m )); | 331 | keyRegisterList.append ( QCopKeyRegister ( k, c, m )); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | void DesktopApplication::sendHeldAction ( ) | 335 | void DesktopApplication::sendHeldAction ( ) |
336 | { | 336 | { |
337 | if ( m_last_button ) { | 337 | if ( m_last_button ) { |
338 | m_last_button-> heldAction ( ). send ( ); | 338 | m_last_button-> heldAction ( ). send ( ); |
339 | m_last_button = 0; | 339 | m_last_button = 0; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) | 345 | bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) |
346 | { | 346 | { |
347 | if ( db ) { | 347 | if ( db ) { |
348 | if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { | 348 | if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { |
349 | m_button_timer-> stop ( ); | 349 | m_button_timer-> stop ( ); |
350 | 350 | ||
351 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) | 351 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) |
352 | { | 352 | { |
353 | 353 | ||
354 | if ( db-> pressedAction ( ). channel ( )!="ignore") { | 354 | if ( db-> pressedAction ( ). channel ( )!="ignore") { |
355 | 355 | ||
356 | db-> pressedAction ( ). send ( ); | 356 | db-> pressedAction ( ). send ( ); |
357 | } | 357 | } |
358 | else | 358 | else |
359 | return false; | 359 | return false; |
360 | } | 360 | } |
361 | } | 361 | } |
362 | else if ( press && !autoRepeat ) { | 362 | else if ( press && !autoRepeat ) { |
363 | m_button_timer-> stop ( ); | 363 | m_button_timer-> stop ( ); |
364 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) | 364 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) |
365 | { | 365 | { |
366 | 366 | ||
367 | if ( db-> heldAction ( ). channel ( )!="ignore") { | 367 | if ( db-> heldAction ( ). channel ( )!="ignore") { |
368 | m_last_button = db; | 368 | m_last_button = db; |
369 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | 369 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); |
370 | } | 370 | } |
371 | else return false; | 371 | else return false; |
372 | } | 372 | } |
373 | } | 373 | } |
374 | } | 374 | } |
375 | return true; | 375 | return true; |
376 | } | 376 | } |
377 | 377 | ||
378 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) | 378 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) |
379 | { | 379 | { |
380 | 380 | ||
381 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { | 381 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { |
382 | QKeyEvent *ke = (QKeyEvent *) e; | 382 | QKeyEvent *ke = (QKeyEvent *) e; |
383 | 383 | ||
384 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); | 384 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); |
385 | 385 | ||
386 | if ( db ) { | 386 | if ( db ) { |
387 | if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ))) | 387 | if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ))) |
388 | return true; //checkButtonAction retrune false if events should be routed through | 388 | return true; //checkButtonAction retrune false if events should be routed through |
389 | } | 389 | } |
390 | } | 390 | } |
391 | return QPEApplication::eventFilter ( o, e ); | 391 | return QPEApplication::eventFilter ( o, e ); |
392 | } | 392 | } |
393 | 393 | ||
394 | #ifdef Q_WS_QWS | 394 | #ifdef Q_WS_QWS |
395 | 395 | ||
396 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 396 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
397 | { | 397 | { |
398 | qpedesktop->checkMemory(); | 398 | qpedesktop->checkMemory(); |
399 | 399 | ||
400 | if ( e->type == QWSEvent::Key ) { | 400 | if ( e->type == QWSEvent::Key ) { |
401 | QWSKeyEvent * ke = (QWSKeyEvent *) e; | 401 | QWSKeyEvent * ke = (QWSKeyEvent *) e; |
402 | ushort keycode = ke-> simpleData. keycode; | 402 | ushort keycode = ke-> simpleData. keycode; |
403 | 403 | ||
404 | if ( !loggedin && keycode != Key_F34 ) | 404 | if ( !loggedin && keycode != Key_F34 ) |
405 | return true; | 405 | return true; |
406 | 406 | ||
407 | bool press = ke-> simpleData. is_press; | 407 | bool press = ke-> simpleData. is_press; |
408 | bool autoRepeat = ke-> simpleData. is_auto_repeat; | 408 | bool autoRepeat = ke-> simpleData. is_auto_repeat; |
409 | 409 | ||
410 | if ( !keyboardGrabbed ( )) { | 410 | if ( !keyboardGrabbed ( )) { |
411 | // app that registers key/message to be sent back to the app, when it doesn't have focus, | 411 | // app that registers key/message to be sent back to the app, when it doesn't have focus, |
412 | // when user presses key, unless keyboard has been requested from app. | 412 | // when user presses key, unless keyboard has been requested from app. |
413 | // will not send multiple repeats if user holds key | 413 | // will not send multiple repeats if user holds key |
414 | // i.e. one shot | 414 | // i.e. one shot |
415 | 415 | ||
416 | if ( keycode != 0 && press && !autoRepeat ) { | 416 | if ( keycode != 0 && press && !autoRepeat ) { |
417 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 417 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
418 | if (( *it ). getKeyCode ( ) == keycode ) { | 418 | if (( *it ). getKeyCode ( ) == keycode ) { |
419 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); | 419 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); |
420 | return true; | 420 | return true; |
421 | } | 421 | } |
422 | } | 422 | } |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | if ( keycode == HardKey_Suspend ) { | 426 | if ( keycode == HardKey_Suspend ) { |
427 | if ( press ) | 427 | if ( press ) |
428 | emit power ( ); | 428 | emit power ( ); |
429 | return true; | 429 | return true; |
430 | } | 430 | } |
431 | else if ( keycode == HardKey_Backlight ) { | 431 | else if ( keycode == HardKey_Backlight ) { |
432 | if ( press ) | 432 | if ( press ) |
433 | emit backlight ( ); | 433 | emit backlight ( ); |
434 | return true; | 434 | return true; |
435 | } | 435 | } |
436 | else if ( keycode == Key_F32 ) { | 436 | else if ( keycode == Key_F32 ) { |
437 | if ( press ) | 437 | if ( press ) |
438 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 438 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
439 | return true; | 439 | return true; |
440 | } | 440 | } |
441 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM | 441 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM |
442 | if ( press ) | 442 | if ( press ) |
443 | emit symbol ( ); | 443 | emit symbol ( ); |
444 | return true; | 444 | return true; |
445 | } | 445 | } |
446 | else if ( keycode == Key_NumLock ) { | 446 | else if ( keycode == Key_NumLock ) { |
447 | if ( press ) | 447 | if ( press ) |
448 | emit numLockStateToggle ( ); | 448 | emit numLockStateToggle ( ); |
449 | } | 449 | } |
450 | else if ( keycode == Key_CapsLock ) { | 450 | else if ( keycode == Key_CapsLock ) { |
451 | if ( press ) | 451 | if ( press ) |
452 | emit capsLockStateToggle(); | 452 | emit capsLockStateToggle(); |
453 | } | 453 | } |
454 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { | 454 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { |
455 | if ( m_keyclick_sound ) | 455 | if ( m_keyclick_sound ) |
456 | ODevice::inst ( )-> keySound ( ); | 456 | ODevice::inst ( )-> keySound ( ); |
457 | } | 457 | } |
458 | } | 458 | } |
459 | else if ( e-> type == QWSEvent::Mouse ) { | 459 | else if ( e-> type == QWSEvent::Mouse ) { |
460 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 460 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
461 | static bool up = true; | 461 | static bool up = true; |
462 | 462 | ||
463 | if ( me-> simpleData. state & LeftButton ) { | 463 | if ( me-> simpleData. state & LeftButton ) { |
464 | if ( up ) { | 464 | if ( up ) { |
465 | up = false; | 465 | up = false; |
466 | if ( m_screentap_sound ) | 466 | if ( m_screentap_sound ) |
467 | ODevice::inst ( ) -> touchSound ( ); | 467 | ODevice::inst ( ) -> touchSound ( ); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | else { | 470 | else { |
471 | up = true; | 471 | up = true; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | return QPEApplication::qwsEventFilter ( e ); | 475 | return QPEApplication::qwsEventFilter ( e ); |
476 | } | 476 | } |
477 | #endif | 477 | #endif |
478 | 478 | ||
479 | 479 | ||
480 | 480 | ||
481 | #if defined(QPE_HAVE_MEMALERTER) | 481 | #if defined(QPE_HAVE_MEMALERTER) |
482 | QPE_MEMALERTER_IMPL | 482 | QPE_MEMALERTER_IMPL |
483 | #endif | 483 | #endif |
484 | 484 | ||
485 | //=========================================================================== | 485 | //=========================================================================== |
486 | 486 | ||
487 | Desktop::Desktop() : | 487 | Desktop::Desktop() : |
488 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 488 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
489 | qcopBridge( 0 ), | 489 | qcopBridge( 0 ), |
490 | transferServer( 0 ), | 490 | transferServer( 0 ), |
491 | packageSlave( 0 ) | 491 | packageSlave( 0 ) |
492 | { | 492 | { |
493 | qpedesktop = this; | 493 | qpedesktop = this; |
494 | 494 | ||
495 | // bg = new Info( this ); | 495 | // bg = new Info( this ); |
496 | tb = new TaskBar; | 496 | tb = new TaskBar; |
497 | 497 | ||
498 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 498 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
499 | 499 | ||
500 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 500 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
501 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 501 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
502 | 502 | ||
503 | int displayw = qApp->desktop() ->width(); | 503 | int displayw = qApp->desktop() ->width(); |
504 | int displayh = qApp->desktop() ->height(); | 504 | int displayh = qApp->desktop() ->height(); |
505 | 505 | ||
506 | 506 | ||
507 | QSize sz = tb->sizeHint(); | 507 | QSize sz = tb->sizeHint(); |
508 | 508 | ||
509 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 509 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
510 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 510 | layout(); |
511 | 511 | ||
512 | tb->show(); | 512 | tb->show(); |
513 | launcher->showMaximized(); | 513 | launcher->showMaximized(); |
514 | launcher->show(); | 514 | launcher->show(); |
515 | launcher->raise(); | 515 | launcher->raise(); |
516 | #if defined(QPE_HAVE_MEMALERTER) | 516 | #if defined(QPE_HAVE_MEMALERTER) |
517 | 517 | ||
518 | initMemalerter(); | 518 | initMemalerter(); |
519 | #endif | 519 | #endif |
520 | // start services | 520 | // start services |
521 | startTransferServer(); | 521 | startTransferServer(); |
522 | ( void ) new IrServer( this ); | 522 | ( void ) new IrServer( this ); |
523 | 523 | ||
524 | packageSlave = new PackageSlave( this ); | 524 | packageSlave = new PackageSlave( this ); |
525 | 525 | ||
526 | qApp->installEventFilter( this ); | 526 | qApp->installEventFilter( this ); |
527 | qApp->desktop()->installEventFilter( this ); | ||
527 | 528 | ||
528 | qApp-> setMainWidget ( launcher ); | 529 | qApp-> setMainWidget ( launcher ); |
529 | } | 530 | } |
530 | 531 | ||
531 | void Desktop::show() | 532 | void Desktop::show() |
532 | { | 533 | { |
533 | login( TRUE ); | 534 | login( TRUE ); |
534 | QWidget::show(); | 535 | QWidget::show(); |
535 | } | 536 | } |
536 | 537 | ||
537 | Desktop::~Desktop() | 538 | Desktop::~Desktop() |
538 | { | 539 | { |
539 | delete launcher; | 540 | delete launcher; |
540 | delete tb; | 541 | delete tb; |
541 | delete qcopBridge; | 542 | delete qcopBridge; |
542 | delete transferServer; | 543 | delete transferServer; |
543 | } | 544 | } |
544 | 545 | ||
545 | bool Desktop::recoverMemory() | 546 | bool Desktop::recoverMemory() |
546 | { | 547 | { |
547 | return tb->recoverMemory(); | 548 | return tb->recoverMemory(); |
548 | } | 549 | } |
549 | 550 | ||
550 | void Desktop::checkMemory() | 551 | void Desktop::checkMemory() |
551 | { | 552 | { |
552 | #if defined(QPE_HAVE_MEMALERTER) | 553 | #if defined(QPE_HAVE_MEMALERTER) |
553 | static bool ignoreNormal = FALSE; | 554 | static bool ignoreNormal = FALSE; |
554 | static bool existingMessage = FALSE; | 555 | static bool existingMessage = FALSE; |
555 | 556 | ||
556 | if ( existingMessage ) | 557 | if ( existingMessage ) |
557 | return ; // don't show a second message while still on first | 558 | return ; // don't show a second message while still on first |
558 | 559 | ||
559 | existingMessage = TRUE; | 560 | existingMessage = TRUE; |
560 | switch ( memstate ) { | 561 | switch ( memstate ) { |
561 | case Unknown: | 562 | case Unknown: |
562 | break; | 563 | break; |
563 | case Low: | 564 | case Low: |
564 | memstate = Unknown; | 565 | memstate = Unknown; |
565 | if ( recoverMemory() ) | 566 | if ( recoverMemory() ) |
566 | ignoreNormal = TRUE; | 567 | ignoreNormal = TRUE; |
567 | else | 568 | else |
568 | QMessageBox::warning( 0 , "Memory Status", | 569 | QMessageBox::warning( 0 , "Memory Status", |
569 | "The memory smacks of shortage. \n" | 570 | "The memory smacks of shortage. \n" |
570 | "Please save data. " ); | 571 | "Please save data. " ); |
571 | break; | 572 | break; |
572 | case Normal: | 573 | case Normal: |
573 | memstate = Unknown; | 574 | memstate = Unknown; |
574 | if ( ignoreNormal ) | 575 | if ( ignoreNormal ) |
575 | ignoreNormal = FALSE; | 576 | ignoreNormal = FALSE; |
576 | // else | 577 | // else |
577 | // QMessageBox::information ( 0 , "Memory Status", | 578 | // QMessageBox::information ( 0 , "Memory Status", |
578 | // "There is enough memory again." ); | 579 | // "There is enough memory again." ); |
579 | break; | 580 | break; |
580 | case VeryLow: | 581 | case VeryLow: |
581 | memstate = Unknown; | 582 | memstate = Unknown; |
582 | QMessageBox::critical( 0 , "Memory Status", | 583 | QMessageBox::critical( 0 , "Memory Status", |
583 | "The memory is very low. \n" | 584 | "The memory is very low. \n" |
584 | "Please end this application \n" | 585 | "Please end this application \n" |
585 | "immediately." ); | 586 | "immediately." ); |
586 | recoverMemory(); | 587 | recoverMemory(); |
587 | } | 588 | } |
588 | existingMessage = FALSE; | 589 | existingMessage = FALSE; |
589 | #endif | 590 | #endif |
590 | } | 591 | } |
591 | 592 | ||
592 | static bool isVisibleWindow( int wid ) | 593 | static bool isVisibleWindow( int wid ) |
593 | { | 594 | { |
594 | #ifdef QWS | 595 | #ifdef QWS |
595 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 596 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
596 | QWSWindow* w; | 597 | QWSWindow* w; |
597 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 598 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
598 | if ( w->winId() == wid ) | 599 | if ( w->winId() == wid ) |
599 | return !w->isFullyObscured(); | 600 | return !w->isFullyObscured(); |
600 | } | 601 | } |
601 | #endif | 602 | #endif |
602 | return FALSE; | 603 | return FALSE; |
603 | } | 604 | } |
604 | 605 | ||
605 | static bool hasVisibleWindow( const QString& clientname ) | 606 | static bool hasVisibleWindow( const QString& clientname ) |
606 | { | 607 | { |
607 | #ifdef QWS | 608 | #ifdef QWS |
608 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 609 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
609 | QWSWindow* w; | 610 | QWSWindow* w; |
610 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 611 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
611 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 612 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
612 | return TRUE; | 613 | return TRUE; |
613 | } | 614 | } |
614 | #endif | 615 | #endif |
615 | return FALSE; | 616 | return FALSE; |
616 | } | 617 | } |
617 | 618 | ||
618 | 619 | ||
619 | void Desktop::executeOrModify( const QString& appLnkFile ) | 620 | void Desktop::executeOrModify( const QString& appLnkFile ) |
620 | { | 621 | { |
621 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 622 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
622 | if ( lnk.isValid() ) { | 623 | if ( lnk.isValid() ) { |
623 | QCString app = lnk.exec().utf8(); | 624 | QCString app = lnk.exec().utf8(); |
624 | Global::terminateBuiltin( "calibrate" ); | 625 | Global::terminateBuiltin( "calibrate" ); |
625 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 626 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
626 | // MRUList::addTask( &lnk ); | 627 | // MRUList::addTask( &lnk ); |
627 | if ( hasVisibleWindow( app ) ) | 628 | if ( hasVisibleWindow( app ) ) |
628 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 629 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
629 | else | 630 | else |
630 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 631 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
631 | } | 632 | } |
632 | else { | 633 | else { |
633 | lnk.execute(); | 634 | lnk.execute(); |
634 | } | 635 | } |
635 | } | 636 | } |
636 | } | 637 | } |
637 | 638 | ||
638 | // autoStarts apps on resume and start | 639 | // autoStarts apps on resume and start |
639 | void Desktop::execAutoStart() | 640 | void Desktop::execAutoStart() |
640 | { | 641 | { |
641 | QString appName; | 642 | QString appName; |
642 | int delay; | 643 | int delay; |
643 | QDateTime now = QDateTime::currentDateTime(); | 644 | QDateTime now = QDateTime::currentDateTime(); |
644 | Config cfg( "autostart" ); | 645 | Config cfg( "autostart" ); |
645 | cfg.setGroup( "AutoStart" ); | 646 | cfg.setGroup( "AutoStart" ); |
646 | appName = cfg.readEntry( "Apps", "" ); | 647 | appName = cfg.readEntry( "Apps", "" ); |
647 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 648 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
648 | // If the time between suspend and resume was longer then the | 649 | // If the time between suspend and resume was longer then the |
649 | // value saved as delay, start the app | 650 | // value saved as delay, start the app |
650 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 651 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
651 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 652 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
652 | e << QString( appName ); | 653 | e << QString( appName ); |
653 | } | 654 | } |
654 | } | 655 | } |
655 | 656 | ||
656 | #if defined(QPE_HAVE_TOGGLELIGHT) | 657 | #if defined(QPE_HAVE_TOGGLELIGHT) |
657 | #include <qpe/config.h> | 658 | #include <qpe/config.h> |
658 | 659 | ||
659 | #include <sys/ioctl.h> | 660 | #include <sys/ioctl.h> |
660 | #include <sys/types.h> | 661 | #include <sys/types.h> |
661 | #include <fcntl.h> | 662 | #include <fcntl.h> |
662 | #include <unistd.h> | 663 | #include <unistd.h> |
663 | #include <errno.h> | 664 | #include <errno.h> |
664 | #include <linux/ioctl.h> | 665 | #include <linux/ioctl.h> |
665 | #include <time.h> | 666 | #include <time.h> |
666 | #endif | 667 | #endif |
667 | 668 | ||
668 | 669 | ||
669 | void Desktop::togglePower() | 670 | void Desktop::togglePower() |
670 | { | 671 | { |
671 | static bool excllock = false; | 672 | static bool excllock = false; |
672 | 673 | ||
673 | if ( excllock ) | 674 | if ( excllock ) |
674 | return ; | 675 | return ; |
675 | 676 | ||
676 | excllock = true; | 677 | excllock = true; |
677 | 678 | ||
678 | bool wasloggedin = loggedin; | 679 | bool wasloggedin = loggedin; |
679 | loggedin = 0; | 680 | loggedin = 0; |
680 | suspendTime = QDateTime::currentDateTime(); | 681 | suspendTime = QDateTime::currentDateTime(); |
681 | 682 | ||
682 | #ifdef QWS | 683 | #ifdef QWS |
683 | 684 | ||
684 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 685 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
685 | // Should use a big black window instead. | 686 | // Should use a big black window instead. |
686 | // But this would not show up fast enough | 687 | // But this would not show up fast enough |
687 | QGfx *g = qt_screen-> screenGfx ( ); | 688 | QGfx *g = qt_screen-> screenGfx ( ); |
688 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 689 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
689 | delete g; | 690 | delete g; |
690 | } | 691 | } |
691 | #endif | 692 | #endif |
692 | 693 | ||
693 | ODevice::inst ( )-> suspend ( ); | 694 | ODevice::inst ( )-> suspend ( ); |
694 | 695 | ||
695 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 696 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
696 | QWSServer::screenSaverActivate ( false ); | 697 | QWSServer::screenSaverActivate ( false ); |
697 | 698 | ||
698 | { | 699 | { |
699 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 700 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
700 | } | 701 | } |
701 | 702 | ||
702 | if ( wasloggedin ) | 703 | if ( wasloggedin ) |
703 | login ( true ); | 704 | login ( true ); |
704 | 705 | ||
705 | execAutoStart(); | 706 | execAutoStart(); |
706 | //qcopBridge->closeOpenConnections(); | 707 | //qcopBridge->closeOpenConnections(); |
707 | 708 | ||
708 | excllock = false; | 709 | excllock = false; |
709 | } | 710 | } |
710 | 711 | ||
711 | void Desktop::toggleLight() | 712 | void Desktop::toggleLight() |
712 | { | 713 | { |
713 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 714 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
714 | e << -2; // toggle | 715 | e << -2; // toggle |
715 | } | 716 | } |
716 | 717 | ||
717 | void Desktop::toggleSymbolInput() | 718 | void Desktop::toggleSymbolInput() |
718 | { | 719 | { |
719 | tb->toggleSymbolInput(); | 720 | tb->toggleSymbolInput(); |
720 | } | 721 | } |
721 | 722 | ||
722 | void Desktop::toggleNumLockState() | 723 | void Desktop::toggleNumLockState() |
723 | { | 724 | { |
724 | tb->toggleNumLockState(); | 725 | tb->toggleNumLockState(); |
725 | } | 726 | } |
726 | 727 | ||
727 | void Desktop::toggleCapsLockState() | 728 | void Desktop::toggleCapsLockState() |
728 | { | 729 | { |
729 | tb->toggleCapsLockState(); | 730 | tb->toggleCapsLockState(); |
730 | } | 731 | } |
731 | 732 | ||
732 | void Desktop::styleChange( QStyle &s ) | 733 | void Desktop::styleChange( QStyle &s ) |
733 | { | 734 | { |
734 | QWidget::styleChange( s ); | 735 | QWidget::styleChange( s ); |
735 | int displayw = qApp->desktop() ->width(); | 736 | layout(); |
736 | int displayh = qApp->desktop() ->height(); | ||
737 | |||
738 | QSize sz = tb->sizeHint(); | ||
739 | |||
740 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | ||
741 | } | 737 | } |
742 | 738 | ||
743 | void DesktopApplication::shutdown() | 739 | void DesktopApplication::shutdown() |
744 | { | 740 | { |
745 | if ( type() != GuiServer ) | 741 | if ( type() != GuiServer ) |
746 | return ; | 742 | return ; |
747 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 743 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
748 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 744 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
749 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 745 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
750 | sd->showMaximized(); | 746 | sd->showMaximized(); |
751 | } | 747 | } |
752 | 748 | ||
753 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 749 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
754 | { | 750 | { |
755 | char *opt = 0; | 751 | char *opt = 0; |
756 | 752 | ||
757 | switch ( t ) { | 753 | switch ( t ) { |
758 | case ShutdownImpl::ShutdownSystem: | 754 | case ShutdownImpl::ShutdownSystem: |
759 | opt = "-h"; | 755 | opt = "-h"; |
760 | // fall through | 756 | // fall through |
761 | case ShutdownImpl::RebootSystem: | 757 | case ShutdownImpl::RebootSystem: |
762 | if ( opt == 0 ) | 758 | if ( opt == 0 ) |
763 | opt = "-r"; | 759 | opt = "-r"; |
764 | 760 | ||
765 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) | 761 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) |
766 | perror("shutdown"); | 762 | perror("shutdown"); |
767 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 763 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
768 | 764 | ||
769 | break; | 765 | break; |
770 | case ShutdownImpl::RestartDesktop: | 766 | case ShutdownImpl::RestartDesktop: |
771 | restart(); | 767 | restart(); |
772 | break; | 768 | break; |
773 | case ShutdownImpl::TerminateDesktop: | 769 | case ShutdownImpl::TerminateDesktop: |
774 | prepareForTermination( FALSE ); | 770 | prepareForTermination( FALSE ); |
775 | 771 | ||
776 | // This is a workaround for a Qt bug | 772 | // This is a workaround for a Qt bug |
777 | // clipboard applet has to stop its poll timer, or Qt/E | 773 | // clipboard applet has to stop its poll timer, or Qt/E |
778 | // will hang on quit() right before it emits aboutToQuit() | 774 | // will hang on quit() right before it emits aboutToQuit() |
779 | emit aboutToQuit ( ); | 775 | emit aboutToQuit ( ); |
780 | 776 | ||
781 | quit(); | 777 | quit(); |
782 | break; | 778 | break; |
783 | } | 779 | } |
784 | } | 780 | } |
785 | 781 | ||
786 | void DesktopApplication::restart() | 782 | void DesktopApplication::restart() |
787 | { | 783 | { |
788 | prepareForTermination( TRUE ); | 784 | prepareForTermination( TRUE ); |
789 | 785 | ||
790 | #ifdef Q_WS_QWS | 786 | #ifdef Q_WS_QWS |
791 | 787 | ||
792 | for ( int fd = 3; fd < 100; fd++ ) | 788 | for ( int fd = 3; fd < 100; fd++ ) |
793 | close( fd ); | 789 | close( fd ); |
794 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 790 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
795 | 791 | ||
796 | execl( "/sbin/init", "qpe", 0 ); | 792 | execl( "/sbin/init", "qpe", 0 ); |
797 | #elif defined(QT_QWS_CASSIOPEIA) | 793 | #elif defined(QT_QWS_CASSIOPEIA) |
798 | 794 | ||
799 | execl( "/bin/sh", "sh", 0 ); | 795 | execl( "/bin/sh", "sh", 0 ); |
800 | #else | 796 | #else |
801 | 797 | ||
802 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 798 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
803 | #endif | 799 | #endif |
804 | 800 | ||
805 | exit( 1 ); | 801 | exit( 1 ); |
806 | #endif | 802 | #endif |
807 | } | 803 | } |
808 | 804 | ||
805 | void Desktop::layout() | ||
806 | { | ||
807 | int displayw = qApp->desktop() ->width(); | ||
808 | int displayh = qApp->desktop() ->height(); | ||
809 | |||
810 | QSize sz = tb->sizeHint(); | ||
811 | |||
812 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | ||
813 | tb->calcMaxWindowRect(); | ||
814 | } | ||
815 | |||
809 | void Desktop::startTransferServer() | 816 | void Desktop::startTransferServer() |
810 | { | 817 | { |
811 | // start qcop bridge server | 818 | // start qcop bridge server |
812 | qcopBridge = new QCopBridge( 4243 ); | 819 | qcopBridge = new QCopBridge( 4243 ); |
813 | if ( !qcopBridge->ok() ) { | 820 | if ( !qcopBridge->ok() ) { |
814 | delete qcopBridge; | 821 | delete qcopBridge; |
815 | qcopBridge = 0; | 822 | qcopBridge = 0; |
816 | } | 823 | } |
817 | // start transfer server | 824 | // start transfer server |
818 | transferServer = new TransferServer( 4242 ); | 825 | transferServer = new TransferServer( 4242 ); |
819 | if ( !transferServer->ok() ) { | 826 | if ( !transferServer->ok() ) { |
820 | delete transferServer; | 827 | delete transferServer; |
821 | transferServer = 0; | 828 | transferServer = 0; |
822 | } | 829 | } |
823 | if ( !transferServer || !qcopBridge ) | 830 | if ( !transferServer || !qcopBridge ) |
824 | startTimer( 2000 ); | 831 | startTimer( 2000 ); |
825 | } | 832 | } |
826 | 833 | ||
827 | void Desktop::timerEvent( QTimerEvent *e ) | 834 | void Desktop::timerEvent( QTimerEvent *e ) |
828 | { | 835 | { |
829 | killTimer( e->timerId() ); | 836 | killTimer( e->timerId() ); |
830 | startTransferServer(); | 837 | startTransferServer(); |
831 | } | 838 | } |
832 | 839 | ||
840 | bool Desktop::eventFilter( QObject *o, QEvent *ev ) | ||
841 | { | ||
842 | if ( o != qApp->desktop() || ev->type() != QEvent::Resize ) | ||
843 | return QWidget::eventFilter( o, ev ); | ||
844 | |||
845 | layout(); | ||
846 | |||
847 | return QWidget::eventFilter( o, ev ); | ||
848 | } | ||
849 | |||
833 | void Desktop::terminateServers() | 850 | void Desktop::terminateServers() |
834 | { | 851 | { |
835 | delete transferServer; | 852 | delete transferServer; |
836 | delete qcopBridge; | 853 | delete qcopBridge; |
837 | transferServer = 0; | 854 | transferServer = 0; |
838 | qcopBridge = 0; | 855 | qcopBridge = 0; |
839 | } | 856 | } |
840 | 857 | ||
841 | void DesktopApplication::rereadVolumes() | 858 | void DesktopApplication::rereadVolumes() |
842 | { | 859 | { |
843 | Config cfg( "qpe" ); | 860 | Config cfg( "qpe" ); |
844 | cfg. setGroup ( "Volume" ); | 861 | cfg. setGroup ( "Volume" ); |
845 | 862 | ||
846 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); | 863 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
847 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); | 864 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); |
848 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); | 865 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); |
849 | } | 866 | } |
850 | 867 | ||
851 | void DesktopApplication::soundAlarm() | 868 | void DesktopApplication::soundAlarm() |
852 | { | 869 | { |
853 | if ( me ( )-> m_alarm_sound ) | 870 | if ( me ( )-> m_alarm_sound ) |
854 | ODevice::inst ( )-> alarmSound ( ); | 871 | ODevice::inst ( )-> alarmSound ( ); |
855 | } | 872 | } |
856 | 873 | ||
857 | DesktopApplication *DesktopApplication::me ( ) | 874 | DesktopApplication *DesktopApplication::me ( ) |
858 | { | 875 | { |
859 | return (DesktopApplication *) qApp; | 876 | return (DesktopApplication *) qApp; |
860 | } | 877 | } |
861 | 878 | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index 4024c38..86d8aa8 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -1,155 +1,157 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __DESKTOP_H__ | 21 | #ifndef __DESKTOP_H__ |
22 | #define __DESKTOP_H__ | 22 | #define __DESKTOP_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <opie/odevicebutton.h> | 28 | #include <opie/odevicebutton.h> |
29 | 29 | ||
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | 32 | ||
33 | class Background; | 33 | class Background; |
34 | class Launcher; | 34 | class Launcher; |
35 | class TaskBar; | 35 | class TaskBar; |
36 | class PowerStatus; | 36 | class PowerStatus; |
37 | class QCopBridge; | 37 | class QCopBridge; |
38 | class TransferServer; | 38 | class TransferServer; |
39 | class DesktopPowerAlerter; | 39 | class DesktopPowerAlerter; |
40 | class PackageSlave; | 40 | class PackageSlave; |
41 | class OpieScreenSaver; | 41 | class OpieScreenSaver; |
42 | 42 | ||
43 | class DesktopApplication : public QPEApplication | 43 | class DesktopApplication : public QPEApplication |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | DesktopApplication( int& argc, char **argv, Type t ); | 47 | DesktopApplication( int& argc, char **argv, Type t ); |
48 | ~DesktopApplication(); | 48 | ~DesktopApplication(); |
49 | 49 | ||
50 | static void switchLCD ( bool on ); // only for togglePower in Desktop | 50 | static void switchLCD ( bool on ); // only for togglePower in Desktop |
51 | 51 | ||
52 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar | 52 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar |
53 | 53 | ||
54 | signals: | 54 | signals: |
55 | void menu(); | 55 | void menu(); |
56 | void home(); | 56 | void home(); |
57 | void launch(); | 57 | void launch(); |
58 | void backlight(); | 58 | void backlight(); |
59 | void power(); | 59 | void power(); |
60 | void symbol(); | 60 | void symbol(); |
61 | void numLockStateToggle(); | 61 | void numLockStateToggle(); |
62 | void capsLockStateToggle(); | 62 | void capsLockStateToggle(); |
63 | void prepareForRestart(); | 63 | void prepareForRestart(); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | #ifdef Q_WS_QWS | 66 | #ifdef Q_WS_QWS |
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 | ||
74 | public slots: | 74 | public slots: |
75 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); | 75 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); |
76 | virtual void launcherMessage ( const QCString &msg, const QByteArray &data ); | 76 | virtual void launcherMessage ( const QCString &msg, const QByteArray &data ); |
77 | void rereadVolumes(); | 77 | void rereadVolumes(); |
78 | 78 | ||
79 | protected slots: | 79 | protected slots: |
80 | void shutdown ( ShutdownImpl::Type ); | 80 | void shutdown ( ShutdownImpl::Type ); |
81 | void apmTimeout ( ); | 81 | void apmTimeout ( ); |
82 | void sendHeldAction ( ); | 82 | void sendHeldAction ( ); |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | virtual bool eventFilter ( QObject *o, QEvent *e ); | 85 | virtual bool eventFilter ( QObject *o, QEvent *e ); |
86 | bool checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); | 86 | bool checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); |
87 | 87 | ||
88 | private: | 88 | private: |
89 | static DesktopApplication *me ( ); | 89 | static DesktopApplication *me ( ); |
90 | 90 | ||
91 | private: | 91 | private: |
92 | void reloadPowerWarnSettings(); | 92 | void reloadPowerWarnSettings(); |
93 | DesktopPowerAlerter *pa; | 93 | DesktopPowerAlerter *pa; |
94 | PowerStatus *m_ps, *m_ps_last; | 94 | PowerStatus *m_ps, *m_ps_last; |
95 | QTimer *cardSendTimer; | 95 | QTimer *cardSendTimer; |
96 | QCopChannel *channel; | 96 | QCopChannel *channel; |
97 | OpieScreenSaver *m_screensaver; | 97 | OpieScreenSaver *m_screensaver; |
98 | QTimer * m_apm_timer; | 98 | QTimer * m_apm_timer; |
99 | int m_powerVeryLow; | 99 | int m_powerVeryLow; |
100 | int m_powerCritical; | 100 | int m_powerCritical; |
101 | int m_currentPowerLevel; | 101 | int m_currentPowerLevel; |
102 | 102 | ||
103 | const Opie::ODeviceButton *m_last_button; | 103 | const Opie::ODeviceButton *m_last_button; |
104 | QTimer *m_button_timer; | 104 | QTimer *m_button_timer; |
105 | 105 | ||
106 | bool m_keyclick_sound : 1; | 106 | bool m_keyclick_sound : 1; |
107 | bool m_screentap_sound : 1; | 107 | bool m_screentap_sound : 1; |
108 | bool m_alarm_sound : 1; | 108 | bool m_alarm_sound : 1; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | 111 | ||
112 | class Desktop : public QWidget | 112 | class Desktop : public QWidget |
113 | { | 113 | { |
114 | Q_OBJECT | 114 | Q_OBJECT |
115 | public: | 115 | public: |
116 | Desktop(); | 116 | Desktop(); |
117 | ~Desktop(); | 117 | ~Desktop(); |
118 | 118 | ||
119 | static bool screenLocked(); | 119 | static bool screenLocked(); |
120 | 120 | ||
121 | void show(); | 121 | void show(); |
122 | void checkMemory(); | 122 | void checkMemory(); |
123 | 123 | ||
124 | public slots: | 124 | public slots: |
125 | void execAutoStart(); | 125 | void execAutoStart(); |
126 | void togglePower(); | 126 | void togglePower(); |
127 | void toggleLight(); | 127 | void toggleLight(); |
128 | void toggleNumLockState(); | 128 | void toggleNumLockState(); |
129 | void toggleCapsLockState(); | 129 | void toggleCapsLockState(); |
130 | void toggleSymbolInput(); | 130 | void toggleSymbolInput(); |
131 | void terminateServers(); | 131 | void terminateServers(); |
132 | 132 | ||
133 | protected: | 133 | protected: |
134 | void executeOrModify( const QString& appLnkFile ); | 134 | void executeOrModify( const QString& appLnkFile ); |
135 | void styleChange( QStyle & ); | 135 | void styleChange( QStyle & ); |
136 | void timerEvent( QTimerEvent *e ); | 136 | void timerEvent( QTimerEvent *e ); |
137 | virtual bool eventFilter( QObject *o, QEvent *ev ); | ||
137 | 138 | ||
138 | QWidget *bg; | 139 | QWidget *bg; |
139 | Launcher *launcher; | 140 | Launcher *launcher; |
140 | TaskBar *tb; | 141 | TaskBar *tb; |
141 | 142 | ||
142 | private: | 143 | private: |
144 | void layout(); | ||
143 | void startTransferServer(); | 145 | void startTransferServer(); |
144 | bool recoverMemory(); | 146 | bool recoverMemory(); |
145 | 147 | ||
146 | QCopBridge *qcopBridge; | 148 | QCopBridge *qcopBridge; |
147 | TransferServer *transferServer; | 149 | TransferServer *transferServer; |
148 | PackageSlave *packageSlave; | 150 | PackageSlave *packageSlave; |
149 | 151 | ||
150 | QDateTime suspendTime; | 152 | QDateTime suspendTime; |
151 | }; | 153 | }; |
152 | 154 | ||
153 | 155 | ||
154 | #endif // __DESKTOP_H__ | 156 | #endif // __DESKTOP_H__ |
155 | 157 | ||
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h index cd631ef..a0bf395 100644 --- a/core/launcher/taskbar.h +++ b/core/launcher/taskbar.h | |||
@@ -1,84 +1,85 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __TASKBAR_H__ | 21 | #ifndef __TASKBAR_H__ |
22 | #define __TASKBAR_H__ | 22 | #define __TASKBAR_H__ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | 25 | ||
26 | class QLabel; | 26 | class QLabel; |
27 | class QTimer; | 27 | class QTimer; |
28 | class InputMethods; | 28 | class InputMethods; |
29 | class Wait; | 29 | class Wait; |
30 | class SysTray; | 30 | class SysTray; |
31 | //class MRUList; | 31 | //class MRUList; |
32 | class RunningAppBar; | 32 | class RunningAppBar; |
33 | class QWidgetStack; | 33 | class QWidgetStack; |
34 | class QTimer; | 34 | class QTimer; |
35 | class QLabel; | 35 | class QLabel; |
36 | class StartMenu; | 36 | class StartMenu; |
37 | class LockKeyState; | 37 | class LockKeyState; |
38 | 38 | ||
39 | class TaskBar : public QHBox { | 39 | class TaskBar : public QHBox { |
40 | Q_OBJECT | 40 | Q_OBJECT |
41 | public: | 41 | public: |
42 | TaskBar(); | 42 | TaskBar(); |
43 | ~TaskBar(); | 43 | ~TaskBar(); |
44 | 44 | ||
45 | static QWidget *calibrate( bool ); | 45 | static QWidget *calibrate( bool ); |
46 | 46 | ||
47 | bool recoverMemory(); | 47 | bool recoverMemory(); |
48 | 48 | ||
49 | StartMenu *startMenu() const { return sm; } | 49 | StartMenu *startMenu() const { return sm; } |
50 | public slots: | 50 | public slots: |
51 | void startWait(); | 51 | void startWait(); |
52 | void stopWait(const QString&); | 52 | void stopWait(const QString&); |
53 | void stopWait(); | 53 | void stopWait(); |
54 | void clearStatusBar(); | 54 | void clearStatusBar(); |
55 | void toggleNumLockState(); | 55 | void toggleNumLockState(); |
56 | void toggleCapsLockState(); | 56 | void toggleCapsLockState(); |
57 | void toggleSymbolInput(); | 57 | void toggleSymbolInput(); |
58 | 58 | ||
59 | protected: | 59 | protected: |
60 | void resizeEvent( QResizeEvent * ); | 60 | void resizeEvent( QResizeEvent * ); |
61 | void styleChange( QStyle & ); | 61 | void styleChange( QStyle & ); |
62 | void setStatusMessage( const QString &text ); | 62 | void setStatusMessage( const QString &text ); |
63 | 63 | ||
64 | private slots: | 64 | public slots: |
65 | void calcMaxWindowRect(); | 65 | void calcMaxWindowRect(); |
66 | private slots: | ||
66 | void receive( const QCString &msg, const QByteArray &data ); | 67 | void receive( const QCString &msg, const QByteArray &data ); |
67 | 68 | ||
68 | private: | 69 | private: |
69 | 70 | ||
70 | QTimer *waitTimer; | 71 | QTimer *waitTimer; |
71 | Wait *waitIcon; | 72 | Wait *waitIcon; |
72 | InputMethods *inputMethods; | 73 | InputMethods *inputMethods; |
73 | SysTray *sysTray; | 74 | SysTray *sysTray; |
74 | // MRUList *mru; | 75 | // MRUList *mru; |
75 | RunningAppBar* runningAppBar; | 76 | RunningAppBar* runningAppBar; |
76 | QWidgetStack *stack; | 77 | QWidgetStack *stack; |
77 | QTimer *clearer; | 78 | QTimer *clearer; |
78 | QLabel *label; | 79 | QLabel *label; |
79 | LockKeyState* lockState; | 80 | LockKeyState* lockState; |
80 | StartMenu *sm; | 81 | StartMenu *sm; |
81 | }; | 82 | }; |
82 | 83 | ||
83 | 84 | ||
84 | #endif // __TASKBAR_H__ | 85 | #endif // __TASKBAR_H__ |