author | sandman <sandman> | 2002-10-04 01:22:50 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-04 01:22:50 (UTC) |
commit | b7ec6d0674f0f7835da7f114683dcfa74e6bc546 (patch) (unidiff) | |
tree | a2dff60b917d943543458f3e47d67f1584fbfb6c | |
parent | e2f23d8a5169ffef63dcbbac920f68ef0f113792 (diff) | |
download | opie-b7ec6d0674f0f7835da7f114683dcfa74e6bc546.zip opie-b7ec6d0674f0f7835da7f114683dcfa74e6bc546.tar.gz opie-b7ec6d0674f0f7835da7f114683dcfa74e6bc546.tar.bz2 |
changes to make the style interface BC with Qtopia 1.6, while still
supporting our extended features
-rw-r--r-- | library/qpeapplication.cpp | 2 | ||||
-rw-r--r-- | library/styleinterface.h | 39 |
2 files changed, 20 insertions, 21 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index e92b4dd..f65f3ab 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -468,1158 +468,1158 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
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 | ||
574 | static QPtrDict<void>* inputMethodDict = 0; | 574 | static QPtrDict<void>* inputMethodDict = 0; |
575 | static void createInputMethodDict() | 575 | static 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 | */ |
588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 588 | QPEApplication::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 | */ |
609 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 609 | void 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 | ||
621 | class HackDialog : public QDialog | 621 | class HackDialog : public QDialog |
622 | { | 622 | { |
623 | public: | 623 | public: |
624 | void acceptIt() { accept(); } | 624 | void acceptIt() { accept(); } |
625 | void rejectIt() { reject(); } | 625 | void rejectIt() { reject(); } |
626 | }; | 626 | }; |
627 | 627 | ||
628 | 628 | ||
629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 629 | void 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 | ||
646 | class HackWidget : public QWidget | 646 | class HackWidget : public QWidget |
647 | { | 647 | { |
648 | public: | 648 | public: |
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 |
658 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 658 | bool 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 | */ |
780 | QPEApplication::~QPEApplication() | 780 | QPEApplication::~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 | */ |
796 | QString QPEApplication::qpeDir() | 796 | QString 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 | */ |
809 | QString QPEApplication::documentDir() | 809 | QString QPEApplication::documentDir() |
810 | { | 810 | { |
811 | const char* base = getenv( "HOME"); | 811 | const char* base = getenv( "HOME"); |
812 | if( base ) | 812 | if( base ) |
813 | return QString( base ) + "/Documents"; | 813 | return QString( base ) + "/Documents"; |
814 | 814 | ||
815 | return QString( "../Documents" ); | 815 | return QString( "../Documents" ); |
816 | } | 816 | } |
817 | 817 | ||
818 | static int deforient = -1; | 818 | static int deforient = -1; |
819 | 819 | ||
820 | /*! | 820 | /*! |
821 | \internal | 821 | \internal |
822 | */ | 822 | */ |
823 | int QPEApplication::defaultRotation() | 823 | int QPEApplication::defaultRotation() |
824 | { | 824 | { |
825 | if ( deforient < 0 ) { | 825 | if ( deforient < 0 ) { |
826 | QString d = getenv( "QWS_DISPLAY" ); | 826 | QString d = getenv( "QWS_DISPLAY" ); |
827 | if ( d.contains( "Rot90" ) ) { | 827 | if ( d.contains( "Rot90" ) ) { |
828 | deforient = 90; | 828 | deforient = 90; |
829 | } | 829 | } |
830 | else if ( d.contains( "Rot180" ) ) { | 830 | else if ( d.contains( "Rot180" ) ) { |
831 | deforient = 180; | 831 | deforient = 180; |
832 | } | 832 | } |
833 | else if ( d.contains( "Rot270" ) ) { | 833 | else if ( d.contains( "Rot270" ) ) { |
834 | deforient = 270; | 834 | deforient = 270; |
835 | } | 835 | } |
836 | else { | 836 | else { |
837 | deforient = 0; | 837 | deforient = 0; |
838 | } | 838 | } |
839 | } | 839 | } |
840 | return deforient; | 840 | return deforient; |
841 | } | 841 | } |
842 | 842 | ||
843 | /*! | 843 | /*! |
844 | \internal | 844 | \internal |
845 | */ | 845 | */ |
846 | void QPEApplication::setDefaultRotation( int r ) | 846 | void QPEApplication::setDefaultRotation( int r ) |
847 | { | 847 | { |
848 | if ( qApp->type() == GuiServer ) { | 848 | if ( qApp->type() == GuiServer ) { |
849 | deforient = r; | 849 | deforient = r; |
850 | 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 ); |
851 | Config config("qpe"); | 851 | Config config("qpe"); |
852 | config.setGroup( "Rotation" ); | 852 | config.setGroup( "Rotation" ); |
853 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 853 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
854 | } else { | 854 | } else { |
855 | #ifndef QT_NO_COP | 855 | #ifndef QT_NO_COP |
856 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } | 856 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } |
857 | #endif | 857 | #endif |
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | /*! | 861 | /*! |
862 | \internal | 862 | \internal |
863 | */ | 863 | */ |
864 | void QPEApplication::applyStyle() | 864 | void QPEApplication::applyStyle() |
865 | { | 865 | { |
866 | Config config( "qpe" ); | 866 | Config config( "qpe" ); |
867 | 867 | ||
868 | config.setGroup( "Appearance" ); | 868 | config.setGroup( "Appearance" ); |
869 | 869 | ||
870 | // Widget style | 870 | // Widget style |
871 | QString style = config.readEntry( "Style", "Light" ); | 871 | QString style = config.readEntry( "Style", "Light" ); |
872 | internalSetStyle( style ); | 872 | internalSetStyle( style ); |
873 | 873 | ||
874 | // Colors | 874 | // Colors |
875 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 875 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
876 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 876 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
877 | QPalette pal( btncolor, bgcolor ); | 877 | QPalette pal( btncolor, bgcolor ); |
878 | QString color = config.readEntry( "Highlight", "#800000" ); | 878 | QString color = config.readEntry( "Highlight", "#800000" ); |
879 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 879 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
880 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 880 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
881 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 881 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
882 | color = config.readEntry( "Text", "#000000" ); | 882 | color = config.readEntry( "Text", "#000000" ); |
883 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 883 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
884 | color = config.readEntry( "ButtonText", "#000000" ); | 884 | color = config.readEntry( "ButtonText", "#000000" ); |
885 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 885 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
886 | color = config.readEntry( "Base", "#FFFFFF" ); | 886 | color = config.readEntry( "Base", "#FFFFFF" ); |
887 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 887 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
888 | 888 | ||
889 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 889 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
890 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 890 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
891 | 891 | ||
892 | setPalette( pal, TRUE ); | 892 | setPalette( pal, TRUE ); |
893 | 893 | ||
894 | // Window Decoration | 894 | // Window Decoration |
895 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 895 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
896 | if ( dec != d->decorationName ) { | 896 | if ( dec != d->decorationName ) { |
897 | qwsSetDecoration( new QPEDecoration( dec ) ); | 897 | qwsSetDecoration( new QPEDecoration( dec ) ); |
898 | d->decorationName = dec; | 898 | d->decorationName = dec; |
899 | } | 899 | } |
900 | 900 | ||
901 | // Font | 901 | // Font |
902 | QString ff = config.readEntry( "FontFamily", font().family() ); | 902 | QString ff = config.readEntry( "FontFamily", font().family() ); |
903 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 903 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
904 | setFont( QFont(ff,fs) ); | 904 | setFont( QFont(ff,fs) ); |
905 | } | 905 | } |
906 | 906 | ||
907 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 907 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
908 | { | 908 | { |
909 | #ifdef Q_WS_QWS | 909 | #ifdef Q_WS_QWS |
910 | QDataStream stream( data, IO_ReadOnly ); | 910 | QDataStream stream( data, IO_ReadOnly ); |
911 | if ( msg == "applyStyle()" ) { | 911 | if ( msg == "applyStyle()" ) { |
912 | applyStyle(); | 912 | applyStyle(); |
913 | } else if ( msg == "setDefaultRotation(int)" ) { | 913 | } else if ( msg == "setDefaultRotation(int)" ) { |
914 | if ( type() == GuiServer ) { | 914 | if ( type() == GuiServer ) { |
915 | int r; | 915 | int r; |
916 | stream >> r; | 916 | stream >> r; |
917 | setDefaultRotation( r ); | 917 | setDefaultRotation( r ); |
918 | } | 918 | } |
919 | } else if ( msg == "shutdown()" ) { | 919 | } else if ( msg == "shutdown()" ) { |
920 | if ( type() == GuiServer ) | 920 | if ( type() == GuiServer ) |
921 | shutdown(); | 921 | shutdown(); |
922 | } else if ( msg == "quit()" ) { | 922 | } else if ( msg == "quit()" ) { |
923 | if ( type() != GuiServer ) | 923 | if ( type() != GuiServer ) |
924 | tryQuit(); | 924 | tryQuit(); |
925 | } else if ( msg == "forceQuit()" ) { | 925 | } else if ( msg == "forceQuit()" ) { |
926 | if ( type() != GuiServer ) | 926 | if ( type() != GuiServer ) |
927 | quit(); | 927 | quit(); |
928 | } else if ( msg == "restart()" ) { | 928 | } else if ( msg == "restart()" ) { |
929 | if ( type() == GuiServer ) | 929 | if ( type() == GuiServer ) |
930 | restart(); | 930 | restart(); |
931 | } else if ( msg == "grabKeyboard(QString)" ) { | 931 | } else if ( msg == "grabKeyboard(QString)" ) { |
932 | QString who; | 932 | QString who; |
933 | stream >> who; | 933 | stream >> who; |
934 | if ( who.isEmpty() ) | 934 | if ( who.isEmpty() ) |
935 | d->kbgrabber = 0; | 935 | d->kbgrabber = 0; |
936 | else if ( who != d->appName ) | 936 | else if ( who != d->appName ) |
937 | d->kbgrabber = 1; | 937 | d->kbgrabber = 1; |
938 | else | 938 | else |
939 | d->kbgrabber = 2; | 939 | d->kbgrabber = 2; |
940 | } else if ( msg == "language(QString)" ) { | 940 | } else if ( msg == "language(QString)" ) { |
941 | if ( type() == GuiServer ) { | 941 | if ( type() == GuiServer ) { |
942 | QString l; | 942 | QString l; |
943 | stream >> l; | 943 | stream >> l; |
944 | QString cl = getenv( "LANG" ); | 944 | QString cl = getenv( "LANG" ); |
945 | if ( cl != l ) { | 945 | if ( cl != l ) { |
946 | if ( l.isNull() ) | 946 | if ( l.isNull() ) |
947 | unsetenv( "LANG" ); | 947 | unsetenv( "LANG" ); |
948 | else | 948 | else |
949 | setenv( "LANG", l.latin1(), 1 ); | 949 | setenv( "LANG", l.latin1(), 1 ); |
950 | restart(); | 950 | restart(); |
951 | } | 951 | } |
952 | } | 952 | } |
953 | } else if ( msg == "timeChange(QString)" ) { | 953 | } else if ( msg == "timeChange(QString)" ) { |
954 | QString t; | 954 | QString t; |
955 | stream >> t; | 955 | stream >> t; |
956 | if ( t.isNull() ) | 956 | if ( t.isNull() ) |
957 | unsetenv( "TZ" ); | 957 | unsetenv( "TZ" ); |
958 | else | 958 | else |
959 | setenv( "TZ", t.latin1(), 1 ); | 959 | setenv( "TZ", t.latin1(), 1 ); |
960 | // emit the signal so everyone else knows... | 960 | // emit the signal so everyone else knows... |
961 | emit timeChanged(); | 961 | emit timeChanged(); |
962 | } else if ( msg == "execute(QString)" ) { | 962 | } else if ( msg == "execute(QString)" ) { |
963 | if ( type() == GuiServer ) { | 963 | if ( type() == GuiServer ) { |
964 | QString t; | 964 | QString t; |
965 | stream >> t; | 965 | stream >> t; |
966 | Global::execute( t ); | 966 | Global::execute( t ); |
967 | } | 967 | } |
968 | } else if ( msg == "execute(QString,QString)" ) { | 968 | } else if ( msg == "execute(QString,QString)" ) { |
969 | if ( type() == GuiServer ) { | 969 | if ( type() == GuiServer ) { |
970 | QString t, d; | 970 | QString t, d; |
971 | stream >> t >> d; | 971 | stream >> t >> d; |
972 | Global::execute( t, d ); | 972 | Global::execute( t, d ); |
973 | } | 973 | } |
974 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 974 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
975 | if ( type() == GuiServer ) { | 975 | if ( type() == GuiServer ) { |
976 | QDateTime when; | 976 | QDateTime when; |
977 | QCString channel, message; | 977 | QCString channel, message; |
978 | int data; | 978 | int data; |
979 | stream >> when >> channel >> message >> data; | 979 | stream >> when >> channel >> message >> data; |
980 | AlarmServer::addAlarm( when, channel, message, data ); | 980 | AlarmServer::addAlarm( when, channel, message, data ); |
981 | } | 981 | } |
982 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 982 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
983 | if ( type() == GuiServer ) { | 983 | if ( type() == GuiServer ) { |
984 | QDateTime when; | 984 | QDateTime when; |
985 | QCString channel, message; | 985 | QCString channel, message; |
986 | int data; | 986 | int data; |
987 | stream >> when >> channel >> message >> data; | 987 | stream >> when >> channel >> message >> data; |
988 | AlarmServer::deleteAlarm( when, channel, message, data ); | 988 | AlarmServer::deleteAlarm( when, channel, message, data ); |
989 | } | 989 | } |
990 | } else if ( msg == "clockChange(bool)" ) { | 990 | } else if ( msg == "clockChange(bool)" ) { |
991 | int tmp; | 991 | int tmp; |
992 | stream >> tmp; | 992 | stream >> tmp; |
993 | emit clockChanged( tmp ); | 993 | emit clockChanged( tmp ); |
994 | } else if ( msg == "weekChange(bool)" ) { | 994 | } else if ( msg == "weekChange(bool)" ) { |
995 | int tmp; | 995 | int tmp; |
996 | stream >> tmp; | 996 | stream >> tmp; |
997 | emit weekChanged( tmp ); | 997 | emit weekChanged( tmp ); |
998 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 998 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
999 | DateFormat tmp; | 999 | DateFormat tmp; |
1000 | stream >> tmp; | 1000 | stream >> tmp; |
1001 | emit dateFormatChanged( tmp ); | 1001 | emit dateFormatChanged( tmp ); |
1002 | } else if ( msg == "setVolume(int,int)" ) { | 1002 | } else if ( msg == "setVolume(int,int)" ) { |
1003 | int t, v; | 1003 | int t, v; |
1004 | stream >> t >> v; | 1004 | stream >> t >> v; |
1005 | setVolume( t, v ); | 1005 | setVolume( t, v ); |
1006 | emit volumeChanged( muted ); | 1006 | emit volumeChanged( muted ); |
1007 | } else if ( msg == "volumeChange(bool)" ) { | 1007 | } else if ( msg == "volumeChange(bool)" ) { |
1008 | stream >> muted; | 1008 | stream >> muted; |
1009 | setVolume(); | 1009 | setVolume(); |
1010 | emit volumeChanged( muted ); | 1010 | emit volumeChanged( muted ); |
1011 | } 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> |
1012 | int t, v; | 1012 | int t, v; |
1013 | stream >> t >> v; | 1013 | stream >> t >> v; |
1014 | setMic( t, v ); | 1014 | setMic( t, v ); |
1015 | emit micChanged( micMuted ); | 1015 | emit micChanged( micMuted ); |
1016 | } 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> |
1017 | stream >> micMuted; | 1017 | stream >> micMuted; |
1018 | setMic(); | 1018 | setMic(); |
1019 | emit micChanged( micMuted ); | 1019 | emit micChanged( micMuted ); |
1020 | } | 1020 | } |
1021 | #endif | 1021 | #endif |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | /*! | 1024 | /*! |
1025 | \internal | 1025 | \internal |
1026 | */ | 1026 | */ |
1027 | bool QPEApplication::raiseAppropriateWindow() | 1027 | bool QPEApplication::raiseAppropriateWindow() |
1028 | { | 1028 | { |
1029 | bool r=FALSE; | 1029 | bool r=FALSE; |
1030 | // ########## raise()ing main window should raise and set active | 1030 | // ########## raise()ing main window should raise and set active |
1031 | // ########## it and then all childen. This belongs in Qt/Embedded | 1031 | // ########## it and then all childen. This belongs in Qt/Embedded |
1032 | QWidget *top = d->qpe_main_widget; | 1032 | QWidget *top = d->qpe_main_widget; |
1033 | if ( !top ) top =mainWidget(); | 1033 | if ( !top ) top =mainWidget(); |
1034 | if ( top && d->keep_running ) { | 1034 | if ( top && d->keep_running ) { |
1035 | if ( top->isVisible() ) | 1035 | if ( top->isVisible() ) |
1036 | r = TRUE; | 1036 | r = TRUE; |
1037 | else if (d->preloaded) { | 1037 | else if (d->preloaded) { |
1038 | // We are preloaded and not visible.. pretend we just started.. | 1038 | // We are preloaded and not visible.. pretend we just started.. |
1039 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1039 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1040 | e << d->appName; | 1040 | e << d->appName; |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | d->show_mx(top,d->nomaximize); | 1043 | d->show_mx(top,d->nomaximize); |
1044 | top->raise(); | 1044 | top->raise(); |
1045 | top->setActiveWindow(); | 1045 | top->setActiveWindow(); |
1046 | } | 1046 | } |
1047 | QWidget *topm = activeModalWidget(); | 1047 | QWidget *topm = activeModalWidget(); |
1048 | if ( topm && topm != top ) { | 1048 | if ( topm && topm != top ) { |
1049 | topm->show(); | 1049 | topm->show(); |
1050 | topm->raise(); | 1050 | topm->raise(); |
1051 | topm->setActiveWindow(); | 1051 | topm->setActiveWindow(); |
1052 | // If we haven't already handled the fastAppShowing message | 1052 | // If we haven't already handled the fastAppShowing message |
1053 | if (!top && d->preloaded) { | 1053 | if (!top && d->preloaded) { |
1054 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1054 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1055 | e << d->appName; | 1055 | e << d->appName; |
1056 | } | 1056 | } |
1057 | r = FALSE; | 1057 | r = FALSE; |
1058 | } | 1058 | } |
1059 | return r; | 1059 | return r; |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1062 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1063 | { | 1063 | { |
1064 | #ifdef Q_WS_QWS | 1064 | #ifdef Q_WS_QWS |
1065 | 1065 | ||
1066 | if ( msg == "quit()" ) { | 1066 | if ( msg == "quit()" ) { |
1067 | tryQuit(); | 1067 | tryQuit(); |
1068 | } else if ( msg == "quitIfInvisible()" ) { | 1068 | } else if ( msg == "quitIfInvisible()" ) { |
1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1070 | quit(); | 1070 | quit(); |
1071 | } else if ( msg == "close()" ) { | 1071 | } else if ( msg == "close()" ) { |
1072 | hideOrQuit(); | 1072 | hideOrQuit(); |
1073 | } else if ( msg == "disablePreload()" ) { | 1073 | } else if ( msg == "disablePreload()" ) { |
1074 | d->preloaded = FALSE; | 1074 | d->preloaded = FALSE; |
1075 | d->keep_running = TRUE; | 1075 | d->keep_running = TRUE; |
1076 | /* so that quit will quit */ | 1076 | /* so that quit will quit */ |
1077 | } else if ( msg == "enablePreload()" ) { | 1077 | } else if ( msg == "enablePreload()" ) { |
1078 | if (d->qpe_main_widget) | 1078 | if (d->qpe_main_widget) |
1079 | d->preloaded = TRUE; | 1079 | d->preloaded = TRUE; |
1080 | d->keep_running = TRUE; | 1080 | d->keep_running = TRUE; |
1081 | /* so next quit won't quit */ | 1081 | /* so next quit won't quit */ |
1082 | } else if ( msg == "raise()" ) { | 1082 | } else if ( msg == "raise()" ) { |
1083 | d->keep_running = TRUE; | 1083 | d->keep_running = TRUE; |
1084 | d->notbusysent = FALSE; | 1084 | d->notbusysent = FALSE; |
1085 | raiseAppropriateWindow(); | 1085 | raiseAppropriateWindow(); |
1086 | // Tell the system we're still chugging along... | 1086 | // Tell the system we're still chugging along... |
1087 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1087 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1088 | e << d->appName; | 1088 | e << d->appName; |
1089 | } else if ( msg == "flush()" ) { | 1089 | } else if ( msg == "flush()" ) { |
1090 | emit flush(); | 1090 | emit flush(); |
1091 | // we need to tell the desktop | 1091 | // we need to tell the desktop |
1092 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1092 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1093 | e << d->appName; | 1093 | e << d->appName; |
1094 | } else if ( msg == "reload()" ) { | 1094 | } else if ( msg == "reload()" ) { |
1095 | emit reload(); | 1095 | emit reload(); |
1096 | } else if ( msg == "setDocument(QString)" ) { | 1096 | } else if ( msg == "setDocument(QString)" ) { |
1097 | d->keep_running = TRUE; | 1097 | d->keep_running = TRUE; |
1098 | QDataStream stream( data, IO_ReadOnly ); | 1098 | QDataStream stream( data, IO_ReadOnly ); |
1099 | QString doc; | 1099 | QString doc; |
1100 | stream >> doc; | 1100 | stream >> doc; |
1101 | QWidget *mw = mainWidget(); | 1101 | QWidget *mw = mainWidget(); |
1102 | if ( !mw ) | 1102 | if ( !mw ) |
1103 | mw = d->qpe_main_widget; | 1103 | mw = d->qpe_main_widget; |
1104 | if ( mw ) | 1104 | if ( mw ) |
1105 | Global::setDocument( mw, doc ); | 1105 | Global::setDocument( mw, doc ); |
1106 | } else if ( msg == "nextView()" ) { | 1106 | } else if ( msg == "nextView()" ) { |
1107 | qDebug("got nextView()"); | 1107 | qDebug("got nextView()"); |
1108 | /* | 1108 | /* |
1109 | if ( raiseAppropriateWindow() ) | 1109 | if ( raiseAppropriateWindow() ) |
1110 | */ | 1110 | */ |
1111 | emit appMessage( msg, data); | 1111 | emit appMessage( msg, data); |
1112 | } else { | 1112 | } else { |
1113 | emit appMessage( msg, data); | 1113 | emit appMessage( msg, data); |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | #endif | 1116 | #endif |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | 1119 | ||
1120 | /*! | 1120 | /*! |
1121 | 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, |
1122 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1122 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1123 | 1123 | ||
1124 | \sa showMainDocumentWidget() | 1124 | \sa showMainDocumentWidget() |
1125 | */ | 1125 | */ |
1126 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1126 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1127 | { | 1127 | { |
1128 | d->show(mw,nomaximize ); | 1128 | d->show(mw,nomaximize ); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | /*! | 1131 | /*! |
1132 | 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, |
1133 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1133 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1134 | 1134 | ||
1135 | This calls designates the application as | 1135 | This calls designates the application as |
1136 | a \link docwidget.html document-oriented\endlink application. | 1136 | a \link docwidget.html document-oriented\endlink application. |
1137 | 1137 | ||
1138 | 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&). |
1139 | 1139 | ||
1140 | \sa showMainWidget() | 1140 | \sa showMainWidget() |
1141 | */ | 1141 | */ |
1142 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1142 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1143 | { | 1143 | { |
1144 | if ( mw && argc() == 2 ) | 1144 | if ( mw && argc() == 2 ) |
1145 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1145 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1146 | 1146 | ||
1147 | d->show(mw, nomaximize ); | 1147 | d->show(mw, nomaximize ); |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | 1150 | ||
1151 | /*! | 1151 | /*! |
1152 | 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 |
1153 | message, the application will process the \link qcop.html | 1153 | message, the application will process the \link qcop.html |
1154 | QCop\endlink message and then quit. If the application calls this | 1154 | QCop\endlink message and then quit. If the application calls this |
1155 | function while processing a \link qcop.html QCop\endlink message, | 1155 | function while processing a \link qcop.html QCop\endlink message, |
1156 | after processing its outstanding \link qcop.html QCop\endlink | 1156 | after processing its outstanding \link qcop.html QCop\endlink |
1157 | messages the application will start 'properly' and show itself. | 1157 | messages the application will start 'properly' and show itself. |
1158 | 1158 | ||
1159 | \sa keepRunning() | 1159 | \sa keepRunning() |
1160 | */ | 1160 | */ |
1161 | void QPEApplication::setKeepRunning() | 1161 | void QPEApplication::setKeepRunning() |
1162 | { | 1162 | { |
1163 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1163 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1164 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1164 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1165 | qpeApp->d->keep_running = TRUE; | 1165 | qpeApp->d->keep_running = TRUE; |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | /*! | 1169 | /*! |
1170 | Returns TRUE if the application will quit after processing the | 1170 | Returns TRUE if the application will quit after processing the |
1171 | current list of qcop messages; otherwise returns FALSE. | 1171 | current list of qcop messages; otherwise returns FALSE. |
1172 | 1172 | ||
1173 | \sa setKeepRunning() | 1173 | \sa setKeepRunning() |
1174 | */ | 1174 | */ |
1175 | bool QPEApplication::keepRunning() const | 1175 | bool QPEApplication::keepRunning() const |
1176 | { | 1176 | { |
1177 | return d->keep_running; | 1177 | return d->keep_running; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | /*! | 1180 | /*! |
1181 | \internal | 1181 | \internal |
1182 | */ | 1182 | */ |
1183 | void QPEApplication::internalSetStyle( const QString &style ) | 1183 | void QPEApplication::internalSetStyle( const QString &style ) |
1184 | { | 1184 | { |
1185 | #if QT_VERSION >= 300 | 1185 | #if QT_VERSION >= 300 |
1186 | if ( style == "QPE" ) { | 1186 | if ( style == "QPE" ) { |
1187 | setStyle( new QPEStyle ); | 1187 | setStyle( new QPEStyle ); |
1188 | } | 1188 | } |
1189 | else { | 1189 | else { |
1190 | QStyle *s = QStyleFactory::create( style ); | 1190 | QStyle *s = QStyleFactory::create( style ); |
1191 | if ( s ) | 1191 | if ( s ) |
1192 | setStyle( s ); | 1192 | setStyle( s ); |
1193 | } | 1193 | } |
1194 | #else | 1194 | #else |
1195 | if ( style == "Windows" ) { | 1195 | if ( style == "Windows" ) { |
1196 | setStyle( new QWindowsStyle ); | 1196 | setStyle( new QWindowsStyle ); |
1197 | } | 1197 | } |
1198 | else if ( style == "QPE" ) { | 1198 | else if ( style == "QPE" ) { |
1199 | setStyle( new QPEStyle ); | 1199 | setStyle( new QPEStyle ); |
1200 | } | 1200 | } |
1201 | else if ( style == "Light" ) { | 1201 | else if ( style == "Light" ) { |
1202 | setStyle( new LightStyle ); | 1202 | setStyle( new LightStyle ); |
1203 | } | 1203 | } |
1204 | #ifndef QT_NO_STYLE_PLATINUM | 1204 | #ifndef QT_NO_STYLE_PLATINUM |
1205 | else if ( style == "Platinum" ) { | 1205 | else if ( style == "Platinum" ) { |
1206 | setStyle( new QPlatinumStyle ); | 1206 | setStyle( new QPlatinumStyle ); |
1207 | } | 1207 | } |
1208 | #endif | 1208 | #endif |
1209 | #ifndef QT_NO_STYLE_MOTIF | 1209 | #ifndef QT_NO_STYLE_MOTIF |
1210 | else if ( style == "Motif" ) { | 1210 | else if ( style == "Motif" ) { |
1211 | setStyle( new QMotifStyle ); | 1211 | setStyle( new QMotifStyle ); |
1212 | } | 1212 | } |
1213 | #endif | 1213 | #endif |
1214 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1214 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1215 | else if ( style == "MotifPlus" ) { | 1215 | else if ( style == "MotifPlus" ) { |
1216 | setStyle( new QMotifPlusStyle ); | 1216 | setStyle( new QMotifPlusStyle ); |
1217 | } | 1217 | } |
1218 | #endif | 1218 | #endif |
1219 | 1219 | ||
1220 | else { | 1220 | else { |
1221 | QStyle *sty = 0; | 1221 | QStyle *sty = 0; |
1222 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1222 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1223 | 1223 | ||
1224 | if ( style. find ( ".so" ) > 0 ) | 1224 | if ( style. find ( ".so" ) > 0 ) |
1225 | path += style; | 1225 | path += style; |
1226 | else | 1226 | else |
1227 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1227 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1228 | 1228 | ||
1229 | static QLibrary *lastlib = 0; | 1229 | static QLibrary *lastlib = 0; |
1230 | static StyleInterface *lastiface = 0; | 1230 | static StyleInterface *lastiface = 0; |
1231 | 1231 | ||
1232 | QLibrary *lib = new QLibrary ( path ); | 1232 | QLibrary *lib = new QLibrary ( path ); |
1233 | StyleInterface *iface = 0; | 1233 | StyleInterface *iface = 0; |
1234 | 1234 | ||
1235 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1235 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1236 | sty = iface-> create ( ); | 1236 | sty = iface-> style ( ); |
1237 | 1237 | ||
1238 | if ( sty ) { | 1238 | if ( sty ) { |
1239 | setStyle ( sty ); | 1239 | setStyle ( sty ); |
1240 | 1240 | ||
1241 | if ( lastiface ) | 1241 | if ( lastiface ) |
1242 | lastiface-> release ( ); | 1242 | lastiface-> release ( ); |
1243 | lastiface = iface; | 1243 | lastiface = iface; |
1244 | 1244 | ||
1245 | if ( lastlib ) { | 1245 | if ( lastlib ) { |
1246 | lastlib-> unload ( ); | 1246 | lastlib-> unload ( ); |
1247 | delete lastlib; | 1247 | delete lastlib; |
1248 | } | 1248 | } |
1249 | lastlib = lib; | 1249 | lastlib = lib; |
1250 | } | 1250 | } |
1251 | else { | 1251 | else { |
1252 | if ( iface ) | 1252 | if ( iface ) |
1253 | iface-> release ( ); | 1253 | iface-> release ( ); |
1254 | delete lib; | 1254 | delete lib; |
1255 | 1255 | ||
1256 | setStyle ( new QPEStyle ( )); | 1256 | setStyle ( new QPEStyle ( )); |
1257 | } | 1257 | } |
1258 | } | 1258 | } |
1259 | #endif | 1259 | #endif |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | /*! | 1262 | /*! |
1263 | \internal | 1263 | \internal |
1264 | */ | 1264 | */ |
1265 | void QPEApplication::prepareForTermination( bool willrestart ) | 1265 | void QPEApplication::prepareForTermination( bool willrestart ) |
1266 | { | 1266 | { |
1267 | if ( willrestart ) { | 1267 | if ( willrestart ) { |
1268 | // Draw a big wait icon, the image can be altered in later revisions | 1268 | // Draw a big wait icon, the image can be altered in later revisions |
1269 | // QWidget *d = QApplication::desktop(); | 1269 | // QWidget *d = QApplication::desktop(); |
1270 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1270 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1271 | QPixmap pix; | 1271 | QPixmap pix; |
1272 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1272 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1273 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1273 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1274 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1274 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1275 | lblWait->setPixmap( pix ); | 1275 | lblWait->setPixmap( pix ); |
1276 | lblWait->setAlignment( QWidget::AlignCenter ); | 1276 | lblWait->setAlignment( QWidget::AlignCenter ); |
1277 | lblWait->show(); | 1277 | lblWait->show(); |
1278 | lblWait->showMaximized(); | 1278 | lblWait->showMaximized(); |
1279 | } | 1279 | } |
1280 | #ifndef SINGLE_APP | 1280 | #ifndef SINGLE_APP |
1281 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1281 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1282 | } | 1282 | } |
1283 | processEvents(); // ensure the message goes out. | 1283 | processEvents(); // ensure the message goes out. |
1284 | sleep( 1 ); // You have 1 second to comply. | 1284 | sleep( 1 ); // You have 1 second to comply. |
1285 | #endif | 1285 | #endif |
1286 | } | 1286 | } |
1287 | 1287 | ||
1288 | /*! | 1288 | /*! |
1289 | \internal | 1289 | \internal |
1290 | */ | 1290 | */ |
1291 | void QPEApplication::shutdown() | 1291 | void QPEApplication::shutdown() |
1292 | { | 1292 | { |
1293 | // Implement in server's QPEApplication subclass | 1293 | // Implement in server's QPEApplication subclass |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | /*! | 1296 | /*! |
1297 | \internal | 1297 | \internal |
1298 | */ | 1298 | */ |
1299 | void QPEApplication::restart() | 1299 | void QPEApplication::restart() |
1300 | { | 1300 | { |
1301 | // Implement in server's QPEApplication subclass | 1301 | // Implement in server's QPEApplication subclass |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | static QPtrDict<void>* stylusDict = 0; | 1304 | static QPtrDict<void>* stylusDict = 0; |
1305 | static void createDict() | 1305 | static void createDict() |
1306 | { | 1306 | { |
1307 | if ( !stylusDict ) | 1307 | if ( !stylusDict ) |
1308 | stylusDict = new QPtrDict<void>; | 1308 | stylusDict = new QPtrDict<void>; |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | /*! | 1311 | /*! |
1312 | Returns the current StylusMode for widget \a w. | 1312 | Returns the current StylusMode for widget \a w. |
1313 | 1313 | ||
1314 | \sa setStylusOperation() StylusMode | 1314 | \sa setStylusOperation() StylusMode |
1315 | */ | 1315 | */ |
1316 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1316 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1317 | { | 1317 | { |
1318 | if ( stylusDict ) | 1318 | if ( stylusDict ) |
1319 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1319 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1320 | return LeftOnly; | 1320 | return LeftOnly; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | /*! | 1323 | /*! |
1324 | \enum QPEApplication::StylusMode | 1324 | \enum QPEApplication::StylusMode |
1325 | 1325 | ||
1326 | \value LeftOnly the stylus only generates LeftButton | 1326 | \value LeftOnly the stylus only generates LeftButton |
1327 | events (the default). | 1327 | events (the default). |
1328 | \value RightOnHold the stylus generates RightButton events | 1328 | \value RightOnHold the stylus generates RightButton events |
1329 | if the user uses the press-and-hold gesture. | 1329 | if the user uses the press-and-hold gesture. |
1330 | 1330 | ||
1331 | \sa setStylusOperation() stylusOperation() | 1331 | \sa setStylusOperation() stylusOperation() |
1332 | */ | 1332 | */ |
1333 | 1333 | ||
1334 | /*! | 1334 | /*! |
1335 | Causes widget \a w to receive mouse events according to the stylus | 1335 | Causes widget \a w to receive mouse events according to the stylus |
1336 | \a mode. | 1336 | \a mode. |
1337 | 1337 | ||
1338 | \sa stylusOperation() StylusMode | 1338 | \sa stylusOperation() StylusMode |
1339 | */ | 1339 | */ |
1340 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1340 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1341 | { | 1341 | { |
1342 | createDict(); | 1342 | createDict(); |
1343 | if ( mode == LeftOnly ) { | 1343 | if ( mode == LeftOnly ) { |
1344 | stylusDict->remove | 1344 | stylusDict->remove |
1345 | ( w ); | 1345 | ( w ); |
1346 | w->removeEventFilter( qApp ); | 1346 | w->removeEventFilter( qApp ); |
1347 | } | 1347 | } |
1348 | else { | 1348 | else { |
1349 | stylusDict->insert( w, ( void* ) mode ); | 1349 | stylusDict->insert( w, ( void* ) mode ); |
1350 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1350 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1351 | w->installEventFilter( qApp ); | 1351 | w->installEventFilter( qApp ); |
1352 | } | 1352 | } |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | 1355 | ||
1356 | /*! | 1356 | /*! |
1357 | \reimp | 1357 | \reimp |
1358 | */ | 1358 | */ |
1359 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1359 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1360 | { | 1360 | { |
1361 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1361 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1362 | QMouseEvent * me = ( QMouseEvent* ) e; | 1362 | QMouseEvent * me = ( QMouseEvent* ) e; |
1363 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1363 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1364 | switch (mode) { | 1364 | switch (mode) { |
1365 | case RightOnHold: | 1365 | case RightOnHold: |
1366 | switch ( me->type() ) { | 1366 | switch ( me->type() ) { |
1367 | case QEvent::MouseButtonPress: | 1367 | case QEvent::MouseButtonPress: |
1368 | if ( me->button() == LeftButton ) { | 1368 | if ( me->button() == LeftButton ) { |
1369 | d->presstimer = startTimer(500); // #### pref. | 1369 | d->presstimer = startTimer(500); // #### pref. |
1370 | d->presswidget = (QWidget*)o; | 1370 | d->presswidget = (QWidget*)o; |
1371 | d->presspos = me->pos(); | 1371 | d->presspos = me->pos(); |
1372 | d->rightpressed = FALSE; | 1372 | d->rightpressed = FALSE; |
1373 | } | 1373 | } |
1374 | break; | 1374 | break; |
1375 | case QEvent::MouseMove: | 1375 | case QEvent::MouseMove: |
1376 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { | 1376 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { |
1377 | killTimer(d->presstimer); | 1377 | killTimer(d->presstimer); |
1378 | d->presstimer = 0; | 1378 | d->presstimer = 0; |
1379 | } | 1379 | } |
1380 | break; | 1380 | break; |
1381 | case QEvent::MouseButtonRelease: | 1381 | case QEvent::MouseButtonRelease: |
1382 | if ( me->button() == LeftButton ) { | 1382 | if ( me->button() == LeftButton ) { |
1383 | if ( d->presstimer ) { | 1383 | if ( d->presstimer ) { |
1384 | killTimer(d->presstimer); | 1384 | killTimer(d->presstimer); |
1385 | d->presstimer = 0; | 1385 | d->presstimer = 0; |
1386 | } | 1386 | } |
1387 | if ( d->rightpressed && d->presswidget ) { | 1387 | if ( d->rightpressed && d->presswidget ) { |
1388 | // Right released | 1388 | // Right released |
1389 | postEvent( d->presswidget, | 1389 | postEvent( d->presswidget, |
1390 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1390 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1391 | RightButton, LeftButton+RightButton ) ); | 1391 | RightButton, LeftButton+RightButton ) ); |
1392 | // Left released, off-widget | 1392 | // Left released, off-widget |
1393 | postEvent( d->presswidget, | 1393 | postEvent( d->presswidget, |
1394 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1394 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1395 | LeftButton, LeftButton ) ); | 1395 | LeftButton, LeftButton ) ); |
1396 | postEvent( d->presswidget, | 1396 | postEvent( d->presswidget, |
1397 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1397 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1398 | LeftButton, LeftButton ) ); | 1398 | LeftButton, LeftButton ) ); |
1399 | d->rightpressed = FALSE; | 1399 | d->rightpressed = FALSE; |
1400 | return TRUE; // don't send the real Left release | 1400 | return TRUE; // don't send the real Left release |
1401 | } | 1401 | } |
1402 | } | 1402 | } |
1403 | break; | 1403 | break; |
1404 | default: | 1404 | default: |
1405 | break; | 1405 | break; |
1406 | } | 1406 | } |
1407 | break; | 1407 | break; |
1408 | default: | 1408 | default: |
1409 | ; | 1409 | ; |
1410 | } | 1410 | } |
1411 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1411 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1412 | QKeyEvent *ke = (QKeyEvent *)e; | 1412 | QKeyEvent *ke = (QKeyEvent *)e; |
1413 | if ( ke->key() == Key_Enter ) { | 1413 | if ( ke->key() == Key_Enter ) { |
1414 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1414 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1415 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1415 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1416 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1416 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1417 | return TRUE; | 1417 | return TRUE; |
1418 | } | 1418 | } |
1419 | } | 1419 | } |
1420 | } | 1420 | } |
1421 | return FALSE; | 1421 | return FALSE; |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | /*! | 1424 | /*! |
1425 | \reimp | 1425 | \reimp |
1426 | */ | 1426 | */ |
1427 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1427 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1428 | { | 1428 | { |
1429 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1429 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1430 | // Right pressed | 1430 | // Right pressed |
1431 | postEvent( d->presswidget, | 1431 | postEvent( d->presswidget, |
1432 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1432 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1433 | RightButton, LeftButton ) ); | 1433 | RightButton, LeftButton ) ); |
1434 | killTimer( d->presstimer ); | 1434 | killTimer( d->presstimer ); |
1435 | d->presstimer = 0; | 1435 | d->presstimer = 0; |
1436 | d->rightpressed = TRUE; | 1436 | d->rightpressed = TRUE; |
1437 | } | 1437 | } |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | void QPEApplication::removeSenderFromStylusDict() | 1440 | void QPEApplication::removeSenderFromStylusDict() |
1441 | { | 1441 | { |
1442 | stylusDict->remove | 1442 | stylusDict->remove |
1443 | ( ( void* ) sender() ); | 1443 | ( ( void* ) sender() ); |
1444 | if ( d->presswidget == sender() ) | 1444 | if ( d->presswidget == sender() ) |
1445 | d->presswidget = 0; | 1445 | d->presswidget = 0; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | /*! | 1448 | /*! |
1449 | \internal | 1449 | \internal |
1450 | */ | 1450 | */ |
1451 | bool QPEApplication::keyboardGrabbed() const | 1451 | bool QPEApplication::keyboardGrabbed() const |
1452 | { | 1452 | { |
1453 | return d->kbgrabber; | 1453 | return d->kbgrabber; |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | 1456 | ||
1457 | /*! | 1457 | /*! |
1458 | Reverses the effect of grabKeyboard(). This is called automatically | 1458 | Reverses the effect of grabKeyboard(). This is called automatically |
1459 | on program exit. | 1459 | on program exit. |
1460 | */ | 1460 | */ |
1461 | void QPEApplication::ungrabKeyboard() | 1461 | void QPEApplication::ungrabKeyboard() |
1462 | { | 1462 | { |
1463 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1463 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1464 | if ( d->kbgrabber == 2 ) { | 1464 | if ( d->kbgrabber == 2 ) { |
1465 | #ifndef QT_NO_COP | 1465 | #ifndef QT_NO_COP |
1466 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1466 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1467 | e << QString::null; | 1467 | e << QString::null; |
1468 | #endif | 1468 | #endif |
1469 | d->kbregrab = FALSE; | 1469 | d->kbregrab = FALSE; |
1470 | d->kbgrabber = 0; | 1470 | d->kbgrabber = 0; |
1471 | } | 1471 | } |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | /*! | 1474 | /*! |
1475 | Grabs the physical keyboard keys, e.g. the application's launching | 1475 | Grabs the physical keyboard keys, e.g. the application's launching |
1476 | keys. Instead of launching applications when these keys are pressed | 1476 | keys. Instead of launching applications when these keys are pressed |
1477 | the signals emitted are sent to this application instead. Some games | 1477 | the signals emitted are sent to this application instead. Some games |
1478 | programs take over the launch keys in this way to make interaction | 1478 | programs take over the launch keys in this way to make interaction |
1479 | easier. | 1479 | easier. |
1480 | 1480 | ||
1481 | \sa ungrabKeyboard() | 1481 | \sa ungrabKeyboard() |
1482 | */ | 1482 | */ |
1483 | void QPEApplication::grabKeyboard() | 1483 | void QPEApplication::grabKeyboard() |
1484 | { | 1484 | { |
1485 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1485 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1486 | if ( qApp->type() == QApplication::GuiServer ) | 1486 | if ( qApp->type() == QApplication::GuiServer ) |
1487 | d->kbgrabber = 0; | 1487 | d->kbgrabber = 0; |
1488 | else { | 1488 | else { |
1489 | #ifndef QT_NO_COP | 1489 | #ifndef QT_NO_COP |
1490 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1490 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1491 | e << d->appName; | 1491 | e << d->appName; |
1492 | #endif | 1492 | #endif |
1493 | d->kbgrabber = 2; // me | 1493 | d->kbgrabber = 2; // me |
1494 | } | 1494 | } |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | /*! | 1497 | /*! |
1498 | \reimp | 1498 | \reimp |
1499 | */ | 1499 | */ |
1500 | int QPEApplication::exec() | 1500 | int QPEApplication::exec() |
1501 | { | 1501 | { |
1502 | #ifndef QT_NO_COP | 1502 | #ifndef QT_NO_COP |
1503 | d->sendQCopQ(); | 1503 | d->sendQCopQ(); |
1504 | #endif | 1504 | #endif |
1505 | if ( d->keep_running ) | 1505 | if ( d->keep_running ) |
1506 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1506 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1507 | return QApplication::exec(); | 1507 | return QApplication::exec(); |
1508 | 1508 | ||
1509 | #ifndef QT_NO_COP | 1509 | #ifndef QT_NO_COP |
1510 | { | 1510 | { |
1511 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1511 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1512 | e << d->appName; | 1512 | e << d->appName; |
1513 | } | 1513 | } |
1514 | #endif | 1514 | #endif |
1515 | processEvents(); | 1515 | processEvents(); |
1516 | return 0; | 1516 | return 0; |
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | /*! | 1519 | /*! |
1520 | \internal | 1520 | \internal |
1521 | External request for application to quit. Quits if possible without | 1521 | External request for application to quit. Quits if possible without |
1522 | loosing state. | 1522 | loosing state. |
1523 | */ | 1523 | */ |
1524 | void QPEApplication::tryQuit() | 1524 | void QPEApplication::tryQuit() |
1525 | { | 1525 | { |
1526 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1526 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1527 | return ; // Inside modal loop or konsole. Too hard to save state. | 1527 | return ; // Inside modal loop or konsole. Too hard to save state. |
1528 | #ifndef QT_NO_COP | 1528 | #ifndef QT_NO_COP |
1529 | { | 1529 | { |
1530 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1530 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1531 | e << d->appName; | 1531 | e << d->appName; |
1532 | } | 1532 | } |
1533 | #endif | 1533 | #endif |
1534 | processEvents(); | 1534 | processEvents(); |
1535 | 1535 | ||
1536 | quit(); | 1536 | quit(); |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | /*! | 1539 | /*! |
1540 | \internal | 1540 | \internal |
1541 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1541 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1542 | hiding the window. If not it means quitting the application. | 1542 | hiding the window. If not it means quitting the application. |
1543 | As this is user initiated we don't need to check state. | 1543 | As this is user initiated we don't need to check state. |
1544 | */ | 1544 | */ |
1545 | void QPEApplication::hideOrQuit() | 1545 | void QPEApplication::hideOrQuit() |
1546 | { | 1546 | { |
1547 | processEvents(); | 1547 | processEvents(); |
1548 | 1548 | ||
1549 | // If we are a preloaded application we don't actually quit, so emit | 1549 | // If we are a preloaded application we don't actually quit, so emit |
1550 | // a System message indicating we're quasi-closing. | 1550 | // a System message indicating we're quasi-closing. |
1551 | if ( d->preloaded && d->qpe_main_widget ) | 1551 | if ( d->preloaded && d->qpe_main_widget ) |
1552 | #ifndef QT_NO_COP | 1552 | #ifndef QT_NO_COP |
1553 | { | 1553 | { |
1554 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1554 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1555 | e << d->appName; | 1555 | e << d->appName; |
1556 | d->qpe_main_widget->hide(); | 1556 | d->qpe_main_widget->hide(); |
1557 | } | 1557 | } |
1558 | #endif | 1558 | #endif |
1559 | else | 1559 | else |
1560 | quit(); | 1560 | quit(); |
1561 | } | 1561 | } |
1562 | 1562 | ||
1563 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 1563 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
1564 | 1564 | ||
1565 | // The libraries with the skiff package (and possibly others) have | 1565 | // The libraries with the skiff package (and possibly others) have |
1566 | // completely useless implementations of builtin new and delete that | 1566 | // completely useless implementations of builtin new and delete that |
1567 | // use about 50% of your CPU. Here we revert to the simple libc | 1567 | // use about 50% of your CPU. Here we revert to the simple libc |
1568 | // functions. | 1568 | // functions. |
1569 | 1569 | ||
1570 | void* operator new[]( size_t size ) | 1570 | void* operator new[]( size_t size ) |
1571 | { | 1571 | { |
1572 | return malloc( size ); | 1572 | return malloc( size ); |
1573 | } | 1573 | } |
1574 | 1574 | ||
1575 | void* operator new( size_t size ) | 1575 | void* operator new( size_t size ) |
1576 | { | 1576 | { |
1577 | return malloc( size ); | 1577 | return malloc( size ); |
1578 | } | 1578 | } |
1579 | 1579 | ||
1580 | void operator delete[]( void* p ) | 1580 | void operator delete[]( void* p ) |
1581 | { | 1581 | { |
1582 | free( p ); | 1582 | free( p ); |
1583 | } | 1583 | } |
1584 | 1584 | ||
1585 | void operator delete[]( void* p, size_t /*size*/ ) | 1585 | void operator delete[]( void* p, size_t /*size*/ ) |
1586 | { | 1586 | { |
1587 | free( p ); | 1587 | free( p ); |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | void operator delete( void* p ) | 1590 | void operator delete( void* p ) |
1591 | { | 1591 | { |
1592 | free( p ); | 1592 | free( p ); |
1593 | } | 1593 | } |
1594 | 1594 | ||
1595 | void operator delete( void* p, size_t /*size*/ ) | 1595 | void operator delete( void* p, size_t /*size*/ ) |
1596 | { | 1596 | { |
1597 | free( p ); | 1597 | free( p ); |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | #endif | 1600 | #endif |
1601 | 1601 | ||
1602 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1602 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1603 | #include <qwidgetlist.h> | 1603 | #include <qwidgetlist.h> |
1604 | #ifdef QWS | 1604 | #ifdef QWS |
1605 | #include <qgfx_qws.h> | 1605 | #include <qgfx_qws.h> |
1606 | extern QRect qt_maxWindowRect; | 1606 | extern QRect qt_maxWindowRect; |
1607 | void qt_setMaxWindowRect(const QRect& r ) | 1607 | void qt_setMaxWindowRect(const QRect& r ) |
1608 | { | 1608 | { |
1609 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1609 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1610 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1610 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
1611 | // Re-resize any maximized windows | 1611 | // Re-resize any maximized windows |
1612 | QWidgetList* l = QApplication::topLevelWidgets(); | 1612 | QWidgetList* l = QApplication::topLevelWidgets(); |
1613 | if ( l ) { | 1613 | if ( l ) { |
1614 | QWidget * w = l->first(); | 1614 | QWidget * w = l->first(); |
1615 | while ( w ) { | 1615 | while ( w ) { |
1616 | if ( w->isVisible() && w->isMaximized() ) { | 1616 | if ( w->isVisible() && w->isMaximized() ) { |
1617 | w->showMaximized(); | 1617 | w->showMaximized(); |
1618 | } | 1618 | } |
1619 | w = l->next(); | 1619 | w = l->next(); |
1620 | } | 1620 | } |
1621 | delete l; | 1621 | delete l; |
1622 | } | 1622 | } |
1623 | } | 1623 | } |
1624 | #endif | 1624 | #endif |
1625 | #endif | 1625 | #endif |
diff --git a/library/styleinterface.h b/library/styleinterface.h index 9fea636..b50f239 100644 --- a/library/styleinterface.h +++ b/library/styleinterface.h | |||
@@ -1,68 +1,67 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Robert Griebl. All rights reserved. | 2 | ** Copyright (C) 2002 Robert Griebl. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of OPIE (http://www.opie.info). | 4 | ** This file is part of OPIE (http://www.opie.info). |
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 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef STYLEINTERFACE_H | 16 | #ifndef STYLEINTERFACE_H |
17 | #define STYLEINTERFACE_H | 17 | #define STYLEINTERFACE_H |
18 | 18 | ||
19 | #include <qpe/qcom.h> | 19 | #include <qpe/qcom.h> |
20 | 20 | ||
21 | #ifndef QT_NO_COMPONENT | 21 | #ifndef QT_NO_COMPONENT |
22 | 22 | ||
23 | // {6C33B4F9-D529-453A-8FB3-DA42B21872BD} | 23 | // {17AF792C-E461-49A9-9B71-068B9A8DDAE4} |
24 | # ifndef IID_Style | 24 | #ifndef IID_Style |
25 | # define IID_Style QUuid( 0x6c33b4f9, 0xd529, 0x453a, 0x8f, 0xb3, 0xda, 0x42, 0xb2, 0x18, 0x72, 0xbd) | 25 | #define IID_Style QUuid( 0x17af792c, 0xe461, 0x49a9, 0x9b, 0x71, 0x06, 0x8b, 0x9a, 0x8d, 0xda, 0xe4) |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | // {9757A252-3FD4-438F-A756-80BE4A9FB8DC} | 28 | // {6C33B4F9-D529-453A-8FB3-DA42B21872BD} |
29 | # ifndef IID_StyleSettings | 29 | # ifndef IID_StyleExtended |
30 | # define IID_StyleSettings QUuid( 0x9757a252, 0x3fd4, 0x438f, 0xa7, 0x56, 0x80, 0xbe, 0x4a, 0x9f, 0xb8, 0xdc) | 30 | # define IID_StyleExtended QUuid( 0x6c33b4f9, 0xd529, 0x453a, 0x8f, 0xb3, 0xda, 0x42, 0xb2, 0x18, 0x72, 0xbd) |
31 | # endif | 31 | #endif |
32 | 32 | ||
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class QWidget; | 35 | class QWidget; |
36 | class QStyle; | 36 | class QStyle; |
37 | 37 | ||
38 | |||
39 | class QStyle; | ||
40 | |||
38 | struct StyleInterface : public QUnknownInterface | 41 | struct StyleInterface : public QUnknownInterface |
39 | { | 42 | { |
40 | //! Return a new style. | 43 | //! Return a new style. |
41 | virtual QStyle *create ( ) = 0; | 44 | virtual QStyle *style() = 0; |
42 | |||
43 | //! Return a (longer) description for the style. | ||
44 | virtual QString description ( ) = 0; | ||
45 | |||
46 | //! Return a short name for the style. | 45 | //! Return a short name for the style. |
47 | virtual QString name ( ) = 0; | 46 | virtual QString name() const = 0; |
48 | |||
49 | //! Return the library basename (libliquid.so => liquid) | ||
50 | virtual QCString key ( ) = 0; | ||
51 | |||
52 | //! QT_VERSION like 1.2.3 == 123 | ||
53 | virtual unsigned int version ( ) = 0; | ||
54 | }; | 47 | }; |
55 | 48 | ||
56 | struct StyleSettingsInterface : public QUnknownInterface | 49 | struct StyleExtendedInterface : public StyleInterface |
57 | { | 50 | { |
51 | //! Return a (longer) description for the style. | ||
52 | virtual QString description ( ) = 0; | ||
53 | |||
54 | //! Does this style support customization | ||
55 | virtual bool hasSettings ( ) const = 0; | ||
56 | |||
58 | //! Return a new settings page. | 57 | //! Return a new settings page. |
59 | virtual QWidget *create ( QWidget *parent, const char *name = 0 ) = 0; | 58 | virtual QWidget *create ( QWidget *parent, const char *name = 0 ) = 0; |
60 | 59 | ||
61 | //! Callback for appearance app when OK is clicked (return true when style has to re-applied). | 60 | //! Callback for appearance app when OK is clicked (return true when style has to re-applied). |
62 | virtual bool accept ( ) = 0; | 61 | virtual bool accept ( ) = 0; |
63 | 62 | ||
64 | //! Callback for appeaeance app when Cancel is clicked. | 63 | //! Callback for appeaeance app when Cancel is clicked. |
65 | virtual void reject ( ) = 0; | 64 | virtual void reject ( ) = 0; |
66 | }; | 65 | }; |
67 | 66 | ||
68 | #endif | 67 | #endif |