summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
authorzecke <zecke>2002-09-25 18:15:58 (UTC)
committer zecke <zecke>2002-09-25 18:15:58 (UTC)
commitc96507591791d48a6d6dad3de6c15739c84e1c93 (patch) (unidiff)
treef5476860497023dd6d9e1c82c61cc6bb3f61a6da /library/qpeapplication.cpp
parentd44c455b86d6cccbc497e3e8d8aa399096eff7db (diff)
downloadopie-c96507591791d48a6d6dad3de6c15739c84e1c93.zip
opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.gz
opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.bz2
ljps patch was/is correct
but for some reason TT is not using QFile so I made it use getenv(HOME) instead
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index bdf67b9..533d7bd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -427,769 +427,773 @@ static void setMic( int t = 0, int percent = -1 )
427 \sa qcop.html 427 \sa qcop.html
428 Note that messages received here may be processed by qpe application 428 Note that messages received here may be processed by qpe application
429 and emitted as signals, such as flush() and reload(). 429 and emitted as signals, such as flush() and reload().
430*/ 430*/
431 431
432/*! 432/*!
433 Constructs a QPEApplication just as you would construct 433 Constructs a QPEApplication just as you would construct
434 a QApplication, passing \a argc, \a argv, and \a t. 434 a QApplication, passing \a argc, \a argv, and \a t.
435 435
436 For applications, \a t should be the default, GuiClient. Only 436 For applications, \a t should be the default, GuiClient. Only
437 the Qtopia server passes GuiServer. 437 the Qtopia server passes GuiServer.
438*/ 438*/
439QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 439QPEApplication::QPEApplication( int & argc, char **argv, Type t )
440 : QApplication( argc, argv, t ) 440 : QApplication( argc, argv, t )
441{ 441{
442 d = new QPEApplicationData; 442 d = new QPEApplicationData;
443 d->loadTextCodecs(); 443 d->loadTextCodecs();
444 d->loadImageCodecs(); 444 d->loadImageCodecs();
445 int dw = desktop() ->width(); 445 int dw = desktop() ->width();
446 qWarning( "Width %d", dw ); 446 qWarning( "Width %d", dw );
447 if ( dw < 200 ) { 447 if ( dw < 200 ) {
448 setFont( QFont( "helvetica", 8 ) ); 448 setFont( QFont( "helvetica", 8 ) );
449 AppLnk::setSmallIconSize( 10 ); 449 AppLnk::setSmallIconSize( 10 );
450 AppLnk::setBigIconSize( 28 ); 450 AppLnk::setBigIconSize( 28 );
451 }else if ( dw > 600 ) { 451 }else if ( dw > 600 ) {
452 setFont( QFont( "helvetica", 12 ) ); 452 setFont( QFont( "helvetica", 12 ) );
453 AppLnk::setSmallIconSize( 24 ); 453 AppLnk::setSmallIconSize( 24 );
454 AppLnk::setBigIconSize( 48 ); 454 AppLnk::setBigIconSize( 48 );
455 }else if ( dw > 200 ) { 455 }else if ( dw > 200 ) {
456 setFont( QFont( "helvetica", 12 ) ); 456 setFont( QFont( "helvetica", 12 ) );
457 AppLnk::setSmallIconSize( 16 ); 457 AppLnk::setSmallIconSize( 16 );
458 AppLnk::setBigIconSize( 32 ); 458 AppLnk::setBigIconSize( 32 );
459 } 459 }
460 460
461 461
462 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 462 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
463 463
464 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 464 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
465#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 465#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
466 466
467 QString qcopfn( "/tmp/qcop-msg-" ); 467 QString qcopfn( "/tmp/qcop-msg-" );
468 qcopfn += QString( argv[ 0 ] ); // append command name 468 qcopfn += QString( argv[ 0 ] ); // append command name
469 469
470 QFile f( qcopfn ); 470 QFile f( qcopfn );
471 if ( f.open( IO_ReadOnly ) ) { 471 if ( f.open( IO_ReadOnly ) ) {
472 flock( f.handle(), LOCK_EX ); 472 flock( f.handle(), LOCK_EX );
473 } 473 }
474 474
475 sysChannel = new QCopChannel( "QPE/System", this ); 475 sysChannel = new QCopChannel( "QPE/System", this );
476 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 476 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
477 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 477 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
478 478
479 QCString channel = QCString( argv[ 0 ] ); 479 QCString channel = QCString( argv[ 0 ] );
480 channel.replace( QRegExp( ".*/" ), "" ); 480 channel.replace( QRegExp( ".*/" ), "" );
481 d->appName = channel; 481 d->appName = channel;
482 channel = "QPE/Application/" + channel; 482 channel = "QPE/Application/" + channel;
483 pidChannel = new QCopChannel( channel, this ); 483 pidChannel = new QCopChannel( channel, this );
484 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 484 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
485 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 485 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
486 486
487 if ( f.isOpen() ) { 487 if ( f.isOpen() ) {
488 d->keep_running = FALSE; 488 d->keep_running = FALSE;
489 QDataStream ds( &f ); 489 QDataStream ds( &f );
490 QCString channel, message; 490 QCString channel, message;
491 QByteArray data; 491 QByteArray data;
492 while ( !ds.atEnd() ) { 492 while ( !ds.atEnd() ) {
493 ds >> channel >> message >> data; 493 ds >> channel >> message >> data;
494 d->enqueueQCop( channel, message, data ); 494 d->enqueueQCop( channel, message, data );
495 } 495 }
496 496
497 flock( f.handle(), LOCK_UN ); 497 flock( f.handle(), LOCK_UN );
498 f.close(); 498 f.close();
499 f.remove(); 499 f.remove();
500 } 500 }
501 501
502 for ( int a = 0; a < argc; a++ ) { 502 for ( int a = 0; a < argc; a++ ) {
503 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 503 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
504 argv[ a ] = argv[ a + 1 ]; 504 argv[ a ] = argv[ a + 1 ];
505 a++; 505 a++;
506 d->preloaded = TRUE; 506 d->preloaded = TRUE;
507 argc -= 1; 507 argc -= 1;
508 } 508 }
509 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 509 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
510 argv[ a ] = argv[ a + 1 ]; 510 argv[ a ] = argv[ a + 1 ];
511 a++; 511 a++;
512 d->preloaded = TRUE; 512 d->preloaded = TRUE;
513 d->forceshow = TRUE; 513 d->forceshow = TRUE;
514 argc -= 1; 514 argc -= 1;
515 } 515 }
516 } 516 }
517 517
518 /* overide stored arguments */ 518 /* overide stored arguments */
519 setArgs( argc, argv ); 519 setArgs( argc, argv );
520 520
521#endif 521#endif
522 522
523// qwsSetDecoration( new QPEDecoration() ); 523// qwsSetDecoration( new QPEDecoration() );
524 524
525#ifndef QT_NO_TRANSLATION 525#ifndef QT_NO_TRANSLATION
526 526
527 QStringList langs = Global::languageList(); 527 QStringList langs = Global::languageList();
528 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 528 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
529 QString lang = *it; 529 QString lang = *it;
530 530
531 QTranslator * trans; 531 QTranslator * trans;
532 QString tfn; 532 QString tfn;
533 533
534 trans = new QTranslator( this ); 534 trans = new QTranslator( this );
535 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; 535 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
536 if ( trans->load( tfn ) ) 536 if ( trans->load( tfn ) )
537 installTranslator( trans ); 537 installTranslator( trans );
538 else 538 else
539 delete trans; 539 delete trans;
540 540
541 trans = new QTranslator( this ); 541 trans = new QTranslator( this );
542 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; 542 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
543 if ( trans->load( tfn ) ) 543 if ( trans->load( tfn ) )
544 installTranslator( trans ); 544 installTranslator( trans );
545 else 545 else
546 delete trans; 546 delete trans;
547 547
548 //###language/font hack; should look it up somewhere 548 //###language/font hack; should look it up somewhere
549#ifdef QWS 549#ifdef QWS
550 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 550 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
551 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 551 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
552 setFont( fn ); 552 setFont( fn );
553 } 553 }
554#endif 554#endif
555 } 555 }
556#endif 556#endif
557 557
558 applyStyle(); 558 applyStyle();
559 559
560 if ( type() == GuiServer ) { 560 if ( type() == GuiServer ) {
561 setVolume(); 561 setVolume();
562 } 562 }
563 563
564 installEventFilter( this ); 564 installEventFilter( this );
565 565
566 QPEMenuToolFocusManager::initialize(); 566 QPEMenuToolFocusManager::initialize();
567 567
568#ifdef QT_NO_QWS_CURSOR 568#ifdef QT_NO_QWS_CURSOR
569 // if we have no cursor, probably don't want tooltips 569 // if we have no cursor, probably don't want tooltips
570 QToolTip::setEnabled( FALSE ); 570 QToolTip::setEnabled( FALSE );
571#endif 571#endif
572} 572}
573 573
574static QPtrDict<void>* inputMethodDict = 0; 574static QPtrDict<void>* inputMethodDict = 0;
575static void createInputMethodDict() 575static void createInputMethodDict()
576{ 576{
577 if ( !inputMethodDict ) 577 if ( !inputMethodDict )
578 inputMethodDict = new QPtrDict<void>; 578 inputMethodDict = new QPtrDict<void>;
579} 579}
580 580
581/*! 581/*!
582 Returns the currently set hint to the system as to whether 582 Returns the currently set hint to the system as to whether
583 widget \a w has any use for text input methods. 583 widget \a w has any use for text input methods.
584 584
585 585
586 \sa setInputMethodHint() InputMethodHint 586 \sa setInputMethodHint() InputMethodHint
587*/ 587*/
588QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 588QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
589{ 589{
590 if ( inputMethodDict && w ) 590 if ( inputMethodDict && w )
591 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 591 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
592 return Normal; 592 return Normal;
593} 593}
594 594
595/*! 595/*!
596 \enum QPEApplication::InputMethodHint 596 \enum QPEApplication::InputMethodHint
597 597
598 \value Normal the application sometimes needs text input (the default). 598 \value Normal the application sometimes needs text input (the default).
599 \value AlwaysOff the application never needs text input. 599 \value AlwaysOff the application never needs text input.
600 \value AlwaysOn the application always needs text input. 600 \value AlwaysOn the application always needs text input.
601*/ 601*/
602 602
603/*! 603/*!
604 Hints to the system that widget \a w has use for text input methods 604 Hints to the system that widget \a w has use for text input methods
605 as specified by \a mode. 605 as specified by \a mode.
606 606
607 \sa inputMethodHint() InputMethodHint 607 \sa inputMethodHint() InputMethodHint
608*/ 608*/
609void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 609void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
610{ 610{
611 createInputMethodDict(); 611 createInputMethodDict();
612 if ( mode == Normal ) { 612 if ( mode == Normal ) {
613 inputMethodDict->remove 613 inputMethodDict->remove
614 ( w ); 614 ( w );
615 } 615 }
616 else { 616 else {
617 inputMethodDict->insert( w, ( void* ) mode ); 617 inputMethodDict->insert( w, ( void* ) mode );
618 } 618 }
619} 619}
620 620
621class HackDialog : public QDialog 621class HackDialog : public QDialog
622{ 622{
623public: 623public:
624 void acceptIt() { accept(); } 624 void acceptIt() { accept(); }
625 void rejectIt() { reject(); } 625 void rejectIt() { reject(); }
626}; 626};
627 627
628 628
629void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 629void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
630{ 630{
631 // specialised actions for certain widgets. May want to 631 // specialised actions for certain widgets. May want to
632 // add more stuff here. 632 // add more stuff here.
633 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 633 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
634 && activePopupWidget() ->parentWidget() 634 && activePopupWidget() ->parentWidget()
635 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 635 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
636 key = Qt::Key_Return; 636 key = Qt::Key_Return;
637 637
638 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 638 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
639 key = Qt::Key_Return; 639 key = Qt::Key_Return;
640 640
641#ifdef QWS 641#ifdef QWS
642 ke->simpleData.keycode = key; 642 ke->simpleData.keycode = key;
643#endif 643#endif
644} 644}
645 645
646class HackWidget : public QWidget 646class HackWidget : public QWidget
647{ 647{
648public: 648public:
649 bool needsOk() 649 bool needsOk()
650 { return ( getWState() & WState_Reserved1 ); } 650 { return ( getWState() & WState_Reserved1 ); }
651}; 651};
652 652
653/*! 653/*!
654 \internal 654 \internal
655*/ 655*/
656 656
657#ifdef QWS 657#ifdef QWS
658bool QPEApplication::qwsEventFilter( QWSEvent * e ) 658bool QPEApplication::qwsEventFilter( QWSEvent * e )
659{ 659{
660 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 660 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
661 if ( qApp->type() != QApplication::GuiServer ) { 661 if ( qApp->type() != QApplication::GuiServer ) {
662 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 662 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
663 e << d->appName; 663 e << d->appName;
664 } 664 }
665 d->notbusysent = TRUE; 665 d->notbusysent = TRUE;
666 } 666 }
667 if ( type() == GuiServer ) { 667 if ( type() == GuiServer ) {
668 switch ( e->type ) { 668 switch ( e->type ) {
669 case QWSEvent::Mouse: 669 case QWSEvent::Mouse:
670 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 670 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
671 emit clientMoused(); 671 emit clientMoused();
672 break; 672 break;
673 default: 673 default:
674 break; 674 break;
675 } 675 }
676 } 676 }
677 if ( e->type == QWSEvent::Key ) { 677 if ( e->type == QWSEvent::Key ) {
678 if ( d->kbgrabber == 1 ) 678 if ( d->kbgrabber == 1 )
679 return TRUE; 679 return TRUE;
680 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 680 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
681 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 681 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
682 // Use special "OK" key to press "OK" on top level widgets 682 // Use special "OK" key to press "OK" on top level widgets
683 QWidget * active = activeWindow(); 683 QWidget * active = activeWindow();
684 QWidget *popup = 0; 684 QWidget *popup = 0;
685 if ( active && active->isPopup() ) { 685 if ( active && active->isPopup() ) {
686 popup = active; 686 popup = active;
687 active = active->parentWidget(); 687 active = active->parentWidget();
688 } 688 }
689 if ( active && ( int ) active->winId() == ke->simpleData.window && 689 if ( active && ( int ) active->winId() == ke->simpleData.window &&
690 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 690 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
691 if ( ke->simpleData.is_press ) { 691 if ( ke->simpleData.is_press ) {
692 if ( popup ) 692 if ( popup )
693 popup->close(); 693 popup->close();
694 if ( active->inherits( "QDialog" ) ) { 694 if ( active->inherits( "QDialog" ) ) {
695 HackDialog * d = ( HackDialog * ) active; 695 HackDialog * d = ( HackDialog * ) active;
696 d->acceptIt(); 696 d->acceptIt();
697 return TRUE; 697 return TRUE;
698 } 698 }
699 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 699 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
700 QSignal s; 700 QSignal s;
701 s.connect( active, SLOT( accept() ) ); 701 s.connect( active, SLOT( accept() ) );
702 s.activate(); 702 s.activate();
703 } 703 }
704 else { 704 else {
705 // do the same as with the select key: Map to the default action of the widget: 705 // do the same as with the select key: Map to the default action of the widget:
706 mapToDefaultAction( ke, Qt::Key_Return ); 706 mapToDefaultAction( ke, Qt::Key_Return );
707 } 707 }
708 } 708 }
709 } 709 }
710 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 710 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
711 // Use special "select" key to do whatever default action a widget has 711 // Use special "select" key to do whatever default action a widget has
712 mapToDefaultAction( ke, Qt::Key_Space ); 712 mapToDefaultAction( ke, Qt::Key_Space );
713 } 713 }
714 else if ( ke->simpleData.keycode == Qt::Key_Escape && 714 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
715 ke->simpleData.is_press ) { 715 ke->simpleData.is_press ) {
716 // Escape key closes app if focus on toplevel 716 // Escape key closes app if focus on toplevel
717 QWidget * active = activeWindow(); 717 QWidget * active = activeWindow();
718 if ( active && active->testWFlags( WType_TopLevel ) && 718 if ( active && active->testWFlags( WType_TopLevel ) &&
719 ( int ) active->winId() == ke->simpleData.window && 719 ( int ) active->winId() == ke->simpleData.window &&
720 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 720 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
721 if ( active->inherits( "QDialog" ) ) { 721 if ( active->inherits( "QDialog" ) ) {
722 HackDialog * d = ( HackDialog * ) active; 722 HackDialog * d = ( HackDialog * ) active;
723 d->rejectIt(); 723 d->rejectIt();
724 return TRUE; 724 return TRUE;
725 } 725 }
726 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { 726 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
727 active->close(); 727 active->close();
728 } 728 }
729 } 729 }
730 } 730 }
731 731
732#if QT_VERSION < 231 732#if QT_VERSION < 231
733 // Filter out the F4/Launcher key from apps 733 // Filter out the F4/Launcher key from apps
734 // ### The launcher key may not always be F4 on all devices 734 // ### The launcher key may not always be F4 on all devices
735 if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) 735 if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 )
736 return TRUE; 736 return TRUE;
737#endif 737#endif
738 738
739 } 739 }
740 if ( e->type == QWSEvent::Focus ) { 740 if ( e->type == QWSEvent::Focus ) {
741 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 741 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
742 QWidget* nfw = QWidget::find( e->window() ); 742 QWidget* nfw = QWidget::find( e->window() );
743 if ( !fe->simpleData.get_focus ) { 743 if ( !fe->simpleData.get_focus ) {
744 QWidget * active = activeWindow(); 744 QWidget * active = activeWindow();
745 while ( active && active->isPopup() ) { 745 while ( active && active->isPopup() ) {
746 active->close(); 746 active->close();
747 active = activeWindow(); 747 active = activeWindow();
748 } 748 }
749 if ( !nfw && d->kbgrabber == 2 ) { 749 if ( !nfw && d->kbgrabber == 2 ) {
750 ungrabKeyboard(); 750 ungrabKeyboard();
751 d->kbregrab = TRUE; // want kb back when we're active 751 d->kbregrab = TRUE; // want kb back when we're active
752 } 752 }
753 } 753 }
754 else { 754 else {
755 // make sure our modal widget is ALWAYS on top 755 // make sure our modal widget is ALWAYS on top
756 QWidget *topm = activeModalWidget(); 756 QWidget *topm = activeModalWidget();
757 if ( topm ) { 757 if ( topm ) {
758 topm->raise(); 758 topm->raise();
759 } 759 }
760 if ( d->kbregrab ) { 760 if ( d->kbregrab ) {
761 grabKeyboard(); 761 grabKeyboard();
762 d->kbregrab = FALSE; 762 d->kbregrab = FALSE;
763 } 763 }
764 } 764 }
765 if ( fe->simpleData.get_focus && inputMethodDict ) { 765 if ( fe->simpleData.get_focus && inputMethodDict ) {
766 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 766 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
767 if ( m == AlwaysOff ) 767 if ( m == AlwaysOff )
768 Global::hideInputMethod(); 768 Global::hideInputMethod();
769 if ( m == AlwaysOn ) 769 if ( m == AlwaysOn )
770 Global::showInputMethod(); 770 Global::showInputMethod();
771 } 771 }
772 } 772 }
773 return QApplication::qwsEventFilter( e ); 773 return QApplication::qwsEventFilter( e );
774} 774}
775#endif 775#endif
776 776
777/*! 777/*!
778 Destroys the QPEApplication. 778 Destroys the QPEApplication.
779*/ 779*/
780QPEApplication::~QPEApplication() 780QPEApplication::~QPEApplication()
781{ 781{
782 ungrabKeyboard(); 782 ungrabKeyboard();
783#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 783#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
784 // Need to delete QCopChannels early, since the display will 784 // Need to delete QCopChannels early, since the display will
785 // be gone by the time we get to ~QObject(). 785 // be gone by the time we get to ~QObject().
786 delete sysChannel; 786 delete sysChannel;
787 delete pidChannel; 787 delete pidChannel;
788#endif 788#endif
789 789
790 delete d; 790 delete d;
791} 791}
792 792
793/*! 793/*!
794 Returns <tt>$OPIEDIR/</tt>. 794 Returns <tt>$OPIEDIR/</tt>.
795*/ 795*/
796QString QPEApplication::qpeDir() 796QString QPEApplication::qpeDir()
797{ 797{
798 const char * base = getenv( "OPIEDIR" ); 798 const char * base = getenv( "OPIEDIR" );
799 if ( base ) 799 if ( base )
800 return QString( base ) + "/"; 800 return QString( base ) + "/";
801 801
802 return QString( "../" ); 802 return QString( "../" );
803} 803}
804 804
805/*! 805/*!
806 Returns the user's current Document directory. There is a trailing "/". 806 Returns the user's current Document directory. There is a trailing "/".
807 .. well, it does now,, and there's no trailing '/' 807 .. well, it does now,, and there's no trailing '/'
808*/ 808*/
809QString QPEApplication::documentDir() 809QString QPEApplication::documentDir()
810{ 810{
811 return QString( QDir::homeDirPath() + "/Documents"); 811 const char* base = getenv( "HOME");
812 if( base )
813 return QString( base ) + "/Documents";
814
815 return QString( "../Documents" );
812} 816}
813 817
814static int deforient = -1; 818static int deforient = -1;
815 819
816/*! 820/*!
817 \internal 821 \internal
818*/ 822*/
819int QPEApplication::defaultRotation() 823int QPEApplication::defaultRotation()
820{ 824{
821 if ( deforient < 0 ) { 825 if ( deforient < 0 ) {
822 QString d = getenv( "QWS_DISPLAY" ); 826 QString d = getenv( "QWS_DISPLAY" );
823 if ( d.contains( "Rot90" ) ) { 827 if ( d.contains( "Rot90" ) ) {
824 deforient = 90; 828 deforient = 90;
825 } 829 }
826 else if ( d.contains( "Rot180" ) ) { 830 else if ( d.contains( "Rot180" ) ) {
827 deforient = 180; 831 deforient = 180;
828 } 832 }
829 else if ( d.contains( "Rot270" ) ) { 833 else if ( d.contains( "Rot270" ) ) {
830 deforient = 270; 834 deforient = 270;
831 } 835 }
832 else { 836 else {
833 deforient = 0; 837 deforient = 0;
834 } 838 }
835 } 839 }
836 return deforient; 840 return deforient;
837} 841}
838 842
839/*! 843/*!
840 \internal 844 \internal
841*/ 845*/
842void QPEApplication::setDefaultRotation( int r ) 846void QPEApplication::setDefaultRotation( int r )
843{ 847{
844 if ( qApp->type() == GuiServer ) { 848 if ( qApp->type() == GuiServer ) {
845 deforient = r; 849 deforient = r;
846 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 850 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
847 Config config("qpe"); 851 Config config("qpe");
848 config.setGroup( "Rotation" ); 852 config.setGroup( "Rotation" );
849 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 853 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
850 } else { 854 } else {
851#ifndef QT_NO_COP 855#ifndef QT_NO_COP
852 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } 856 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; }
853#endif 857#endif
854 } 858 }
855} 859}
856 860
857/*! 861/*!
858 \internal 862 \internal
859*/ 863*/
860void QPEApplication::applyStyle() 864void QPEApplication::applyStyle()
861{ 865{
862 Config config( "qpe" ); 866 Config config( "qpe" );
863 867
864 config.setGroup( "Appearance" ); 868 config.setGroup( "Appearance" );
865 869
866 // Widget style 870 // Widget style
867 QString style = config.readEntry( "Style", "Light" ); 871 QString style = config.readEntry( "Style", "Light" );
868 internalSetStyle( style ); 872 internalSetStyle( style );
869 873
870 // Colors 874 // Colors
871 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 875 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
872 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 876 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
873 QPalette pal( btncolor, bgcolor ); 877 QPalette pal( btncolor, bgcolor );
874 QString color = config.readEntry( "Highlight", "#800000" ); 878 QString color = config.readEntry( "Highlight", "#800000" );
875 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 879 pal.setColor( QColorGroup::Highlight, QColor( color ) );
876 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 880 color = config.readEntry( "HighlightedText", "#FFFFFF" );
877 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 881 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
878 color = config.readEntry( "Text", "#000000" ); 882 color = config.readEntry( "Text", "#000000" );
879 pal.setColor( QColorGroup::Text, QColor( color ) ); 883 pal.setColor( QColorGroup::Text, QColor( color ) );
880 color = config.readEntry( "ButtonText", "#000000" ); 884 color = config.readEntry( "ButtonText", "#000000" );
881 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 885 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
882 color = config.readEntry( "Base", "#FFFFFF" ); 886 color = config.readEntry( "Base", "#FFFFFF" );
883 pal.setColor( QColorGroup::Base, QColor( color ) ); 887 pal.setColor( QColorGroup::Base, QColor( color ) );
884 888
885 pal.setColor( QPalette::Disabled, QColorGroup::Text, 889 pal.setColor( QPalette::Disabled, QColorGroup::Text,
886 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 890 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
887 891
888 setPalette( pal, TRUE ); 892 setPalette( pal, TRUE );
889 893
890 // Window Decoration 894 // Window Decoration
891 QString dec = config.readEntry( "Decoration", "Qtopia" ); 895 QString dec = config.readEntry( "Decoration", "Qtopia" );
892 if ( dec != d->decorationName ) { 896 if ( dec != d->decorationName ) {
893 qwsSetDecoration( new QPEDecoration( dec ) ); 897 qwsSetDecoration( new QPEDecoration( dec ) );
894 d->decorationName = dec; 898 d->decorationName = dec;
895 } 899 }
896 900
897 // Font 901 // Font
898 QString ff = config.readEntry( "FontFamily", font().family() ); 902 QString ff = config.readEntry( "FontFamily", font().family() );
899 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 903 int fs = config.readNumEntry( "FontSize", font().pointSize() );
900 setFont( QFont(ff,fs) ); 904 setFont( QFont(ff,fs) );
901} 905}
902 906
903void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 907void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
904{ 908{
905#ifdef Q_WS_QWS 909#ifdef Q_WS_QWS
906 QDataStream stream( data, IO_ReadOnly ); 910 QDataStream stream( data, IO_ReadOnly );
907 if ( msg == "applyStyle()" ) { 911 if ( msg == "applyStyle()" ) {
908 applyStyle(); 912 applyStyle();
909 } else if ( msg == "setDefaultRotation(int)" ) { 913 } else if ( msg == "setDefaultRotation(int)" ) {
910 if ( type() == GuiServer ) { 914 if ( type() == GuiServer ) {
911 int r; 915 int r;
912 stream >> r; 916 stream >> r;
913 setDefaultRotation( r ); 917 setDefaultRotation( r );
914 } 918 }
915 } else if ( msg == "shutdown()" ) { 919 } else if ( msg == "shutdown()" ) {
916 if ( type() == GuiServer ) 920 if ( type() == GuiServer )
917 shutdown(); 921 shutdown();
918 } else if ( msg == "quit()" ) { 922 } else if ( msg == "quit()" ) {
919 if ( type() != GuiServer ) 923 if ( type() != GuiServer )
920 tryQuit(); 924 tryQuit();
921 } else if ( msg == "forceQuit()" ) { 925 } else if ( msg == "forceQuit()" ) {
922 if ( type() != GuiServer ) 926 if ( type() != GuiServer )
923 quit(); 927 quit();
924 } else if ( msg == "restart()" ) { 928 } else if ( msg == "restart()" ) {
925 if ( type() == GuiServer ) 929 if ( type() == GuiServer )
926 restart(); 930 restart();
927 } else if ( msg == "grabKeyboard(QString)" ) { 931 } else if ( msg == "grabKeyboard(QString)" ) {
928 QString who; 932 QString who;
929 stream >> who; 933 stream >> who;
930 if ( who.isEmpty() ) 934 if ( who.isEmpty() )
931 d->kbgrabber = 0; 935 d->kbgrabber = 0;
932 else if ( who != d->appName ) 936 else if ( who != d->appName )
933 d->kbgrabber = 1; 937 d->kbgrabber = 1;
934 else 938 else
935 d->kbgrabber = 2; 939 d->kbgrabber = 2;
936 } else if ( msg == "language(QString)" ) { 940 } else if ( msg == "language(QString)" ) {
937 if ( type() == GuiServer ) { 941 if ( type() == GuiServer ) {
938 QString l; 942 QString l;
939 stream >> l; 943 stream >> l;
940 QString cl = getenv( "LANG" ); 944 QString cl = getenv( "LANG" );
941 if ( cl != l ) { 945 if ( cl != l ) {
942 if ( l.isNull() ) 946 if ( l.isNull() )
943 unsetenv( "LANG" ); 947 unsetenv( "LANG" );
944 else 948 else
945 setenv( "LANG", l.latin1(), 1 ); 949 setenv( "LANG", l.latin1(), 1 );
946 restart(); 950 restart();
947 } 951 }
948 } 952 }
949 } else if ( msg == "timeChange(QString)" ) { 953 } else if ( msg == "timeChange(QString)" ) {
950 QString t; 954 QString t;
951 stream >> t; 955 stream >> t;
952 if ( t.isNull() ) 956 if ( t.isNull() )
953 unsetenv( "TZ" ); 957 unsetenv( "TZ" );
954 else 958 else
955 setenv( "TZ", t.latin1(), 1 ); 959 setenv( "TZ", t.latin1(), 1 );
956 // emit the signal so everyone else knows... 960 // emit the signal so everyone else knows...
957 emit timeChanged(); 961 emit timeChanged();
958 } else if ( msg == "execute(QString)" ) { 962 } else if ( msg == "execute(QString)" ) {
959 if ( type() == GuiServer ) { 963 if ( type() == GuiServer ) {
960 QString t; 964 QString t;
961 stream >> t; 965 stream >> t;
962 Global::execute( t ); 966 Global::execute( t );
963 } 967 }
964 } else if ( msg == "execute(QString,QString)" ) { 968 } else if ( msg == "execute(QString,QString)" ) {
965 if ( type() == GuiServer ) { 969 if ( type() == GuiServer ) {
966 QString t, d; 970 QString t, d;
967 stream >> t >> d; 971 stream >> t >> d;
968 Global::execute( t, d ); 972 Global::execute( t, d );
969 } 973 }
970 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 974 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
971 if ( type() == GuiServer ) { 975 if ( type() == GuiServer ) {
972 QDateTime when; 976 QDateTime when;
973 QCString channel, message; 977 QCString channel, message;
974 int data; 978 int data;
975 stream >> when >> channel >> message >> data; 979 stream >> when >> channel >> message >> data;
976 AlarmServer::addAlarm( when, channel, message, data ); 980 AlarmServer::addAlarm( when, channel, message, data );
977 } 981 }
978 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 982 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
979 if ( type() == GuiServer ) { 983 if ( type() == GuiServer ) {
980 QDateTime when; 984 QDateTime when;
981 QCString channel, message; 985 QCString channel, message;
982 int data; 986 int data;
983 stream >> when >> channel >> message >> data; 987 stream >> when >> channel >> message >> data;
984 AlarmServer::deleteAlarm( when, channel, message, data ); 988 AlarmServer::deleteAlarm( when, channel, message, data );
985 } 989 }
986 } else if ( msg == "clockChange(bool)" ) { 990 } else if ( msg == "clockChange(bool)" ) {
987 int tmp; 991 int tmp;
988 stream >> tmp; 992 stream >> tmp;
989 emit clockChanged( tmp ); 993 emit clockChanged( tmp );
990 } else if ( msg == "weekChange(bool)" ) { 994 } else if ( msg == "weekChange(bool)" ) {
991 int tmp; 995 int tmp;
992 stream >> tmp; 996 stream >> tmp;
993 emit weekChanged( tmp ); 997 emit weekChanged( tmp );
994 } else if ( msg == "setDateFormat(DateFormat)" ) { 998 } else if ( msg == "setDateFormat(DateFormat)" ) {
995 DateFormat tmp; 999 DateFormat tmp;
996 stream >> tmp; 1000 stream >> tmp;
997 emit dateFormatChanged( tmp ); 1001 emit dateFormatChanged( tmp );
998 } else if ( msg == "setVolume(int,int)" ) { 1002 } else if ( msg == "setVolume(int,int)" ) {
999 int t, v; 1003 int t, v;
1000 stream >> t >> v; 1004 stream >> t >> v;
1001 setVolume( t, v ); 1005 setVolume( t, v );
1002 emit volumeChanged( muted ); 1006 emit volumeChanged( muted );
1003 } else if ( msg == "volumeChange(bool)" ) { 1007 } else if ( msg == "volumeChange(bool)" ) {
1004 stream >> muted; 1008 stream >> muted;
1005 setVolume(); 1009 setVolume();
1006 emit volumeChanged( muted ); 1010 emit volumeChanged( muted );
1007 } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1011 } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1008 int t, v; 1012 int t, v;
1009 stream >> t >> v; 1013 stream >> t >> v;
1010 setMic( t, v ); 1014 setMic( t, v );
1011 emit micChanged( micMuted ); 1015 emit micChanged( micMuted );
1012 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1016 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1013 stream >> micMuted; 1017 stream >> micMuted;
1014 setMic(); 1018 setMic();
1015 emit micChanged( micMuted ); 1019 emit micChanged( micMuted );
1016 } 1020 }
1017#endif 1021#endif
1018} 1022}
1019 1023
1020/*! 1024/*!
1021 \internal 1025 \internal
1022*/ 1026*/
1023bool QPEApplication::raiseAppropriateWindow() 1027bool QPEApplication::raiseAppropriateWindow()
1024{ 1028{
1025 bool r=FALSE; 1029 bool r=FALSE;
1026 // ########## raise()ing main window should raise and set active 1030 // ########## raise()ing main window should raise and set active
1027 // ########## it and then all childen. This belongs in Qt/Embedded 1031 // ########## it and then all childen. This belongs in Qt/Embedded
1028 QWidget *top = d->qpe_main_widget; 1032 QWidget *top = d->qpe_main_widget;
1029 if ( !top ) top =mainWidget(); 1033 if ( !top ) top =mainWidget();
1030 if ( top && d->keep_running ) { 1034 if ( top && d->keep_running ) {
1031 if ( top->isVisible() ) 1035 if ( top->isVisible() )
1032 r = TRUE; 1036 r = TRUE;
1033 else if (d->preloaded) { 1037 else if (d->preloaded) {
1034 // We are preloaded and not visible.. pretend we just started.. 1038 // We are preloaded and not visible.. pretend we just started..
1035 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1039 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1036 e << d->appName; 1040 e << d->appName;
1037 } 1041 }
1038 1042
1039 d->show_mx(top,d->nomaximize); 1043 d->show_mx(top,d->nomaximize);
1040 top->raise(); 1044 top->raise();
1041 top->setActiveWindow(); 1045 top->setActiveWindow();
1042 } 1046 }
1043 QWidget *topm = activeModalWidget(); 1047 QWidget *topm = activeModalWidget();
1044 if ( topm && topm != top ) { 1048 if ( topm && topm != top ) {
1045 topm->show(); 1049 topm->show();
1046 topm->raise(); 1050 topm->raise();
1047 topm->setActiveWindow(); 1051 topm->setActiveWindow();
1048 // If we haven't already handled the fastAppShowing message 1052 // If we haven't already handled the fastAppShowing message
1049 if (!top && d->preloaded) { 1053 if (!top && d->preloaded) {
1050 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1054 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1051 e << d->appName; 1055 e << d->appName;
1052 } 1056 }
1053 r = FALSE; 1057 r = FALSE;
1054 } 1058 }
1055 return r; 1059 return r;
1056} 1060}
1057 1061
1058void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1062void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1059{ 1063{
1060#ifdef Q_WS_QWS 1064#ifdef Q_WS_QWS
1061 1065
1062 if ( msg == "quit()" ) { 1066 if ( msg == "quit()" ) {
1063 tryQuit(); 1067 tryQuit();
1064 } else if ( msg == "quitIfInvisible()" ) { 1068 } else if ( msg == "quitIfInvisible()" ) {
1065 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1069 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1066 quit(); 1070 quit();
1067 } else if ( msg == "close()" ) { 1071 } else if ( msg == "close()" ) {
1068 hideOrQuit(); 1072 hideOrQuit();
1069 } else if ( msg == "disablePreload()" ) { 1073 } else if ( msg == "disablePreload()" ) {
1070 d->preloaded = FALSE; 1074 d->preloaded = FALSE;
1071 d->keep_running = TRUE; 1075 d->keep_running = TRUE;
1072 /* so that quit will quit */ 1076 /* so that quit will quit */
1073 } else if ( msg == "enablePreload()" ) { 1077 } else if ( msg == "enablePreload()" ) {
1074 if (d->qpe_main_widget) 1078 if (d->qpe_main_widget)
1075 d->preloaded = TRUE; 1079 d->preloaded = TRUE;
1076 d->keep_running = TRUE; 1080 d->keep_running = TRUE;
1077 /* so next quit won't quit */ 1081 /* so next quit won't quit */
1078 } else if ( msg == "raise()" ) { 1082 } else if ( msg == "raise()" ) {
1079 d->keep_running = TRUE; 1083 d->keep_running = TRUE;
1080 d->notbusysent = FALSE; 1084 d->notbusysent = FALSE;
1081 raiseAppropriateWindow(); 1085 raiseAppropriateWindow();
1082 // Tell the system we're still chugging along... 1086 // Tell the system we're still chugging along...
1083 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1087 QCopEnvelope e("QPE/System", "appRaised(QString)");
1084 e << d->appName; 1088 e << d->appName;
1085 } else if ( msg == "flush()" ) { 1089 } else if ( msg == "flush()" ) {
1086 emit flush(); 1090 emit flush();
1087 // we need to tell the desktop 1091 // we need to tell the desktop
1088 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1092 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1089 e << d->appName; 1093 e << d->appName;
1090 } else if ( msg == "reload()" ) { 1094 } else if ( msg == "reload()" ) {
1091 emit reload(); 1095 emit reload();
1092 } else if ( msg == "setDocument(QString)" ) { 1096 } else if ( msg == "setDocument(QString)" ) {
1093 d->keep_running = TRUE; 1097 d->keep_running = TRUE;
1094 QDataStream stream( data, IO_ReadOnly ); 1098 QDataStream stream( data, IO_ReadOnly );
1095 QString doc; 1099 QString doc;
1096 stream >> doc; 1100 stream >> doc;
1097 QWidget *mw = mainWidget(); 1101 QWidget *mw = mainWidget();
1098 if ( !mw ) 1102 if ( !mw )
1099 mw = d->qpe_main_widget; 1103 mw = d->qpe_main_widget;
1100 if ( mw ) 1104 if ( mw )
1101 Global::setDocument( mw, doc ); 1105 Global::setDocument( mw, doc );
1102 } else if ( msg == "nextView()" ) { 1106 } else if ( msg == "nextView()" ) {
1103 qDebug("got nextView()"); 1107 qDebug("got nextView()");
1104/* 1108/*
1105 if ( raiseAppropriateWindow() ) 1109 if ( raiseAppropriateWindow() )
1106*/ 1110*/
1107 emit appMessage( msg, data); 1111 emit appMessage( msg, data);
1108 } else { 1112 } else {
1109 emit appMessage( msg, data); 1113 emit appMessage( msg, data);
1110 } 1114 }
1111 1115
1112#endif 1116#endif
1113} 1117}
1114 1118
1115 1119
1116/*! 1120/*!
1117 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1121 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1118 consider passing TRUE for \a nomaximize rather than the default FALSE. 1122 consider passing TRUE for \a nomaximize rather than the default FALSE.
1119 1123
1120 \sa showMainDocumentWidget() 1124 \sa showMainDocumentWidget()
1121*/ 1125*/
1122void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1126void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1123{ 1127{
1124 d->show(mw,nomaximize ); 1128 d->show(mw,nomaximize );
1125} 1129}
1126 1130
1127/*! 1131/*!
1128 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1132 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1129 consider passing TRUE for \a nomaximize rather than the default FALSE. 1133 consider passing TRUE for \a nomaximize rather than the default FALSE.
1130 1134
1131 This calls designates the application as 1135 This calls designates the application as
1132 a \link docwidget.html document-oriented\endlink application. 1136 a \link docwidget.html document-oriented\endlink application.
1133 1137
1134 The \a mw widget \e must have this slot: setDocument(const QString&). 1138 The \a mw widget \e must have this slot: setDocument(const QString&).
1135 1139
1136 \sa showMainWidget() 1140 \sa showMainWidget()
1137*/ 1141*/
1138void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1142void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1139{ 1143{
1140 if ( mw && argc() == 2 ) 1144 if ( mw && argc() == 2 )
1141 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1145 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1142 1146
1143 d->show(mw, nomaximize ); 1147 d->show(mw, nomaximize );
1144} 1148}
1145 1149
1146 1150
1147/*! 1151/*!
1148 If an application is started via a \link qcop.html QCop\endlink 1152 If an application is started via a \link qcop.html QCop\endlink
1149 message, the application will process the \link qcop.html 1153 message, the application will process the \link qcop.html
1150 QCop\endlink message and then quit. If the application calls this 1154 QCop\endlink message and then quit. If the application calls this
1151 function while processing a \link qcop.html QCop\endlink message, 1155 function while processing a \link qcop.html QCop\endlink message,
1152 after processing its outstanding \link qcop.html QCop\endlink 1156 after processing its outstanding \link qcop.html QCop\endlink
1153 messages the application will start 'properly' and show itself. 1157 messages the application will start 'properly' and show itself.
1154 1158
1155 \sa keepRunning() 1159 \sa keepRunning()
1156*/ 1160*/
1157void QPEApplication::setKeepRunning() 1161void QPEApplication::setKeepRunning()
1158{ 1162{
1159 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1163 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1160 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1164 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1161 qpeApp->d->keep_running = TRUE; 1165 qpeApp->d->keep_running = TRUE;
1162 } 1166 }
1163} 1167}
1164 1168
1165/*! 1169/*!
1166 Returns TRUE if the application will quit after processing the 1170 Returns TRUE if the application will quit after processing the
1167 current list of qcop messages; otherwise returns FALSE. 1171 current list of qcop messages; otherwise returns FALSE.
1168 1172
1169 \sa setKeepRunning() 1173 \sa setKeepRunning()
1170*/ 1174*/
1171bool QPEApplication::keepRunning() const 1175bool QPEApplication::keepRunning() const
1172{ 1176{
1173 return d->keep_running; 1177 return d->keep_running;
1174} 1178}
1175 1179
1176/*! 1180/*!
1177 \internal 1181 \internal
1178*/ 1182*/
1179void QPEApplication::internalSetStyle( const QString &style ) 1183void QPEApplication::internalSetStyle( const QString &style )
1180{ 1184{
1181#if QT_VERSION >= 300 1185#if QT_VERSION >= 300
1182 if ( style == "QPE" ) { 1186 if ( style == "QPE" ) {
1183 setStyle( new QPEStyle ); 1187 setStyle( new QPEStyle );
1184 } 1188 }
1185 else { 1189 else {
1186 QStyle *s = QStyleFactory::create( style ); 1190 QStyle *s = QStyleFactory::create( style );
1187 if ( s ) 1191 if ( s )
1188 setStyle( s ); 1192 setStyle( s );
1189 } 1193 }
1190#else 1194#else
1191 if ( style == "Windows" ) { 1195 if ( style == "Windows" ) {
1192 setStyle( new QWindowsStyle ); 1196 setStyle( new QWindowsStyle );
1193 } 1197 }
1194 else if ( style == "QPE" ) { 1198 else if ( style == "QPE" ) {
1195 setStyle( new QPEStyle ); 1199 setStyle( new QPEStyle );