summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-12 13:07:37 (UTC)
committer zecke <zecke>2003-05-12 13:07:37 (UTC)
commit4765c92ba3dcbd829cb2adde4a097dfe6283d7cc (patch) (unidiff)
tree7a13062058737af1564863f9caec692f145fdfaa
parent65a043f4ac4b43967947c1e8d99c629bb993f065 (diff)
downloadopie-4765c92ba3dcbd829cb2adde4a097dfe6283d7cc.zip
opie-4765c92ba3dcbd829cb2adde4a097dfe6283d7cc.tar.gz
opie-4765c92ba3dcbd829cb2adde4a097dfe6283d7cc.tar.bz2
Hospital Hacking Session
Install libopie.qm make apps fully translatable... refactor installing trans into a method instead of having the same code copy and pasted three times
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp30
-rw-r--r--library/qpeapplication.h3
2 files changed, 18 insertions, 15 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index e5da48c..f4db1ab 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -510,208 +510,196 @@ static void setTreble( int t = 0, int percent = -1 )
510 the Qtopia server passes GuiServer. 510 the Qtopia server passes GuiServer.
511*/ 511*/
512QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 512QPEApplication::QPEApplication( int & argc, char **argv, Type t )
513 : QApplication( argc, argv, t ) 513 : QApplication( argc, argv, t )
514{ 514{
515 d = new QPEApplicationData; 515 d = new QPEApplicationData;
516 d->loadTextCodecs(); 516 d->loadTextCodecs();
517 d->loadImageCodecs(); 517 d->loadImageCodecs();
518 int dw = desktop() ->width(); 518 int dw = desktop() ->width();
519 519
520 if ( dw < 200 ) { 520 if ( dw < 200 ) {
521 setFont( QFont( "vera", 8 ) ); 521 setFont( QFont( "vera", 8 ) );
522 AppLnk::setSmallIconSize( 10 ); 522 AppLnk::setSmallIconSize( 10 );
523 AppLnk::setBigIconSize( 28 ); 523 AppLnk::setBigIconSize( 28 );
524 } 524 }
525 else if ( dw > 600 ) { 525 else if ( dw > 600 ) {
526 setFont( QFont( "vera", 16 ) ); 526 setFont( QFont( "vera", 16 ) );
527 AppLnk::setSmallIconSize( 24 ); 527 AppLnk::setSmallIconSize( 24 );
528 AppLnk::setBigIconSize( 48 ); 528 AppLnk::setBigIconSize( 48 );
529 } 529 }
530 else if ( dw > 200 ) { 530 else if ( dw > 200 ) {
531 setFont( QFont( "vera", 10 ) ); 531 setFont( QFont( "vera", 10 ) );
532 AppLnk::setSmallIconSize( 14 ); 532 AppLnk::setSmallIconSize( 14 );
533 AppLnk::setBigIconSize( 32 ); 533 AppLnk::setBigIconSize( 32 );
534 } 534 }
535 535
536 536
537 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 537 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
538 538
539 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 539 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
540#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 540#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
541 541
542 QString qcopfn( "/tmp/qcop-msg-" ); 542 QString qcopfn( "/tmp/qcop-msg-" );
543 qcopfn += QString( argv[ 0 ] ); // append command name 543 qcopfn += QString( argv[ 0 ] ); // append command name
544 544
545 QFile f( qcopfn ); 545 QFile f( qcopfn );
546 if ( f.open( IO_ReadOnly ) ) { 546 if ( f.open( IO_ReadOnly ) ) {
547 flock( f.handle(), LOCK_EX ); 547 flock( f.handle(), LOCK_EX );
548 } 548 }
549 549
550 sysChannel = new QCopChannel( "QPE/System", this ); 550 sysChannel = new QCopChannel( "QPE/System", this );
551 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 551 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
552 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 552 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
553 553
554 QCString channel = QCString( argv[ 0 ] ); 554 QCString channel = QCString( argv[ 0 ] );
555 channel.replace( QRegExp( ".*/" ), "" ); 555 channel.replace( QRegExp( ".*/" ), "" );
556 d->appName = channel; 556 d->appName = channel;
557 channel = "QPE/Application/" + channel; 557 channel = "QPE/Application/" + channel;
558 pidChannel = new QCopChannel( channel, this ); 558 pidChannel = new QCopChannel( channel, this );
559 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 559 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
560 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 560 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
561 561
562 if ( f.isOpen() ) { 562 if ( f.isOpen() ) {
563 d->keep_running = FALSE; 563 d->keep_running = FALSE;
564 QDataStream ds( &f ); 564 QDataStream ds( &f );
565 QCString channel, message; 565 QCString channel, message;
566 QByteArray data; 566 QByteArray data;
567 while ( !ds.atEnd() ) { 567 while ( !ds.atEnd() ) {
568 ds >> channel >> message >> data; 568 ds >> channel >> message >> data;
569 d->enqueueQCop( channel, message, data ); 569 d->enqueueQCop( channel, message, data );
570 } 570 }
571 571
572 flock( f.handle(), LOCK_UN ); 572 flock( f.handle(), LOCK_UN );
573 f.close(); 573 f.close();
574 f.remove(); 574 f.remove();
575 } 575 }
576 576
577 for ( int a = 0; a < argc; a++ ) { 577 for ( int a = 0; a < argc; a++ ) {
578 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 578 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
579 argv[ a ] = argv[ a + 1 ]; 579 argv[ a ] = argv[ a + 1 ];
580 a++; 580 a++;
581 d->preloaded = TRUE; 581 d->preloaded = TRUE;
582 argc -= 1; 582 argc -= 1;
583 } 583 }
584 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 584 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
585 argv[ a ] = argv[ a + 1 ]; 585 argv[ a ] = argv[ a + 1 ];
586 a++; 586 a++;
587 d->preloaded = TRUE; 587 d->preloaded = TRUE;
588 d->forceshow = TRUE; 588 d->forceshow = TRUE;
589 argc -= 1; 589 argc -= 1;
590 } 590 }
591 } 591 }
592 592
593 /* overide stored arguments */ 593 /* overide stored arguments */
594 setArgs( argc, argv ); 594 setArgs( argc, argv );
595 595
596#endif 596#endif
597 597
598 // qwsSetDecoration( new QPEDecoration() ); 598 // qwsSetDecoration( new QPEDecoration() );
599 599
600#ifndef QT_NO_TRANSLATION 600#ifndef QT_NO_TRANSLATION
601 601
602 QStringList langs = Global::languageList(); 602 QStringList langs = Global::languageList();
603 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 603 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
604 QString lang = *it; 604 QString lang = *it;
605 605
606 QTranslator * trans; 606 installTranslation( lang + "/libopie.qm");
607 QString tfn; 607 installTranslation( lang + "/libqpe.qm" );
608 installTranslation( lang + "/" + d->appName + ".qm" );
608 609
609 trans = new QTranslator( this );
610 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
611 if ( trans->load( tfn ) )
612 installTranslator( trans );
613 else
614 delete trans;
615
616 trans = new QTranslator( this );
617 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
618 if ( trans->load( tfn ) )
619 installTranslator( trans );
620 else
621 delete trans;
622 610
623 //###language/font hack; should look it up somewhere 611 //###language/font hack; should look it up somewhere
624#ifdef QWS 612#ifdef QWS
625 613
626 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 614 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
627 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 615 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
628 setFont( fn ); 616 setFont( fn );
629 } 617 }
630#endif 618#endif
631 619
632 } 620 }
633#endif 621#endif
634 622
635 applyStyle(); 623 applyStyle();
636 624
637 if ( type() == GuiServer ) { 625 if ( type() == GuiServer ) {
638 setVolume(); 626 setVolume();
639 } 627 }
640 628
641 installEventFilter( this ); 629 installEventFilter( this );
642 630
643 QPEMenuToolFocusManager::initialize(); 631 QPEMenuToolFocusManager::initialize();
644 632
645#ifdef QT_NO_QWS_CURSOR 633#ifdef QT_NO_QWS_CURSOR
646 // if we have no cursor, probably don't want tooltips 634 // if we have no cursor, probably don't want tooltips
647 QToolTip::setEnabled( FALSE ); 635 QToolTip::setEnabled( FALSE );
648#endif 636#endif
649} 637}
650 638
651static QPtrDict<void>* inputMethodDict = 0; 639static QPtrDict<void>* inputMethodDict = 0;
652static void createInputMethodDict() 640static void createInputMethodDict()
653{ 641{
654 if ( !inputMethodDict ) 642 if ( !inputMethodDict )
655 inputMethodDict = new QPtrDict<void>; 643 inputMethodDict = new QPtrDict<void>;
656} 644}
657 645
658/*! 646/*!
659 Returns the currently set hint to the system as to whether 647 Returns the currently set hint to the system as to whether
660 widget \a w has any use for text input methods. 648 widget \a w has any use for text input methods.
661 649
662 650
663 \sa setInputMethodHint() InputMethodHint 651 \sa setInputMethodHint() InputMethodHint
664*/ 652*/
665QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 653QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
666{ 654{
667 if ( inputMethodDict && w ) 655 if ( inputMethodDict && w )
668 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 656 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
669 return Normal; 657 return Normal;
670} 658}
671 659
672/*! 660/*!
673 \enum QPEApplication::InputMethodHint 661 \enum QPEApplication::InputMethodHint
674 662
675 \value Normal the application sometimes needs text input (the default). 663 \value Normal the application sometimes needs text input (the default).
676 \value AlwaysOff the application never needs text input. 664 \value AlwaysOff the application never needs text input.
677 \value AlwaysOn the application always needs text input. 665 \value AlwaysOn the application always needs text input.
678*/ 666*/
679 667
680/*! 668/*!
681 Hints to the system that widget \a w has use for text input methods 669 Hints to the system that widget \a w has use for text input methods
682 as specified by \a mode. 670 as specified by \a mode.
683 671
684 \sa inputMethodHint() InputMethodHint 672 \sa inputMethodHint() InputMethodHint
685*/ 673*/
686void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 674void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
687{ 675{
688 createInputMethodDict(); 676 createInputMethodDict();
689 if ( mode == Normal ) { 677 if ( mode == Normal ) {
690 inputMethodDict->remove 678 inputMethodDict->remove
691 ( w ); 679 ( w );
692 } 680 }
693 else { 681 else {
694 inputMethodDict->insert( w, ( void* ) mode ); 682 inputMethodDict->insert( w, ( void* ) mode );
695 } 683 }
696} 684}
697 685
698class HackDialog : public QDialog 686class HackDialog : public QDialog
699{ 687{
700public: 688public:
701 void acceptIt() 689 void acceptIt()
702 { 690 {
703 accept(); 691 accept();
704 } 692 }
705 void rejectIt() 693 void rejectIt()
706 { 694 {
707 reject(); 695 reject();
708 } 696 }
709}; 697};
710 698
711 699
712void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 700void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
713{ 701{
714 // specialised actions for certain widgets. May want to 702 // specialised actions for certain widgets. May want to
715 // add more stuff here. 703 // add more stuff here.
716 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 704 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
717 && activePopupWidget() ->parentWidget() 705 && activePopupWidget() ->parentWidget()
@@ -1634,184 +1622,196 @@ void QPEApplication::timerEvent( QTimerEvent *e )
1634 postEvent( d->presswidget, 1622 postEvent( d->presswidget,
1635 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1623 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1636 RightButton, LeftButton ) ); 1624 RightButton, LeftButton ) );
1637 killTimer( d->presstimer ); 1625 killTimer( d->presstimer );
1638 d->presstimer = 0; 1626 d->presstimer = 0;
1639 d->rightpressed = TRUE; 1627 d->rightpressed = TRUE;
1640 } 1628 }
1641} 1629}
1642 1630
1643void QPEApplication::removeSenderFromStylusDict() 1631void QPEApplication::removeSenderFromStylusDict()
1644{ 1632{
1645 stylusDict->remove 1633 stylusDict->remove
1646 ( ( void* ) sender() ); 1634 ( ( void* ) sender() );
1647 if ( d->presswidget == sender() ) 1635 if ( d->presswidget == sender() )
1648 d->presswidget = 0; 1636 d->presswidget = 0;
1649} 1637}
1650 1638
1651/*! 1639/*!
1652 \internal 1640 \internal
1653*/ 1641*/
1654bool QPEApplication::keyboardGrabbed() const 1642bool QPEApplication::keyboardGrabbed() const
1655{ 1643{
1656 return d->kbgrabbed; 1644 return d->kbgrabbed;
1657} 1645}
1658 1646
1659 1647
1660/*! 1648/*!
1661 Reverses the effect of grabKeyboard(). This is called automatically 1649 Reverses the effect of grabKeyboard(). This is called automatically
1662 on program exit. 1650 on program exit.
1663*/ 1651*/
1664void QPEApplication::ungrabKeyboard() 1652void QPEApplication::ungrabKeyboard()
1665{ 1653{
1666 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 1654 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
1667} 1655}
1668 1656
1669/*! 1657/*!
1670 Grabs the physical keyboard keys, e.g. the application's launching 1658 Grabs the physical keyboard keys, e.g. the application's launching
1671 keys. Instead of launching applications when these keys are pressed 1659 keys. Instead of launching applications when these keys are pressed
1672 the signals emitted are sent to this application instead. Some games 1660 the signals emitted are sent to this application instead. Some games
1673 programs take over the launch keys in this way to make interaction 1661 programs take over the launch keys in this way to make interaction
1674 easier. 1662 easier.
1675 1663
1676 \sa ungrabKeyboard() 1664 \sa ungrabKeyboard()
1677*/ 1665*/
1678void QPEApplication::grabKeyboard() 1666void QPEApplication::grabKeyboard()
1679{ 1667{
1680 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 1668 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
1681} 1669}
1682 1670
1683/*! 1671/*!
1684 \reimp 1672 \reimp
1685*/ 1673*/
1686int QPEApplication::exec() 1674int QPEApplication::exec()
1687{ 1675{
1688#ifndef QT_NO_COP 1676#ifndef QT_NO_COP
1689 d->sendQCopQ(); 1677 d->sendQCopQ();
1690#endif 1678#endif
1691 1679
1692 if ( d->keep_running ) 1680 if ( d->keep_running )
1693 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1681 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1694 return QApplication::exec(); 1682 return QApplication::exec();
1695 1683
1696#ifndef QT_NO_COP 1684#ifndef QT_NO_COP
1697 1685
1698 { 1686 {
1699 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1687 QCopEnvelope e( "QPE/System", "closing(QString)" );
1700 e << d->appName; 1688 e << d->appName;
1701 } 1689 }
1702#endif 1690#endif
1703 processEvents(); 1691 processEvents();
1704 return 0; 1692 return 0;
1705} 1693}
1706 1694
1707/*! 1695/*!
1708 \internal 1696 \internal
1709 External request for application to quit. Quits if possible without 1697 External request for application to quit. Quits if possible without
1710 loosing state. 1698 loosing state.
1711*/ 1699*/
1712void QPEApplication::tryQuit() 1700void QPEApplication::tryQuit()
1713{ 1701{
1714 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1702 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1715 return ; // Inside modal loop or konsole. Too hard to save state. 1703 return ; // Inside modal loop or konsole. Too hard to save state.
1716#ifndef QT_NO_COP 1704#ifndef QT_NO_COP
1717 1705
1718 { 1706 {
1719 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1707 QCopEnvelope e( "QPE/System", "closing(QString)" );
1720 e << d->appName; 1708 e << d->appName;
1721 } 1709 }
1722#endif 1710#endif
1723 processEvents(); 1711 processEvents();
1724 1712
1725 quit(); 1713 quit();
1726} 1714}
1727 1715
1728/*! 1716/*!
1729 \internal 1717 \internal
1718*/
1719void QPEApplication::installTranslation( const QString& baseName ) {
1720 QTranslator* trans = new QTranslator(this);
1721 QString tfn = qpeDir() + "/i18n/"+baseName;
1722 if ( trans->load( tfn ) )
1723 installTranslator( trans );
1724 else
1725 delete trans;
1726}
1727
1728/*!
1729 \internal
1730 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1730 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1731 hiding the window. If not it means quitting the application. 1731 hiding the window. If not it means quitting the application.
1732 As this is user initiated we don't need to check state. 1732 As this is user initiated we don't need to check state.
1733*/ 1733*/
1734void QPEApplication::hideOrQuit() 1734void QPEApplication::hideOrQuit()
1735{ 1735{
1736 processEvents(); 1736 processEvents();
1737 1737
1738 // If we are a preloaded application we don't actually quit, so emit 1738 // If we are a preloaded application we don't actually quit, so emit
1739 // a System message indicating we're quasi-closing. 1739 // a System message indicating we're quasi-closing.
1740 if ( d->preloaded && d->qpe_main_widget ) 1740 if ( d->preloaded && d->qpe_main_widget )
1741#ifndef QT_NO_COP 1741#ifndef QT_NO_COP
1742 1742
1743 { 1743 {
1744 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1744 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1745 e << d->appName; 1745 e << d->appName;
1746 d->qpe_main_widget->hide(); 1746 d->qpe_main_widget->hide();
1747 } 1747 }
1748#endif 1748#endif
1749 else 1749 else
1750 quit(); 1750 quit();
1751} 1751}
1752 1752
1753 1753
1754#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 1754#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
1755 1755
1756// The libraries with the skiff package (and possibly others) have 1756// The libraries with the skiff package (and possibly others) have
1757// completely useless implementations of builtin new and delete that 1757// completely useless implementations of builtin new and delete that
1758// use about 50% of your CPU. Here we revert to the simple libc 1758// use about 50% of your CPU. Here we revert to the simple libc
1759// functions. 1759// functions.
1760 1760
1761void* operator new[]( size_t size ) 1761void* operator new[]( size_t size )
1762{ 1762{
1763 return malloc( size ); 1763 return malloc( size );
1764} 1764}
1765 1765
1766void* operator new( size_t size ) 1766void* operator new( size_t size )
1767{ 1767{
1768 return malloc( size ); 1768 return malloc( size );
1769} 1769}
1770 1770
1771void operator delete[]( void* p ) 1771void operator delete[]( void* p )
1772{ 1772{
1773 free( p ); 1773 free( p );
1774} 1774}
1775 1775
1776void operator delete[]( void* p, size_t /*size*/ ) 1776void operator delete[]( void* p, size_t /*size*/ )
1777{ 1777{
1778 free( p ); 1778 free( p );
1779} 1779}
1780 1780
1781 1781
1782void operator delete( void* p ) 1782void operator delete( void* p )
1783{ 1783{
1784 free( p ); 1784 free( p );
1785} 1785}
1786 1786
1787void operator delete( void* p, size_t /*size*/ ) 1787void operator delete( void* p, size_t /*size*/ )
1788{ 1788{
1789 free( p ); 1789 free( p );
1790} 1790}
1791 1791
1792#endif 1792#endif
1793 1793
1794#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1794#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1795#include <qwidgetlist.h> 1795#include <qwidgetlist.h>
1796#ifdef QWS 1796#ifdef QWS
1797#include <qgfx_qws.h> 1797#include <qgfx_qws.h>
1798extern QRect qt_maxWindowRect; 1798extern QRect qt_maxWindowRect;
1799void qt_setMaxWindowRect(const QRect& r ) 1799void qt_setMaxWindowRect(const QRect& r )
1800{ 1800{
1801 qt_maxWindowRect = qt_screen->mapFromDevice( r, 1801 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1802 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 1802 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1803 // Re-resize any maximized windows 1803 // Re-resize any maximized windows
1804 QWidgetList* l = QApplication::topLevelWidgets(); 1804 QWidgetList* l = QApplication::topLevelWidgets();
1805 if ( l ) { 1805 if ( l ) {
1806 QWidget * w = l->first(); 1806 QWidget * w = l->first();
1807 while ( w ) { 1807 while ( w ) {
1808 if ( w->isVisible() && w->isMaximized() ) { 1808 if ( w->isVisible() && w->isMaximized() ) {
1809 w->showMaximized(); 1809 w->showMaximized();
1810 } 1810 }
1811 w = l->next(); 1811 w = l->next();
1812 } 1812 }
1813 delete l; 1813 delete l;
1814 } 1814 }
1815} 1815}
1816#endif 1816#endif
1817#endif 1817#endif
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 0bad8b7..e35c008 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -29,162 +29,165 @@
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 34
35class QCopChannel; 35class QCopChannel;
36class QPEApplicationData; 36class QPEApplicationData;
37class QWSEvent; 37class QWSEvent;
38class QWSKeyEvent; 38class QWSKeyEvent;
39 39
40 40
41class QPEApplication : public QApplication 41class QPEApplication : public QApplication
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 QPEApplication( int& argc, char **argv, Type=GuiClient ); 45 QPEApplication( int& argc, char **argv, Type=GuiClient );
46 ~QPEApplication(); 46 ~QPEApplication();
47 47
48 static QString qpeDir(); 48 static QString qpeDir();
49 static QString documentDir(); 49 static QString documentDir();
50 void applyStyle(); 50 void applyStyle();
51 static int defaultRotation(); 51 static int defaultRotation();
52 static void setDefaultRotation(int r); 52 static void setDefaultRotation(int r);
53 static void setCurrentRotation(int r); 53 static void setCurrentRotation(int r);
54 static void grabKeyboard(); 54 static void grabKeyboard();
55 static void ungrabKeyboard(); 55 static void ungrabKeyboard();
56 56
57 enum StylusMode { 57 enum StylusMode {
58 LeftOnly, 58 LeftOnly,
59 RightOnHold 59 RightOnHold
60 // RightOnHoldLeftDelayed, etc. 60 // RightOnHoldLeftDelayed, etc.
61 }; 61 };
62 static void setStylusOperation( QWidget*, StylusMode ); 62 static void setStylusOperation( QWidget*, StylusMode );
63 static StylusMode stylusOperation( QWidget* ); 63 static StylusMode stylusOperation( QWidget* );
64 64
65 enum InputMethodHint { 65 enum InputMethodHint {
66 Normal, 66 Normal,
67 AlwaysOff, 67 AlwaysOff,
68 AlwaysOn 68 AlwaysOn
69 }; 69 };
70 70
71 enum screenSaverHint { 71 enum screenSaverHint {
72 Disable = 0, 72 Disable = 0,
73 DisableLightOff = 1, 73 DisableLightOff = 1,
74 DisableSuspend = 2, 74 DisableSuspend = 2,
75 Enable = 100 75 Enable = 100
76 }; 76 };
77 77
78 static void setInputMethodHint( QWidget *, InputMethodHint ); 78 static void setInputMethodHint( QWidget *, InputMethodHint );
79 static InputMethodHint inputMethodHint( QWidget * ); 79 static InputMethodHint inputMethodHint( QWidget * );
80 80
81 void showMainWidget( QWidget*, bool nomax=FALSE ); 81 void showMainWidget( QWidget*, bool nomax=FALSE );
82 void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); 82 void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
83 static void showDialog( QDialog*, bool nomax=FALSE ); 83 static void showDialog( QDialog*, bool nomax=FALSE );
84 static int execDialog( QDialog*, bool nomax=FALSE ); 84 static int execDialog( QDialog*, bool nomax=FALSE );
85 85
86 static void setKeepRunning(); 86 static void setKeepRunning();
87 bool keepRunning() const; 87 bool keepRunning() const;
88 88
89 bool keyboardGrabbed() const; 89 bool keyboardGrabbed() const;
90 90
91 int exec(); 91 int exec();
92 92
93signals: 93signals:
94 void clientMoused(); 94 void clientMoused();
95 void timeChanged(); 95 void timeChanged();
96 void clockChanged( bool pm ); 96 void clockChanged( bool pm );
97 void micChanged( bool muted ); 97 void micChanged( bool muted );
98 void volumeChanged( bool muted ); 98 void volumeChanged( bool muted );
99 void appMessage( const QCString& msg, const QByteArray& data); 99 void appMessage( const QCString& msg, const QByteArray& data);
100 void weekChanged( bool startOnMonday ); 100 void weekChanged( bool startOnMonday );
101 void dateFormatChanged( DateFormat ); 101 void dateFormatChanged( DateFormat );
102 void flush(); 102 void flush();
103 void reload(); 103 void reload();
104 104
105private slots: 105private slots:
106 void systemMessage( const QCString &msg, const QByteArray &data ); 106 void systemMessage( const QCString &msg, const QByteArray &data );
107 void pidMessage( const QCString &msg, const QByteArray &data ); 107 void pidMessage( const QCString &msg, const QByteArray &data );
108 void removeSenderFromStylusDict(); 108 void removeSenderFromStylusDict();
109 void hideOrQuit(); 109 void hideOrQuit();
110 110
111protected: 111protected:
112 bool qwsEventFilter( QWSEvent * ); 112 bool qwsEventFilter( QWSEvent * );
113 void internalSetStyle( const QString &style ); 113 void internalSetStyle( const QString &style );
114 void prepareForTermination(bool willrestart); 114 void prepareForTermination(bool willrestart);
115 virtual void restart(); 115 virtual void restart();
116 virtual void shutdown(); 116 virtual void shutdown();
117 bool eventFilter( QObject *, QEvent * ); 117 bool eventFilter( QObject *, QEvent * );
118 void timerEvent( QTimerEvent * ); 118 void timerEvent( QTimerEvent * );
119 bool raiseAppropriateWindow(); 119 bool raiseAppropriateWindow();
120 virtual void tryQuit(); 120 virtual void tryQuit();
121 121
122 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) 122 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
123 123
124private: 124private:
125#ifndef QT_NO_TRANSLATION
126 void installTranslation( const QString& baseName );
127#endif
125 void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); 128 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
126 129
127#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 130#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
128 QCopChannel *sysChannel; 131 QCopChannel *sysChannel;
129 QCopChannel *pidChannel; 132 QCopChannel *pidChannel;
130#endif 133#endif
131 QPEApplicationData *d; 134 QPEApplicationData *d;
132 135
133 bool reserved_sh; 136 bool reserved_sh;
134 137
135 138
136 139
137}; 140};
138 141
139inline void QPEApplication::showDialog( QDialog* d, bool nomax ) 142inline void QPEApplication::showDialog( QDialog* d, bool nomax )
140{ 143{
141 QSize sh = d->sizeHint(); 144 QSize sh = d->sizeHint();
142 int w = QMAX(sh.width(),d->width()); 145 int w = QMAX(sh.width(),d->width());
143 int h = QMAX(sh.height(),d->height()); 146 int h = QMAX(sh.height(),d->height());
144 if ( !nomax 147 if ( !nomax
145 && ( w > qApp->desktop()->width()*3/4 148 && ( w > qApp->desktop()->width()*3/4
146 || h > qApp->desktop()->height()*3/4 ) ) 149 || h > qApp->desktop()->height()*3/4 ) )
147 { 150 {
148 d->showMaximized(); 151 d->showMaximized();
149 } else { 152 } else {
150 d->resize(w,h); 153 d->resize(w,h);
151 d->show(); 154 d->show();
152 } 155 }
153} 156}
154 157
155inline int QPEApplication::execDialog( QDialog* d, bool nomax ) 158inline int QPEApplication::execDialog( QDialog* d, bool nomax )
156{ 159{
157 showDialog(d,nomax); 160 showDialog(d,nomax);
158 return d->exec(); 161 return d->exec();
159} 162}
160 163
161enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ 164enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
162 165
163inline int TransToDeg ( Transformation t ) 166inline int TransToDeg ( Transformation t )
164{ 167{
165 int d = static_cast<int>( t ); 168 int d = static_cast<int>( t );
166 return d * 90; 169 return d * 90;
167} 170}
168 171
169inline Transformation DegToTrans ( int d ) 172inline Transformation DegToTrans ( int d )
170{ 173{
171 Transformation t = static_cast<Transformation>( d / 90 ); 174 Transformation t = static_cast<Transformation>( d / 90 );
172 return t; 175 return t;
173} 176}
174 177
175/* 178/*
176 * Set current rotation of Opie, and rotation for newly started apps. 179 * Set current rotation of Opie, and rotation for newly started apps.
177 * Differs from setDefaultRotation in that 1) it rotates currently running apps, 180 * Differs from setDefaultRotation in that 1) it rotates currently running apps,
178 * and 2) does not set deforient or save orientation to qpe.conf. 181 * and 2) does not set deforient or save orientation to qpe.conf.
179 */ 182 */
180 183
181inline void QPEApplication::setCurrentRotation( int r ) 184inline void QPEApplication::setCurrentRotation( int r )
182{ 185{
183 Transformation e = DegToTrans( r ); 186 Transformation e = DegToTrans( r );
184 187
185 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 188 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
186 qApp->desktop()->qwsDisplay()->setTransformation( e ); 189 qApp->desktop()->qwsDisplay()->setTransformation( e );
187} 190}
188 191
189 192
190#endif 193#endif