summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index c562f6c..2ef60d5 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -357,193 +357,193 @@ static void setTreble( int t = 0, int percent = -1 )
357 case 0: { 357 case 0: {
358 Config cfg( "qpe" ); 358 Config cfg( "qpe" );
359 cfg.setGroup( "Volume" ); 359 cfg.setGroup( "Volume" );
360 if ( percent < 0 ) 360 if ( percent < 0 )
361 percent = cfg.readNumEntry( "TreblePercent", 50 ); 361 percent = cfg.readNumEntry( "TreblePercent", 50 );
362 362
363 int fd = 0; 363 int fd = 0;
364 int treble = percent; 364 int treble = percent;
365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
367 ::close( fd ); 367 ::close( fd );
368 } 368 }
369 } 369 }
370 break; 370 break;
371 } 371 }
372} 372}
373 373
374 374
375/*! 375/*!
376 \class QPEApplication qpeapplication.h 376 \class QPEApplication qpeapplication.h
377 \brief The QPEApplication class implements various system services 377 \brief The QPEApplication class implements various system services
378 that are available to all Qtopia applications. 378 that are available to all Qtopia applications.
379 379
380 Simply by using QPEApplication instead of QApplication, a standard Qt 380 Simply by using QPEApplication instead of QApplication, a standard Qt
381 application becomes a Qtopia application. It automatically follows 381 application becomes a Qtopia application. It automatically follows
382 style changes, quits and raises, and in the 382 style changes, quits and raises, and in the
383 case of \link docwidget.html document-oriented\endlink applications, 383 case of \link docwidget.html document-oriented\endlink applications,
384 changes the currently displayed document in response to the environment. 384 changes the currently displayed document in response to the environment.
385 385
386 To create a \link docwidget.html document-oriented\endlink 386 To create a \link docwidget.html document-oriented\endlink
387 application use showMainDocumentWidget(); to create a 387 application use showMainDocumentWidget(); to create a
388 non-document-oriented application use showMainWidget(). The 388 non-document-oriented application use showMainWidget(). The
389 keepRunning() function indicates whether the application will 389 keepRunning() function indicates whether the application will
390 continue running after it's processed the last \link qcop.html 390 continue running after it's processed the last \link qcop.html
391 QCop\endlink message. This can be changed using setKeepRunning(). 391 QCop\endlink message. This can be changed using setKeepRunning().
392 392
393 A variety of signals are emitted when certain events occur, for 393 A variety of signals are emitted when certain events occur, for
394 example, timeChanged(), clockChanged(), weekChanged(), 394 example, timeChanged(), clockChanged(), weekChanged(),
395 dateFormatChanged() and volumeChanged(). If the application receives 395 dateFormatChanged() and volumeChanged(). If the application receives
396 a \link qcop.html QCop\endlink message on the application's 396 a \link qcop.html QCop\endlink message on the application's
397 QPE/Application/\e{appname} channel, the appMessage() signal is 397 QPE/Application/\e{appname} channel, the appMessage() signal is
398 emitted. There are also flush() and reload() signals, which 398 emitted. There are also flush() and reload() signals, which
399 are emitted when synching begins and ends respectively - upon these 399 are emitted when synching begins and ends respectively - upon these
400 signals, the application should save and reload any data 400 signals, the application should save and reload any data
401 files that are involved in synching. Most of these signals will initially 401 files that are involved in synching. Most of these signals will initially
402 be received and unfiltered through the appMessage() signal. 402 be received and unfiltered through the appMessage() signal.
403 403
404 This class also provides a set of useful static functions. The 404 This class also provides a set of useful static functions. The
405 qpeDir() and documentDir() functions return the respective paths. 405 qpeDir() and documentDir() functions return the respective paths.
406 The grabKeyboard() and ungrabKeyboard() functions are used to 406 The grabKeyboard() and ungrabKeyboard() functions are used to
407 control whether the application takes control of the device's 407 control whether the application takes control of the device's
408 physical buttons (e.g. application launch keys). The stylus' mode of 408 physical buttons (e.g. application launch keys). The stylus' mode of
409 operation is set with setStylusOperation() and retrieved with 409 operation is set with setStylusOperation() and retrieved with
410 stylusOperation(). There are also setInputMethodHint() and 410 stylusOperation(). There are also setInputMethodHint() and
411 inputMethodHint() functions. 411 inputMethodHint() functions.
412 412
413 \ingroup qtopiaemb 413 \ingroup qtopiaemb
414*/ 414*/
415 415
416/*! 416/*!
417 \fn void QPEApplication::clientMoused() 417 \fn void QPEApplication::clientMoused()
418 418
419 \internal 419 \internal
420*/ 420*/
421 421
422/*! 422/*!
423 \fn void QPEApplication::timeChanged(); 423 \fn void QPEApplication::timeChanged();
424 This signal is emitted when the time changes outside the normal 424 This signal is emitted when the time changes outside the normal
425 passage of time, i.e. if the time is set backwards or forwards. 425 passage of time, i.e. if the time is set backwards or forwards.
426*/ 426*/
427 427
428/*! 428/*!
429 \fn void QPEApplication::clockChanged( bool ampm ); 429 \fn void QPEApplication::clockChanged( bool ampm );
430 430
431 This signal is emitted when the user changes the clock's style. If 431 This signal is emitted when the user changes the clock's style. If
432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
433 they want a 24-hour clock. 433 they want a 24-hour clock.
434*/ 434*/
435 435
436/*! 436/*!
437 \fn void QPEApplication::volumeChanged( bool muted ) 437 \fn void QPEApplication::volumeChanged( bool muted )
438 438
439 This signal is emitted whenever the mute state is changed. If \a 439 This signal is emitted whenever the mute state is changed. If \a
440 muted is TRUE, then sound output has been muted. 440 muted is TRUE, then sound output has been muted.
441*/ 441*/
442 442
443/*! 443/*!
444 \fn void QPEApplication::weekChanged( bool startOnMonday ) 444 \fn void QPEApplication::weekChanged( bool startOnMonday )
445 445
446 This signal is emitted if the week start day is changed. If \a 446 This signal is emitted if the week start day is changed. If \a
447 startOnMonday is TRUE then the first day of the week is Monday; if 447 startOnMonday is TRUE then the first day of the week is Monday; if
448 \a startOnMonday is FALSE then the first day of the week is 448 \a startOnMonday is FALSE then the first day of the week is
449 Sunday. 449 Sunday.
450*/ 450*/
451 451
452/*! 452/*!
453 \fn void QPEApplication::dateFormatChanged() 453 \fn void QPEApplication::dateFormatChanged(DateFormat)
454 454
455 This signal is emitted whenever the date format is changed. 455 This signal is emitted whenever the date format is changed.
456*/ 456*/
457 457
458/*! 458/*!
459 \fn void QPEApplication::flush() 459 \fn void QPEApplication::flush()
460 460
461 ### 461 ###
462*/ 462*/
463 463
464/*! 464/*!
465 \fn void QPEApplication::reload() 465 \fn void QPEApplication::reload()
466 466
467*/ 467*/
468 468
469/*! 469/*!
470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
471 471
472 This signal is emitted when a message is received on this 472 This signal is emitted when a message is received on this
473 application's QPE/Application/<i>appname</i> \link qcop.html 473 application's QPE/Application/<i>appname</i> \link qcop.html
474 QCop\endlink channel. 474 QCop\endlink channel.
475 475
476 The slot to which you connect this signal uses \a msg and \a data 476 The slot to which you connect this signal uses \a msg and \a data
477 in the following way: 477 in the following way:
478 478
479\code 479\code
480 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 480 void MyWidget::receive( const QCString& msg, const QByteArray& data )
481 { 481 {
482 QDataStream stream( data, IO_ReadOnly ); 482 QDataStream stream( data, IO_ReadOnly );
483 if ( msg == "someMessage(int,int,int)" ) { 483 if ( msg == "someMessage(int,int,int)" ) {
484 int a,b,c; 484 int a,b,c;
485 stream >> a >> b >> c; 485 stream >> a >> b >> c;
486 ... 486 ...
487 } else if ( msg == "otherMessage(QString)" ) { 487 } else if ( msg == "otherMessage(QString)" ) {
488 ... 488 ...
489 } 489 }
490 } 490 }
491\endcode 491\endcode
492 492
493 \sa qcop.html 493 \sa qcop.html
494 Note that messages received here may be processed by qpe application 494 Note that messages received here may be processed by qpe application
495 and emitted as signals, such as flush() and reload(). 495 and emitted as signals, such as flush() and reload().
496*/ 496*/
497 497
498/*! 498/*!
499 Constructs a QPEApplication just as you would construct 499 Constructs a QPEApplication just as you would construct
500 a QApplication, passing \a argc, \a argv, and \a t. 500 a QApplication, passing \a argc, \a argv, and \a t.
501 501
502 For applications, \a t should be the default, GuiClient. Only 502 For applications, \a t should be the default, GuiClient. Only
503 the Qtopia server passes GuiServer. 503 the Qtopia server passes GuiServer.
504*/ 504*/
505QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 505QPEApplication::QPEApplication( int & argc, char **argv, Type t )
506 : QApplication( argc, argv, t ) 506 : QApplication( argc, argv, t )
507{ 507{
508 d = new QPEApplicationData; 508 d = new QPEApplicationData;
509 d->loadTextCodecs(); 509 d->loadTextCodecs();
510 d->loadImageCodecs(); 510 d->loadImageCodecs();
511 int dw = desktop() ->width(); 511 int dw = desktop() ->width();
512 512
513 if ( dw < 200 ) { 513 if ( dw < 200 ) {
514 setFont( QFont( "helvetica", 8 ) ); 514 setFont( QFont( "helvetica", 8 ) );
515 AppLnk::setSmallIconSize( 10 ); 515 AppLnk::setSmallIconSize( 10 );
516 AppLnk::setBigIconSize( 28 ); 516 AppLnk::setBigIconSize( 28 );
517 } 517 }
518 else if ( dw > 600 ) { 518 else if ( dw > 600 ) {
519 setFont( QFont( "helvetica", 18 ) ); 519 setFont( QFont( "helvetica", 18 ) );
520 AppLnk::setSmallIconSize( 24 ); 520 AppLnk::setSmallIconSize( 24 );
521 AppLnk::setBigIconSize( 48 ); 521 AppLnk::setBigIconSize( 48 );
522 } 522 }
523 else if ( dw > 200 ) { 523 else if ( dw > 200 ) {
524 setFont( QFont( "helvetica", 10 ) ); 524 setFont( QFont( "helvetica", 10 ) );
525 AppLnk::setSmallIconSize( 14 ); 525 AppLnk::setSmallIconSize( 14 );
526 AppLnk::setBigIconSize( 32 ); 526 AppLnk::setBigIconSize( 32 );
527 } 527 }
528 528
529 529
530 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 530 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
531 531
532 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 532 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
533#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 533#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
534 534
535 QString qcopfn( "/tmp/qcop-msg-" ); 535 QString qcopfn( "/tmp/qcop-msg-" );
536 qcopfn += QString( argv[ 0 ] ); // append command name 536 qcopfn += QString( argv[ 0 ] ); // append command name
537 537
538 QFile f( qcopfn ); 538 QFile f( qcopfn );
539 if ( f.open( IO_ReadOnly ) ) { 539 if ( f.open( IO_ReadOnly ) ) {
540 flock( f.handle(), LOCK_EX ); 540 flock( f.handle(), LOCK_EX );
541 } 541 }
542 542
543 sysChannel = new QCopChannel( "QPE/System", this ); 543 sysChannel = new QCopChannel( "QPE/System", this );
544 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 544 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
545 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 545 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
546 546
547 QCString channel = QCString( argv[ 0 ] ); 547 QCString channel = QCString( argv[ 0 ] );
548 channel.replace( QRegExp( ".*/" ), "" ); 548 channel.replace( QRegExp( ".*/" ), "" );
549 d->appName = channel; 549 d->appName = channel;
@@ -1675,132 +1675,133 @@ void QPEApplication::grabKeyboard()
1675*/ 1675*/
1676int QPEApplication::exec() 1676int QPEApplication::exec()
1677{ 1677{
1678#ifndef QT_NO_COP 1678#ifndef QT_NO_COP
1679 d->sendQCopQ(); 1679 d->sendQCopQ();
1680#endif 1680#endif
1681 1681
1682 if ( d->keep_running ) 1682 if ( d->keep_running )
1683 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1683 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1684 return QApplication::exec(); 1684 return QApplication::exec();
1685 1685
1686#ifndef QT_NO_COP 1686#ifndef QT_NO_COP
1687 1687
1688 { 1688 {
1689 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1689 QCopEnvelope e( "QPE/System", "closing(QString)" );
1690 e << d->appName; 1690 e << d->appName;
1691 } 1691 }
1692#endif 1692#endif
1693 processEvents(); 1693 processEvents();
1694 return 0; 1694 return 0;
1695} 1695}
1696 1696
1697/*! 1697/*!
1698 \internal 1698 \internal
1699 External request for application to quit. Quits if possible without 1699 External request for application to quit. Quits if possible without
1700 loosing state. 1700 loosing state.
1701*/ 1701*/
1702void QPEApplication::tryQuit() 1702void QPEApplication::tryQuit()
1703{ 1703{
1704 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1704 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1705 return ; // Inside modal loop or konsole. Too hard to save state. 1705 return ; // Inside modal loop or konsole. Too hard to save state.
1706#ifndef QT_NO_COP 1706#ifndef QT_NO_COP
1707 1707
1708 { 1708 {
1709 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1709 QCopEnvelope e( "QPE/System", "closing(QString)" );
1710 e << d->appName; 1710 e << d->appName;
1711 } 1711 }
1712#endif 1712#endif
1713 processEvents(); 1713 processEvents();
1714 1714
1715 quit(); 1715 quit();
1716} 1716}
1717 1717
1718/*! 1718/*!
1719 \internal 1719 \internal
1720 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1720 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1721 hiding the window. If not it means quitting the application. 1721 hiding the window. If not it means quitting the application.
1722 As this is user initiated we don't need to check state. 1722 As this is user initiated we don't need to check state.
1723*/ 1723*/
1724void QPEApplication::hideOrQuit() 1724void QPEApplication::hideOrQuit()
1725{ 1725{
1726 processEvents(); 1726 processEvents();
1727 1727
1728 // If we are a preloaded application we don't actually quit, so emit 1728 // If we are a preloaded application we don't actually quit, so emit
1729 // a System message indicating we're quasi-closing. 1729 // a System message indicating we're quasi-closing.
1730 if ( d->preloaded && d->qpe_main_widget ) 1730 if ( d->preloaded && d->qpe_main_widget )
1731#ifndef QT_NO_COP 1731#ifndef QT_NO_COP
1732 1732
1733 { 1733 {
1734 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1734 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1735 e << d->appName; 1735 e << d->appName;
1736 d->qpe_main_widget->hide(); 1736 d->qpe_main_widget->hide();
1737 } 1737 }
1738#endif 1738#endif
1739 else 1739 else
1740 quit(); 1740 quit();
1741} 1741}
1742 1742
1743 1743
1744#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 1744#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
1745 1745
1746// The libraries with the skiff package (and possibly others) have 1746// The libraries with the skiff package (and possibly others) have
1747// completely useless implementations of builtin new and delete that 1747// completely useless implementations of builtin new and delete that
1748// use about 50% of your CPU. Here we revert to the simple libc 1748// use about 50% of your CPU. Here we revert to the simple libc
1749// functions. 1749// functions.
1750 1750
1751void* operator new[]( size_t size ) 1751void* operator new[]( size_t size )
1752{ 1752{
1753 return malloc( size ); 1753 return malloc( size );
1754} 1754}
1755 1755
1756void* operator new( size_t size ) 1756void* operator new( size_t size )
1757{ 1757{
1758 return malloc( size ); 1758 return malloc( size );
1759} 1759}
1760 1760
1761void operator delete[]( void* p ) 1761void operator delete[]( void* p )
1762{ 1762{
1763 free( p ); 1763 free( p );
1764} 1764}
1765 1765
1766void operator delete[]( void* p, size_t /*size*/ ) 1766void operator delete[]( void* p, size_t /*size*/ )
1767{ 1767{
1768 free( p ); 1768 free( p );
1769} 1769}
1770 1770
1771
1771void operator delete( void* p ) 1772void operator delete( void* p )
1772{ 1773{
1773 free( p ); 1774 free( p );
1774} 1775}
1775 1776
1776void operator delete( void* p, size_t /*size*/ ) 1777void operator delete( void* p, size_t /*size*/ )
1777{ 1778{
1778 free( p ); 1779 free( p );
1779} 1780}
1780 1781
1781#endif 1782#endif
1782 1783
1783#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1784#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1784#include <qwidgetlist.h> 1785#include <qwidgetlist.h>
1785#ifdef QWS 1786#ifdef QWS
1786#include <qgfx_qws.h> 1787#include <qgfx_qws.h>
1787extern QRect qt_maxWindowRect; 1788extern QRect qt_maxWindowRect;
1788void qt_setMaxWindowRect(const QRect& r ) 1789void qt_setMaxWindowRect(const QRect& r )
1789{ 1790{
1790 qt_maxWindowRect = qt_screen->mapFromDevice( r, 1791 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1791 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 1792 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1792 // Re-resize any maximized windows 1793 // Re-resize any maximized windows
1793 QWidgetList* l = QApplication::topLevelWidgets(); 1794 QWidgetList* l = QApplication::topLevelWidgets();
1794 if ( l ) { 1795 if ( l ) {
1795 QWidget * w = l->first(); 1796 QWidget * w = l->first();
1796 while ( w ) { 1797 while ( w ) {
1797 if ( w->isVisible() && w->isMaximized() ) { 1798 if ( w->isVisible() && w->isMaximized() ) {
1798 w->showMaximized(); 1799 w->showMaximized();
1799 } 1800 }
1800 w = l->next(); 1801 w = l->next();
1801 } 1802 }
1802 delete l; 1803 delete l;
1803 } 1804 }
1804} 1805}
1805#endif 1806#endif
1806#endif 1807#endif