-rw-r--r-- | library/qpeapplication.cpp | 3 |
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 | |||
@@ -261,385 +261,385 @@ public: | |||
261 | ResourceMimeFactory() | 261 | ResourceMimeFactory() |
262 | { | 262 | { |
263 | setFilePath( Global::helpPath() ); | 263 | setFilePath( Global::helpPath() ); |
264 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 264 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
265 | } | 265 | } |
266 | 266 | ||
267 | const QMimeSource* data( const QString& abs_name ) const | 267 | const QMimeSource* data( const QString& abs_name ) const |
268 | { | 268 | { |
269 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 269 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
270 | if ( !r ) { | 270 | if ( !r ) { |
271 | int sl = abs_name.length(); | 271 | int sl = abs_name.length(); |
272 | do { | 272 | do { |
273 | sl = abs_name.findRev( '/', sl - 1 ); | 273 | sl = abs_name.findRev( '/', sl - 1 ); |
274 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 274 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
275 | int dot = name.findRev( '.' ); | 275 | int dot = name.findRev( '.' ); |
276 | if ( dot >= 0 ) | 276 | if ( dot >= 0 ) |
277 | name = name.left( dot ); | 277 | name = name.left( dot ); |
278 | QImage img = Resource::loadImage( name ); | 278 | QImage img = Resource::loadImage( name ); |
279 | if ( !img.isNull() ) | 279 | if ( !img.isNull() ) |
280 | r = new QImageDrag( img ); | 280 | r = new QImageDrag( img ); |
281 | } | 281 | } |
282 | while ( !r && sl > 0 ); | 282 | while ( !r && sl > 0 ); |
283 | } | 283 | } |
284 | return r; | 284 | return r; |
285 | } | 285 | } |
286 | }; | 286 | }; |
287 | 287 | ||
288 | static int muted = 0; | 288 | static int muted = 0; |
289 | static int micMuted = 0; | 289 | static int micMuted = 0; |
290 | 290 | ||
291 | static void setVolume( int t = 0, int percent = -1 ) | 291 | static void setVolume( int t = 0, int percent = -1 ) |
292 | { | 292 | { |
293 | switch ( t ) { | 293 | switch ( t ) { |
294 | case 0: { | 294 | case 0: { |
295 | Config cfg( "qpe" ); | 295 | Config cfg( "qpe" ); |
296 | cfg.setGroup( "Volume" ); | 296 | cfg.setGroup( "Volume" ); |
297 | if ( percent < 0 ) | 297 | if ( percent < 0 ) |
298 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 298 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
299 | int fd = 0; | 299 | int fd = 0; |
300 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 300 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
301 | int vol = muted ? 0 : percent; | 301 | int vol = muted ? 0 : percent; |
302 | // set both channels to same volume | 302 | // set both channels to same volume |
303 | vol |= vol << 8; | 303 | vol |= vol << 8; |
304 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 304 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
305 | ::close( fd ); | 305 | ::close( fd ); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | static void setMic( int t = 0, int percent = -1 ) | 312 | static void setMic( int t = 0, int percent = -1 ) |
313 | { | 313 | { |
314 | switch ( t ) { | 314 | switch ( t ) { |
315 | case 0: { | 315 | case 0: { |
316 | Config cfg( "qpe" ); | 316 | Config cfg( "qpe" ); |
317 | cfg.setGroup( "Volume" ); | 317 | cfg.setGroup( "Volume" ); |
318 | if ( percent < 0 ) | 318 | if ( percent < 0 ) |
319 | percent = cfg.readNumEntry( "Mic", 50 ); | 319 | percent = cfg.readNumEntry( "Mic", 50 ); |
320 | 320 | ||
321 | int fd = 0; | 321 | int fd = 0; |
322 | int mic = micMuted ? 0 : percent; | 322 | int mic = micMuted ? 0 : percent; |
323 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 323 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
324 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 324 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
325 | ::close( fd ); | 325 | ::close( fd ); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | break; | 328 | break; |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | static void setBass( int t = 0, int percent = -1 ) | 333 | static void setBass( int t = 0, int percent = -1 ) |
334 | { | 334 | { |
335 | switch ( t ) { | 335 | switch ( t ) { |
336 | case 0: { | 336 | case 0: { |
337 | Config cfg( "qpe" ); | 337 | Config cfg( "qpe" ); |
338 | cfg.setGroup( "Volume" ); | 338 | cfg.setGroup( "Volume" ); |
339 | if ( percent < 0 ) | 339 | if ( percent < 0 ) |
340 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 340 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
341 | 341 | ||
342 | int fd = 0; | 342 | int fd = 0; |
343 | int bass = percent; | 343 | int bass = percent; |
344 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 344 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
345 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 345 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
346 | ::close( fd ); | 346 | ::close( fd ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | break; | 349 | break; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | static void setTreble( int t = 0, int percent = -1 ) | 354 | static void setTreble( int t = 0, int percent = -1 ) |
355 | { | 355 | { |
356 | switch ( t ) { | 356 | switch ( t ) { |
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 | */ |
505 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 505 | QPEApplication::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; |
550 | channel = "QPE/Application/" + channel; | 550 | channel = "QPE/Application/" + channel; |
551 | pidChannel = new QCopChannel( channel, this ); | 551 | pidChannel = new QCopChannel( channel, this ); |
552 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 552 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
553 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 553 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
554 | 554 | ||
555 | if ( f.isOpen() ) { | 555 | if ( f.isOpen() ) { |
556 | d->keep_running = FALSE; | 556 | d->keep_running = FALSE; |
557 | QDataStream ds( &f ); | 557 | QDataStream ds( &f ); |
558 | QCString channel, message; | 558 | QCString channel, message; |
559 | QByteArray data; | 559 | QByteArray data; |
560 | while ( !ds.atEnd() ) { | 560 | while ( !ds.atEnd() ) { |
561 | ds >> channel >> message >> data; | 561 | ds >> channel >> message >> data; |
562 | d->enqueueQCop( channel, message, data ); | 562 | d->enqueueQCop( channel, message, data ); |
563 | } | 563 | } |
564 | 564 | ||
565 | flock( f.handle(), LOCK_UN ); | 565 | flock( f.handle(), LOCK_UN ); |
566 | f.close(); | 566 | f.close(); |
567 | f.remove(); | 567 | f.remove(); |
568 | } | 568 | } |
569 | 569 | ||
570 | for ( int a = 0; a < argc; a++ ) { | 570 | for ( int a = 0; a < argc; a++ ) { |
571 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 571 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
572 | argv[ a ] = argv[ a + 1 ]; | 572 | argv[ a ] = argv[ a + 1 ]; |
573 | a++; | 573 | a++; |
574 | d->preloaded = TRUE; | 574 | d->preloaded = TRUE; |
575 | argc -= 1; | 575 | argc -= 1; |
576 | } | 576 | } |
577 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 577 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
578 | argv[ a ] = argv[ a + 1 ]; | 578 | argv[ a ] = argv[ a + 1 ]; |
579 | a++; | 579 | a++; |
580 | d->preloaded = TRUE; | 580 | d->preloaded = TRUE; |
581 | d->forceshow = TRUE; | 581 | d->forceshow = TRUE; |
582 | argc -= 1; | 582 | argc -= 1; |
583 | } | 583 | } |
584 | } | 584 | } |
585 | 585 | ||
586 | /* overide stored arguments */ | 586 | /* overide stored arguments */ |
587 | setArgs( argc, argv ); | 587 | setArgs( argc, argv ); |
588 | 588 | ||
589 | #endif | 589 | #endif |
590 | 590 | ||
591 | // qwsSetDecoration( new QPEDecoration() ); | 591 | // qwsSetDecoration( new QPEDecoration() ); |
592 | 592 | ||
593 | #ifndef QT_NO_TRANSLATION | 593 | #ifndef QT_NO_TRANSLATION |
594 | 594 | ||
595 | QStringList langs = Global::languageList(); | 595 | QStringList langs = Global::languageList(); |
596 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 596 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
597 | QString lang = *it; | 597 | QString lang = *it; |
598 | 598 | ||
599 | QTranslator * trans; | 599 | QTranslator * trans; |
600 | QString tfn; | 600 | QString tfn; |
601 | 601 | ||
602 | trans = new QTranslator( this ); | 602 | trans = new QTranslator( this ); |
603 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 603 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
604 | if ( trans->load( tfn ) ) | 604 | if ( trans->load( tfn ) ) |
605 | installTranslator( trans ); | 605 | installTranslator( trans ); |
606 | else | 606 | else |
607 | delete trans; | 607 | delete trans; |
608 | 608 | ||
609 | trans = new QTranslator( this ); | 609 | trans = new QTranslator( this ); |
610 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 610 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
611 | if ( trans->load( tfn ) ) | 611 | if ( trans->load( tfn ) ) |
612 | installTranslator( trans ); | 612 | installTranslator( trans ); |
613 | else | 613 | else |
614 | delete trans; | 614 | delete trans; |
615 | 615 | ||
616 | //###language/font hack; should look it up somewhere | 616 | //###language/font hack; should look it up somewhere |
617 | #ifdef QWS | 617 | #ifdef QWS |
618 | 618 | ||
619 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 619 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
620 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 620 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
621 | setFont( fn ); | 621 | setFont( fn ); |
622 | } | 622 | } |
623 | #endif | 623 | #endif |
624 | 624 | ||
625 | } | 625 | } |
626 | #endif | 626 | #endif |
627 | 627 | ||
628 | applyStyle(); | 628 | applyStyle(); |
629 | 629 | ||
630 | if ( type() == GuiServer ) { | 630 | if ( type() == GuiServer ) { |
631 | setVolume(); | 631 | setVolume(); |
632 | } | 632 | } |
633 | 633 | ||
634 | installEventFilter( this ); | 634 | installEventFilter( this ); |
635 | 635 | ||
636 | QPEMenuToolFocusManager::initialize(); | 636 | QPEMenuToolFocusManager::initialize(); |
637 | 637 | ||
638 | #ifdef QT_NO_QWS_CURSOR | 638 | #ifdef QT_NO_QWS_CURSOR |
639 | // if we have no cursor, probably don't want tooltips | 639 | // if we have no cursor, probably don't want tooltips |
640 | QToolTip::setEnabled( FALSE ); | 640 | QToolTip::setEnabled( FALSE ); |
641 | #endif | 641 | #endif |
642 | } | 642 | } |
643 | 643 | ||
644 | static QPtrDict<void>* inputMethodDict = 0; | 644 | static QPtrDict<void>* inputMethodDict = 0; |
645 | static void createInputMethodDict() | 645 | static void createInputMethodDict() |
@@ -1579,228 +1579,229 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1579 | if ( d->rightpressed && d->presswidget ) { | 1579 | if ( d->rightpressed && d->presswidget ) { |
1580 | // Right released | 1580 | // Right released |
1581 | postEvent( d->presswidget, | 1581 | postEvent( d->presswidget, |
1582 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1582 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1583 | RightButton, LeftButton + RightButton ) ); | 1583 | RightButton, LeftButton + RightButton ) ); |
1584 | // Left released, off-widget | 1584 | // Left released, off-widget |
1585 | postEvent( d->presswidget, | 1585 | postEvent( d->presswidget, |
1586 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1586 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1587 | LeftButton, LeftButton ) ); | 1587 | LeftButton, LeftButton ) ); |
1588 | postEvent( d->presswidget, | 1588 | postEvent( d->presswidget, |
1589 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1589 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1590 | LeftButton, LeftButton ) ); | 1590 | LeftButton, LeftButton ) ); |
1591 | d->rightpressed = FALSE; | 1591 | d->rightpressed = FALSE; |
1592 | return TRUE; // don't send the real Left release | 1592 | return TRUE; // don't send the real Left release |
1593 | } | 1593 | } |
1594 | } | 1594 | } |
1595 | break; | 1595 | break; |
1596 | default: | 1596 | default: |
1597 | break; | 1597 | break; |
1598 | } | 1598 | } |
1599 | break; | 1599 | break; |
1600 | default: | 1600 | default: |
1601 | ; | 1601 | ; |
1602 | } | 1602 | } |
1603 | } | 1603 | } |
1604 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1604 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1605 | QKeyEvent *ke = (QKeyEvent *)e; | 1605 | QKeyEvent *ke = (QKeyEvent *)e; |
1606 | if ( ke->key() == Key_Enter ) { | 1606 | if ( ke->key() == Key_Enter ) { |
1607 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1607 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1608 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1608 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1609 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1609 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1610 | return TRUE; | 1610 | return TRUE; |
1611 | } | 1611 | } |
1612 | } | 1612 | } |
1613 | } | 1613 | } |
1614 | return FALSE; | 1614 | return FALSE; |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | /*! | 1617 | /*! |
1618 | \reimp | 1618 | \reimp |
1619 | */ | 1619 | */ |
1620 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1620 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1621 | { | 1621 | { |
1622 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1622 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1623 | // Right pressed | 1623 | // Right pressed |
1624 | postEvent( d->presswidget, | 1624 | postEvent( d->presswidget, |
1625 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1625 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1626 | RightButton, LeftButton ) ); | 1626 | RightButton, LeftButton ) ); |
1627 | killTimer( d->presstimer ); | 1627 | killTimer( d->presstimer ); |
1628 | d->presstimer = 0; | 1628 | d->presstimer = 0; |
1629 | d->rightpressed = TRUE; | 1629 | d->rightpressed = TRUE; |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | void QPEApplication::removeSenderFromStylusDict() | 1633 | void QPEApplication::removeSenderFromStylusDict() |
1634 | { | 1634 | { |
1635 | stylusDict->remove | 1635 | stylusDict->remove |
1636 | ( ( void* ) sender() ); | 1636 | ( ( void* ) sender() ); |
1637 | if ( d->presswidget == sender() ) | 1637 | if ( d->presswidget == sender() ) |
1638 | d->presswidget = 0; | 1638 | d->presswidget = 0; |
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | /*! | 1641 | /*! |
1642 | \internal | 1642 | \internal |
1643 | */ | 1643 | */ |
1644 | bool QPEApplication::keyboardGrabbed() const | 1644 | bool QPEApplication::keyboardGrabbed() const |
1645 | { | 1645 | { |
1646 | return d->kbgrabbed; | 1646 | return d->kbgrabbed; |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | 1649 | ||
1650 | /*! | 1650 | /*! |
1651 | Reverses the effect of grabKeyboard(). This is called automatically | 1651 | Reverses the effect of grabKeyboard(). This is called automatically |
1652 | on program exit. | 1652 | on program exit. |
1653 | */ | 1653 | */ |
1654 | void QPEApplication::ungrabKeyboard() | 1654 | void QPEApplication::ungrabKeyboard() |
1655 | { | 1655 | { |
1656 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 1656 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | /*! | 1659 | /*! |
1660 | Grabs the physical keyboard keys, e.g. the application's launching | 1660 | Grabs the physical keyboard keys, e.g. the application's launching |
1661 | keys. Instead of launching applications when these keys are pressed | 1661 | keys. Instead of launching applications when these keys are pressed |
1662 | the signals emitted are sent to this application instead. Some games | 1662 | the signals emitted are sent to this application instead. Some games |
1663 | programs take over the launch keys in this way to make interaction | 1663 | programs take over the launch keys in this way to make interaction |
1664 | easier. | 1664 | easier. |
1665 | 1665 | ||
1666 | \sa ungrabKeyboard() | 1666 | \sa ungrabKeyboard() |
1667 | */ | 1667 | */ |
1668 | void QPEApplication::grabKeyboard() | 1668 | void QPEApplication::grabKeyboard() |
1669 | { | 1669 | { |
1670 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 1670 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | /*! | 1673 | /*! |
1674 | \reimp | 1674 | \reimp |
1675 | */ | 1675 | */ |
1676 | int QPEApplication::exec() | 1676 | int 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 | */ |
1702 | void QPEApplication::tryQuit() | 1702 | void 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 | */ |
1724 | void QPEApplication::hideOrQuit() | 1724 | void 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 | ||
1751 | void* operator new[]( size_t size ) | 1751 | void* operator new[]( size_t size ) |
1752 | { | 1752 | { |
1753 | return malloc( size ); | 1753 | return malloc( size ); |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | void* operator new( size_t size ) | 1756 | void* operator new( size_t size ) |
1757 | { | 1757 | { |
1758 | return malloc( size ); | 1758 | return malloc( size ); |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | void operator delete[]( void* p ) | 1761 | void operator delete[]( void* p ) |
1762 | { | 1762 | { |
1763 | free( p ); | 1763 | free( p ); |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | void operator delete[]( void* p, size_t /*size*/ ) | 1766 | void operator delete[]( void* p, size_t /*size*/ ) |
1767 | { | 1767 | { |
1768 | free( p ); | 1768 | free( p ); |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | |||
1771 | void operator delete( void* p ) | 1772 | void operator delete( void* p ) |
1772 | { | 1773 | { |
1773 | free( p ); | 1774 | free( p ); |
1774 | } | 1775 | } |
1775 | 1776 | ||
1776 | void operator delete( void* p, size_t /*size*/ ) | 1777 | void 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> |
1787 | extern QRect qt_maxWindowRect; | 1788 | extern QRect qt_maxWindowRect; |
1788 | void qt_setMaxWindowRect(const QRect& r ) | 1789 | void 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 |