-rw-r--r-- | library/applnk.cpp | 6 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 5 | ||||
-rw-r--r-- | library/qpeapplication.h | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index c82d3b9..874a1b6 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -496,387 +496,389 @@ const QPixmap& AppLnk::pixmap() const | |||
496 | { | 496 | { |
497 | if ( d->mPixmaps[0].isNull() ) { | 497 | if ( d->mPixmaps[0].isNull() ) { |
498 | return pixmap(AppLnkPrivate::Normal, smallSize ); | 498 | return pixmap(AppLnkPrivate::Normal, smallSize ); |
499 | } | 499 | } |
500 | return d->mPixmaps[0]; | 500 | return d->mPixmaps[0]; |
501 | } | 501 | } |
502 | 502 | ||
503 | /*! | 503 | /*! |
504 | Returns a large pixmap associated with the application. | 504 | Returns a large pixmap associated with the application. |
505 | 505 | ||
506 | \sa pixmap() setIcon() | 506 | \sa pixmap() setIcon() |
507 | */ | 507 | */ |
508 | const QPixmap& AppLnk::bigPixmap() const | 508 | const QPixmap& AppLnk::bigPixmap() const |
509 | { | 509 | { |
510 | if ( d->mPixmaps[1].isNull() ) { | 510 | if ( d->mPixmaps[1].isNull() ) { |
511 | return pixmap( AppLnkPrivate::Big, bigSize ); | 511 | return pixmap( AppLnkPrivate::Big, bigSize ); |
512 | } | 512 | } |
513 | return d->mPixmaps[1]; | 513 | return d->mPixmaps[1]; |
514 | } | 514 | } |
515 | 515 | ||
516 | /*! | 516 | /*! |
517 | Returns the type of the AppLnk. For applications, games and | 517 | Returns the type of the AppLnk. For applications, games and |
518 | settings the type is \c Application; for documents the type is the | 518 | settings the type is \c Application; for documents the type is the |
519 | document's MIME type. | 519 | document's MIME type. |
520 | */ | 520 | */ |
521 | QString AppLnk::type() const | 521 | QString AppLnk::type() const |
522 | { | 522 | { |
523 | if ( mType.isNull() ) { | 523 | if ( mType.isNull() ) { |
524 | AppLnk* that = (AppLnk*)this; | 524 | AppLnk* that = (AppLnk*)this; |
525 | QString f = file(); | 525 | QString f = file(); |
526 | if ( !f.isNull() ) { | 526 | if ( !f.isNull() ) { |
527 | MimeType mt(f); | 527 | MimeType mt(f); |
528 | that->mType = mt.id(); | 528 | that->mType = mt.id(); |
529 | return that->mType; | 529 | return that->mType; |
530 | } | 530 | } |
531 | } | 531 | } |
532 | return mType; | 532 | return mType; |
533 | } | 533 | } |
534 | 534 | ||
535 | /*! | 535 | /*! |
536 | Returns the file associated with the AppLnk. | 536 | Returns the file associated with the AppLnk. |
537 | 537 | ||
538 | \sa exec() name() | 538 | \sa exec() name() |
539 | */ | 539 | */ |
540 | QString AppLnk::file() const | 540 | QString AppLnk::file() const |
541 | { | 541 | { |
542 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { | 542 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { |
543 | AppLnk* that = (AppLnk*)this; | 543 | AppLnk* that = (AppLnk*)this; |
544 | QString ext = MimeType(mType).extension(); | 544 | QString ext = MimeType(mType).extension(); |
545 | if ( !ext.isEmpty() ) | 545 | if ( !ext.isEmpty() ) |
546 | ext = "." + ext; | 546 | ext = "." + ext; |
547 | if ( !mLinkFile.isEmpty() ) { | 547 | if ( !mLinkFile.isEmpty() ) { |
548 | that->mFile = | 548 | that->mFile = |
549 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 549 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
550 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 550 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
551 | qDebug("mFile now == %s", mFile.latin1()); | 551 | qDebug("mFile now == %s", mFile.latin1()); |
552 | } else if ( mType.contains('/') ) { | 552 | } else if ( mType.contains('/') ) { |
553 | that->mFile = | 553 | that->mFile = |
554 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 554 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
555 | /* | 555 | /* |
556 | * A file with the same name or a .desktop file already exists | 556 | * A file with the same name or a .desktop file already exists |
557 | */ | 557 | */ |
558 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { | 558 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { |
559 | int n=1; | 559 | int n=1; |
560 | QString nn; | 560 | QString nn; |
561 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 561 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
562 | || QFile::exists(nn+".desktop")) | 562 | || QFile::exists(nn+".desktop")) |
563 | n++; | 563 | n++; |
564 | that->mFile = nn; | 564 | that->mFile = nn; |
565 | } | 565 | } |
566 | that->mLinkFile = that->mFile+".desktop"; | 566 | that->mLinkFile = that->mFile+".desktop"; |
567 | that->mFile += ext; | 567 | that->mFile += ext; |
568 | } | 568 | } |
569 | prepareDirectories(that->mFile); | 569 | prepareDirectories(that->mFile); |
570 | if ( !that->mFile.isEmpty() ) { | 570 | if ( !that->mFile.isEmpty() ) { |
571 | QFile f(that->mFile); | 571 | QFile f(that->mFile); |
572 | if ( !f.open(IO_WriteOnly) ) | 572 | if ( !f.open(IO_WriteOnly) ) |
573 | that->mFile = QString::null; | 573 | that->mFile = QString::null; |
574 | return that->mFile; | 574 | return that->mFile; |
575 | } | 575 | } |
576 | } | 576 | } |
577 | return mFile; | 577 | return mFile; |
578 | } | 578 | } |
579 | 579 | ||
580 | /*! | 580 | /*! |
581 | Returns the desktop file corresponding to this AppLnk. | 581 | Returns the desktop file corresponding to this AppLnk. |
582 | 582 | ||
583 | \sa file() exec() name() | 583 | \sa file() exec() name() |
584 | */ | 584 | */ |
585 | QString AppLnk::linkFile() const | 585 | QString AppLnk::linkFile() const |
586 | { | 586 | { |
587 | if ( mLinkFile.isNull() ) { | 587 | if ( mLinkFile.isNull() ) { |
588 | AppLnk* that = (AppLnk*)this; | 588 | AppLnk* that = (AppLnk*)this; |
589 | if ( type().contains('/') ) { | 589 | if ( type().contains('/') ) { |
590 | StorageInfo storage; | 590 | StorageInfo storage; |
591 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 591 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
592 | /* tmpfs + and ramfs are available too but not removable | 592 | /* tmpfs + and ramfs are available too but not removable |
593 | * either we fix storage or add this | 593 | * either we fix storage or add this |
594 | */ | 594 | */ |
595 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { | 595 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { |
596 | that->mLinkFile = fs->path(); | 596 | that->mLinkFile = fs->path(); |
597 | } else | 597 | } else |
598 | that->mLinkFile = getenv( "HOME" ); | 598 | that->mLinkFile = getenv( "HOME" ); |
599 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 599 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
600 | 600 | ||
601 | /* the desktop file exists make sure we don't point to the same file */ | 601 | /* the desktop file exists make sure we don't point to the same file */ |
602 | if ( QFile::exists(that->mLinkFile+".desktop") ) { | 602 | if ( QFile::exists(that->mLinkFile+".desktop") ) { |
603 | AppLnk lnk( that->mLinkFile + ".desktop" ); | 603 | AppLnk lnk( that->mLinkFile + ".desktop" ); |
604 | 604 | ||
605 | /* the linked is different */ | 605 | /* the linked is different */ |
606 | if(that->file() != lnk.file() ) { | 606 | if(that->file() != lnk.file() ) { |
607 | int n = 1; | 607 | int n = 1; |
608 | QString nn; | 608 | QString nn; |
609 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")) { | 609 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")) { |
610 | n++; | 610 | n++; |
611 | /* just to be sure */ | 611 | /* just to be sure */ |
612 | AppLnk lnk(nn ); | 612 | AppLnk lnk(nn ); |
613 | if (lnk.file() == that->file() ) | 613 | if (lnk.file() == that->file() ) |
614 | break; | 614 | break; |
615 | } | 615 | } |
616 | that->mLinkFile = nn; | 616 | that->mLinkFile = nn; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | that->mLinkFile += ".desktop"; | 619 | that->mLinkFile += ".desktop"; |
620 | storeLink(); | 620 | storeLink(); |
621 | } | 621 | } |
622 | return that->mLinkFile; | 622 | return that->mLinkFile; |
623 | } | 623 | } |
624 | return mLinkFile; | 624 | return mLinkFile; |
625 | } | 625 | } |
626 | 626 | ||
627 | /*! | 627 | /*! |
628 | Copies \a copy. | 628 | Copies \a copy. |
629 | */ | 629 | */ |
630 | AppLnk::AppLnk( const AppLnk © ) | 630 | AppLnk::AppLnk( const AppLnk © ) |
631 | { | 631 | { |
632 | mName = copy.mName; | 632 | mName = copy.mName; |
633 | mPixmap = copy.mPixmap; | 633 | mPixmap = copy.mPixmap; |
634 | mBigPixmap = copy.mBigPixmap; | 634 | mBigPixmap = copy.mBigPixmap; |
635 | mExec = copy.mExec; | 635 | mExec = copy.mExec; |
636 | mType = copy.mType; | 636 | mType = copy.mType; |
637 | mRotation = copy.mRotation; | 637 | mRotation = copy.mRotation; |
638 | mComment = copy.mComment; | 638 | mComment = copy.mComment; |
639 | mFile = copy.mFile; | 639 | mFile = copy.mFile; |
640 | mLinkFile = copy.mLinkFile; | 640 | mLinkFile = copy.mLinkFile; |
641 | mIconFile = copy.mIconFile; | 641 | mIconFile = copy.mIconFile; |
642 | mMimeTypes = copy.mMimeTypes; | 642 | mMimeTypes = copy.mMimeTypes; |
643 | mMimeTypeIcons = copy.mMimeTypeIcons; | 643 | mMimeTypeIcons = copy.mMimeTypeIcons; |
644 | mId = 0; | 644 | mId = 0; |
645 | d = new AppLnkPrivate(); | 645 | d = new AppLnkPrivate(); |
646 | d->mCat = copy.d->mCat; | 646 | d->mCat = copy.d->mCat; |
647 | d->mCatList = copy.d->mCatList; | 647 | d->mCatList = copy.d->mCatList; |
648 | d->mPixmaps = copy.d->mPixmaps; | 648 | d->mPixmaps = copy.d->mPixmaps; |
649 | } | 649 | } |
650 | 650 | ||
651 | /*! | 651 | /*! |
652 | Destroys the AppLnk. Note that if the AppLnk is currently a member | 652 | Destroys the AppLnk. Note that if the AppLnk is currently a member |
653 | of an AppLnkSet, this will produce a run-time warning. | 653 | of an AppLnkSet, this will produce a run-time warning. |
654 | 654 | ||
655 | \sa AppLnkSet::add() AppLnkSet::remove() | 655 | \sa AppLnkSet::add() AppLnkSet::remove() |
656 | */ | 656 | */ |
657 | AppLnk::~AppLnk() | 657 | AppLnk::~AppLnk() |
658 | { | 658 | { |
659 | if ( mId ) | 659 | if ( mId ) |
660 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 660 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
661 | if ( d ) | 661 | if ( d ) |
662 | delete d; | 662 | delete d; |
663 | } | 663 | } |
664 | 664 | ||
665 | /*! | 665 | /*! |
666 | \overload | 666 | \overload |
667 | Executes the application associated with this AppLnk. | 667 | Executes the application associated with this AppLnk. |
668 | 668 | ||
669 | \sa exec() | 669 | \sa exec() |
670 | */ | 670 | */ |
671 | void AppLnk::execute() const | 671 | void AppLnk::execute() const |
672 | { | 672 | { |
673 | execute( QStringList::split( ' ', property( "Arguments" ) ) ); | 673 | execute( QStringList::split( ' ', property( "Arguments" ) ) ); |
674 | } | 674 | } |
675 | 675 | ||
676 | /*! | 676 | /*! |
677 | Executes the application associated with this AppLnk, with | 677 | Executes the application associated with this AppLnk, with |
678 | \a args as arguments. | 678 | \a args as arguments. |
679 | 679 | ||
680 | \sa exec() | 680 | \sa exec() |
681 | */ | 681 | */ |
682 | void AppLnk::execute(const QStringList& args) const | 682 | void AppLnk::execute(const QStringList& args) const |
683 | { | 683 | { |
684 | #ifdef Q_WS_QWS | 684 | #ifdef Q_WS_QWS |
685 | if ( !mRotation.isEmpty() ) { | 685 | if ( !mRotation.isEmpty() ) { |
686 | // ######## this will only work in the server | 686 | // ######## this will only work in the server |
687 | int rot = QPEApplication::defaultRotation(); | 687 | int rot = QPEApplication::defaultRotation(); |
688 | int j = 0; | ||
688 | rot = (rot+mRotation.toInt())%360; | 689 | rot = (rot+mRotation.toInt())%360; |
689 | QCString old = getenv("QWS_DISPLAY"); | 690 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; |
690 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 691 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); |
692 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( rot ), 1 ); | ||
691 | invoke(args); | 693 | invoke(args); |
692 | setenv("QWS_DISPLAY", old.data(), 1); | 694 | setenv("QWS_DISPLAY", old.data(), 1); |
693 | } else | 695 | } else |
694 | #endif | 696 | #endif |
695 | invoke(args); | 697 | invoke(args); |
696 | } | 698 | } |
697 | 699 | ||
698 | /*! | 700 | /*! |
699 | Invokes the application associated with this AppLnk, with | 701 | Invokes the application associated with this AppLnk, with |
700 | \a args as arguments. Rotation is not taken into account by | 702 | \a args as arguments. Rotation is not taken into account by |
701 | this function, so you should not call it directly. | 703 | this function, so you should not call it directly. |
702 | 704 | ||
703 | \sa execute() | 705 | \sa execute() |
704 | */ | 706 | */ |
705 | void AppLnk::invoke(const QStringList& args) const | 707 | void AppLnk::invoke(const QStringList& args) const |
706 | { | 708 | { |
707 | if ( property( "Arguments" ).isEmpty() ) | 709 | if ( property( "Arguments" ).isEmpty() ) |
708 | Global::execute( exec(), args[0] ); | 710 | Global::execute( exec(), args[0] ); |
709 | else | 711 | else |
710 | Global::execute( exec(), args.join( " " ) ); | 712 | Global::execute( exec(), args.join( " " ) ); |
711 | } | 713 | } |
712 | 714 | ||
713 | /*! | 715 | /*! |
714 | Sets the Exec property to \a exec. | 716 | Sets the Exec property to \a exec. |
715 | 717 | ||
716 | \sa exec() name() | 718 | \sa exec() name() |
717 | */ | 719 | */ |
718 | void AppLnk::setExec( const QString& exec ) | 720 | void AppLnk::setExec( const QString& exec ) |
719 | { | 721 | { |
720 | mExec = exec; | 722 | mExec = exec; |
721 | } | 723 | } |
722 | 724 | ||
723 | #if 0 // this was inlined for better BC | 725 | #if 0 // this was inlined for better BC |
724 | /*! | 726 | /*! |
725 | Sets the Rotation property to \a rot. | 727 | Sets the Rotation property to \a rot. |
726 | 728 | ||
727 | \sa rotation() | 729 | \sa rotation() |
728 | */ | 730 | */ |
729 | void AppLnk::setRotation ( const QString &rot ) | 731 | void AppLnk::setRotation ( const QString &rot ) |
730 | { | 732 | { |
731 | mRotation = rot; | 733 | mRotation = rot; |
732 | } | 734 | } |
733 | #endif | 735 | #endif |
734 | 736 | ||
735 | /*! | 737 | /*! |
736 | Sets the Name property to \a docname. | 738 | Sets the Name property to \a docname. |
737 | 739 | ||
738 | \sa name() | 740 | \sa name() |
739 | */ | 741 | */ |
740 | void AppLnk::setName( const QString& docname ) | 742 | void AppLnk::setName( const QString& docname ) |
741 | { | 743 | { |
742 | mName = docname; | 744 | mName = docname; |
743 | } | 745 | } |
744 | 746 | ||
745 | /*! | 747 | /*! |
746 | Sets the File property to \a filename. | 748 | Sets the File property to \a filename. |
747 | 749 | ||
748 | \sa file() name() | 750 | \sa file() name() |
749 | */ | 751 | */ |
750 | void AppLnk::setFile( const QString& filename ) | 752 | void AppLnk::setFile( const QString& filename ) |
751 | { | 753 | { |
752 | mFile = filename; | 754 | mFile = filename; |
753 | } | 755 | } |
754 | 756 | ||
755 | /*! | 757 | /*! |
756 | Sets the LinkFile property to \a filename. | 758 | Sets the LinkFile property to \a filename. |
757 | 759 | ||
758 | \sa linkFile() | 760 | \sa linkFile() |
759 | */ | 761 | */ |
760 | void AppLnk::setLinkFile( const QString& filename ) | 762 | void AppLnk::setLinkFile( const QString& filename ) |
761 | { | 763 | { |
762 | mLinkFile = filename; | 764 | mLinkFile = filename; |
763 | } | 765 | } |
764 | 766 | ||
765 | /*! | 767 | /*! |
766 | Sets the Comment property to \a comment. | 768 | Sets the Comment property to \a comment. |
767 | 769 | ||
768 | This text is displayed in the 'Details Dialog', for example if the | 770 | This text is displayed in the 'Details Dialog', for example if the |
769 | user uses the 'press-and-hold' gesture. | 771 | user uses the 'press-and-hold' gesture. |
770 | 772 | ||
771 | \sa comment() | 773 | \sa comment() |
772 | */ | 774 | */ |
773 | void AppLnk::setComment( const QString& comment ) | 775 | void AppLnk::setComment( const QString& comment ) |
774 | { | 776 | { |
775 | mComment = comment; | 777 | mComment = comment; |
776 | } | 778 | } |
777 | 779 | ||
778 | /*! | 780 | /*! |
779 | Sets the Type property to \a type. | 781 | Sets the Type property to \a type. |
780 | 782 | ||
781 | For applications, games and settings the type should be \c | 783 | For applications, games and settings the type should be \c |
782 | Application; for documents the type should be the document's MIME | 784 | Application; for documents the type should be the document's MIME |
783 | type. | 785 | type. |
784 | 786 | ||
785 | \sa type() | 787 | \sa type() |
786 | */ | 788 | */ |
787 | void AppLnk::setType( const QString& type ) | 789 | void AppLnk::setType( const QString& type ) |
788 | { | 790 | { |
789 | mType = type; | 791 | mType = type; |
790 | } | 792 | } |
791 | 793 | ||
792 | /*! | 794 | /*! |
793 | \fn QString AppLnk::icon() const | 795 | \fn QString AppLnk::icon() const |
794 | 796 | ||
795 | Returns the Icon property. | 797 | Returns the Icon property. |
796 | 798 | ||
797 | \sa setIcon() | 799 | \sa setIcon() |
798 | */ | 800 | */ |
799 | 801 | ||
800 | /*! | 802 | /*! |
801 | Sets the Icon property to \a iconname. This is the filename from | 803 | Sets the Icon property to \a iconname. This is the filename from |
802 | which the pixmap() and bigPixmap() are obtained. | 804 | which the pixmap() and bigPixmap() are obtained. |
803 | 805 | ||
804 | \sa icon() setSmallIconSize() setBigIconSize() | 806 | \sa icon() setSmallIconSize() setBigIconSize() |
805 | */ | 807 | */ |
806 | void AppLnk::setIcon( const QString& iconname ) | 808 | void AppLnk::setIcon( const QString& iconname ) |
807 | { | 809 | { |
808 | mIconFile = iconname; | 810 | mIconFile = iconname; |
809 | QImage unscaledIcon = Resource::loadImage( mIconFile ); | 811 | QImage unscaledIcon = Resource::loadImage( mIconFile ); |
810 | d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 812 | d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
811 | d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 813 | d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
812 | } | 814 | } |
813 | 815 | ||
814 | /*! | 816 | /*! |
815 | Sets the Categories property to \a c. | 817 | Sets the Categories property to \a c. |
816 | 818 | ||
817 | See the CategoryWidget for more details. | 819 | See the CategoryWidget for more details. |
818 | 820 | ||
819 | \sa categories() | 821 | \sa categories() |
820 | */ | 822 | */ |
821 | void AppLnk::setCategories( const QArray<int>& c ) | 823 | void AppLnk::setCategories( const QArray<int>& c ) |
822 | { | 824 | { |
823 | d->mCat = c; | 825 | d->mCat = c; |
824 | d->updateCatListFromArray(); | 826 | d->updateCatListFromArray(); |
825 | } | 827 | } |
826 | 828 | ||
827 | /*! | 829 | /*! |
828 | \fn QStringList AppLnk::mimeTypeIcons() const | 830 | \fn QStringList AppLnk::mimeTypeIcons() const |
829 | 831 | ||
830 | Returns the MimeTypeIcons property of the AppLnk. | 832 | Returns the MimeTypeIcons property of the AppLnk. |
831 | */ | 833 | */ |
832 | 834 | ||
833 | /*! | 835 | /*! |
834 | Attempts to ensure that the link file for this AppLnk exists, | 836 | Attempts to ensure that the link file for this AppLnk exists, |
835 | including creating any required directories. Returns TRUE if | 837 | including creating any required directories. Returns TRUE if |
836 | successful; otherwise returns FALSE. | 838 | successful; otherwise returns FALSE. |
837 | 839 | ||
838 | You should not need to use this function. | 840 | You should not need to use this function. |
839 | */ | 841 | */ |
840 | bool AppLnk::ensureLinkExists() const | 842 | bool AppLnk::ensureLinkExists() const |
841 | { | 843 | { |
842 | QString lf = linkFile(); | 844 | QString lf = linkFile(); |
843 | return prepareDirectories(lf); | 845 | return prepareDirectories(lf); |
844 | } | 846 | } |
845 | 847 | ||
846 | /*! | 848 | /*! |
847 | Commits the AppLnk to disk. Returns TRUE if the operation succeeded; | 849 | Commits the AppLnk to disk. Returns TRUE if the operation succeeded; |
848 | otherwise returns FALSE. | 850 | otherwise returns FALSE. |
849 | 851 | ||
850 | In addition, the "linkChanged(QString)" message is sent to the | 852 | In addition, the "linkChanged(QString)" message is sent to the |
851 | "QPE/System" \link qcop.html QCop\endlink channel. | 853 | "QPE/System" \link qcop.html QCop\endlink channel. |
852 | */ | 854 | */ |
853 | bool AppLnk::writeLink() const | 855 | bool AppLnk::writeLink() const |
854 | { | 856 | { |
855 | // Only re-writes settable parts | 857 | // Only re-writes settable parts |
856 | QString lf = linkFile(); | 858 | QString lf = linkFile(); |
857 | if ( !ensureLinkExists() ) | 859 | if ( !ensureLinkExists() ) |
858 | return FALSE; | 860 | return FALSE; |
859 | storeLink(); | 861 | storeLink(); |
860 | return TRUE; | 862 | return TRUE; |
861 | } | 863 | } |
862 | 864 | ||
863 | /*! | 865 | /*! |
864 | \internal | 866 | \internal |
865 | */ | 867 | */ |
866 | void AppLnk::storeLink() const | 868 | void AppLnk::storeLink() const |
867 | { | 869 | { |
868 | Config config( mLinkFile, Config::File ); | 870 | Config config( mLinkFile, Config::File ); |
869 | config.setGroup("Desktop Entry"); | 871 | config.setGroup("Desktop Entry"); |
870 | config.writeEntry("Name",mName); | 872 | config.writeEntry("Name",mName); |
871 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); | 873 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); |
872 | config.writeEntry("Type",type()); | 874 | config.writeEntry("Type",type()); |
873 | if(!rotation().isEmpty()) | 875 | if(!rotation().isEmpty()) |
874 | config.writeEntry("Rotation",rotation()); | 876 | config.writeEntry("Rotation",rotation()); |
875 | else | 877 | else |
876 | config.removeEntry("Rotation"); | 878 | config.removeEntry("Rotation"); |
877 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); | 879 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); |
878 | QString f = file(); | 880 | QString f = file(); |
879 | int i = 0; | 881 | int i = 0; |
880 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) | 882 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) |
881 | i++; | 883 | i++; |
882 | while ( i && f[i] != '/' ) | 884 | while ( i && f[i] != '/' ) |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 0f3e4a4..19e99f2 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1099,385 +1099,388 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
1099 | popup->close(); | 1099 | popup->close(); |
1100 | if ( active->inherits( "QDialog" ) ) { | 1100 | if ( active->inherits( "QDialog" ) ) { |
1101 | HackDialog * d = ( HackDialog * ) active; | 1101 | HackDialog * d = ( HackDialog * ) active; |
1102 | d->acceptIt(); | 1102 | d->acceptIt(); |
1103 | return TRUE; | 1103 | return TRUE; |
1104 | } | 1104 | } |
1105 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1105 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1106 | QSignal s; | 1106 | QSignal s; |
1107 | s.connect( active, SLOT( accept() ) ); | 1107 | s.connect( active, SLOT( accept() ) ); |
1108 | s.activate(); | 1108 | s.activate(); |
1109 | } | 1109 | } |
1110 | else { | 1110 | else { |
1111 | // do the same as with the select key: Map to the default action of the widget: | 1111 | // do the same as with the select key: Map to the default action of the widget: |
1112 | mapToDefaultAction( ke, Qt::Key_Return ); | 1112 | mapToDefaultAction( ke, Qt::Key_Return ); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1117 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1118 | // Use special "select" key to do whatever default action a widget has | 1118 | // Use special "select" key to do whatever default action a widget has |
1119 | mapToDefaultAction( ke, Qt::Key_Space ); | 1119 | mapToDefaultAction( ke, Qt::Key_Space ); |
1120 | } | 1120 | } |
1121 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1121 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1122 | ke->simpleData.is_press ) { | 1122 | ke->simpleData.is_press ) { |
1123 | // Escape key closes app if focus on toplevel | 1123 | // Escape key closes app if focus on toplevel |
1124 | QWidget * active = activeWindow(); | 1124 | QWidget * active = activeWindow(); |
1125 | if ( active && active->testWFlags( WType_TopLevel ) && | 1125 | if ( active && active->testWFlags( WType_TopLevel ) && |
1126 | ( int ) active->winId() == ke->simpleData.window && | 1126 | ( int ) active->winId() == ke->simpleData.window && |
1127 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1127 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1128 | if ( active->inherits( "QDialog" ) ) { | 1128 | if ( active->inherits( "QDialog" ) ) { |
1129 | HackDialog * d = ( HackDialog * ) active; | 1129 | HackDialog * d = ( HackDialog * ) active; |
1130 | d->rejectIt(); | 1130 | d->rejectIt(); |
1131 | return TRUE; | 1131 | return TRUE; |
1132 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1132 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1133 | active->close(); | 1133 | active->close(); |
1134 | } | 1134 | } |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | } | 1137 | } |
1138 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1138 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1139 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1139 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1140 | // but we cannot access libopie function within libqpe :( | 1140 | // but we cannot access libopie function within libqpe :( |
1141 | 1141 | ||
1142 | QWidget * active = activeWindow ( ); | 1142 | QWidget * active = activeWindow ( ); |
1143 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1143 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1144 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1144 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1145 | QChar ch ( ke-> simpleData.unicode ); | 1145 | QChar ch ( ke-> simpleData.unicode ); |
1146 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1146 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1147 | ke-> simpleData.keycode, | 1147 | ke-> simpleData.keycode, |
1148 | ch. latin1 ( ), | 1148 | ch. latin1 ( ), |
1149 | ke-> simpleData.modifiers, | 1149 | ke-> simpleData.modifiers, |
1150 | QString ( ch ), | 1150 | QString ( ch ), |
1151 | ke-> simpleData.is_auto_repeat, 1 ); | 1151 | ke-> simpleData.is_auto_repeat, 1 ); |
1152 | 1152 | ||
1153 | QObject *which = QWidget::keyboardGrabber ( ); | 1153 | QObject *which = QWidget::keyboardGrabber ( ); |
1154 | if ( !which ) | 1154 | if ( !which ) |
1155 | which = QApplication::focusWidget ( ); | 1155 | which = QApplication::focusWidget ( ); |
1156 | if ( !which ) | 1156 | if ( !which ) |
1157 | which = QApplication::activeWindow ( ); | 1157 | which = QApplication::activeWindow ( ); |
1158 | if ( !which ) | 1158 | if ( !which ) |
1159 | which = qApp; | 1159 | which = qApp; |
1160 | 1160 | ||
1161 | QApplication::sendEvent ( which, &qke ); | 1161 | QApplication::sendEvent ( which, &qke ); |
1162 | } | 1162 | } |
1163 | else { // we didn't grab the keyboard, so send the event to the launcher | 1163 | else { // we didn't grab the keyboard, so send the event to the launcher |
1164 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1164 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1165 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1165 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
1168 | return true; | 1168 | return true; |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | if ( e->type == QWSEvent::Focus ) { | 1171 | if ( e->type == QWSEvent::Focus ) { |
1172 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1172 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1173 | if ( !fe->simpleData.get_focus ) { | 1173 | if ( !fe->simpleData.get_focus ) { |
1174 | QWidget * active = activeWindow(); | 1174 | QWidget * active = activeWindow(); |
1175 | while ( active && active->isPopup() ) { | 1175 | while ( active && active->isPopup() ) { |
1176 | active->close(); | 1176 | active->close(); |
1177 | active = activeWindow(); | 1177 | active = activeWindow(); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | else { | 1180 | else { |
1181 | // make sure our modal widget is ALWAYS on top | 1181 | // make sure our modal widget is ALWAYS on top |
1182 | QWidget *topm = activeModalWidget(); | 1182 | QWidget *topm = activeModalWidget(); |
1183 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1183 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1184 | topm->raise(); | 1184 | topm->raise(); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1187 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1188 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1188 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1189 | if ( m == AlwaysOff ) | 1189 | if ( m == AlwaysOff ) |
1190 | Global::hideInputMethod(); | 1190 | Global::hideInputMethod(); |
1191 | if ( m == AlwaysOn ) | 1191 | if ( m == AlwaysOn ) |
1192 | Global::showInputMethod(); | 1192 | Global::showInputMethod(); |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | 1196 | ||
1197 | return QApplication::qwsEventFilter( e ); | 1197 | return QApplication::qwsEventFilter( e ); |
1198 | } | 1198 | } |
1199 | #endif | 1199 | #endif |
1200 | 1200 | ||
1201 | /*! | 1201 | /*! |
1202 | Destroys the QPEApplication. | 1202 | Destroys the QPEApplication. |
1203 | */ | 1203 | */ |
1204 | QPEApplication::~QPEApplication() | 1204 | QPEApplication::~QPEApplication() |
1205 | { | 1205 | { |
1206 | ungrabKeyboard(); | 1206 | ungrabKeyboard(); |
1207 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1207 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1208 | // Need to delete QCopChannels early, since the display will | 1208 | // Need to delete QCopChannels early, since the display will |
1209 | // be gone by the time we get to ~QObject(). | 1209 | // be gone by the time we get to ~QObject(). |
1210 | delete sysChannel; | 1210 | delete sysChannel; |
1211 | delete pidChannel; | 1211 | delete pidChannel; |
1212 | #endif | 1212 | #endif |
1213 | 1213 | ||
1214 | #ifdef OPIE_WITHROHFEEDBACK | 1214 | #ifdef OPIE_WITHROHFEEDBACK |
1215 | if( d->RoH ) | 1215 | if( d->RoH ) |
1216 | delete d->RoH; | 1216 | delete d->RoH; |
1217 | #endif | 1217 | #endif |
1218 | delete d; | 1218 | delete d; |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | /*! | 1221 | /*! |
1222 | Returns <tt>$OPIEDIR/</tt>. | 1222 | Returns <tt>$OPIEDIR/</tt>. |
1223 | */ | 1223 | */ |
1224 | QString QPEApplication::qpeDir() | 1224 | QString QPEApplication::qpeDir() |
1225 | { | 1225 | { |
1226 | QString base, dir; | 1226 | QString base, dir; |
1227 | 1227 | ||
1228 | if (getenv( "OPIEDIR" )) | 1228 | if (getenv( "OPIEDIR" )) |
1229 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); | 1229 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); |
1230 | if ( !base.isNull() && (base.length() > 0 )){ | 1230 | if ( !base.isNull() && (base.length() > 0 )){ |
1231 | #ifdef Q_OS_WIN32 | 1231 | #ifdef Q_OS_WIN32 |
1232 | QString temp(base); | 1232 | QString temp(base); |
1233 | if (temp[(int)temp.length()-1] != QDir::separator()) | 1233 | if (temp[(int)temp.length()-1] != QDir::separator()) |
1234 | temp.append(QDir::separator()); | 1234 | temp.append(QDir::separator()); |
1235 | dir = temp; | 1235 | dir = temp; |
1236 | #else | 1236 | #else |
1237 | dir = QString( base ) + "/"; | 1237 | dir = QString( base ) + "/"; |
1238 | #endif | 1238 | #endif |
1239 | }else{ | 1239 | }else{ |
1240 | dir = QString( ".." ) + QDir::separator(); | 1240 | dir = QString( ".." ) + QDir::separator(); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | return dir; | 1243 | return dir; |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | /*! | 1246 | /*! |
1247 | Returns the user's current Document directory. There is a trailing "/". | 1247 | Returns the user's current Document directory. There is a trailing "/". |
1248 | .. well, it does now,, and there's no trailing '/' | 1248 | .. well, it does now,, and there's no trailing '/' |
1249 | */ | 1249 | */ |
1250 | QString QPEApplication::documentDir() | 1250 | QString QPEApplication::documentDir() |
1251 | { | 1251 | { |
1252 | const char* base = getenv( "HOME"); | 1252 | const char* base = getenv( "HOME"); |
1253 | if ( base ) | 1253 | if ( base ) |
1254 | return QString( base ) + "/Documents"; | 1254 | return QString( base ) + "/Documents"; |
1255 | 1255 | ||
1256 | return QString( "../Documents" ); | 1256 | return QString( "../Documents" ); |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | static int deforient = -1; | 1259 | static int deforient = -1; |
1260 | 1260 | ||
1261 | /*! | 1261 | /*! |
1262 | \internal | 1262 | \internal |
1263 | */ | 1263 | */ |
1264 | int QPEApplication::defaultRotation() | 1264 | int QPEApplication::defaultRotation() |
1265 | { | 1265 | { |
1266 | if ( deforient < 0 ) { | 1266 | if ( deforient < 0 ) { |
1267 | QString d = getenv( "QWS_DISPLAY" ); | 1267 | QString d = getenv( "QWS_DISPLAY" ); |
1268 | if ( d.contains( "Rot90" ) ) { | 1268 | if ( d.contains( "Rot90" ) ) { |
1269 | deforient = 90; | 1269 | deforient = 90; |
1270 | } | 1270 | } |
1271 | else if ( d.contains( "Rot180" ) ) { | 1271 | else if ( d.contains( "Rot180" ) ) { |
1272 | deforient = 180; | 1272 | deforient = 180; |
1273 | } | 1273 | } |
1274 | else if ( d.contains( "Rot270" ) ) { | 1274 | else if ( d.contains( "Rot270" ) ) { |
1275 | deforient = 270; | 1275 | deforient = 270; |
1276 | } | 1276 | } |
1277 | else { | 1277 | else { |
1278 | deforient = 0; | 1278 | deforient = 0; |
1279 | } | 1279 | } |
1280 | } | 1280 | } |
1281 | return deforient; | 1281 | return deforient; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | /*! | 1284 | /*! |
1285 | \internal | 1285 | \internal |
1286 | */ | 1286 | */ |
1287 | void QPEApplication::setDefaultRotation( int r ) | 1287 | void QPEApplication::setDefaultRotation( int r ) |
1288 | { | 1288 | { |
1289 | if ( qApp->type() == GuiServer ) { | 1289 | if ( qApp->type() == GuiServer ) { |
1290 | deforient = r; | 1290 | deforient = r; |
1291 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1291 | int j = 0; |
1292 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; | ||
1293 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); | ||
1294 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 ); | ||
1292 | Config config("qpe"); | 1295 | Config config("qpe"); |
1293 | config.setGroup( "Rotation" ); | 1296 | config.setGroup( "Rotation" ); |
1294 | config.writeEntry( "Rot", r ); | 1297 | config.writeEntry( "Rot", r ); |
1295 | } | 1298 | } |
1296 | else { | 1299 | else { |
1297 | #ifndef QT_NO_COP | 1300 | #ifndef QT_NO_COP |
1298 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1301 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1299 | e << r; | 1302 | e << r; |
1300 | } | 1303 | } |
1301 | #endif | 1304 | #endif |
1302 | 1305 | ||
1303 | } | 1306 | } |
1304 | } | 1307 | } |
1305 | 1308 | ||
1306 | #include <qgfx_qws.h> | 1309 | #include <qgfx_qws.h> |
1307 | #include <qwindowsystem_qws.h> | 1310 | #include <qwindowsystem_qws.h> |
1308 | 1311 | ||
1309 | #if QT_VERSION > 236 | 1312 | #if QT_VERSION > 236 |
1310 | extern void qws_clearLoadedFonts(); | 1313 | extern void qws_clearLoadedFonts(); |
1311 | #endif | 1314 | #endif |
1312 | 1315 | ||
1313 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1316 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1314 | { | 1317 | { |
1315 | // Reset the caches | 1318 | // Reset the caches |
1316 | #if QT_VERSION > 236 | 1319 | #if QT_VERSION > 236 |
1317 | qws_clearLoadedFonts(); | 1320 | qws_clearLoadedFonts(); |
1318 | #endif | 1321 | #endif |
1319 | QPixmapCache::clear(); | 1322 | QPixmapCache::clear(); |
1320 | 1323 | ||
1321 | // Change the screen mode | 1324 | // Change the screen mode |
1322 | qt_screen->setMode(x, y, depth); | 1325 | qt_screen->setMode(x, y, depth); |
1323 | 1326 | ||
1324 | if ( qApp->type() == GuiServer ) { | 1327 | if ( qApp->type() == GuiServer ) { |
1325 | #if QT_VERSION > 236 | 1328 | #if QT_VERSION > 236 |
1326 | // Reconfigure the GuiServer | 1329 | // Reconfigure the GuiServer |
1327 | qwsServer->beginDisplayReconfigure(); | 1330 | qwsServer->beginDisplayReconfigure(); |
1328 | qwsServer->endDisplayReconfigure(); | 1331 | qwsServer->endDisplayReconfigure(); |
1329 | #endif | 1332 | #endif |
1330 | // Get all the running apps to reset | 1333 | // Get all the running apps to reset |
1331 | QCopEnvelope env( "QPE/System", "reset()" ); | 1334 | QCopEnvelope env( "QPE/System", "reset()" ); |
1332 | } | 1335 | } |
1333 | } | 1336 | } |
1334 | 1337 | ||
1335 | void QPEApplication::reset() { | 1338 | void QPEApplication::reset() { |
1336 | // Reconnect to the screen | 1339 | // Reconnect to the screen |
1337 | qt_screen->disconnect(); | 1340 | qt_screen->disconnect(); |
1338 | qt_screen->connect( QString::null ); | 1341 | qt_screen->connect( QString::null ); |
1339 | 1342 | ||
1340 | // Redraw everything | 1343 | // Redraw everything |
1341 | applyStyle(); | 1344 | applyStyle(); |
1342 | } | 1345 | } |
1343 | 1346 | ||
1344 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1347 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1345 | bool qt_left_hand_scrollbars = false; | 1348 | bool qt_left_hand_scrollbars = false; |
1346 | #else | 1349 | #else |
1347 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; | 1350 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; |
1348 | #endif | 1351 | #endif |
1349 | 1352 | ||
1350 | /*! | 1353 | /*! |
1351 | \internal | 1354 | \internal |
1352 | */ | 1355 | */ |
1353 | void QPEApplication::applyStyle() | 1356 | void QPEApplication::applyStyle() |
1354 | { | 1357 | { |
1355 | Config config( "qpe" ); | 1358 | Config config( "qpe" ); |
1356 | config.setGroup( "Appearance" ); | 1359 | config.setGroup( "Appearance" ); |
1357 | 1360 | ||
1358 | #if QT_VERSION > 233 | 1361 | #if QT_VERSION > 233 |
1359 | // Widget style | 1362 | // Widget style |
1360 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1363 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1361 | 1364 | ||
1362 | internalSetStyle ( style ); | 1365 | internalSetStyle ( style ); |
1363 | 1366 | ||
1364 | // Colors - from /etc/colors/Liquid.scheme | 1367 | // Colors - from /etc/colors/Liquid.scheme |
1365 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1368 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1366 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1369 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1367 | QPalette pal( btncolor, bgcolor ); | 1370 | QPalette pal( btncolor, bgcolor ); |
1368 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1371 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1369 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1372 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1370 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1373 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1371 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1374 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1372 | color = config.readEntry( "Text", "#000000" ); | 1375 | color = config.readEntry( "Text", "#000000" ); |
1373 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1376 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1374 | color = config.readEntry( "ButtonText", "#000000" ); | 1377 | color = config.readEntry( "ButtonText", "#000000" ); |
1375 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1378 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1376 | color = config.readEntry( "Base", "#FFFFFF" ); | 1379 | color = config.readEntry( "Base", "#FFFFFF" ); |
1377 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1380 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1378 | 1381 | ||
1379 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1382 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1380 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1383 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1381 | 1384 | ||
1382 | setPalette( pal, TRUE ); | 1385 | setPalette( pal, TRUE ); |
1383 | 1386 | ||
1384 | 1387 | ||
1385 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1388 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1386 | if (&qt_left_hand_scrollbars ) | 1389 | if (&qt_left_hand_scrollbars ) |
1387 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1390 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1388 | 1391 | ||
1389 | // Window Decoration | 1392 | // Window Decoration |
1390 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1393 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1391 | 1394 | ||
1392 | if ( dec != d->decorationName ) { | 1395 | if ( dec != d->decorationName ) { |
1393 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1396 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1394 | d->decorationName = dec; | 1397 | d->decorationName = dec; |
1395 | } | 1398 | } |
1396 | 1399 | ||
1397 | // Font | 1400 | // Font |
1398 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1401 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1399 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1402 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1400 | 1403 | ||
1401 | setFont ( QFont ( ff, fs ), true ); | 1404 | setFont ( QFont ( ff, fs ), true ); |
1402 | #endif | 1405 | #endif |
1403 | } | 1406 | } |
1404 | 1407 | ||
1405 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1408 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1406 | { | 1409 | { |
1407 | #ifdef Q_WS_QWS | 1410 | #ifdef Q_WS_QWS |
1408 | QDataStream stream( data, IO_ReadOnly ); | 1411 | QDataStream stream( data, IO_ReadOnly ); |
1409 | if ( msg == "applyStyle()" ) { | 1412 | if ( msg == "applyStyle()" ) { |
1410 | applyStyle(); | 1413 | applyStyle(); |
1411 | } | 1414 | } |
1412 | else if ( msg == "toggleApplicationMenu()" ) { | 1415 | else if ( msg == "toggleApplicationMenu()" ) { |
1413 | QWidget *active = activeWindow ( ); | 1416 | QWidget *active = activeWindow ( ); |
1414 | 1417 | ||
1415 | if ( active ) { | 1418 | if ( active ) { |
1416 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1419 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1417 | bool oldactive = man-> isActive ( ); | 1420 | bool oldactive = man-> isActive ( ); |
1418 | 1421 | ||
1419 | man-> setActive( !man-> isActive() ); | 1422 | man-> setActive( !man-> isActive() ); |
1420 | 1423 | ||
1421 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1424 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1422 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1425 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1423 | } | 1426 | } |
1424 | } | 1427 | } |
1425 | } | 1428 | } |
1426 | else if ( msg == "setDefaultRotation(int)" ) { | 1429 | else if ( msg == "setDefaultRotation(int)" ) { |
1427 | if ( type() == GuiServer ) { | 1430 | if ( type() == GuiServer ) { |
1428 | int r; | 1431 | int r; |
1429 | stream >> r; | 1432 | stream >> r; |
1430 | setDefaultRotation( r ); | 1433 | setDefaultRotation( r ); |
1431 | } | 1434 | } |
1432 | } | 1435 | } |
1433 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1436 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1434 | if ( type() == GuiServer ) { | 1437 | if ( type() == GuiServer ) { |
1435 | int x, y, depth; | 1438 | int x, y, depth; |
1436 | stream >> x; | 1439 | stream >> x; |
1437 | stream >> y; | 1440 | stream >> y; |
1438 | stream >> depth; | 1441 | stream >> depth; |
1439 | setCurrentMode( x, y, depth ); | 1442 | setCurrentMode( x, y, depth ); |
1440 | } | 1443 | } |
1441 | } | 1444 | } |
1442 | else if ( msg == "reset()" ) { | 1445 | else if ( msg == "reset()" ) { |
1443 | if ( type() != GuiServer ) | 1446 | if ( type() != GuiServer ) |
1444 | reset(); | 1447 | reset(); |
1445 | } | 1448 | } |
1446 | else if ( msg == "setCurrentRotation(int)" ) { | 1449 | else if ( msg == "setCurrentRotation(int)" ) { |
1447 | int r; | 1450 | int r; |
1448 | stream >> r; | 1451 | stream >> r; |
1449 | setCurrentRotation( r ); | 1452 | setCurrentRotation( r ); |
1450 | } | 1453 | } |
1451 | else if ( msg == "shutdown()" ) { | 1454 | else if ( msg == "shutdown()" ) { |
1452 | if ( type() == GuiServer ) | 1455 | if ( type() == GuiServer ) |
1453 | shutdown(); | 1456 | shutdown(); |
1454 | } | 1457 | } |
1455 | else if ( msg == "quit()" ) { | 1458 | else if ( msg == "quit()" ) { |
1456 | if ( type() != GuiServer ) | 1459 | if ( type() != GuiServer ) |
1457 | tryQuit(); | 1460 | tryQuit(); |
1458 | } | 1461 | } |
1459 | else if ( msg == "forceQuit()" ) { | 1462 | else if ( msg == "forceQuit()" ) { |
1460 | if ( type() != GuiServer ) | 1463 | if ( type() != GuiServer ) |
1461 | quit(); | 1464 | quit(); |
1462 | } | 1465 | } |
1463 | else if ( msg == "restart()" ) { | 1466 | else if ( msg == "restart()" ) { |
1464 | if ( type() == GuiServer ) | 1467 | if ( type() == GuiServer ) |
1465 | restart(); | 1468 | restart(); |
1466 | } | 1469 | } |
1467 | else if ( msg == "language(QString)" ) { | 1470 | else if ( msg == "language(QString)" ) { |
1468 | if ( type() == GuiServer ) { | 1471 | if ( type() == GuiServer ) { |
1469 | QString l; | 1472 | QString l; |
1470 | stream >> l; | 1473 | stream >> l; |
1471 | QString cl = getenv( "LANG" ); | 1474 | QString cl = getenv( "LANG" ); |
1472 | if ( cl != l ) { | 1475 | if ( cl != l ) { |
1473 | if ( l.isNull() ) | 1476 | if ( l.isNull() ) |
1474 | unsetenv( "LANG" ); | 1477 | unsetenv( "LANG" ); |
1475 | else | 1478 | else |
1476 | setenv( "LANG", l.latin1(), 1 ); | 1479 | setenv( "LANG", l.latin1(), 1 ); |
1477 | restart(); | 1480 | restart(); |
1478 | } | 1481 | } |
1479 | } | 1482 | } |
1480 | } | 1483 | } |
1481 | else if ( msg == "timeChange(QString)" ) { | 1484 | else if ( msg == "timeChange(QString)" ) { |
1482 | QString t; | 1485 | QString t; |
1483 | stream >> t; | 1486 | stream >> t; |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 167fe69..cff3e43 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -19,221 +19,224 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QPE_APPLICATION_H__ | 20 | #ifndef __QPE_APPLICATION_H__ |
21 | #define __QPE_APPLICATION_H__ | 21 | #define __QPE_APPLICATION_H__ |
22 | 22 | ||
23 | #include <stdlib.h> // for setenv() | 23 | #include <stdlib.h> // for setenv() |
24 | 24 | ||
25 | #include <qglobal.h> | 25 | #include <qglobal.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qdialog.h> | 27 | #include <qdialog.h> |
28 | #include <qwsdisplay_qws.h> | 28 | #include <qwsdisplay_qws.h> |
29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
30 | #define Q_WS_QWS | 30 | #define Q_WS_QWS |
31 | #endif | 31 | #endif |
32 | #include "qpedecoration_qws.h" | 32 | #include "qpedecoration_qws.h" |
33 | #include "timestring.h" | 33 | #include "timestring.h" |
34 | #include "qpeglobal.h" | 34 | #include "qpeglobal.h" |
35 | 35 | ||
36 | class QCopChannel; | 36 | class QCopChannel; |
37 | class QPEApplicationData; | 37 | class QPEApplicationData; |
38 | class QWSEvent; | 38 | class QWSEvent; |
39 | class QWSKeyEvent; | 39 | class QWSKeyEvent; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | \brief The QPEApplication class implements various system services | 42 | \brief The QPEApplication class implements various system services |
43 | that are available to all Qtopia applications. | 43 | that are available to all Qtopia applications. |
44 | 44 | ||
45 | Simply by using QPEApplication instead of QApplication, a standard Qt | 45 | Simply by using QPEApplication instead of QApplication, a standard Qt |
46 | application becomes a Qtopia application. It automatically follows | 46 | application becomes a Qtopia application. It automatically follows |
47 | style changes, quits and raises, and in the | 47 | style changes, quits and raises, and in the |
48 | case of \link docwidget.html document-oriented\endlink applications, | 48 | case of \link docwidget.html document-oriented\endlink applications, |
49 | changes the currently displayed document in response to the environment. | 49 | changes the currently displayed document in response to the environment. |
50 | 50 | ||
51 | To create a \link docwidget.html document-oriented\endlink | 51 | To create a \link docwidget.html document-oriented\endlink |
52 | application use showMainDocumentWidget(); to create a | 52 | application use showMainDocumentWidget(); to create a |
53 | non-document-oriented application use showMainWidget(). The | 53 | non-document-oriented application use showMainWidget(). The |
54 | keepRunning() function indicates whether the application will | 54 | keepRunning() function indicates whether the application will |
55 | continue running after it's processed the last \link qcop.html | 55 | continue running after it's processed the last \link qcop.html |
56 | QCop\endlink message. This can be changed using setKeepRunning(). | 56 | QCop\endlink message. This can be changed using setKeepRunning(). |
57 | 57 | ||
58 | A variety of signals are emitted when certain events occur, for | 58 | A variety of signals are emitted when certain events occur, for |
59 | example, timeChanged(), clockChanged(), weekChanged(), | 59 | example, timeChanged(), clockChanged(), weekChanged(), |
60 | dateFormatChanged() and volumeChanged(). If the application receives | 60 | dateFormatChanged() and volumeChanged(). If the application receives |
61 | a \link qcop.html QCop\endlink message on the application's | 61 | a \link qcop.html QCop\endlink message on the application's |
62 | QPE/Application/\e{appname} channel, the appMessage() signal is | 62 | QPE/Application/\e{appname} channel, the appMessage() signal is |
63 | emitted. There are also flush() and reload() signals, which | 63 | emitted. There are also flush() and reload() signals, which |
64 | are emitted when synching begins and ends respectively - upon these | 64 | are emitted when synching begins and ends respectively - upon these |
65 | signals, the application should save and reload any data | 65 | signals, the application should save and reload any data |
66 | files that are involved in synching. Most of these signals will initially | 66 | files that are involved in synching. Most of these signals will initially |
67 | be received and unfiltered through the appMessage() signal. | 67 | be received and unfiltered through the appMessage() signal. |
68 | 68 | ||
69 | This class also provides a set of useful static functions. The | 69 | This class also provides a set of useful static functions. The |
70 | qpeDir() and documentDir() functions return the respective paths. | 70 | qpeDir() and documentDir() functions return the respective paths. |
71 | The grabKeyboard() and ungrabKeyboard() functions are used to | 71 | The grabKeyboard() and ungrabKeyboard() functions are used to |
72 | control whether the application takes control of the device's | 72 | control whether the application takes control of the device's |
73 | physical buttons (e.g. application launch keys). The stylus' mode of | 73 | physical buttons (e.g. application launch keys). The stylus' mode of |
74 | operation is set with setStylusOperation() and retrieved with | 74 | operation is set with setStylusOperation() and retrieved with |
75 | stylusOperation(). There are also setInputMethodHint() and | 75 | stylusOperation(). There are also setInputMethodHint() and |
76 | inputMethodHint() functions. | 76 | inputMethodHint() functions. |
77 | 77 | ||
78 | \ingroup qtopiaemb | 78 | \ingroup qtopiaemb |
79 | */ | 79 | */ |
80 | class QPEApplication : public QApplication | 80 | class QPEApplication : public QApplication |
81 | { | 81 | { |
82 | Q_OBJECT | 82 | Q_OBJECT |
83 | public: | 83 | public: |
84 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 84 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
85 | ~QPEApplication(); | 85 | ~QPEApplication(); |
86 | 86 | ||
87 | static QString qpeDir(); | 87 | static QString qpeDir(); |
88 | static QString documentDir(); | 88 | static QString documentDir(); |
89 | void applyStyle(); | 89 | void applyStyle(); |
90 | void reset(); | 90 | void reset(); |
91 | static int defaultRotation(); | 91 | static int defaultRotation(); |
92 | static void setDefaultRotation(int r); | 92 | static void setDefaultRotation(int r); |
93 | static void setCurrentRotation(int r); | 93 | static void setCurrentRotation(int r); |
94 | static void setCurrentMode(int x, int y, int depth ); | 94 | static void setCurrentMode(int x, int y, int depth ); |
95 | static void grabKeyboard(); | 95 | static void grabKeyboard(); |
96 | static void ungrabKeyboard(); | 96 | static void ungrabKeyboard(); |
97 | 97 | ||
98 | enum StylusMode { | 98 | enum StylusMode { |
99 | LeftOnly, | 99 | LeftOnly, |
100 | RightOnHold | 100 | RightOnHold |
101 | // RightOnHoldLeftDelayed, etc. | 101 | // RightOnHoldLeftDelayed, etc. |
102 | }; | 102 | }; |
103 | static void setStylusOperation( QWidget*, StylusMode ); | 103 | static void setStylusOperation( QWidget*, StylusMode ); |
104 | static StylusMode stylusOperation( QWidget* ); | 104 | static StylusMode stylusOperation( QWidget* ); |
105 | 105 | ||
106 | enum InputMethodHint { | 106 | enum InputMethodHint { |
107 | Normal, | 107 | Normal, |
108 | AlwaysOff, | 108 | AlwaysOff, |
109 | AlwaysOn | 109 | AlwaysOn |
110 | }; | 110 | }; |
111 | 111 | ||
112 | enum screenSaverHint { | 112 | enum screenSaverHint { |
113 | Disable = 0, | 113 | Disable = 0, |
114 | DisableLightOff = 1, | 114 | DisableLightOff = 1, |
115 | DisableSuspend = 2, | 115 | DisableSuspend = 2, |
116 | Enable = 100 | 116 | Enable = 100 |
117 | }; | 117 | }; |
118 | 118 | ||
119 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 119 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
120 | static InputMethodHint inputMethodHint( QWidget * ); | 120 | static InputMethodHint inputMethodHint( QWidget * ); |
121 | 121 | ||
122 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 122 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
123 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 123 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
124 | 124 | ||
125 | static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; | 125 | static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; |
126 | static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; | 126 | static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; |
127 | static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; | 127 | static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; |
128 | /* Merge setTempScreenSaverMode */ | 128 | /* Merge setTempScreenSaverMode */ |
129 | #ifdef QTOPIA_INTERNAL_INITAPP | 129 | #ifdef QTOPIA_INTERNAL_INITAPP |
130 | void initApp( int argv, char **argv ); | 130 | void initApp( int argv, char **argv ); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | static void setKeepRunning(); | 133 | static void setKeepRunning(); |
134 | bool keepRunning() const; | 134 | bool keepRunning() const; |
135 | 135 | ||
136 | bool keyboardGrabbed() const; | 136 | bool keyboardGrabbed() const; |
137 | 137 | ||
138 | int exec(); | 138 | int exec(); |
139 | 139 | ||
140 | signals: | 140 | signals: |
141 | void clientMoused(); | 141 | void clientMoused(); |
142 | void timeChanged(); | 142 | void timeChanged(); |
143 | void clockChanged( bool pm ); | 143 | void clockChanged( bool pm ); |
144 | void micChanged( bool muted ); | 144 | void micChanged( bool muted ); |
145 | void volumeChanged( bool muted ); | 145 | void volumeChanged( bool muted ); |
146 | void appMessage( const QCString& msg, const QByteArray& data); | 146 | void appMessage( const QCString& msg, const QByteArray& data); |
147 | void weekChanged( bool startOnMonday ); | 147 | void weekChanged( bool startOnMonday ); |
148 | void dateFormatChanged( DateFormat ); | 148 | void dateFormatChanged( DateFormat ); |
149 | void flush(); | 149 | void flush(); |
150 | void reload(); | 150 | void reload(); |
151 | /* linkChanged signal */ | 151 | /* linkChanged signal */ |
152 | 152 | ||
153 | private slots: | 153 | private slots: |
154 | void systemMessage( const QCString &msg, const QByteArray &data ); | 154 | void systemMessage( const QCString &msg, const QByteArray &data ); |
155 | void pidMessage( const QCString &msg, const QByteArray &data ); | 155 | void pidMessage( const QCString &msg, const QByteArray &data ); |
156 | void removeSenderFromStylusDict(); | 156 | void removeSenderFromStylusDict(); |
157 | void hideOrQuit(); | 157 | void hideOrQuit(); |
158 | 158 | ||
159 | protected: | 159 | protected: |
160 | bool qwsEventFilter( QWSEvent * ); | 160 | bool qwsEventFilter( QWSEvent * ); |
161 | void internalSetStyle( const QString &style ); | 161 | void internalSetStyle( const QString &style ); |
162 | void prepareForTermination(bool willrestart); | 162 | void prepareForTermination(bool willrestart); |
163 | virtual void restart(); | 163 | virtual void restart(); |
164 | virtual void shutdown(); | 164 | virtual void shutdown(); |
165 | bool eventFilter( QObject *, QEvent * ); | 165 | bool eventFilter( QObject *, QEvent * ); |
166 | void timerEvent( QTimerEvent * ); | 166 | void timerEvent( QTimerEvent * ); |
167 | bool raiseAppropriateWindow(); | 167 | bool raiseAppropriateWindow(); |
168 | virtual void tryQuit(); | 168 | virtual void tryQuit(); |
169 | private: | 169 | private: |
170 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 170 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
171 | void processQCopFile(); | 171 | void processQCopFile(); |
172 | 172 | ||
173 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 173 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
174 | QCopChannel *sysChannel; | 174 | QCopChannel *sysChannel; |
175 | QCopChannel *pidChannel; | 175 | QCopChannel *pidChannel; |
176 | #endif | 176 | #endif |
177 | QPEApplicationData *d; | 177 | QPEApplicationData *d; |
178 | 178 | ||
179 | bool reserved_sh; | 179 | bool reserved_sh; |
180 | 180 | ||
181 | }; | 181 | }; |
182 | 182 | ||
183 | 183 | ||
184 | 184 | ||
185 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ | 185 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ |
186 | 186 | ||
187 | inline int TransToDeg ( Transformation t ) | 187 | inline int TransToDeg ( Transformation t ) |
188 | { | 188 | { |
189 | int d = static_cast<int>( t ); | 189 | int d = static_cast<int>( t ); |
190 | return d * 90; | 190 | return d * 90; |
191 | } | 191 | } |
192 | 192 | ||
193 | inline Transformation DegToTrans ( int d ) | 193 | inline Transformation DegToTrans ( int d ) |
194 | { | 194 | { |
195 | Transformation t = static_cast<Transformation>( d / 90 ); | 195 | Transformation t = static_cast<Transformation>( d / 90 ); |
196 | return t; | 196 | return t; |
197 | } | 197 | } |
198 | 198 | ||
199 | /* | 199 | /* |
200 | * Set current rotation of Opie, and rotation for newly started apps. | 200 | * Set current rotation of Opie, and rotation for newly started apps. |
201 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, | 201 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, |
202 | * and 2) does not set deforient or save orientation to qpe.conf. | 202 | * and 2) does not set deforient or save orientation to qpe.conf. |
203 | */ | 203 | */ |
204 | 204 | ||
205 | inline void QPEApplication::setCurrentRotation( int r ) | 205 | inline void QPEApplication::setCurrentRotation( int r ) |
206 | { | 206 | { |
207 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots | 207 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots |
208 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() | 208 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() |
209 | #if QT_VERSION > 233 | 209 | #if QT_VERSION > 233 |
210 | Transformation e = DegToTrans( r ); | 210 | Transformation e = DegToTrans( r ); |
211 | ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 211 | QCString old = getenv("QWS_DISPLAY") ? getenv( "QWS_DISPLAY" ) : "Transformed"; |
212 | int j = 0; | ||
213 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); | ||
214 | ::setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( r ).latin1(), 1 ); | ||
212 | qApp->desktop()->qwsDisplay()->setTransformation( e ); | 215 | qApp->desktop()->qwsDisplay()->setTransformation( e ); |
213 | #else | 216 | #else |
214 | setDefaultRotation( r ); | 217 | setDefaultRotation( r ); |
215 | #endif | 218 | #endif |
216 | } | 219 | } |
217 | 220 | ||
218 | /* | 221 | /* |
219 | * Qtopia 1.7 SDK compatibility macros | 222 | * Qtopia 1.7 SDK compatibility macros |
220 | * FIXME: Support Opie Quicklaunch Interface | 223 | * FIXME: Support Opie Quicklaunch Interface |
221 | */ | 224 | */ |
222 | #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \ | 225 | #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \ |
223 | int main( int argc, char** argv ) \ | 226 | int main( int argc, char** argv ) \ |
224 | { \ | 227 | { \ |
225 | QPEApplication app = QPEApplication( argc, argv );\ | 228 | QPEApplication app = QPEApplication( argc, argv );\ |
226 | IMPLEMENTATION* mw = new IMPLEMENTATION(); \ | 229 | IMPLEMENTATION* mw = new IMPLEMENTATION(); \ |
227 | app.showMainWidget( mw ); \ | 230 | app.showMainWidget( mw ); \ |
228 | app.exec(); \ | 231 | app.exec(); \ |
229 | } | 232 | } |
230 | #define QTOPIA_MAIN // Bee-Bop-Alula | 233 | #define QTOPIA_MAIN // Bee-Bop-Alula |
231 | 234 | ||
232 | /* | 235 | /* |
233 | * -remove me | 236 | * -remove me |
234 | */ | 237 | */ |
235 | #ifdef Q_WS_QWS | 238 | #ifdef Q_WS_QWS |
236 | extern Q_EXPORT QRect qt_maxWindowRect; | 239 | extern Q_EXPORT QRect qt_maxWindowRect; |
237 | #endif | 240 | #endif |
238 | 241 | ||
239 | #endif | 242 | #endif |