-rw-r--r-- | library/global.cpp | 16 | ||||
-rw-r--r-- | library/library.pro | 7 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 40 | ||||
-rw-r--r-- | library/qpeapplication.h | 2 | ||||
-rw-r--r-- | library/qt_override.cpp | 166 | ||||
-rw-r--r-- | library/qt_override_p.h | 21 |
6 files changed, 209 insertions, 43 deletions
diff --git a/library/global.cpp b/library/global.cpp index 2162e02..d6ba84f 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -222,599 +222,585 @@ static QString dictDir() | |||
222 | \internal | 222 | \internal |
223 | */ | 223 | */ |
224 | Global::Global() | 224 | Global::Global() |
225 | { | 225 | { |
226 | } | 226 | } |
227 | 227 | ||
228 | /*! | 228 | /*! |
229 | Returns the unchangeable QDawg that contains general | 229 | Returns the unchangeable QDawg that contains general |
230 | words for the current locale. | 230 | words for the current locale. |
231 | 231 | ||
232 | \sa addedDawg() | 232 | \sa addedDawg() |
233 | */ | 233 | */ |
234 | const QDawg& Global::fixedDawg() | 234 | const QDawg& Global::fixedDawg() |
235 | { | 235 | { |
236 | if ( !fixed_dawg ) { | 236 | if ( !fixed_dawg ) { |
237 | if ( !docDirCreated ) | 237 | if ( !docDirCreated ) |
238 | createDocDir(); | 238 | createDocDir(); |
239 | 239 | ||
240 | fixed_dawg = new QDawg; | 240 | fixed_dawg = new QDawg; |
241 | QString dawgfilename = dictDir() + "/dawg"; | 241 | QString dawgfilename = dictDir() + "/dawg"; |
242 | QString words_lang; | 242 | QString words_lang; |
243 | QStringList langs = Global::languageList(); | 243 | QStringList langs = Global::languageList(); |
244 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 244 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
245 | QString lang = *it; | 245 | QString lang = *it; |
246 | words_lang = dictDir() + "/words." + lang; | 246 | words_lang = dictDir() + "/words." + lang; |
247 | QString dawgfilename_lang = dawgfilename + "." + lang; | 247 | QString dawgfilename_lang = dawgfilename + "." + lang; |
248 | if ( QFile::exists(dawgfilename_lang) || | 248 | if ( QFile::exists(dawgfilename_lang) || |
249 | QFile::exists(words_lang) ) { | 249 | QFile::exists(words_lang) ) { |
250 | dawgfilename = dawgfilename_lang; | 250 | dawgfilename = dawgfilename_lang; |
251 | break; | 251 | break; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | QFile dawgfile(dawgfilename); | 254 | QFile dawgfile(dawgfilename); |
255 | 255 | ||
256 | if ( !dawgfile.exists() ) { | 256 | if ( !dawgfile.exists() ) { |
257 | QString fn = dictDir() + "/words"; | 257 | QString fn = dictDir() + "/words"; |
258 | if ( QFile::exists(words_lang) ) | 258 | if ( QFile::exists(words_lang) ) |
259 | fn = words_lang; | 259 | fn = words_lang; |
260 | QFile in(fn); | 260 | QFile in(fn); |
261 | if ( in.open(IO_ReadOnly) ) { | 261 | if ( in.open(IO_ReadOnly) ) { |
262 | fixed_dawg->createFromWords(&in); | 262 | fixed_dawg->createFromWords(&in); |
263 | dawgfile.open(IO_WriteOnly); | 263 | dawgfile.open(IO_WriteOnly); |
264 | fixed_dawg->write(&dawgfile); | 264 | fixed_dawg->write(&dawgfile); |
265 | dawgfile.close(); | 265 | dawgfile.close(); |
266 | } | 266 | } |
267 | } else { | 267 | } else { |
268 | fixed_dawg->readFile(dawgfilename); | 268 | fixed_dawg->readFile(dawgfilename); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | return *fixed_dawg; | 272 | return *fixed_dawg; |
273 | } | 273 | } |
274 | 274 | ||
275 | /*! | 275 | /*! |
276 | Returns the changeable QDawg that contains general | 276 | Returns the changeable QDawg that contains general |
277 | words for the current locale. | 277 | words for the current locale. |
278 | 278 | ||
279 | \sa fixedDawg() | 279 | \sa fixedDawg() |
280 | */ | 280 | */ |
281 | const QDawg& Global::addedDawg() | 281 | const QDawg& Global::addedDawg() |
282 | { | 282 | { |
283 | return dawg("local"); | 283 | return dawg("local"); |
284 | } | 284 | } |
285 | 285 | ||
286 | /*! | 286 | /*! |
287 | Returns the QDawg with the given \a name. | 287 | Returns the QDawg with the given \a name. |
288 | This is an application-specific word list. | 288 | This is an application-specific word list. |
289 | 289 | ||
290 | \a name should not contain "/". | 290 | \a name should not contain "/". |
291 | */ | 291 | */ |
292 | const QDawg& Global::dawg(const QString& name) | 292 | const QDawg& Global::dawg(const QString& name) |
293 | { | 293 | { |
294 | createDocDir(); | 294 | createDocDir(); |
295 | if ( !named_dawg ) | 295 | if ( !named_dawg ) |
296 | named_dawg = new QDict<QDawg>; | 296 | named_dawg = new QDict<QDawg>; |
297 | QDawg* r = named_dawg->find(name); | 297 | QDawg* r = named_dawg->find(name); |
298 | if ( !r ) { | 298 | if ( !r ) { |
299 | r = new QDawg; | 299 | r = new QDawg; |
300 | named_dawg->insert(name,r); | 300 | named_dawg->insert(name,r); |
301 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; | 301 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; |
302 | QFile dawgfile(dawgfilename); | 302 | QFile dawgfile(dawgfilename); |
303 | if ( dawgfile.open(IO_ReadOnly) ) | 303 | if ( dawgfile.open(IO_ReadOnly) ) |
304 | r->readFile(dawgfilename); | 304 | r->readFile(dawgfilename); |
305 | } | 305 | } |
306 | return *r; | 306 | return *r; |
307 | } | 307 | } |
308 | 308 | ||
309 | /*! | 309 | /*! |
310 | \overload | 310 | \overload |
311 | Adds \a wordlist to the addedDawg(). | 311 | Adds \a wordlist to the addedDawg(). |
312 | 312 | ||
313 | Note that the addition of words persists between program executions | 313 | Note that the addition of words persists between program executions |
314 | (they are saved in the dictionary files), so you should confirm the | 314 | (they are saved in the dictionary files), so you should confirm the |
315 | words with the user before adding them. | 315 | words with the user before adding them. |
316 | */ | 316 | */ |
317 | void Global::addWords(const QStringList& wordlist) | 317 | void Global::addWords(const QStringList& wordlist) |
318 | { | 318 | { |
319 | addWords("local",wordlist); | 319 | addWords("local",wordlist); |
320 | } | 320 | } |
321 | 321 | ||
322 | /*! | 322 | /*! |
323 | \overload | 323 | \overload |
324 | Adds \a wordlist to the addedDawg(). | 324 | Adds \a wordlist to the addedDawg(). |
325 | 325 | ||
326 | Note that the addition of words persists between program executions | 326 | Note that the addition of words persists between program executions |
327 | (they are saved in the dictionary files), so you should confirm the | 327 | (they are saved in the dictionary files), so you should confirm the |
328 | words with the user before adding them. | 328 | words with the user before adding them. |
329 | */ | 329 | */ |
330 | void Global::addWords(const QString& dictname, const QStringList& wordlist) | 330 | void Global::addWords(const QString& dictname, const QStringList& wordlist) |
331 | { | 331 | { |
332 | QDawg& d = (QDawg&)dawg(dictname); | 332 | QDawg& d = (QDawg&)dawg(dictname); |
333 | QStringList all = d.allWords() + wordlist; | 333 | QStringList all = d.allWords() + wordlist; |
334 | d.createFromWords(all); | 334 | d.createFromWords(all); |
335 | 335 | ||
336 | QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; | 336 | QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; |
337 | QFile dawgfile(dawgfilename); | 337 | QFile dawgfile(dawgfilename); |
338 | if ( dawgfile.open(IO_WriteOnly) ) { | 338 | if ( dawgfile.open(IO_WriteOnly) ) { |
339 | d.write(&dawgfile); | 339 | d.write(&dawgfile); |
340 | dawgfile.close(); | 340 | dawgfile.close(); |
341 | } | 341 | } |
342 | 342 | ||
343 | // #### Re-read the dawg here if we use mmap(). | 343 | // #### Re-read the dawg here if we use mmap(). |
344 | 344 | ||
345 | // #### Signal other processes to re-read. | 345 | // #### Signal other processes to re-read. |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | /*! | 349 | /*! |
350 | Returns the full path for the application called \a appname, with the | 350 | Returns the full path for the application called \a appname, with the |
351 | given \a filename. Returns QString::null if there was a problem creating | 351 | given \a filename. Returns QString::null if there was a problem creating |
352 | the directory tree for \a appname. | 352 | the directory tree for \a appname. |
353 | If \a filename contains "/", it is the caller's responsibility to | 353 | If \a filename contains "/", it is the caller's responsibility to |
354 | ensure that those directories exist. | 354 | ensure that those directories exist. |
355 | */ | 355 | */ |
356 | QString Global::applicationFileName(const QString& appname, const QString& filename) | 356 | QString Global::applicationFileName(const QString& appname, const QString& filename) |
357 | { | 357 | { |
358 | QDir d; | 358 | QDir d; |
359 | QString r = getenv("HOME"); | 359 | QString r = getenv("HOME"); |
360 | r += "/Applications/"; | 360 | r += "/Applications/"; |
361 | if ( !QFile::exists( r ) ) | 361 | if ( !QFile::exists( r ) ) |
362 | if ( d.mkdir(r) == false ) | 362 | if ( d.mkdir(r) == false ) |
363 | return QString::null; | 363 | return QString::null; |
364 | r += appname; | 364 | r += appname; |
365 | if ( !QFile::exists( r ) ) | 365 | if ( !QFile::exists( r ) ) |
366 | if ( d.mkdir(r) == false ) | 366 | if ( d.mkdir(r) == false ) |
367 | return QString::null; | 367 | return QString::null; |
368 | r += "/"; r += filename; | 368 | r += "/"; r += filename; |
369 | return r; | 369 | return r; |
370 | } | 370 | } |
371 | 371 | ||
372 | /*! | 372 | /*! |
373 | \internal | 373 | \internal |
374 | */ | 374 | */ |
375 | void Global::createDocDir() | 375 | void Global::createDocDir() |
376 | { | 376 | { |
377 | if ( !docDirCreated ) { | 377 | if ( !docDirCreated ) { |
378 | docDirCreated = TRUE; | 378 | docDirCreated = TRUE; |
379 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 379 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | /*! | 384 | /*! |
385 | Displays a status \a message to the user. This usually appears | 385 | Displays a status \a message to the user. This usually appears |
386 | in the taskbar for a short amount of time, then disappears. | 386 | in the taskbar for a short amount of time, then disappears. |
387 | */ | 387 | */ |
388 | void Global::statusMessage(const QString& message) | 388 | void Global::statusMessage(const QString& message) |
389 | { | 389 | { |
390 | #if!defined(QT_NO_COP) | 390 | #if!defined(QT_NO_COP) |
391 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); | 391 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); |
392 | e << message; | 392 | e << message; |
393 | #endif | 393 | #endif |
394 | } | 394 | } |
395 | 395 | ||
396 | /*! | 396 | /*! |
397 | \internal | 397 | \internal |
398 | */ | 398 | */ |
399 | void Global::applyStyle() | 399 | void Global::applyStyle() |
400 | { | 400 | { |
401 | #if !defined(QT_NO_COP) | 401 | #if !defined(QT_NO_COP) |
402 | QCopChannel::send( "QPE/System", "applyStyle()" ); | 402 | QCopChannel::send( "QPE/System", "applyStyle()" ); |
403 | #else | 403 | #else |
404 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version | 404 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version |
405 | #endif | 405 | #endif |
406 | } | 406 | } |
407 | 407 | ||
408 | /*! | 408 | /*! |
409 | \internal | 409 | \internal |
410 | */ | 410 | */ |
411 | QWidget *Global::shutdown( bool ) | 411 | QWidget *Global::shutdown( bool ) |
412 | { | 412 | { |
413 | #if !defined(QT_NO_COP) | 413 | #if !defined(QT_NO_COP) |
414 | QCopChannel::send( "QPE/System", "shutdown()" ); | 414 | QCopChannel::send( "QPE/System", "shutdown()" ); |
415 | #endif | 415 | #endif |
416 | return 0; | 416 | return 0; |
417 | } | 417 | } |
418 | 418 | ||
419 | /*! | 419 | /*! |
420 | \internal | 420 | \internal |
421 | */ | 421 | */ |
422 | QWidget *Global::restart( bool ) | 422 | QWidget *Global::restart( bool ) |
423 | { | 423 | { |
424 | #if !defined(QT_NO_COP) | 424 | #if !defined(QT_NO_COP) |
425 | QCopChannel::send( "QPE/System", "restart()" ); | 425 | QCopChannel::send( "QPE/System", "restart()" ); |
426 | #endif | 426 | #endif |
427 | return 0; | 427 | return 0; |
428 | } | 428 | } |
429 | 429 | ||
430 | /*! | 430 | /*! |
431 | Explicitly show the current input method. | 431 | Explicitly show the current input method. |
432 | 432 | ||
433 | Input methods are indicated in the taskbar by a small icon. If the | 433 | Input methods are indicated in the taskbar by a small icon. If the |
434 | input method is activated (shown) then it takes up some proportion | 434 | input method is activated (shown) then it takes up some proportion |
435 | of the bottom of the screen, to allow the user to interact (input | 435 | of the bottom of the screen, to allow the user to interact (input |
436 | characters) with it. | 436 | characters) with it. |
437 | 437 | ||
438 | \sa hideInputMethod() | 438 | \sa hideInputMethod() |
439 | */ | 439 | */ |
440 | void Global::showInputMethod() | 440 | void Global::showInputMethod() |
441 | { | 441 | { |
442 | #if !defined(QT_NO_COP) | 442 | #if !defined(QT_NO_COP) |
443 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); | 443 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); |
444 | #endif | 444 | #endif |
445 | } | 445 | } |
446 | 446 | ||
447 | /*! | 447 | /*! |
448 | Explicitly hide the current input method. | 448 | Explicitly hide the current input method. |
449 | 449 | ||
450 | The current input method is still indicated in the taskbar, but no | 450 | The current input method is still indicated in the taskbar, but no |
451 | longer takes up screen space, and can no longer be interacted with. | 451 | longer takes up screen space, and can no longer be interacted with. |
452 | 452 | ||
453 | \sa showInputMethod() | 453 | \sa showInputMethod() |
454 | */ | 454 | */ |
455 | void Global::hideInputMethod() | 455 | void Global::hideInputMethod() |
456 | { | 456 | { |
457 | #if !defined(QT_NO_COP) | 457 | #if !defined(QT_NO_COP) |
458 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); | 458 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); |
459 | #endif | 459 | #endif |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | /*! | 463 | /*! |
464 | \internal | 464 | \internal |
465 | */ | 465 | */ |
466 | bool Global::isBuiltinCommand( const QString &name ) | 466 | bool Global::isBuiltinCommand( const QString &name ) |
467 | { | 467 | { |
468 | if(!builtin) | 468 | if(!builtin) |
469 | return FALSE; // yes, it can happen | 469 | return FALSE; // yes, it can happen |
470 | for (int i = 0; builtin[i].file; i++) { | 470 | for (int i = 0; builtin[i].file; i++) { |
471 | if ( builtin[i].file == name ) { | 471 | if ( builtin[i].file == name ) { |
472 | return TRUE; | 472 | return TRUE; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | return FALSE; | 475 | return FALSE; |
476 | } | 476 | } |
477 | 477 | ||
478 | Global::Command* Global::builtin=0; | 478 | Global::Command* Global::builtin=0; |
479 | QGuardedPtr<QWidget> *Global::running=0; | 479 | QGuardedPtr<QWidget> *Global::running=0; |
480 | 480 | ||
481 | /*! | 481 | /*! |
482 | \class Global::Command | 482 | \class Global::Command |
483 | \brief The Global::Command class is internal. | 483 | \brief The Global::Command class is internal. |
484 | \internal | 484 | \internal |
485 | */ | 485 | */ |
486 | 486 | ||
487 | /*! | 487 | /*! |
488 | \internal | 488 | \internal |
489 | */ | 489 | */ |
490 | void Global::setBuiltinCommands( Command* list ) | 490 | void Global::setBuiltinCommands( Command* list ) |
491 | { | 491 | { |
492 | if ( running ) | 492 | if ( running ) |
493 | delete [] running; | 493 | delete [] running; |
494 | 494 | ||
495 | builtin = list; | 495 | builtin = list; |
496 | int count = 0; | 496 | int count = 0; |
497 | if (!builtin) | 497 | if (!builtin) |
498 | return; | 498 | return; |
499 | while ( builtin[count].file ) | 499 | while ( builtin[count].file ) |
500 | count++; | 500 | count++; |
501 | 501 | ||
502 | running = new QGuardedPtr<QWidget> [ count ]; | 502 | running = new QGuardedPtr<QWidget> [ count ]; |
503 | } | 503 | } |
504 | 504 | ||
505 | /*! | 505 | /*! |
506 | \internal | 506 | \internal |
507 | */ | 507 | */ |
508 | void Global::setDocument( QWidget* receiver, const QString& document ) | 508 | void Global::setDocument( QWidget* receiver, const QString& document ) |
509 | { | 509 | { |
510 | Emitter emitter(receiver,document); | 510 | Emitter emitter(receiver,document); |
511 | } | 511 | } |
512 | 512 | ||
513 | /*! | 513 | /*! |
514 | \internal | 514 | \internal |
515 | */ | 515 | */ |
516 | bool Global::terminateBuiltin( const QString& n ) | 516 | bool Global::terminateBuiltin( const QString& n ) |
517 | { | 517 | { |
518 | if (!builtin) | 518 | if (!builtin) |
519 | return FALSE; | 519 | return FALSE; |
520 | for (int i = 0; builtin[i].file; i++) { | 520 | for (int i = 0; builtin[i].file; i++) { |
521 | if ( builtin[i].file == n ) { | 521 | if ( builtin[i].file == n ) { |
522 | delete running[i]; | 522 | delete running[i]; |
523 | return TRUE; | 523 | return TRUE; |
524 | } | 524 | } |
525 | } | 525 | } |
526 | return FALSE; | 526 | return FALSE; |
527 | } | 527 | } |
528 | 528 | ||
529 | /*! | 529 | /*! |
530 | \internal | 530 | \internal |
531 | */ | 531 | */ |
532 | void Global::terminate( const AppLnk* app ) | 532 | void Global::terminate( const AppLnk* app ) |
533 | { | 533 | { |
534 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this | 534 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this |
535 | 535 | ||
536 | #ifndef QT_NO_COP | 536 | #ifndef QT_NO_COP |
537 | QCString channel = "QPE/Application/" + app->exec().utf8(); | 537 | QCString channel = "QPE/Application/" + app->exec().utf8(); |
538 | if ( QCopChannel::isRegistered(channel) ) { | 538 | if ( QCopChannel::isRegistered(channel) ) { |
539 | QCopEnvelope e(channel, "quit()"); | 539 | QCopEnvelope e(channel, "quit()"); |
540 | } | 540 | } |
541 | #endif | 541 | #endif |
542 | } | 542 | } |
543 | 543 | ||
544 | /*! | 544 | /*! |
545 | Low-level function to run command \a c. | 545 | Low-level function to run command \a c. |
546 | 546 | ||
547 | \warning Do not use this function. Use execute instead. | 547 | \warning Do not use this function. Use execute instead. |
548 | 548 | ||
549 | \sa execute() | 549 | \sa execute() |
550 | */ | 550 | */ |
551 | void Global::invoke(const QString &c) | 551 | void Global::invoke(const QString &c) |
552 | { | 552 | { |
553 | // Convert the command line in to a list of arguments | 553 | // Convert the command line in to a list of arguments |
554 | QStringList list = QStringList::split(QRegExp(" *"),c); | 554 | QStringList list = QStringList::split(QRegExp(" *"),c); |
555 | 555 | ||
556 | #if !defined(QT_NO_COP) | 556 | #if !defined(QT_NO_COP) |
557 | QString ap=list[0]; | 557 | QString ap=list[0]; |
558 | // see if the application is already running | 558 | // see if the application is already running |
559 | // XXX should lock file /tmp/qcop-msg-ap | 559 | // XXX should lock file /tmp/qcop-msg-ap |
560 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 560 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
561 | // If the channel is already register, the app is already running, so show it. | 561 | // If the channel is already register, the app is already running, so show it. |
562 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 562 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
563 | 563 | ||
564 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 564 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
565 | e << ap; | 565 | e << ap; |
566 | return; | 566 | return; |
567 | } | 567 | } |
568 | // XXX should unlock file /tmp/qcop-msg-ap | 568 | // XXX should unlock file /tmp/qcop-msg-ap |
569 | //see if it is being started | 569 | //see if it is being started |
570 | if ( StartingAppList::isStarting( ap ) ) { | 570 | if ( StartingAppList::isStarting( ap ) ) { |
571 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 571 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
572 | e << ap; | 572 | e << ap; |
573 | return; | 573 | return; |
574 | } | 574 | } |
575 | 575 | ||
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | #ifdef QT_NO_QWS_MULTIPROCESS | 578 | #ifdef QT_NO_QWS_MULTIPROCESS |
579 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 579 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
580 | #else | 580 | #else |
581 | 581 | ||
582 | QStrList slist; | 582 | QStrList slist; |
583 | unsigned int j; | 583 | unsigned int j; |
584 | for ( j = 0; j < list.count(); j++ ) | 584 | for ( j = 0; j < list.count(); j++ ) |
585 | slist.append( list[j].utf8() ); | 585 | slist.append( list[j].utf8() ); |
586 | 586 | ||
587 | const char **args = new (const char *)[slist.count() + 1]; | 587 | const char **args = new (const char *)[slist.count() + 1]; |
588 | for ( j = 0; j < slist.count(); j++ ) | 588 | for ( j = 0; j < slist.count(); j++ ) |
589 | args[j] = slist.at(j); | 589 | args[j] = slist.at(j); |
590 | args[j] = NULL; | 590 | args[j] = NULL; |
591 | 591 | ||
592 | #if !defined(QT_NO_COP) | 592 | #if !defined(QT_NO_COP) |
593 | // an attempt to show a wait... | 593 | // an attempt to show a wait... |
594 | // more logic should be used, but this will be fine for the moment... | 594 | // more logic should be used, but this will be fine for the moment... |
595 | QCopEnvelope ( "QPE/System", "busy()" ); | 595 | QCopEnvelope ( "QPE/System", "busy()" ); |
596 | #endif | 596 | #endif |
597 | 597 | ||
598 | #ifdef HAVE_QUICKEXEC | 598 | #ifdef HAVE_QUICKEXEC |
599 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 599 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
600 | qDebug("libfile = %s", libexe.latin1() ); | 600 | qDebug("libfile = %s", libexe.latin1() ); |
601 | if ( QFile::exists( libexe ) ) { | 601 | if ( QFile::exists( libexe ) ) { |
602 | qDebug("calling quickexec %s", libexe.latin1() ); | 602 | qDebug("calling quickexec %s", libexe.latin1() ); |
603 | quickexecv( libexe.utf8().data(), (const char **)args ); | 603 | quickexecv( libexe.utf8().data(), (const char **)args ); |
604 | } else | 604 | } else |
605 | #endif | 605 | #endif |
606 | { | 606 | { |
607 | char *oldpre = ::getenv ( "LD_PRELOAD" ); | ||
608 | |||
609 | QString newpre = QPEApplication::qpeDir ( ) + "/lib/libpreload.so"; | ||
610 | if ( QFile::exists ( newpre )) { | ||
611 | if ( oldpre && oldpre [0] ) | ||
612 | newpre = newpre + ":" + oldpre; | ||
613 | ::setenv ( "LD_PRELOAD", newpre. latin1( ), 1 ); | ||
614 | qDebug ( "\nPRELOADING\n" ); | ||
615 | } | ||
616 | |||
617 | if ( !::vfork() ) { | 607 | if ( !::vfork() ) { |
618 | for ( int fd = 3; fd < 100; fd++ ) | 608 | for ( int fd = 3; fd < 100; fd++ ) |
619 | ::close( fd ); | 609 | ::close( fd ); |
620 | ::setpgid( ::getpid(), ::getppid() ); | 610 | ::setpgid( ::getpid(), ::getppid() ); |
621 | // Try bindir first, so that foo/bar works too | 611 | // Try bindir first, so that foo/bar works too |
622 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); | 612 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); |
623 | ::execvp( args[0], (char * const *)args ); | 613 | ::execvp( args[0], (char * const *)args ); |
624 | _exit( -1 ); | 614 | _exit( -1 ); |
625 | } | 615 | } |
626 | if ( oldpre ) | ||
627 | ::setenv ( "LD_PRELOAD", oldpre, 1 ); | ||
628 | else | ||
629 | ::unsetenv ( "LD_PRELOAD" ); | ||
630 | } | 616 | } |
631 | StartingAppList::add( list[0] ); | 617 | StartingAppList::add( list[0] ); |
632 | #endif //QT_NO_QWS_MULTIPROCESS | 618 | #endif //QT_NO_QWS_MULTIPROCESS |
633 | } | 619 | } |
634 | 620 | ||
635 | 621 | ||
636 | /*! | 622 | /*! |
637 | Executes the application identfied by \a c, passing \a | 623 | Executes the application identfied by \a c, passing \a |
638 | document if it isn't null. | 624 | document if it isn't null. |
639 | 625 | ||
640 | Note that a better approach might be to send a QCop message to the | 626 | Note that a better approach might be to send a QCop message to the |
641 | application's QPE/Application/\e{appname} channel. | 627 | application's QPE/Application/\e{appname} channel. |
642 | */ | 628 | */ |
643 | void Global::execute( const QString &c, const QString& document ) | 629 | void Global::execute( const QString &c, const QString& document ) |
644 | { | 630 | { |
645 | if ( qApp->type() != QApplication::GuiServer ) { | 631 | if ( qApp->type() != QApplication::GuiServer ) { |
646 | // ask the server to do the work | 632 | // ask the server to do the work |
647 | #if !defined(QT_NO_COP) | 633 | #if !defined(QT_NO_COP) |
648 | if ( document.isNull() ) { | 634 | if ( document.isNull() ) { |
649 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 635 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
650 | e << c; | 636 | e << c; |
651 | } else { | 637 | } else { |
652 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 638 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
653 | e << c << document; | 639 | e << c << document; |
654 | } | 640 | } |
655 | #endif | 641 | #endif |
656 | return; | 642 | return; |
657 | } | 643 | } |
658 | 644 | ||
659 | // Attempt to execute the app using a builtin class for the app first | 645 | // Attempt to execute the app using a builtin class for the app first |
660 | // else try and find it in the bin directory | 646 | // else try and find it in the bin directory |
661 | if (builtin) { | 647 | if (builtin) { |
662 | for (int i = 0; builtin[i].file; i++) { | 648 | for (int i = 0; builtin[i].file; i++) { |
663 | if ( builtin[i].file == c ) { | 649 | if ( builtin[i].file == c ) { |
664 | if ( running[i] ) { | 650 | if ( running[i] ) { |
665 | if ( !document.isNull() && builtin[i].documentary ) | 651 | if ( !document.isNull() && builtin[i].documentary ) |
666 | setDocument(running[i], document); | 652 | setDocument(running[i], document); |
667 | running[i]->raise(); | 653 | running[i]->raise(); |
668 | running[i]->show(); | 654 | running[i]->show(); |
669 | running[i]->setActiveWindow(); | 655 | running[i]->setActiveWindow(); |
670 | } else { | 656 | } else { |
671 | running[i] = builtin[i].func( builtin[i].maximized ); | 657 | running[i] = builtin[i].func( builtin[i].maximized ); |
672 | } | 658 | } |
673 | #ifndef QT_NO_COP | 659 | #ifndef QT_NO_COP |
674 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 660 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
675 | e << c; // that was quick ;-) | 661 | e << c; // that was quick ;-) |
676 | #endif | 662 | #endif |
677 | return; | 663 | return; |
678 | } | 664 | } |
679 | } | 665 | } |
680 | } | 666 | } |
681 | 667 | ||
682 | //Global::invoke(c, document); | 668 | //Global::invoke(c, document); |
683 | 669 | ||
684 | // Convert the command line in to a list of arguments | 670 | // Convert the command line in to a list of arguments |
685 | QStringList list = QStringList::split(QRegExp(" *"),c); | 671 | QStringList list = QStringList::split(QRegExp(" *"),c); |
686 | 672 | ||
687 | #if !defined(QT_NO_COP) | 673 | #if !defined(QT_NO_COP) |
688 | QString ap=list[0]; | 674 | QString ap=list[0]; |
689 | 675 | ||
690 | qDebug("executing %s", ap.latin1() ); | 676 | qDebug("executing %s", ap.latin1() ); |
691 | 677 | ||
692 | /* if need be, sending a qcop message will result in an invoke, see | 678 | /* if need be, sending a qcop message will result in an invoke, see |
693 | preceeding function */ | 679 | preceeding function */ |
694 | invoke( ap ); | 680 | invoke( ap ); |
695 | //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 681 | //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
696 | if ( !document.isEmpty() ) { | 682 | if ( !document.isEmpty() ) { |
697 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | 683 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); |
698 | env << document; | 684 | env << document; |
699 | } | 685 | } |
700 | #endif | 686 | #endif |
701 | } | 687 | } |
702 | 688 | ||
703 | /*! | 689 | /*! |
704 | Returns the string \a s with the characters '\', '"', and '$' quoted | 690 | Returns the string \a s with the characters '\', '"', and '$' quoted |
705 | by a preceeding '\'. | 691 | by a preceeding '\'. |
706 | 692 | ||
707 | \sa stringQuote() | 693 | \sa stringQuote() |
708 | */ | 694 | */ |
709 | QString Global::shellQuote(const QString& s) | 695 | QString Global::shellQuote(const QString& s) |
710 | { | 696 | { |
711 | QString r="\""; | 697 | QString r="\""; |
712 | for (int i=0; i<(int)s.length(); i++) { | 698 | for (int i=0; i<(int)s.length(); i++) { |
713 | char c = s[i].latin1(); | 699 | char c = s[i].latin1(); |
714 | switch (c) { | 700 | switch (c) { |
715 | case '\\': case '"': case '$': | 701 | case '\\': case '"': case '$': |
716 | r+="\\"; | 702 | r+="\\"; |
717 | } | 703 | } |
718 | r += s[i]; | 704 | r += s[i]; |
719 | } | 705 | } |
720 | r += "\""; | 706 | r += "\""; |
721 | return r; | 707 | return r; |
722 | } | 708 | } |
723 | 709 | ||
724 | /*! | 710 | /*! |
725 | Returns the string \a s with the characters '\' and '"' quoted by a | 711 | Returns the string \a s with the characters '\' and '"' quoted by a |
726 | preceeding '\'. | 712 | preceeding '\'. |
727 | 713 | ||
728 | \sa shellQuote() | 714 | \sa shellQuote() |
729 | */ | 715 | */ |
730 | QString Global::stringQuote(const QString& s) | 716 | QString Global::stringQuote(const QString& s) |
731 | { | 717 | { |
732 | QString r="\""; | 718 | QString r="\""; |
733 | for (int i=0; i<(int)s.length(); i++) { | 719 | for (int i=0; i<(int)s.length(); i++) { |
734 | char c = s[i].latin1(); | 720 | char c = s[i].latin1(); |
735 | switch (c) { | 721 | switch (c) { |
736 | case '\\': case '"': | 722 | case '\\': case '"': |
737 | r+="\\"; | 723 | r+="\\"; |
738 | } | 724 | } |
739 | r += s[i]; | 725 | r += s[i]; |
740 | } | 726 | } |
741 | r += "\""; | 727 | r += "\""; |
742 | return r; | 728 | return r; |
743 | } | 729 | } |
744 | 730 | ||
745 | /*! | 731 | /*! |
746 | Finds all documents on the system's document directories which | 732 | Finds all documents on the system's document directories which |
747 | match the filter \a mimefilter, and appends the resulting DocLnk | 733 | match the filter \a mimefilter, and appends the resulting DocLnk |
748 | objects to \a folder. | 734 | objects to \a folder. |
749 | */ | 735 | */ |
750 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 736 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
751 | { | 737 | { |
752 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 738 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
753 | DocLnkSet d(homedocs,mimefilter); | 739 | DocLnkSet d(homedocs,mimefilter); |
754 | folder->appendFrom(d); | 740 | folder->appendFrom(d); |
755 | /** let's do intellegint way of searching these files | 741 | /** let's do intellegint way of searching these files |
756 | * a) the user don't want to check mediums global | 742 | * a) the user don't want to check mediums global |
757 | * b) the user wants to check but use the global options for it | 743 | * b) the user wants to check but use the global options for it |
758 | * c) the user wants to check it but not this medium | 744 | * c) the user wants to check it but not this medium |
759 | * d) the user wants to check and this medium as well | 745 | * d) the user wants to check and this medium as well |
760 | * | 746 | * |
761 | * In all cases we need to apply a different mimefilter to | 747 | * In all cases we need to apply a different mimefilter to |
762 | * the medium. | 748 | * the medium. |
763 | * a) mimefilter.isEmpty() we need to apply the responding filter | 749 | * a) mimefilter.isEmpty() we need to apply the responding filter |
764 | * either the global or the one on the medium | 750 | * either the global or the one on the medium |
765 | * | 751 | * |
766 | * b) mimefilter is set to an application we need to find out if the | 752 | * b) mimefilter is set to an application we need to find out if the |
767 | * mimetypes are included in the mime mask of the medium | 753 | * mimetypes are included in the mime mask of the medium |
768 | */ | 754 | */ |
769 | StorageInfo storage; | 755 | StorageInfo storage; |
770 | const QList<FileSystem> &fs = storage.fileSystems(); | 756 | const QList<FileSystem> &fs = storage.fileSystems(); |
771 | QListIterator<FileSystem> it ( fs ); | 757 | QListIterator<FileSystem> it ( fs ); |
772 | for ( ; it.current(); ++it ) { | 758 | for ( ; it.current(); ++it ) { |
773 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 759 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
774 | // this is a candidate look at the cf and see if we should search on it | 760 | // this is a candidate look at the cf and see if we should search on it |
775 | QString path = (*it)->path(); | 761 | QString path = (*it)->path(); |
776 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) | 762 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) |
777 | continue; | 763 | continue; |
778 | DocLnkSet ide( path, mimefilter ); | 764 | DocLnkSet ide( path, mimefilter ); |
779 | folder->appendFrom(ide); | 765 | folder->appendFrom(ide); |
780 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 766 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
781 | QString path = (*it)->path() + "/Documents"; | 767 | QString path = (*it)->path() + "/Documents"; |
782 | DocLnkSet ide( path, mimefilter ); | 768 | DocLnkSet ide( path, mimefilter ); |
783 | folder->appendFrom(ide); | 769 | folder->appendFrom(ide); |
784 | } | 770 | } |
785 | } | 771 | } |
786 | } | 772 | } |
787 | 773 | ||
788 | QStringList Global::languageList() | 774 | QStringList Global::languageList() |
789 | { | 775 | { |
790 | QString lang = getenv("LANG"); | 776 | QString lang = getenv("LANG"); |
791 | QStringList langs; | 777 | QStringList langs; |
792 | langs.append(lang); | 778 | langs.append(lang); |
793 | int i = lang.find("."); | 779 | int i = lang.find("."); |
794 | if ( i > 0 ) | 780 | if ( i > 0 ) |
795 | lang = lang.left( i ); | 781 | lang = lang.left( i ); |
796 | i = lang.find( "_" ); | 782 | i = lang.find( "_" ); |
797 | if ( i > 0 ) | 783 | if ( i > 0 ) |
798 | langs.append(lang.left(i)); | 784 | langs.append(lang.left(i)); |
799 | return langs; | 785 | return langs; |
800 | } | 786 | } |
801 | 787 | ||
802 | QStringList Global::helpPath() | 788 | QStringList Global::helpPath() |
803 | { | 789 | { |
804 | QStringList path; | 790 | QStringList path; |
805 | QStringList langs = Global::languageList(); | 791 | QStringList langs = Global::languageList(); |
806 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 792 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
807 | QString lang = *it; | 793 | QString lang = *it; |
808 | if ( !lang.isEmpty() ) | 794 | if ( !lang.isEmpty() ) |
809 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; | 795 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; |
810 | } | 796 | } |
811 | path += QPEApplication::qpeDir() + "/pics"; | 797 | path += QPEApplication::qpeDir() + "/pics"; |
812 | path += QPEApplication::qpeDir() + "/help/html"; | 798 | path += QPEApplication::qpeDir() + "/help/html"; |
813 | path += QPEApplication::qpeDir() + "/docs"; | 799 | path += QPEApplication::qpeDir() + "/docs"; |
814 | 800 | ||
815 | 801 | ||
816 | return path; | 802 | return path; |
817 | } | 803 | } |
818 | 804 | ||
819 | 805 | ||
820 | #include "global.moc" | 806 | #include "global.moc" |
diff --git a/library/library.pro b/library/library.pro index 4a06550..d9538fb 100644 --- a/library/library.pro +++ b/library/library.pro | |||
@@ -1,143 +1,146 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= calendar.h \ | 3 | HEADERS= calendar.h \ |
4 | global.h \ | 4 | global.h \ |
5 | resource.h \ | 5 | resource.h \ |
6 | xmlreader.h \ | 6 | xmlreader.h \ |
7 | mimetype.h \ | 7 | mimetype.h \ |
8 | menubutton.h \ | 8 | menubutton.h \ |
9 | network.h \ | 9 | network.h \ |
10 | networkinterface.h \ | 10 | networkinterface.h \ |
11 | filemanager.h \ | 11 | filemanager.h \ |
12 | fontmanager.h \ | 12 | fontmanager.h \ |
13 | qdawg.h \ | 13 | qdawg.h \ |
14 | datebookmonth.h \ | 14 | datebookmonth.h \ |
15 | fileselector.h \ | 15 | fileselector.h \ |
16 | fileselector_p.h \ | 16 | fileselector_p.h \ |
17 | imageedit.h \ | 17 | imageedit.h \ |
18 | qcopenvelope_qws.h \ | 18 | qcopenvelope_qws.h \ |
19 | qpedecoration_qws.h \ | 19 | qpedecoration_qws.h \ |
20 | qpeapplication.h \ | 20 | qpeapplication.h \ |
21 | qpestyle.h \ | 21 | qpestyle.h \ |
22 | qpedialog.h \ | 22 | qpedialog.h \ |
23 | lightstyle.h \ | 23 | lightstyle.h \ |
24 | config.h \ | 24 | config.h \ |
25 | applnk.h \ | 25 | applnk.h \ |
26 | sound.h \ | 26 | sound.h \ |
27 | tzselect.h \ | 27 | tzselect.h \ |
28 | qmath.h \ | 28 | qmath.h \ |
29 | datebookdb.h \ | 29 | datebookdb.h \ |
30 | alarmserver.h \ | 30 | alarmserver.h \ |
31 | process.h \ | 31 | process.h \ |
32 | password.h \ | 32 | password.h \ |
33 | timestring.h \ | 33 | timestring.h \ |
34 | fontfactoryinterface.h \ | 34 | fontfactoryinterface.h \ |
35 | fontdatabase.h \ | 35 | fontdatabase.h \ |
36 | power.h \ | 36 | power.h \ |
37 | storage.h \ | 37 | storage.h \ |
38 | qpemessagebox.h \ | 38 | qpemessagebox.h \ |
39 | timeconversion.h \ | 39 | timeconversion.h \ |
40 | qpedebug.h \ | 40 | qpedebug.h \ |
41 | qpemenubar.h \ | 41 | qpemenubar.h \ |
42 | qpetoolbar.h \ | 42 | qpetoolbar.h \ |
43 | backend/categories.h \ | 43 | backend/categories.h \ |
44 | stringutil.h \ | 44 | stringutil.h \ |
45 | backend/palmtoprecord.h \ | 45 | backend/palmtoprecord.h \ |
46 | backend/task.h \ | 46 | backend/task.h \ |
47 | backend/event.h \ | 47 | backend/event.h \ |
48 | backend/contact.h\ | 48 | backend/contact.h\ |
49 | categorymenu.h \ | 49 | categorymenu.h \ |
50 | categoryedit_p.h \ | 50 | categoryedit_p.h \ |
51 | categoryselect.h \ | 51 | categoryselect.h \ |
52 | categorywidget.h \ | 52 | categorywidget.h \ |
53 | ir.h \ | 53 | ir.h \ |
54 | backend/vobject_p.h \ | 54 | backend/vobject_p.h \ |
55 | findwidget_p.h \ | 55 | findwidget_p.h \ |
56 | finddialog.h \ | 56 | finddialog.h \ |
57 | lnkproperties.h \ | 57 | lnkproperties.h \ |
58 | windowdecorationinterface.h \ | 58 | windowdecorationinterface.h \ |
59 | textcodecinterface.h \ | 59 | textcodecinterface.h \ |
60 | imagecodecinterface.h | 60 | imagecodecinterface.h \ |
61 | qt_override_p.h | ||
62 | |||
61 | SOURCES= calendar.cpp \ | 63 | SOURCES= calendar.cpp \ |
62 | global.cpp \ | 64 | global.cpp \ |
63 | xmlreader.cpp \ | 65 | xmlreader.cpp \ |
64 | mimetype.cpp \ | 66 | mimetype.cpp \ |
65 | menubutton.cpp \ | 67 | menubutton.cpp \ |
66 | network.cpp \ | 68 | network.cpp \ |
67 | networkinterface.cpp \ | 69 | networkinterface.cpp \ |
68 | filemanager.cpp \ | 70 | filemanager.cpp \ |
69 | fontmanager.cpp \ | 71 | fontmanager.cpp \ |
70 | qdawg.cpp \ | 72 | qdawg.cpp \ |
71 | datebookmonth.cpp \ | 73 | datebookmonth.cpp \ |
72 | fileselector.cpp \ | 74 | fileselector.cpp \ |
73 | imageedit.cpp \ | 75 | imageedit.cpp \ |
74 | resource.cpp \ | 76 | resource.cpp \ |
75 | qpedecoration_qws.cpp \ | 77 | qpedecoration_qws.cpp \ |
76 | qcopenvelope_qws.cpp \ | 78 | qcopenvelope_qws.cpp \ |
77 | qpeapplication.cpp \ | 79 | qpeapplication.cpp \ |
78 | qpestyle.cpp \ | 80 | qpestyle.cpp \ |
79 | qpedialog.cpp \ | 81 | qpedialog.cpp \ |
80 | lightstyle.cpp \ | 82 | lightstyle.cpp \ |
81 | config.cpp \ | 83 | config.cpp \ |
82 | applnk.cpp \ | 84 | applnk.cpp \ |
83 | sound.cpp \ | 85 | sound.cpp \ |
84 | tzselect.cpp \ | 86 | tzselect.cpp \ |
85 | qmath.c \ | 87 | qmath.c \ |
86 | datebookdb.cpp \ | 88 | datebookdb.cpp \ |
87 | alarmserver.cpp \ | 89 | alarmserver.cpp \ |
88 | password.cpp \ | 90 | password.cpp \ |
89 | process.cpp \ | 91 | process.cpp \ |
90 | process_unix.cpp \ | 92 | process_unix.cpp \ |
91 | timestring.cpp \ | 93 | timestring.cpp \ |
92 | fontdatabase.cpp \ | 94 | fontdatabase.cpp \ |
93 | power.cpp \ | 95 | power.cpp \ |
94 | storage.cpp \ | 96 | storage.cpp \ |
95 | qpemessagebox.cpp \ | 97 | qpemessagebox.cpp \ |
96 | backend/timeconversion.cpp \ | 98 | backend/timeconversion.cpp \ |
97 | qpedebug.cpp \ | 99 | qpedebug.cpp \ |
98 | qpemenubar.cpp \ | 100 | qpemenubar.cpp \ |
99 | qpetoolbar.cpp \ | 101 | qpetoolbar.cpp \ |
100 | backend/categories.cpp \ | 102 | backend/categories.cpp \ |
101 | backend/stringutil.cpp \ | 103 | backend/stringutil.cpp \ |
102 | backend/palmtoprecord.cpp \ | 104 | backend/palmtoprecord.cpp \ |
103 | backend/task.cpp \ | 105 | backend/task.cpp \ |
104 | backend/event.cpp \ | 106 | backend/event.cpp \ |
105 | backend/contact.cpp \ | 107 | backend/contact.cpp \ |
106 | categorymenu.cpp \ | 108 | categorymenu.cpp \ |
107 | categoryedit_p.cpp \ | 109 | categoryedit_p.cpp \ |
108 | categoryselect.cpp \ | 110 | categoryselect.cpp \ |
109 | categorywidget.cpp \ | 111 | categorywidget.cpp \ |
110 | ir.cpp \ | 112 | ir.cpp \ |
111 | backend/vcc_yacc.cpp \ | 113 | backend/vcc_yacc.cpp \ |
112 | backend/vobject.cpp \ | 114 | backend/vobject.cpp \ |
113 | findwidget_p.cpp \ | 115 | findwidget_p.cpp \ |
114 | finddialog.cpp \ | 116 | finddialog.cpp \ |
115 | lnkproperties.cpp | 117 | lnkproperties.cpp \ |
118 | qt_override.cpp | ||
116 | 119 | ||
117 | # Qt 3 compatibility | 120 | # Qt 3 compatibility |
118 | HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h | 121 | HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h |
119 | SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp | 122 | SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp |
120 | INCLUDEPATH += $(OPIEDIR)/include backend | 123 | INCLUDEPATH += $(OPIEDIR)/include backend |
121 | LIBS += -ldl -lcrypt -lm | 124 | LIBS += -ldl -lcrypt -lm |
122 | INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui | 125 | INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui |
123 | TARGET = qpe | 126 | TARGET = qpe |
124 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 127 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
125 | # This is set by configure$(OPIEDIR). | 128 | # This is set by configure$(OPIEDIR). |
126 | VERSION = 1.5.0.1 | 129 | VERSION = 1.5.0.1 |
127 | 130 | ||
128 | TRANSLATIONS = ../i18n/de/libqpe.ts \ | 131 | TRANSLATIONS = ../i18n/de/libqpe.ts \ |
129 | ../i18n/en/libqpe.ts \ | 132 | ../i18n/en/libqpe.ts \ |
130 | ../i18n/es/libqpe.ts \ | 133 | ../i18n/es/libqpe.ts \ |
131 | ../i18n/fr/libqpe.ts \ | 134 | ../i18n/fr/libqpe.ts \ |
132 | ../i18n/hu/libqpe.ts \ | 135 | ../i18n/hu/libqpe.ts \ |
133 | ../i18n/ja/libqpe.ts \ | 136 | ../i18n/ja/libqpe.ts \ |
134 | ../i18n/ko/libqpe.ts \ | 137 | ../i18n/ko/libqpe.ts \ |
135 | ../i18n/no/libqpe.ts \ | 138 | ../i18n/no/libqpe.ts \ |
136 | ../i18n/pl/libqpe.ts \ | 139 | ../i18n/pl/libqpe.ts \ |
137 | ../i18n/pt/libqpe.ts \ | 140 | ../i18n/pt/libqpe.ts \ |
138 | ../i18n/pt_BR/libqpe.ts \ | 141 | ../i18n/pt_BR/libqpe.ts \ |
139 | ../i18n/sl/libqpe.ts \ | 142 | ../i18n/sl/libqpe.ts \ |
140 | ../i18n/zh_CN/libqpe.ts \ | 143 | ../i18n/zh_CN/libqpe.ts \ |
141 | ../i18n/it/libqpe.ts \ | 144 | ../i18n/it/libqpe.ts \ |
142 | ../i18n/zh_TW/libqpe.ts \ | 145 | ../i18n/zh_TW/libqpe.ts \ |
143 | ../i18n/da/libqpe.ts | 146 | ../i18n/da/libqpe.ts |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 7cbda92..4c93111 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,472 +1,474 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #ifndef QT_NO_COP | 28 | #ifndef QT_NO_COP |
29 | #if QT_VERSION <= 231 | 29 | #if QT_VERSION <= 231 |
30 | #define private public | 30 | #define private public |
31 | #define sendLocally processEvent | 31 | #define sendLocally processEvent |
32 | #include "qcopenvelope_qws.h" | 32 | #include "qcopenvelope_qws.h" |
33 | #undef private | 33 | #undef private |
34 | #else | 34 | #else |
35 | #include "qcopenvelope_qws.h" | 35 | #include "qcopenvelope_qws.h" |
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | 39 | #endif |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qpalette.h> | 41 | #include <qpalette.h> |
42 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
43 | #include <qptrdict.h> | 43 | #include <qptrdict.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qevent.h> | 50 | #include <qevent.h> |
51 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
52 | #include <qsignal.h> | 52 | #include <qsignal.h> |
53 | #include "qpeapplication.h" | 53 | #include "qpeapplication.h" |
54 | #include "qpestyle.h" | 54 | #include "qpestyle.h" |
55 | #include "styleinterface.h" | 55 | #include "styleinterface.h" |
56 | #if QT_VERSION >= 300 | 56 | #if QT_VERSION >= 300 |
57 | #include <qstylefactory.h> | 57 | #include <qstylefactory.h> |
58 | #else | 58 | #else |
59 | #include <qplatinumstyle.h> | 59 | #include <qplatinumstyle.h> |
60 | #include <qwindowsstyle.h> | 60 | #include <qwindowsstyle.h> |
61 | #include <qmotifstyle.h> | 61 | #include <qmotifstyle.h> |
62 | #include <qmotifplusstyle.h> | 62 | #include <qmotifplusstyle.h> |
63 | #include "lightstyle.h" | 63 | #include "lightstyle.h" |
64 | 64 | ||
65 | #include <qpe/qlibrary.h> | 65 | #include <qpe/qlibrary.h> |
66 | #endif | 66 | #endif |
67 | #include "global.h" | 67 | #include "global.h" |
68 | #include "resource.h" | 68 | #include "resource.h" |
69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
70 | #include "qutfcodec.h" | 70 | #include "qutfcodec.h" |
71 | #endif | 71 | #endif |
72 | #include "config.h" | 72 | #include "config.h" |
73 | #include "network.h" | 73 | #include "network.h" |
74 | #ifdef QWS | 74 | #ifdef QWS |
75 | #include "fontmanager.h" | 75 | #include "fontmanager.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "alarmserver.h" | 78 | #include "alarmserver.h" |
79 | #include "applnk.h" | 79 | #include "applnk.h" |
80 | #include "qpemenubar.h" | 80 | #include "qpemenubar.h" |
81 | #include "textcodecinterface.h" | 81 | #include "textcodecinterface.h" |
82 | #include "imagecodecinterface.h" | 82 | #include "imagecodecinterface.h" |
83 | 83 | ||
84 | #include <unistd.h> | 84 | #include <unistd.h> |
85 | #include <sys/file.h> | 85 | #include <sys/file.h> |
86 | #include <sys/ioctl.h> | 86 | #include <sys/ioctl.h> |
87 | #include <sys/soundcard.h> | 87 | #include <sys/soundcard.h> |
88 | 88 | ||
89 | #include "qt_override_p.h" | ||
90 | |||
89 | 91 | ||
90 | class QPEApplicationData | 92 | class QPEApplicationData |
91 | { | 93 | { |
92 | public: | 94 | public: |
93 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
94 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 96 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
95 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 97 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
96 | keep_running( TRUE ) | 98 | keep_running( TRUE ) |
97 | { | 99 | { |
98 | qcopq.setAutoDelete( TRUE ); | 100 | qcopq.setAutoDelete( TRUE ); |
99 | } | 101 | } |
100 | 102 | ||
101 | int presstimer; | 103 | int presstimer; |
102 | QWidget* presswidget; | 104 | QWidget* presswidget; |
103 | QPoint presspos; | 105 | QPoint presspos; |
104 | bool rightpressed : | 106 | bool rightpressed : |
105 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 107 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke |
106 | int kbgrabber; | 108 | int kbgrabber; |
107 | bool kbregrab : | 109 | bool kbregrab : |
108 | 1; | 110 | 1; |
109 | bool notbusysent : | 111 | bool notbusysent : |
110 | 1; | 112 | 1; |
111 | QString appName; | 113 | QString appName; |
112 | struct QCopRec | 114 | struct QCopRec |
113 | { | 115 | { |
114 | QCopRec( const QCString &ch, const QCString &msg, | 116 | QCopRec( const QCString &ch, const QCString &msg, |
115 | const QByteArray &d ) : | 117 | const QByteArray &d ) : |
116 | channel( ch ), message( msg ), data( d ) | 118 | channel( ch ), message( msg ), data( d ) |
117 | { } | 119 | { } |
118 | 120 | ||
119 | QCString channel; | 121 | QCString channel; |
120 | QCString message; | 122 | QCString message; |
121 | QByteArray data; | 123 | QByteArray data; |
122 | }; | 124 | }; |
123 | bool preloaded : | 125 | bool preloaded : |
124 | 1; | 126 | 1; |
125 | bool forceshow : | 127 | bool forceshow : |
126 | 1; | 128 | 1; |
127 | bool nomaximize : | 129 | bool nomaximize : |
128 | 1; | 130 | 1; |
129 | QWidget* qpe_main_widget; | 131 | QWidget* qpe_main_widget; |
130 | bool keep_running : | 132 | bool keep_running : |
131 | 1; | 133 | 1; |
132 | QList<QCopRec> qcopq; | 134 | QList<QCopRec> qcopq; |
133 | 135 | ||
134 | void enqueueQCop( const QCString &ch, const QCString &msg, | 136 | void enqueueQCop( const QCString &ch, const QCString &msg, |
135 | const QByteArray &data ) | 137 | const QByteArray &data ) |
136 | { | 138 | { |
137 | qcopq.append( new QCopRec( ch, msg, data ) ); | 139 | qcopq.append( new QCopRec( ch, msg, data ) ); |
138 | } | 140 | } |
139 | void sendQCopQ() | 141 | void sendQCopQ() |
140 | { | 142 | { |
141 | QCopRec * r; | 143 | QCopRec * r; |
142 | #ifndef QT_NO_COP | 144 | #ifndef QT_NO_COP |
143 | 145 | ||
144 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 146 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
145 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 147 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
146 | #endif | 148 | #endif |
147 | 149 | ||
148 | qcopq.clear(); | 150 | qcopq.clear(); |
149 | } | 151 | } |
150 | static void show_mx(QWidget* mw, bool nomaximize) | 152 | static void show_mx(QWidget* mw, bool nomaximize) |
151 | { | 153 | { |
152 | if ( mw->layout() && mw->inherits("QDialog") ) { | 154 | if ( mw->layout() && mw->inherits("QDialog") ) { |
153 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 155 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
154 | } | 156 | } |
155 | else { | 157 | else { |
156 | #ifdef Q_WS_QWS | 158 | #ifdef Q_WS_QWS |
157 | if ( !nomaximize ) | 159 | if ( !nomaximize ) |
158 | mw->showMaximized(); | 160 | mw->showMaximized(); |
159 | else | 161 | else |
160 | #endif | 162 | #endif |
161 | 163 | ||
162 | mw->show(); | 164 | mw->show(); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 167 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
166 | { | 168 | { |
167 | /* | 169 | /* |
168 | // This works but disable it for now until it is safe to apply | 170 | // This works but disable it for now until it is safe to apply |
169 | // What is does is scan the .desktop files of all the apps for | 171 | // What is does is scan the .desktop files of all the apps for |
170 | // the applnk that has the corresponding argv[0] as this program | 172 | // the applnk that has the corresponding argv[0] as this program |
171 | // then it uses the name stored in the .desktop file as the caption | 173 | // then it uses the name stored in the .desktop file as the caption |
172 | // for the main widget. This saves duplicating translations for | 174 | // for the main widget. This saves duplicating translations for |
173 | // the app name in the program and in the .desktop files. | 175 | // the app name in the program and in the .desktop files. |
174 | 176 | ||
175 | AppLnkSet apps( appsPath ); | 177 | AppLnkSet apps( appsPath ); |
176 | 178 | ||
177 | QList<AppLnk> appsList = apps.children(); | 179 | QList<AppLnk> appsList = apps.children(); |
178 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 180 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
179 | if ( (*it)->exec() == appName ) { | 181 | if ( (*it)->exec() == appName ) { |
180 | mw->setCaption( (*it)->name() ); | 182 | mw->setCaption( (*it)->name() ); |
181 | return TRUE; | 183 | return TRUE; |
182 | } | 184 | } |
183 | } | 185 | } |
184 | */ | 186 | */ |
185 | return FALSE; | 187 | return FALSE; |
186 | } | 188 | } |
187 | 189 | ||
188 | 190 | ||
189 | void show(QWidget* mw, bool nomax) | 191 | void show(QWidget* mw, bool nomax) |
190 | { | 192 | { |
191 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 193 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
192 | nomaximize = nomax; | 194 | nomaximize = nomax; |
193 | qpe_main_widget = mw; | 195 | qpe_main_widget = mw; |
194 | #ifndef QT_NO_COP | 196 | #ifndef QT_NO_COP |
195 | 197 | ||
196 | sendQCopQ(); | 198 | sendQCopQ(); |
197 | #endif | 199 | #endif |
198 | 200 | ||
199 | if ( preloaded ) { | 201 | if ( preloaded ) { |
200 | if (forceshow) | 202 | if (forceshow) |
201 | show_mx(mw, nomax); | 203 | show_mx(mw, nomax); |
202 | } | 204 | } |
203 | else if ( keep_running ) { | 205 | else if ( keep_running ) { |
204 | show_mx(mw, nomax); | 206 | show_mx(mw, nomax); |
205 | } | 207 | } |
206 | } | 208 | } |
207 | 209 | ||
208 | void loadTextCodecs() | 210 | void loadTextCodecs() |
209 | { | 211 | { |
210 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 212 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
211 | QDir dir( path, "lib*.so" ); | 213 | QDir dir( path, "lib*.so" ); |
212 | QStringList list = dir.entryList(); | 214 | QStringList list = dir.entryList(); |
213 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
214 | for ( it = list.begin(); it != list.end(); ++it ) { | 216 | for ( it = list.begin(); it != list.end(); ++it ) { |
215 | TextCodecInterface *iface = 0; | 217 | TextCodecInterface *iface = 0; |
216 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 218 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
217 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 219 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
218 | QValueList<int> mibs = iface->mibEnums(); | 220 | QValueList<int> mibs = iface->mibEnums(); |
219 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 221 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
220 | (void)iface->createForMib(*i); | 222 | (void)iface->createForMib(*i); |
221 | // ### it exists now; need to remember if we can delete it | 223 | // ### it exists now; need to remember if we can delete it |
222 | } | 224 | } |
223 | } | 225 | } |
224 | else { | 226 | else { |
225 | lib->unload(); | 227 | lib->unload(); |
226 | delete lib; | 228 | delete lib; |
227 | } | 229 | } |
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
231 | void loadImageCodecs() | 233 | void loadImageCodecs() |
232 | { | 234 | { |
233 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 235 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
234 | QDir dir( path, "lib*.so" ); | 236 | QDir dir( path, "lib*.so" ); |
235 | QStringList list = dir.entryList(); | 237 | QStringList list = dir.entryList(); |
236 | QStringList::Iterator it; | 238 | QStringList::Iterator it; |
237 | for ( it = list.begin(); it != list.end(); ++it ) { | 239 | for ( it = list.begin(); it != list.end(); ++it ) { |
238 | ImageCodecInterface *iface = 0; | 240 | ImageCodecInterface *iface = 0; |
239 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 241 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
240 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 242 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
241 | QStringList formats = iface->keys(); | 243 | QStringList formats = iface->keys(); |
242 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 244 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
243 | (void)iface->installIOHandler(*i); | 245 | (void)iface->installIOHandler(*i); |
244 | // ### it exists now; need to remember if we can delete it | 246 | // ### it exists now; need to remember if we can delete it |
245 | } | 247 | } |
246 | } | 248 | } |
247 | else { | 249 | else { |
248 | lib->unload(); | 250 | lib->unload(); |
249 | delete lib; | 251 | delete lib; |
250 | } | 252 | } |
251 | } | 253 | } |
252 | } | 254 | } |
253 | QString styleName; | 255 | QString styleName; |
254 | QString decorationName; | 256 | QString decorationName; |
255 | }; | 257 | }; |
256 | 258 | ||
257 | class ResourceMimeFactory : public QMimeSourceFactory | 259 | class ResourceMimeFactory : public QMimeSourceFactory |
258 | { | 260 | { |
259 | public: | 261 | public: |
260 | ResourceMimeFactory() | 262 | ResourceMimeFactory() |
261 | { | 263 | { |
262 | setFilePath( Global::helpPath() ); | 264 | setFilePath( Global::helpPath() ); |
263 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 265 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
264 | } | 266 | } |
265 | 267 | ||
266 | const QMimeSource* data( const QString& abs_name ) const | 268 | const QMimeSource* data( const QString& abs_name ) const |
267 | { | 269 | { |
268 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 270 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
269 | if ( !r ) { | 271 | if ( !r ) { |
270 | int sl = abs_name.length(); | 272 | int sl = abs_name.length(); |
271 | do { | 273 | do { |
272 | sl = abs_name.findRev( '/', sl - 1 ); | 274 | sl = abs_name.findRev( '/', sl - 1 ); |
273 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 275 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
274 | int dot = name.findRev( '.' ); | 276 | int dot = name.findRev( '.' ); |
275 | if ( dot >= 0 ) | 277 | if ( dot >= 0 ) |
276 | name = name.left( dot ); | 278 | name = name.left( dot ); |
277 | QImage img = Resource::loadImage( name ); | 279 | QImage img = Resource::loadImage( name ); |
278 | if ( !img.isNull() ) | 280 | if ( !img.isNull() ) |
279 | r = new QImageDrag( img ); | 281 | r = new QImageDrag( img ); |
280 | } | 282 | } |
281 | while ( !r && sl > 0 ); | 283 | while ( !r && sl > 0 ); |
282 | } | 284 | } |
283 | return r; | 285 | return r; |
284 | } | 286 | } |
285 | }; | 287 | }; |
286 | 288 | ||
287 | static int muted = 0; | 289 | static int muted = 0; |
288 | static int micMuted = 0; | 290 | static int micMuted = 0; |
289 | 291 | ||
290 | static void setVolume( int t = 0, int percent = -1 ) | 292 | static void setVolume( int t = 0, int percent = -1 ) |
291 | { | 293 | { |
292 | switch ( t ) { | 294 | switch ( t ) { |
293 | case 0: { | 295 | case 0: { |
294 | Config cfg( "qpe" ); | 296 | Config cfg( "qpe" ); |
295 | cfg.setGroup( "Volume" ); | 297 | cfg.setGroup( "Volume" ); |
296 | if ( percent < 0 ) | 298 | if ( percent < 0 ) |
297 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 299 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
298 | int fd = 0; | 300 | int fd = 0; |
299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 301 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
300 | int vol = muted ? 0 : percent; | 302 | int vol = muted ? 0 : percent; |
301 | // set both channels to same volume | 303 | // set both channels to same volume |
302 | vol |= vol << 8; | 304 | vol |= vol << 8; |
303 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 305 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
304 | ::close( fd ); | 306 | ::close( fd ); |
305 | } | 307 | } |
306 | } | 308 | } |
307 | break; | 309 | break; |
308 | } | 310 | } |
309 | } | 311 | } |
310 | 312 | ||
311 | static void setMic( int t = 0, int percent = -1 ) | 313 | static void setMic( int t = 0, int percent = -1 ) |
312 | { | 314 | { |
313 | switch ( t ) { | 315 | switch ( t ) { |
314 | case 0: { | 316 | case 0: { |
315 | Config cfg( "qpe" ); | 317 | Config cfg( "qpe" ); |
316 | cfg.setGroup( "Volume" ); | 318 | cfg.setGroup( "Volume" ); |
317 | if ( percent < 0 ) | 319 | if ( percent < 0 ) |
318 | percent = cfg.readNumEntry( "Mic", 50 ); | 320 | percent = cfg.readNumEntry( "Mic", 50 ); |
319 | 321 | ||
320 | int fd = 0; | 322 | int fd = 0; |
321 | int mic = micMuted ? 0 : percent; | 323 | int mic = micMuted ? 0 : percent; |
322 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 324 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
323 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 325 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
324 | ::close( fd ); | 326 | ::close( fd ); |
325 | } | 327 | } |
326 | } | 328 | } |
327 | break; | 329 | break; |
328 | } | 330 | } |
329 | } | 331 | } |
330 | 332 | ||
331 | 333 | ||
332 | /*! | 334 | /*! |
333 | \class QPEApplication qpeapplication.h | 335 | \class QPEApplication qpeapplication.h |
334 | \brief The QPEApplication class implements various system services | 336 | \brief The QPEApplication class implements various system services |
335 | that are available to all Qtopia applications. | 337 | that are available to all Qtopia applications. |
336 | 338 | ||
337 | Simply by using QPEApplication instead of QApplication, a standard Qt | 339 | Simply by using QPEApplication instead of QApplication, a standard Qt |
338 | application becomes a Qtopia application. It automatically follows | 340 | application becomes a Qtopia application. It automatically follows |
339 | style changes, quits and raises, and in the | 341 | style changes, quits and raises, and in the |
340 | case of \link docwidget.html document-oriented\endlink applications, | 342 | case of \link docwidget.html document-oriented\endlink applications, |
341 | changes the currently displayed document in response to the environment. | 343 | changes the currently displayed document in response to the environment. |
342 | 344 | ||
343 | To create a \link docwidget.html document-oriented\endlink | 345 | To create a \link docwidget.html document-oriented\endlink |
344 | application use showMainDocumentWidget(); to create a | 346 | application use showMainDocumentWidget(); to create a |
345 | non-document-oriented application use showMainWidget(). The | 347 | non-document-oriented application use showMainWidget(). The |
346 | keepRunning() function indicates whether the application will | 348 | keepRunning() function indicates whether the application will |
347 | continue running after it's processed the last \link qcop.html | 349 | continue running after it's processed the last \link qcop.html |
348 | QCop\endlink message. This can be changed using setKeepRunning(). | 350 | QCop\endlink message. This can be changed using setKeepRunning(). |
349 | 351 | ||
350 | A variety of signals are emitted when certain events occur, for | 352 | A variety of signals are emitted when certain events occur, for |
351 | example, timeChanged(), clockChanged(), weekChanged(), | 353 | example, timeChanged(), clockChanged(), weekChanged(), |
352 | dateFormatChanged() and volumeChanged(). If the application receives | 354 | dateFormatChanged() and volumeChanged(). If the application receives |
353 | a \link qcop.html QCop\endlink message on the application's | 355 | a \link qcop.html QCop\endlink message on the application's |
354 | QPE/Application/\e{appname} channel, the appMessage() signal is | 356 | QPE/Application/\e{appname} channel, the appMessage() signal is |
355 | emitted. There are also flush() and reload() signals, which | 357 | emitted. There are also flush() and reload() signals, which |
356 | are emitted when synching begins and ends respectively - upon these | 358 | are emitted when synching begins and ends respectively - upon these |
357 | signals, the application should save and reload any data | 359 | signals, the application should save and reload any data |
358 | files that are involved in synching. Most of these signals will initially | 360 | files that are involved in synching. Most of these signals will initially |
359 | be received and unfiltered through the appMessage() signal. | 361 | be received and unfiltered through the appMessage() signal. |
360 | 362 | ||
361 | This class also provides a set of useful static functions. The | 363 | This class also provides a set of useful static functions. The |
362 | qpeDir() and documentDir() functions return the respective paths. | 364 | qpeDir() and documentDir() functions return the respective paths. |
363 | The grabKeyboard() and ungrabKeyboard() functions are used to | 365 | The grabKeyboard() and ungrabKeyboard() functions are used to |
364 | control whether the application takes control of the device's | 366 | control whether the application takes control of the device's |
365 | physical buttons (e.g. application launch keys). The stylus' mode of | 367 | physical buttons (e.g. application launch keys). The stylus' mode of |
366 | operation is set with setStylusOperation() and retrieved with | 368 | operation is set with setStylusOperation() and retrieved with |
367 | stylusOperation(). There are also setInputMethodHint() and | 369 | stylusOperation(). There are also setInputMethodHint() and |
368 | inputMethodHint() functions. | 370 | inputMethodHint() functions. |
369 | 371 | ||
370 | \ingroup qtopiaemb | 372 | \ingroup qtopiaemb |
371 | */ | 373 | */ |
372 | 374 | ||
373 | /*! | 375 | /*! |
374 | \fn void QPEApplication::clientMoused() | 376 | \fn void QPEApplication::clientMoused() |
375 | 377 | ||
376 | \internal | 378 | \internal |
377 | */ | 379 | */ |
378 | 380 | ||
379 | /*! | 381 | /*! |
380 | \fn void QPEApplication::timeChanged(); | 382 | \fn void QPEApplication::timeChanged(); |
381 | This signal is emitted when the time changes outside the normal | 383 | This signal is emitted when the time changes outside the normal |
382 | passage of time, i.e. if the time is set backwards or forwards. | 384 | passage of time, i.e. if the time is set backwards or forwards. |
383 | */ | 385 | */ |
384 | 386 | ||
385 | /*! | 387 | /*! |
386 | \fn void QPEApplication::clockChanged( bool ampm ); | 388 | \fn void QPEApplication::clockChanged( bool ampm ); |
387 | 389 | ||
388 | This signal is emitted when the user changes the clock's style. If | 390 | This signal is emitted when the user changes the clock's style. If |
389 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 391 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
390 | they want a 24-hour clock. | 392 | they want a 24-hour clock. |
391 | */ | 393 | */ |
392 | 394 | ||
393 | /*! | 395 | /*! |
394 | \fn void QPEApplication::volumeChanged( bool muted ) | 396 | \fn void QPEApplication::volumeChanged( bool muted ) |
395 | 397 | ||
396 | This signal is emitted whenever the mute state is changed. If \a | 398 | This signal is emitted whenever the mute state is changed. If \a |
397 | muted is TRUE, then sound output has been muted. | 399 | muted is TRUE, then sound output has been muted. |
398 | */ | 400 | */ |
399 | 401 | ||
400 | /*! | 402 | /*! |
401 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 403 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
402 | 404 | ||
403 | This signal is emitted if the week start day is changed. If \a | 405 | This signal is emitted if the week start day is changed. If \a |
404 | startOnMonday is TRUE then the first day of the week is Monday; if | 406 | startOnMonday is TRUE then the first day of the week is Monday; if |
405 | \a startOnMonday is FALSE then the first day of the week is | 407 | \a startOnMonday is FALSE then the first day of the week is |
406 | Sunday. | 408 | Sunday. |
407 | */ | 409 | */ |
408 | 410 | ||
409 | /*! | 411 | /*! |
410 | \fn void QPEApplication::dateFormatChanged() | 412 | \fn void QPEApplication::dateFormatChanged() |
411 | 413 | ||
412 | This signal is emitted whenever the date format is changed. | 414 | This signal is emitted whenever the date format is changed. |
413 | */ | 415 | */ |
414 | 416 | ||
415 | /*! | 417 | /*! |
416 | \fn void QPEApplication::flush() | 418 | \fn void QPEApplication::flush() |
417 | 419 | ||
418 | ### | 420 | ### |
419 | */ | 421 | */ |
420 | 422 | ||
421 | /*! | 423 | /*! |
422 | \fn void QPEApplication::reload() | 424 | \fn void QPEApplication::reload() |
423 | 425 | ||
424 | */ | 426 | */ |
425 | 427 | ||
426 | /*! | 428 | /*! |
427 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 429 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
428 | 430 | ||
429 | This signal is emitted when a message is received on this | 431 | This signal is emitted when a message is received on this |
430 | application's QPE/Application/<i>appname</i> \link qcop.html | 432 | application's QPE/Application/<i>appname</i> \link qcop.html |
431 | QCop\endlink channel. | 433 | QCop\endlink channel. |
432 | 434 | ||
433 | The slot to which you connect this signal uses \a msg and \a data | 435 | The slot to which you connect this signal uses \a msg and \a data |
434 | in the following way: | 436 | in the following way: |
435 | 437 | ||
436 | \code | 438 | \code |
437 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 439 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
438 | { | 440 | { |
439 | QDataStream stream( data, IO_ReadOnly ); | 441 | QDataStream stream( data, IO_ReadOnly ); |
440 | if ( msg == "someMessage(int,int,int)" ) { | 442 | if ( msg == "someMessage(int,int,int)" ) { |
441 | int a,b,c; | 443 | int a,b,c; |
442 | stream >> a >> b >> c; | 444 | stream >> a >> b >> c; |
443 | ... | 445 | ... |
444 | } else if ( msg == "otherMessage(QString)" ) { | 446 | } else if ( msg == "otherMessage(QString)" ) { |
445 | ... | 447 | ... |
446 | } | 448 | } |
447 | } | 449 | } |
448 | \endcode | 450 | \endcode |
449 | 451 | ||
450 | \sa qcop.html | 452 | \sa qcop.html |
451 | Note that messages received here may be processed by qpe application | 453 | Note that messages received here may be processed by qpe application |
452 | and emitted as signals, such as flush() and reload(). | 454 | and emitted as signals, such as flush() and reload(). |
453 | */ | 455 | */ |
454 | 456 | ||
455 | /*! | 457 | /*! |
456 | Constructs a QPEApplication just as you would construct | 458 | Constructs a QPEApplication just as you would construct |
457 | a QApplication, passing \a argc, \a argv, and \a t. | 459 | a QApplication, passing \a argc, \a argv, and \a t. |
458 | 460 | ||
459 | For applications, \a t should be the default, GuiClient. Only | 461 | For applications, \a t should be the default, GuiClient. Only |
460 | the Qtopia server passes GuiServer. | 462 | the Qtopia server passes GuiServer. |
461 | */ | 463 | */ |
462 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 464 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
463 | : QApplication( argc, argv, t ) | 465 | : QApplication( argc, argv, t ) |
464 | { | 466 | { |
465 | d = new QPEApplicationData; | 467 | d = new QPEApplicationData; |
466 | d->loadTextCodecs(); | 468 | d->loadTextCodecs(); |
467 | d->loadImageCodecs(); | 469 | d->loadImageCodecs(); |
468 | int dw = desktop() ->width(); | 470 | int dw = desktop() ->width(); |
469 | qWarning( "Width %d", dw ); | 471 | qWarning( "Width %d", dw ); |
470 | if ( dw < 200 ) { | 472 | if ( dw < 200 ) { |
471 | setFont( QFont( "helvetica", 8 ) ); | 473 | setFont( QFont( "helvetica", 8 ) ); |
472 | AppLnk::setSmallIconSize( 10 ); | 474 | AppLnk::setSmallIconSize( 10 ); |
@@ -518,1241 +520,1227 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
518 | ds >> channel >> message >> data; | 520 | ds >> channel >> message >> data; |
519 | d->enqueueQCop( channel, message, data ); | 521 | d->enqueueQCop( channel, message, data ); |
520 | } | 522 | } |
521 | 523 | ||
522 | flock( f.handle(), LOCK_UN ); | 524 | flock( f.handle(), LOCK_UN ); |
523 | f.close(); | 525 | f.close(); |
524 | f.remove(); | 526 | f.remove(); |
525 | } | 527 | } |
526 | 528 | ||
527 | for ( int a = 0; a < argc; a++ ) { | 529 | for ( int a = 0; a < argc; a++ ) { |
528 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 530 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
529 | argv[ a ] = argv[ a + 1 ]; | 531 | argv[ a ] = argv[ a + 1 ]; |
530 | a++; | 532 | a++; |
531 | d->preloaded = TRUE; | 533 | d->preloaded = TRUE; |
532 | argc -= 1; | 534 | argc -= 1; |
533 | } | 535 | } |
534 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 536 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
535 | argv[ a ] = argv[ a + 1 ]; | 537 | argv[ a ] = argv[ a + 1 ]; |
536 | a++; | 538 | a++; |
537 | d->preloaded = TRUE; | 539 | d->preloaded = TRUE; |
538 | d->forceshow = TRUE; | 540 | d->forceshow = TRUE; |
539 | argc -= 1; | 541 | argc -= 1; |
540 | } | 542 | } |
541 | } | 543 | } |
542 | 544 | ||
543 | /* overide stored arguments */ | 545 | /* overide stored arguments */ |
544 | setArgs( argc, argv ); | 546 | setArgs( argc, argv ); |
545 | 547 | ||
546 | #endif | 548 | #endif |
547 | 549 | ||
548 | // qwsSetDecoration( new QPEDecoration() ); | 550 | // qwsSetDecoration( new QPEDecoration() ); |
549 | 551 | ||
550 | #ifndef QT_NO_TRANSLATION | 552 | #ifndef QT_NO_TRANSLATION |
551 | 553 | ||
552 | QStringList langs = Global::languageList(); | 554 | QStringList langs = Global::languageList(); |
553 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 555 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
554 | QString lang = *it; | 556 | QString lang = *it; |
555 | 557 | ||
556 | QTranslator * trans; | 558 | QTranslator * trans; |
557 | QString tfn; | 559 | QString tfn; |
558 | 560 | ||
559 | trans = new QTranslator( this ); | 561 | trans = new QTranslator( this ); |
560 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 562 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
561 | if ( trans->load( tfn ) ) | 563 | if ( trans->load( tfn ) ) |
562 | installTranslator( trans ); | 564 | installTranslator( trans ); |
563 | else | 565 | else |
564 | delete trans; | 566 | delete trans; |
565 | 567 | ||
566 | trans = new QTranslator( this ); | 568 | trans = new QTranslator( this ); |
567 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 569 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
568 | if ( trans->load( tfn ) ) | 570 | if ( trans->load( tfn ) ) |
569 | installTranslator( trans ); | 571 | installTranslator( trans ); |
570 | else | 572 | else |
571 | delete trans; | 573 | delete trans; |
572 | 574 | ||
573 | //###language/font hack; should look it up somewhere | 575 | //###language/font hack; should look it up somewhere |
574 | #ifdef QWS | 576 | #ifdef QWS |
575 | 577 | ||
576 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 578 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
577 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 579 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
578 | setFont( fn ); | 580 | setFont( fn ); |
579 | } | 581 | } |
580 | #endif | 582 | #endif |
581 | 583 | ||
582 | } | 584 | } |
583 | #endif | 585 | #endif |
584 | 586 | ||
585 | applyStyle(); | 587 | applyStyle(); |
586 | 588 | ||
587 | if ( type() == GuiServer ) { | 589 | if ( type() == GuiServer ) { |
588 | setVolume(); | 590 | setVolume(); |
589 | } | 591 | } |
590 | 592 | ||
591 | installEventFilter( this ); | 593 | installEventFilter( this ); |
592 | 594 | ||
593 | QPEMenuToolFocusManager::initialize(); | 595 | QPEMenuToolFocusManager::initialize(); |
594 | 596 | ||
595 | #ifdef QT_NO_QWS_CURSOR | 597 | #ifdef QT_NO_QWS_CURSOR |
596 | // if we have no cursor, probably don't want tooltips | 598 | // if we have no cursor, probably don't want tooltips |
597 | QToolTip::setEnabled( FALSE ); | 599 | QToolTip::setEnabled( FALSE ); |
598 | #endif | 600 | #endif |
599 | } | 601 | } |
600 | 602 | ||
601 | static QPtrDict<void>* inputMethodDict = 0; | 603 | static QPtrDict<void>* inputMethodDict = 0; |
602 | static void createInputMethodDict() | 604 | static void createInputMethodDict() |
603 | { | 605 | { |
604 | if ( !inputMethodDict ) | 606 | if ( !inputMethodDict ) |
605 | inputMethodDict = new QPtrDict<void>; | 607 | inputMethodDict = new QPtrDict<void>; |
606 | } | 608 | } |
607 | 609 | ||
608 | /*! | 610 | /*! |
609 | Returns the currently set hint to the system as to whether | 611 | Returns the currently set hint to the system as to whether |
610 | widget \a w has any use for text input methods. | 612 | widget \a w has any use for text input methods. |
611 | 613 | ||
612 | 614 | ||
613 | \sa setInputMethodHint() InputMethodHint | 615 | \sa setInputMethodHint() InputMethodHint |
614 | */ | 616 | */ |
615 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 617 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
616 | { | 618 | { |
617 | if ( inputMethodDict && w ) | 619 | if ( inputMethodDict && w ) |
618 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 620 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
619 | return Normal; | 621 | return Normal; |
620 | } | 622 | } |
621 | 623 | ||
622 | /*! | 624 | /*! |
623 | \enum QPEApplication::InputMethodHint | 625 | \enum QPEApplication::InputMethodHint |
624 | 626 | ||
625 | \value Normal the application sometimes needs text input (the default). | 627 | \value Normal the application sometimes needs text input (the default). |
626 | \value AlwaysOff the application never needs text input. | 628 | \value AlwaysOff the application never needs text input. |
627 | \value AlwaysOn the application always needs text input. | 629 | \value AlwaysOn the application always needs text input. |
628 | */ | 630 | */ |
629 | 631 | ||
630 | /*! | 632 | /*! |
631 | Hints to the system that widget \a w has use for text input methods | 633 | Hints to the system that widget \a w has use for text input methods |
632 | as specified by \a mode. | 634 | as specified by \a mode. |
633 | 635 | ||
634 | \sa inputMethodHint() InputMethodHint | 636 | \sa inputMethodHint() InputMethodHint |
635 | */ | 637 | */ |
636 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 638 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
637 | { | 639 | { |
638 | createInputMethodDict(); | 640 | createInputMethodDict(); |
639 | if ( mode == Normal ) { | 641 | if ( mode == Normal ) { |
640 | inputMethodDict->remove | 642 | inputMethodDict->remove |
641 | ( w ); | 643 | ( w ); |
642 | } | 644 | } |
643 | else { | 645 | else { |
644 | inputMethodDict->insert( w, ( void* ) mode ); | 646 | inputMethodDict->insert( w, ( void* ) mode ); |
645 | } | 647 | } |
646 | } | 648 | } |
647 | 649 | ||
648 | class HackDialog : public QDialog | 650 | class HackDialog : public QDialog |
649 | { | 651 | { |
650 | public: | 652 | public: |
651 | void acceptIt() | 653 | void acceptIt() |
652 | { | 654 | { |
653 | accept(); | 655 | accept(); |
654 | } | 656 | } |
655 | void rejectIt() | 657 | void rejectIt() |
656 | { | 658 | { |
657 | reject(); | 659 | reject(); |
658 | } | 660 | } |
659 | }; | 661 | }; |
660 | 662 | ||
661 | 663 | ||
662 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 664 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
663 | { | 665 | { |
664 | // specialised actions for certain widgets. May want to | 666 | // specialised actions for certain widgets. May want to |
665 | // add more stuff here. | 667 | // add more stuff here. |
666 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 668 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
667 | && activePopupWidget() ->parentWidget() | 669 | && activePopupWidget() ->parentWidget() |
668 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 670 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
669 | key = Qt::Key_Return; | 671 | key = Qt::Key_Return; |
670 | 672 | ||
671 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 673 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
672 | key = Qt::Key_Return; | 674 | key = Qt::Key_Return; |
673 | 675 | ||
674 | #ifdef QWS | 676 | #ifdef QWS |
675 | 677 | ||
676 | ke->simpleData.keycode = key; | 678 | ke->simpleData.keycode = key; |
677 | #endif | 679 | #endif |
678 | } | 680 | } |
679 | 681 | ||
680 | class HackWidget : public QWidget | 682 | class HackWidget : public QWidget |
681 | { | 683 | { |
682 | public: | 684 | public: |
683 | bool needsOk() | 685 | bool needsOk() |
684 | { | 686 | { |
685 | return ( getWState() & WState_Reserved1 ); | 687 | return ( getWState() & WState_Reserved1 ); |
686 | } | 688 | } |
687 | }; | 689 | }; |
688 | 690 | ||
689 | /*! | 691 | /*! |
690 | \internal | 692 | \internal |
691 | */ | 693 | */ |
692 | 694 | ||
693 | #ifdef QWS | 695 | #ifdef QWS |
694 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 696 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
695 | { | 697 | { |
696 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 698 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
697 | if ( qApp->type() != QApplication::GuiServer ) { | 699 | if ( qApp->type() != QApplication::GuiServer ) { |
698 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 700 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
699 | e << d->appName; | 701 | e << d->appName; |
700 | } | 702 | } |
701 | d->notbusysent = TRUE; | 703 | d->notbusysent = TRUE; |
702 | } | 704 | } |
703 | if ( type() == GuiServer ) { | 705 | if ( type() == GuiServer ) { |
704 | switch ( e->type ) { | 706 | switch ( e->type ) { |
705 | case QWSEvent::Mouse: | 707 | case QWSEvent::Mouse: |
706 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 708 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
707 | emit clientMoused(); | 709 | emit clientMoused(); |
708 | break; | 710 | break; |
709 | default: | 711 | default: |
710 | break; | 712 | break; |
711 | } | 713 | } |
712 | } | 714 | } |
713 | if ( e->type == QWSEvent::Key ) { | 715 | if ( e->type == QWSEvent::Key ) { |
714 | if ( d->kbgrabber == 1 ) | 716 | if ( d->kbgrabber == 1 ) |
715 | return TRUE; | 717 | return TRUE; |
716 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 718 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
717 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 719 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
718 | // Use special "OK" key to press "OK" on top level widgets | 720 | // Use special "OK" key to press "OK" on top level widgets |
719 | QWidget * active = activeWindow(); | 721 | QWidget * active = activeWindow(); |
720 | QWidget *popup = 0; | 722 | QWidget *popup = 0; |
721 | if ( active && active->isPopup() ) { | 723 | if ( active && active->isPopup() ) { |
722 | popup = active; | 724 | popup = active; |
723 | active = active->parentWidget(); | 725 | active = active->parentWidget(); |
724 | } | 726 | } |
725 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 727 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
726 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 728 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
727 | if ( ke->simpleData.is_press ) { | 729 | if ( ke->simpleData.is_press ) { |
728 | if ( popup ) | 730 | if ( popup ) |
729 | popup->close(); | 731 | popup->close(); |
730 | if ( active->inherits( "QDialog" ) ) { | 732 | if ( active->inherits( "QDialog" ) ) { |
731 | HackDialog * d = ( HackDialog * ) active; | 733 | HackDialog * d = ( HackDialog * ) active; |
732 | d->acceptIt(); | 734 | d->acceptIt(); |
733 | return TRUE; | 735 | return TRUE; |
734 | } | 736 | } |
735 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 737 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
736 | QSignal s; | 738 | QSignal s; |
737 | s.connect( active, SLOT( accept() ) ); | 739 | s.connect( active, SLOT( accept() ) ); |
738 | s.activate(); | 740 | s.activate(); |
739 | } | 741 | } |
740 | else { | 742 | else { |
741 | // do the same as with the select key: Map to the default action of the widget: | 743 | // do the same as with the select key: Map to the default action of the widget: |
742 | mapToDefaultAction( ke, Qt::Key_Return ); | 744 | mapToDefaultAction( ke, Qt::Key_Return ); |
743 | } | 745 | } |
744 | } | 746 | } |
745 | } | 747 | } |
746 | } | 748 | } |
747 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 749 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
748 | // Use special "select" key to do whatever default action a widget has | 750 | // Use special "select" key to do whatever default action a widget has |
749 | mapToDefaultAction( ke, Qt::Key_Space ); | 751 | mapToDefaultAction( ke, Qt::Key_Space ); |
750 | } | 752 | } |
751 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 753 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
752 | ke->simpleData.is_press ) { | 754 | ke->simpleData.is_press ) { |
753 | // Escape key closes app if focus on toplevel | 755 | // Escape key closes app if focus on toplevel |
754 | QWidget * active = activeWindow(); | 756 | QWidget * active = activeWindow(); |
755 | if ( active && active->testWFlags( WType_TopLevel ) && | 757 | if ( active && active->testWFlags( WType_TopLevel ) && |
756 | ( int ) active->winId() == ke->simpleData.window && | 758 | ( int ) active->winId() == ke->simpleData.window && |
757 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 759 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
758 | if ( active->inherits( "QDialog" ) ) { | 760 | if ( active->inherits( "QDialog" ) ) { |
759 | HackDialog * d = ( HackDialog * ) active; | 761 | HackDialog * d = ( HackDialog * ) active; |
760 | d->rejectIt(); | 762 | d->rejectIt(); |
761 | return TRUE; | 763 | return TRUE; |
762 | } | 764 | } |
763 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 765 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
764 | active->close(); | 766 | active->close(); |
765 | } | 767 | } |
766 | } | 768 | } |
767 | } | 769 | } |
768 | 770 | ||
769 | #if QT_VERSION < 231 | 771 | #if QT_VERSION < 231 |
770 | // Filter out the F4/Launcher key from apps | 772 | // Filter out the F4/Launcher key from apps |
771 | // ### The launcher key may not always be F4 on all devices | 773 | // ### The launcher key may not always be F4 on all devices |
772 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) | 774 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) |
773 | return TRUE; | 775 | return TRUE; |
774 | #endif | 776 | #endif |
775 | 777 | ||
776 | } | 778 | } |
777 | if ( e->type == QWSEvent::Focus ) { | 779 | if ( e->type == QWSEvent::Focus ) { |
778 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 780 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
779 | QWidget* nfw = QWidget::find( e->window() ); | 781 | QWidget* nfw = QWidget::find( e->window() ); |
780 | if ( !fe->simpleData.get_focus ) { | 782 | if ( !fe->simpleData.get_focus ) { |
781 | QWidget * active = activeWindow(); | 783 | QWidget * active = activeWindow(); |
782 | while ( active && active->isPopup() ) { | 784 | while ( active && active->isPopup() ) { |
783 | active->close(); | 785 | active->close(); |
784 | active = activeWindow(); | 786 | active = activeWindow(); |
785 | } | 787 | } |
786 | if ( !nfw && d->kbgrabber == 2 ) { | 788 | if ( !nfw && d->kbgrabber == 2 ) { |
787 | ungrabKeyboard(); | 789 | ungrabKeyboard(); |
788 | d->kbregrab = TRUE; // want kb back when we're active | 790 | d->kbregrab = TRUE; // want kb back when we're active |
789 | } | 791 | } |
790 | } | 792 | } |
791 | else { | 793 | else { |
792 | // make sure our modal widget is ALWAYS on top | 794 | // make sure our modal widget is ALWAYS on top |
793 | QWidget *topm = activeModalWidget(); | 795 | QWidget *topm = activeModalWidget(); |
794 | if ( topm ) { | 796 | if ( topm ) { |
795 | topm->raise(); | 797 | topm->raise(); |
796 | } | 798 | } |
797 | if ( d->kbregrab ) { | 799 | if ( d->kbregrab ) { |
798 | grabKeyboard(); | 800 | grabKeyboard(); |
799 | d->kbregrab = FALSE; | 801 | d->kbregrab = FALSE; |
800 | } | 802 | } |
801 | } | 803 | } |
802 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 804 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
803 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 805 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
804 | if ( m == AlwaysOff ) | 806 | if ( m == AlwaysOff ) |
805 | Global::hideInputMethod(); | 807 | Global::hideInputMethod(); |
806 | if ( m == AlwaysOn ) | 808 | if ( m == AlwaysOn ) |
807 | Global::showInputMethod(); | 809 | Global::showInputMethod(); |
808 | } | 810 | } |
809 | } | 811 | } |
810 | return QApplication::qwsEventFilter( e ); | 812 | return QApplication::qwsEventFilter( e ); |
811 | } | 813 | } |
812 | #endif | 814 | #endif |
813 | 815 | ||
814 | /*! | 816 | /*! |
815 | Destroys the QPEApplication. | 817 | Destroys the QPEApplication. |
816 | */ | 818 | */ |
817 | QPEApplication::~QPEApplication() | 819 | QPEApplication::~QPEApplication() |
818 | { | 820 | { |
819 | ungrabKeyboard(); | 821 | ungrabKeyboard(); |
820 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 822 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
821 | // Need to delete QCopChannels early, since the display will | 823 | // Need to delete QCopChannels early, since the display will |
822 | // be gone by the time we get to ~QObject(). | 824 | // be gone by the time we get to ~QObject(). |
823 | delete sysChannel; | 825 | delete sysChannel; |
824 | delete pidChannel; | 826 | delete pidChannel; |
825 | #endif | 827 | #endif |
826 | 828 | ||
827 | delete d; | 829 | delete d; |
828 | } | 830 | } |
829 | 831 | ||
830 | /*! | 832 | /*! |
831 | Returns <tt>$OPIEDIR/</tt>. | 833 | Returns <tt>$OPIEDIR/</tt>. |
832 | */ | 834 | */ |
833 | QString QPEApplication::qpeDir() | 835 | QString QPEApplication::qpeDir() |
834 | { | 836 | { |
835 | const char * base = getenv( "OPIEDIR" ); | 837 | const char * base = getenv( "OPIEDIR" ); |
836 | if ( base ) | 838 | if ( base ) |
837 | return QString( base ) + "/"; | 839 | return QString( base ) + "/"; |
838 | 840 | ||
839 | return QString( "../" ); | 841 | return QString( "../" ); |
840 | } | 842 | } |
841 | 843 | ||
842 | /*! | 844 | /*! |
843 | Returns the user's current Document directory. There is a trailing "/". | 845 | Returns the user's current Document directory. There is a trailing "/". |
844 | .. well, it does now,, and there's no trailing '/' | 846 | .. well, it does now,, and there's no trailing '/' |
845 | */ | 847 | */ |
846 | QString QPEApplication::documentDir() | 848 | QString QPEApplication::documentDir() |
847 | { | 849 | { |
848 | const char* base = getenv( "HOME"); | 850 | const char* base = getenv( "HOME"); |
849 | if ( base ) | 851 | if ( base ) |
850 | return QString( base ) + "/Documents"; | 852 | return QString( base ) + "/Documents"; |
851 | 853 | ||
852 | return QString( "../Documents" ); | 854 | return QString( "../Documents" ); |
853 | } | 855 | } |
854 | 856 | ||
855 | static int deforient = -1; | 857 | static int deforient = -1; |
856 | 858 | ||
857 | /*! | 859 | /*! |
858 | \internal | 860 | \internal |
859 | */ | 861 | */ |
860 | int QPEApplication::defaultRotation() | 862 | int QPEApplication::defaultRotation() |
861 | { | 863 | { |
862 | if ( deforient < 0 ) { | 864 | if ( deforient < 0 ) { |
863 | QString d = getenv( "QWS_DISPLAY" ); | 865 | QString d = getenv( "QWS_DISPLAY" ); |
864 | if ( d.contains( "Rot90" ) ) { | 866 | if ( d.contains( "Rot90" ) ) { |
865 | deforient = 90; | 867 | deforient = 90; |
866 | } | 868 | } |
867 | else if ( d.contains( "Rot180" ) ) { | 869 | else if ( d.contains( "Rot180" ) ) { |
868 | deforient = 180; | 870 | deforient = 180; |
869 | } | 871 | } |
870 | else if ( d.contains( "Rot270" ) ) { | 872 | else if ( d.contains( "Rot270" ) ) { |
871 | deforient = 270; | 873 | deforient = 270; |
872 | } | 874 | } |
873 | else { | 875 | else { |
874 | deforient = 0; | 876 | deforient = 0; |
875 | } | 877 | } |
876 | } | 878 | } |
877 | return deforient; | 879 | return deforient; |
878 | } | 880 | } |
879 | 881 | ||
880 | /*! | 882 | /*! |
881 | \internal | 883 | \internal |
882 | */ | 884 | */ |
883 | void QPEApplication::setDefaultRotation( int r ) | 885 | void QPEApplication::setDefaultRotation( int r ) |
884 | { | 886 | { |
885 | if ( qApp->type() == GuiServer ) { | 887 | if ( qApp->type() == GuiServer ) { |
886 | deforient = r; | 888 | deforient = r; |
887 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 889 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
888 | Config config("qpe"); | 890 | Config config("qpe"); |
889 | config.setGroup( "Rotation" ); | 891 | config.setGroup( "Rotation" ); |
890 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 892 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
891 | } | 893 | } |
892 | else { | 894 | else { |
893 | #ifndef QT_NO_COP | 895 | #ifndef QT_NO_COP |
894 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 896 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
895 | e << r; | 897 | e << r; |
896 | } | 898 | } |
897 | #endif | 899 | #endif |
898 | 900 | ||
899 | } | 901 | } |
900 | } | 902 | } |
901 | 903 | ||
902 | // exported to libpreload.so | ||
903 | int opie_block_style = 0; | ||
904 | 904 | ||
905 | /*! | 905 | /*! |
906 | \internal | 906 | \internal |
907 | */ | 907 | */ |
908 | void QPEApplication::applyStyle() | 908 | void QPEApplication::applyStyle() |
909 | { | 909 | { |
910 | Config config( "qpe" ); | 910 | Config config( "qpe" ); |
911 | config.setGroup( "Appearance" ); | 911 | config.setGroup( "Appearance" ); |
912 | 912 | ||
913 | // don't block ourselves ... | 913 | // don't block ourselves ... |
914 | opie_block_style = 0; | 914 | Opie::force_appearance = 0; |
915 | 915 | ||
916 | 916 | static QString appname = Opie::binaryName ( ); | |
917 | static QString appname; | ||
918 | |||
919 | if ( appname. isNull ( )) { | ||
920 | char src [32]; | ||
921 | char dst [PATH_MAX + 1]; | ||
922 | ::sprintf ( src, "/proc/%d/exe", ::getpid ( )); | ||
923 | int l = ::readlink ( src, dst, PATH_MAX ); | ||
924 | if ( l > 0 ) { | ||
925 | dst [l] = 0; | ||
926 | const char *b = ::strrchr ( dst, '/' ); | ||
927 | appname = ( b ? b + 1 : dst ); | ||
928 | } | ||
929 | else | ||
930 | appname = ""; | ||
931 | } | ||
932 | |||
933 | 917 | ||
934 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 918 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
935 | int nostyle = 0; | 919 | int nostyle = 0; |
936 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 920 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
937 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 921 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
938 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 922 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
939 | break; | 923 | break; |
940 | } | 924 | } |
941 | } | 925 | } |
942 | 926 | ||
943 | // Widget style | 927 | // Widget style |
944 | QString style = config.readEntry( "Style", "Light" ); | 928 | QString style = config.readEntry( "Style", "Light" ); |
945 | 929 | ||
946 | // don't set a custom style | 930 | // don't set a custom style |
947 | if ( nostyle & 0x01 ) | 931 | if ( nostyle & Opie::Force_Style ) |
948 | style = "Light"; | 932 | style = "Light"; |
949 | 933 | ||
950 | internalSetStyle ( style ); | 934 | internalSetStyle ( style ); |
951 | 935 | ||
952 | // Colors | 936 | // Colors |
953 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 937 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
954 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 938 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
955 | QPalette pal( btncolor, bgcolor ); | 939 | QPalette pal( btncolor, bgcolor ); |
956 | QString color = config.readEntry( "Highlight", "#800000" ); | 940 | QString color = config.readEntry( "Highlight", "#800000" ); |
957 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 941 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
958 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 942 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
959 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 943 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
960 | color = config.readEntry( "Text", "#000000" ); | 944 | color = config.readEntry( "Text", "#000000" ); |
961 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 945 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
962 | color = config.readEntry( "ButtonText", "#000000" ); | 946 | color = config.readEntry( "ButtonText", "#000000" ); |
963 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 947 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
964 | color = config.readEntry( "Base", "#FFFFFF" ); | 948 | color = config.readEntry( "Base", "#FFFFFF" ); |
965 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 949 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
966 | 950 | ||
967 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 951 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
968 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 952 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
969 | 953 | ||
970 | setPalette( pal, TRUE ); | 954 | setPalette( pal, TRUE ); |
971 | 955 | ||
972 | // Window Decoration | 956 | // Window Decoration |
973 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 957 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
974 | 958 | ||
975 | // don't set a custom deco | 959 | // don't set a custom deco |
976 | if ( nostyle & 0x04 ) | 960 | if ( nostyle & Opie::Force_Decoration ) |
977 | dec = ""; | 961 | dec = ""; |
978 | 962 | ||
979 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 963 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
980 | 964 | ||
981 | if ( dec != d->decorationName ) { | 965 | if ( dec != d->decorationName ) { |
982 | qwsSetDecoration( new QPEDecoration( dec ) ); | 966 | qwsSetDecoration( new QPEDecoration( dec ) ); |
983 | d->decorationName = dec; | 967 | d->decorationName = dec; |
984 | } | 968 | } |
985 | 969 | ||
986 | // Font | 970 | // Font |
987 | QString ff = config.readEntry( "FontFamily", font().family() ); | 971 | QString ff = config.readEntry( "FontFamily", font().family() ); |
988 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 972 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
989 | 973 | ||
990 | // don't set a custom font | 974 | // don't set a custom font |
991 | if ( nostyle & 0x02 ) { | 975 | if ( nostyle & Opie::Force_Font ) { |
992 | ff = "Helvetica"; | 976 | ff = "Helvetica"; |
993 | fs = 10; | 977 | fs = 10; |
994 | } | 978 | } |
995 | 979 | ||
996 | setFont ( QFont ( ff, fs ), true ); | 980 | setFont ( QFont ( ff, fs ), true ); |
997 | 981 | ||
998 | // revert to global blocking policy ... | 982 | // revert to global blocking policy ... |
999 | opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00; | 983 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1000 | opie_block_style -= nostyle; | 984 | Opie::force_appearance &= ~nostyle; |
1001 | } | 985 | } |
1002 | 986 | ||
1003 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 987 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1004 | { | 988 | { |
1005 | #ifdef Q_WS_QWS | 989 | #ifdef Q_WS_QWS |
1006 | QDataStream stream( data, IO_ReadOnly ); | 990 | QDataStream stream( data, IO_ReadOnly ); |
1007 | if ( msg == "applyStyle()" ) { | 991 | if ( msg == "applyStyle()" ) { |
1008 | applyStyle(); | 992 | applyStyle(); |
1009 | } | 993 | } |
1010 | else if ( msg == "setDefaultRotation(int)" ) { | 994 | else if ( msg == "setDefaultRotation(int)" ) { |
1011 | if ( type() == GuiServer ) { | 995 | if ( type() == GuiServer ) { |
1012 | int r; | 996 | int r; |
1013 | stream >> r; | 997 | stream >> r; |
1014 | setDefaultRotation( r ); | 998 | setDefaultRotation( r ); |
1015 | } | 999 | } |
1016 | } | 1000 | } |
1017 | else if ( msg == "shutdown()" ) { | 1001 | else if ( msg == "shutdown()" ) { |
1018 | if ( type() == GuiServer ) | 1002 | if ( type() == GuiServer ) |
1019 | shutdown(); | 1003 | shutdown(); |
1020 | } | 1004 | } |
1021 | else if ( msg == "quit()" ) { | 1005 | else if ( msg == "quit()" ) { |
1022 | if ( type() != GuiServer ) | 1006 | if ( type() != GuiServer ) |
1023 | tryQuit(); | 1007 | tryQuit(); |
1024 | } | 1008 | } |
1025 | else if ( msg == "forceQuit()" ) { | 1009 | else if ( msg == "forceQuit()" ) { |
1026 | if ( type() != GuiServer ) | 1010 | if ( type() != GuiServer ) |
1027 | quit(); | 1011 | quit(); |
1028 | } | 1012 | } |
1029 | else if ( msg == "restart()" ) { | 1013 | else if ( msg == "restart()" ) { |
1030 | if ( type() == GuiServer ) | 1014 | if ( type() == GuiServer ) |
1031 | restart(); | 1015 | restart(); |
1032 | } | 1016 | } |
1033 | else if ( msg == "grabKeyboard(QString)" ) { | 1017 | else if ( msg == "grabKeyboard(QString)" ) { |
1034 | QString who; | 1018 | QString who; |
1035 | stream >> who; | 1019 | stream >> who; |
1036 | if ( who.isEmpty() ) | 1020 | if ( who.isEmpty() ) |
1037 | d->kbgrabber = 0; | 1021 | d->kbgrabber = 0; |
1038 | else if ( who != d->appName ) | 1022 | else if ( who != d->appName ) |
1039 | d->kbgrabber = 1; | 1023 | d->kbgrabber = 1; |
1040 | else | 1024 | else |
1041 | d->kbgrabber = 2; | 1025 | d->kbgrabber = 2; |
1042 | } | 1026 | } |
1043 | else if ( msg == "language(QString)" ) { | 1027 | else if ( msg == "language(QString)" ) { |
1044 | if ( type() == GuiServer ) { | 1028 | if ( type() == GuiServer ) { |
1045 | QString l; | 1029 | QString l; |
1046 | stream >> l; | 1030 | stream >> l; |
1047 | QString cl = getenv( "LANG" ); | 1031 | QString cl = getenv( "LANG" ); |
1048 | if ( cl != l ) { | 1032 | if ( cl != l ) { |
1049 | if ( l.isNull() ) | 1033 | if ( l.isNull() ) |
1050 | unsetenv( "LANG" ); | 1034 | unsetenv( "LANG" ); |
1051 | else | 1035 | else |
1052 | setenv( "LANG", l.latin1(), 1 ); | 1036 | setenv( "LANG", l.latin1(), 1 ); |
1053 | restart(); | 1037 | restart(); |
1054 | } | 1038 | } |
1055 | } | 1039 | } |
1056 | } | 1040 | } |
1057 | else if ( msg == "timeChange(QString)" ) { | 1041 | else if ( msg == "timeChange(QString)" ) { |
1058 | QString t; | 1042 | QString t; |
1059 | stream >> t; | 1043 | stream >> t; |
1060 | if ( t.isNull() ) | 1044 | if ( t.isNull() ) |
1061 | unsetenv( "TZ" ); | 1045 | unsetenv( "TZ" ); |
1062 | else | 1046 | else |
1063 | setenv( "TZ", t.latin1(), 1 ); | 1047 | setenv( "TZ", t.latin1(), 1 ); |
1064 | // emit the signal so everyone else knows... | 1048 | // emit the signal so everyone else knows... |
1065 | emit timeChanged(); | 1049 | emit timeChanged(); |
1066 | } | 1050 | } |
1067 | else if ( msg == "execute(QString)" ) { | 1051 | else if ( msg == "execute(QString)" ) { |
1068 | if ( type() == GuiServer ) { | 1052 | if ( type() == GuiServer ) { |
1069 | QString t; | 1053 | QString t; |
1070 | stream >> t; | 1054 | stream >> t; |
1071 | Global::execute( t ); | 1055 | Global::execute( t ); |
1072 | } | 1056 | } |
1073 | } | 1057 | } |
1074 | else if ( msg == "execute(QString,QString)" ) { | 1058 | else if ( msg == "execute(QString,QString)" ) { |
1075 | if ( type() == GuiServer ) { | 1059 | if ( type() == GuiServer ) { |
1076 | QString t, d; | 1060 | QString t, d; |
1077 | stream >> t >> d; | 1061 | stream >> t >> d; |
1078 | Global::execute( t, d ); | 1062 | Global::execute( t, d ); |
1079 | } | 1063 | } |
1080 | } | 1064 | } |
1081 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1065 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1082 | if ( type() == GuiServer ) { | 1066 | if ( type() == GuiServer ) { |
1083 | QDateTime when; | 1067 | QDateTime when; |
1084 | QCString channel, message; | 1068 | QCString channel, message; |
1085 | int data; | 1069 | int data; |
1086 | stream >> when >> channel >> message >> data; | 1070 | stream >> when >> channel >> message >> data; |
1087 | AlarmServer::addAlarm( when, channel, message, data ); | 1071 | AlarmServer::addAlarm( when, channel, message, data ); |
1088 | } | 1072 | } |
1089 | } | 1073 | } |
1090 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1074 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1091 | if ( type() == GuiServer ) { | 1075 | if ( type() == GuiServer ) { |
1092 | QDateTime when; | 1076 | QDateTime when; |
1093 | QCString channel, message; | 1077 | QCString channel, message; |
1094 | int data; | 1078 | int data; |
1095 | stream >> when >> channel >> message >> data; | 1079 | stream >> when >> channel >> message >> data; |
1096 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1080 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1097 | } | 1081 | } |
1098 | } | 1082 | } |
1099 | else if ( msg == "clockChange(bool)" ) { | 1083 | else if ( msg == "clockChange(bool)" ) { |
1100 | int tmp; | 1084 | int tmp; |
1101 | stream >> tmp; | 1085 | stream >> tmp; |
1102 | emit clockChanged( tmp ); | 1086 | emit clockChanged( tmp ); |
1103 | } | 1087 | } |
1104 | else if ( msg == "weekChange(bool)" ) { | 1088 | else if ( msg == "weekChange(bool)" ) { |
1105 | int tmp; | 1089 | int tmp; |
1106 | stream >> tmp; | 1090 | stream >> tmp; |
1107 | emit weekChanged( tmp ); | 1091 | emit weekChanged( tmp ); |
1108 | } | 1092 | } |
1109 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1093 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1110 | DateFormat tmp; | 1094 | DateFormat tmp; |
1111 | stream >> tmp; | 1095 | stream >> tmp; |
1112 | emit dateFormatChanged( tmp ); | 1096 | emit dateFormatChanged( tmp ); |
1113 | } | 1097 | } |
1114 | else if ( msg == "setVolume(int,int)" ) { | 1098 | else if ( msg == "setVolume(int,int)" ) { |
1115 | int t, v; | 1099 | int t, v; |
1116 | stream >> t >> v; | 1100 | stream >> t >> v; |
1117 | setVolume( t, v ); | 1101 | setVolume( t, v ); |
1118 | emit volumeChanged( muted ); | 1102 | emit volumeChanged( muted ); |
1119 | } | 1103 | } |
1120 | else if ( msg == "volumeChange(bool)" ) { | 1104 | else if ( msg == "volumeChange(bool)" ) { |
1121 | stream >> muted; | 1105 | stream >> muted; |
1122 | setVolume(); | 1106 | setVolume(); |
1123 | emit volumeChanged( muted ); | 1107 | emit volumeChanged( muted ); |
1124 | } | 1108 | } |
1125 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1109 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1126 | int t, v; | 1110 | int t, v; |
1127 | stream >> t >> v; | 1111 | stream >> t >> v; |
1128 | setMic( t, v ); | 1112 | setMic( t, v ); |
1129 | emit micChanged( micMuted ); | 1113 | emit micChanged( micMuted ); |
1130 | } | 1114 | } |
1131 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1115 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1132 | stream >> micMuted; | 1116 | stream >> micMuted; |
1133 | setMic(); | 1117 | setMic(); |
1134 | emit micChanged( micMuted ); | 1118 | emit micChanged( micMuted ); |
1135 | } | 1119 | } |
1136 | #endif | 1120 | #endif |
1137 | } | 1121 | } |
1138 | 1122 | ||
1139 | /*! | 1123 | /*! |
1140 | \internal | 1124 | \internal |
1141 | */ | 1125 | */ |
1142 | bool QPEApplication::raiseAppropriateWindow() | 1126 | bool QPEApplication::raiseAppropriateWindow() |
1143 | { | 1127 | { |
1144 | bool r = FALSE; | 1128 | bool r = FALSE; |
1145 | // ########## raise()ing main window should raise and set active | 1129 | // ########## raise()ing main window should raise and set active |
1146 | // ########## it and then all childen. This belongs in Qt/Embedded | 1130 | // ########## it and then all childen. This belongs in Qt/Embedded |
1147 | QWidget *top = d->qpe_main_widget; | 1131 | QWidget *top = d->qpe_main_widget; |
1148 | if ( !top ) | 1132 | if ( !top ) |
1149 | top = mainWidget(); | 1133 | top = mainWidget(); |
1150 | if ( top && d->keep_running ) { | 1134 | if ( top && d->keep_running ) { |
1151 | if ( top->isVisible() ) | 1135 | if ( top->isVisible() ) |
1152 | r = TRUE; | 1136 | r = TRUE; |
1153 | else if (d->preloaded) { | 1137 | else if (d->preloaded) { |
1154 | // We are preloaded and not visible.. pretend we just started.. | 1138 | // We are preloaded and not visible.. pretend we just started.. |
1155 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1139 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1156 | e << d->appName; | 1140 | e << d->appName; |
1157 | } | 1141 | } |
1158 | 1142 | ||
1159 | d->show_mx(top, d->nomaximize); | 1143 | d->show_mx(top, d->nomaximize); |
1160 | top->raise(); | 1144 | top->raise(); |
1161 | top->setActiveWindow(); | 1145 | top->setActiveWindow(); |
1162 | } | 1146 | } |
1163 | QWidget *topm = activeModalWidget(); | 1147 | QWidget *topm = activeModalWidget(); |
1164 | if ( topm && topm != top ) { | 1148 | if ( topm && topm != top ) { |
1165 | topm->show(); | 1149 | topm->show(); |
1166 | topm->raise(); | 1150 | topm->raise(); |
1167 | topm->setActiveWindow(); | 1151 | topm->setActiveWindow(); |
1168 | // If we haven't already handled the fastAppShowing message | 1152 | // If we haven't already handled the fastAppShowing message |
1169 | if (!top && d->preloaded) { | 1153 | if (!top && d->preloaded) { |
1170 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1154 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1171 | e << d->appName; | 1155 | e << d->appName; |
1172 | } | 1156 | } |
1173 | r = FALSE; | 1157 | r = FALSE; |
1174 | } | 1158 | } |
1175 | return r; | 1159 | return r; |
1176 | } | 1160 | } |
1177 | 1161 | ||
1178 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1162 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1179 | { | 1163 | { |
1180 | #ifdef Q_WS_QWS | 1164 | #ifdef Q_WS_QWS |
1181 | 1165 | ||
1182 | if ( msg == "quit()" ) { | 1166 | if ( msg == "quit()" ) { |
1183 | tryQuit(); | 1167 | tryQuit(); |
1184 | } | 1168 | } |
1185 | else if ( msg == "quitIfInvisible()" ) { | 1169 | else if ( msg == "quitIfInvisible()" ) { |
1186 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1170 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1187 | quit(); | 1171 | quit(); |
1188 | } | 1172 | } |
1189 | else if ( msg == "close()" ) { | 1173 | else if ( msg == "close()" ) { |
1190 | hideOrQuit(); | 1174 | hideOrQuit(); |
1191 | } | 1175 | } |
1192 | else if ( msg == "disablePreload()" ) { | 1176 | else if ( msg == "disablePreload()" ) { |
1193 | d->preloaded = FALSE; | 1177 | d->preloaded = FALSE; |
1194 | d->keep_running = TRUE; | 1178 | d->keep_running = TRUE; |
1195 | /* so that quit will quit */ | 1179 | /* so that quit will quit */ |
1196 | } | 1180 | } |
1197 | else if ( msg == "enablePreload()" ) { | 1181 | else if ( msg == "enablePreload()" ) { |
1198 | if (d->qpe_main_widget) | 1182 | if (d->qpe_main_widget) |
1199 | d->preloaded = TRUE; | 1183 | d->preloaded = TRUE; |
1200 | d->keep_running = TRUE; | 1184 | d->keep_running = TRUE; |
1201 | /* so next quit won't quit */ | 1185 | /* so next quit won't quit */ |
1202 | } | 1186 | } |
1203 | else if ( msg == "raise()" ) { | 1187 | else if ( msg == "raise()" ) { |
1204 | d->keep_running = TRUE; | 1188 | d->keep_running = TRUE; |
1205 | d->notbusysent = FALSE; | 1189 | d->notbusysent = FALSE; |
1206 | raiseAppropriateWindow(); | 1190 | raiseAppropriateWindow(); |
1207 | // Tell the system we're still chugging along... | 1191 | // Tell the system we're still chugging along... |
1208 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1192 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1209 | e << d->appName; | 1193 | e << d->appName; |
1210 | } | 1194 | } |
1211 | else if ( msg == "flush()" ) { | 1195 | else if ( msg == "flush()" ) { |
1212 | emit flush(); | 1196 | emit flush(); |
1213 | // we need to tell the desktop | 1197 | // we need to tell the desktop |
1214 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1198 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1215 | e << d->appName; | 1199 | e << d->appName; |
1216 | } | 1200 | } |
1217 | else if ( msg == "reload()" ) { | 1201 | else if ( msg == "reload()" ) { |
1218 | emit reload(); | 1202 | emit reload(); |
1219 | } | 1203 | } |
1220 | else if ( msg == "setDocument(QString)" ) { | 1204 | else if ( msg == "setDocument(QString)" ) { |
1221 | d->keep_running = TRUE; | 1205 | d->keep_running = TRUE; |
1222 | QDataStream stream( data, IO_ReadOnly ); | 1206 | QDataStream stream( data, IO_ReadOnly ); |
1223 | QString doc; | 1207 | QString doc; |
1224 | stream >> doc; | 1208 | stream >> doc; |
1225 | QWidget *mw = mainWidget(); | 1209 | QWidget *mw = mainWidget(); |
1226 | if ( !mw ) | 1210 | if ( !mw ) |
1227 | mw = d->qpe_main_widget; | 1211 | mw = d->qpe_main_widget; |
1228 | if ( mw ) | 1212 | if ( mw ) |
1229 | Global::setDocument( mw, doc ); | 1213 | Global::setDocument( mw, doc ); |
1230 | } | 1214 | } |
1231 | else if ( msg == "nextView()" ) { | 1215 | else if ( msg == "nextView()" ) { |
1232 | qDebug("got nextView()"); | 1216 | qDebug("got nextView()"); |
1233 | /* | 1217 | /* |
1234 | if ( raiseAppropriateWindow() ) | 1218 | if ( raiseAppropriateWindow() ) |
1235 | */ | 1219 | */ |
1236 | emit appMessage( msg, data); | 1220 | emit appMessage( msg, data); |
1237 | } | 1221 | } |
1238 | else { | 1222 | else { |
1239 | emit appMessage( msg, data); | 1223 | emit appMessage( msg, data); |
1240 | } | 1224 | } |
1241 | 1225 | ||
1242 | #endif | 1226 | #endif |
1243 | } | 1227 | } |
1244 | 1228 | ||
1245 | 1229 | ||
1246 | /*! | 1230 | /*! |
1247 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1231 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1248 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1232 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1249 | 1233 | ||
1250 | \sa showMainDocumentWidget() | 1234 | \sa showMainDocumentWidget() |
1251 | */ | 1235 | */ |
1252 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1236 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1253 | { | 1237 | { |
1254 | d->show(mw, nomaximize ); | 1238 | d->show(mw, nomaximize ); |
1255 | } | 1239 | } |
1256 | 1240 | ||
1257 | /*! | 1241 | /*! |
1258 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1242 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1259 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1243 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1260 | 1244 | ||
1261 | This calls designates the application as | 1245 | This calls designates the application as |
1262 | a \link docwidget.html document-oriented\endlink application. | 1246 | a \link docwidget.html document-oriented\endlink application. |
1263 | 1247 | ||
1264 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1248 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1265 | 1249 | ||
1266 | \sa showMainWidget() | 1250 | \sa showMainWidget() |
1267 | */ | 1251 | */ |
1268 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1252 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1269 | { | 1253 | { |
1270 | if ( mw && argc() == 2 ) | 1254 | if ( mw && argc() == 2 ) |
1271 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1255 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1272 | 1256 | ||
1273 | d->show(mw, nomaximize ); | 1257 | d->show(mw, nomaximize ); |
1274 | } | 1258 | } |
1275 | 1259 | ||
1276 | 1260 | ||
1277 | /*! | 1261 | /*! |
1278 | If an application is started via a \link qcop.html QCop\endlink | 1262 | If an application is started via a \link qcop.html QCop\endlink |
1279 | message, the application will process the \link qcop.html | 1263 | message, the application will process the \link qcop.html |
1280 | QCop\endlink message and then quit. If the application calls this | 1264 | QCop\endlink message and then quit. If the application calls this |
1281 | function while processing a \link qcop.html QCop\endlink message, | 1265 | function while processing a \link qcop.html QCop\endlink message, |
1282 | after processing its outstanding \link qcop.html QCop\endlink | 1266 | after processing its outstanding \link qcop.html QCop\endlink |
1283 | messages the application will start 'properly' and show itself. | 1267 | messages the application will start 'properly' and show itself. |
1284 | 1268 | ||
1285 | \sa keepRunning() | 1269 | \sa keepRunning() |
1286 | */ | 1270 | */ |
1287 | void QPEApplication::setKeepRunning() | 1271 | void QPEApplication::setKeepRunning() |
1288 | { | 1272 | { |
1289 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1273 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1290 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1274 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1291 | qpeApp->d->keep_running = TRUE; | 1275 | qpeApp->d->keep_running = TRUE; |
1292 | } | 1276 | } |
1293 | } | 1277 | } |
1294 | 1278 | ||
1295 | /*! | 1279 | /*! |
1296 | Returns TRUE if the application will quit after processing the | 1280 | Returns TRUE if the application will quit after processing the |
1297 | current list of qcop messages; otherwise returns FALSE. | 1281 | current list of qcop messages; otherwise returns FALSE. |
1298 | 1282 | ||
1299 | \sa setKeepRunning() | 1283 | \sa setKeepRunning() |
1300 | */ | 1284 | */ |
1301 | bool QPEApplication::keepRunning() const | 1285 | bool QPEApplication::keepRunning() const |
1302 | { | 1286 | { |
1303 | return d->keep_running; | 1287 | return d->keep_running; |
1304 | } | 1288 | } |
1305 | 1289 | ||
1306 | /*! | 1290 | /*! |
1307 | \internal | 1291 | \internal |
1308 | */ | 1292 | */ |
1309 | void QPEApplication::internalSetStyle( const QString &style ) | 1293 | void QPEApplication::internalSetStyle( const QString &style ) |
1310 | { | 1294 | { |
1311 | #if QT_VERSION >= 300 | 1295 | #if QT_VERSION >= 300 |
1312 | if ( style == "QPE" ) { | 1296 | if ( style == "QPE" ) { |
1313 | setStyle( new QPEStyle ); | 1297 | setStyle( new QPEStyle ); |
1314 | } | 1298 | } |
1315 | else { | 1299 | else { |
1316 | QStyle *s = QStyleFactory::create( style ); | 1300 | QStyle *s = QStyleFactory::create( style ); |
1317 | if ( s ) | 1301 | if ( s ) |
1318 | setStyle( s ); | 1302 | setStyle( s ); |
1319 | } | 1303 | } |
1320 | #else | 1304 | #else |
1321 | if ( style == "Windows" ) { | 1305 | if ( style == "Windows" ) { |
1322 | setStyle( new QWindowsStyle ); | 1306 | setStyle( new QWindowsStyle ); |
1323 | } | 1307 | } |
1324 | else if ( style == "QPE" ) { | 1308 | else if ( style == "QPE" ) { |
1325 | setStyle( new QPEStyle ); | 1309 | setStyle( new QPEStyle ); |
1326 | } | 1310 | } |
1327 | else if ( style == "Light" ) { | 1311 | else if ( style == "Light" ) { |
1328 | setStyle( new LightStyle ); | 1312 | setStyle( new LightStyle ); |
1329 | } | 1313 | } |
1330 | #ifndef QT_NO_STYLE_PLATINUM | 1314 | #ifndef QT_NO_STYLE_PLATINUM |
1331 | else if ( style == "Platinum" ) { | 1315 | else if ( style == "Platinum" ) { |
1332 | setStyle( new QPlatinumStyle ); | 1316 | setStyle( new QPlatinumStyle ); |
1333 | } | 1317 | } |
1334 | #endif | 1318 | #endif |
1335 | #ifndef QT_NO_STYLE_MOTIF | 1319 | #ifndef QT_NO_STYLE_MOTIF |
1336 | else if ( style == "Motif" ) { | 1320 | else if ( style == "Motif" ) { |
1337 | setStyle( new QMotifStyle ); | 1321 | setStyle( new QMotifStyle ); |
1338 | } | 1322 | } |
1339 | #endif | 1323 | #endif |
1340 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1324 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1341 | else if ( style == "MotifPlus" ) { | 1325 | else if ( style == "MotifPlus" ) { |
1342 | setStyle( new QMotifPlusStyle ); | 1326 | setStyle( new QMotifPlusStyle ); |
1343 | } | 1327 | } |
1344 | #endif | 1328 | #endif |
1345 | 1329 | ||
1346 | else { | 1330 | else { |
1347 | QStyle *sty = 0; | 1331 | QStyle *sty = 0; |
1348 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1332 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1349 | 1333 | ||
1350 | if ( style. find ( ".so" ) > 0 ) | 1334 | if ( style. find ( ".so" ) > 0 ) |
1351 | path += style; | 1335 | path += style; |
1352 | else | 1336 | else |
1353 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1337 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1354 | 1338 | ||
1355 | static QLibrary *lastlib = 0; | 1339 | static QLibrary *lastlib = 0; |
1356 | static StyleInterface *lastiface = 0; | 1340 | static StyleInterface *lastiface = 0; |
1357 | 1341 | ||
1358 | QLibrary *lib = new QLibrary ( path ); | 1342 | QLibrary *lib = new QLibrary ( path ); |
1359 | StyleInterface *iface = 0; | 1343 | StyleInterface *iface = 0; |
1360 | 1344 | ||
1361 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1345 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1362 | sty = iface-> style ( ); | 1346 | sty = iface-> style ( ); |
1363 | 1347 | ||
1364 | if ( sty ) { | 1348 | if ( sty ) { |
1365 | setStyle ( sty ); | 1349 | setStyle ( sty ); |
1366 | 1350 | ||
1367 | if ( lastiface ) | 1351 | if ( lastiface ) |
1368 | lastiface-> release ( ); | 1352 | lastiface-> release ( ); |
1369 | lastiface = iface; | 1353 | lastiface = iface; |
1370 | 1354 | ||
1371 | if ( lastlib ) { | 1355 | if ( lastlib ) { |
1372 | lastlib-> unload ( ); | 1356 | lastlib-> unload ( ); |
1373 | delete lastlib; | 1357 | delete lastlib; |
1374 | } | 1358 | } |
1375 | lastlib = lib; | 1359 | lastlib = lib; |
1376 | } | 1360 | } |
1377 | else { | 1361 | else { |
1378 | if ( iface ) | 1362 | if ( iface ) |
1379 | iface-> release ( ); | 1363 | iface-> release ( ); |
1380 | delete lib; | 1364 | delete lib; |
1381 | 1365 | ||
1382 | setStyle ( new LightStyle ( )); | 1366 | setStyle ( new LightStyle ( )); |
1383 | } | 1367 | } |
1384 | } | 1368 | } |
1385 | #endif | 1369 | #endif |
1386 | } | 1370 | } |
1387 | 1371 | ||
1388 | /*! | 1372 | /*! |
1389 | \internal | 1373 | \internal |
1390 | */ | 1374 | */ |
1391 | void QPEApplication::prepareForTermination( bool willrestart ) | 1375 | void QPEApplication::prepareForTermination( bool willrestart ) |
1392 | { | 1376 | { |
1393 | if ( willrestart ) { | 1377 | if ( willrestart ) { |
1394 | // Draw a big wait icon, the image can be altered in later revisions | 1378 | // Draw a big wait icon, the image can be altered in later revisions |
1395 | // QWidget *d = QApplication::desktop(); | 1379 | // QWidget *d = QApplication::desktop(); |
1396 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1380 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1397 | QPixmap pix; | 1381 | QPixmap pix; |
1398 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1382 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1399 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1383 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1400 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1384 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1401 | lblWait->setPixmap( pix ); | 1385 | lblWait->setPixmap( pix ); |
1402 | lblWait->setAlignment( QWidget::AlignCenter ); | 1386 | lblWait->setAlignment( QWidget::AlignCenter ); |
1403 | lblWait->show(); | 1387 | lblWait->show(); |
1404 | lblWait->showMaximized(); | 1388 | lblWait->showMaximized(); |
1405 | } | 1389 | } |
1406 | #ifndef SINGLE_APP | 1390 | #ifndef SINGLE_APP |
1407 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1391 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1408 | } | 1392 | } |
1409 | processEvents(); // ensure the message goes out. | 1393 | processEvents(); // ensure the message goes out. |
1410 | sleep( 1 ); // You have 1 second to comply. | 1394 | sleep( 1 ); // You have 1 second to comply. |
1411 | #endif | 1395 | #endif |
1412 | } | 1396 | } |
1413 | 1397 | ||
1414 | /*! | 1398 | /*! |
1415 | \internal | 1399 | \internal |
1416 | */ | 1400 | */ |
1417 | void QPEApplication::shutdown() | 1401 | void QPEApplication::shutdown() |
1418 | { | 1402 | { |
1419 | // Implement in server's QPEApplication subclass | 1403 | // Implement in server's QPEApplication subclass |
1420 | } | 1404 | } |
1421 | 1405 | ||
1422 | /*! | 1406 | /*! |
1423 | \internal | 1407 | \internal |
1424 | */ | 1408 | */ |
1425 | void QPEApplication::restart() | 1409 | void QPEApplication::restart() |
1426 | { | 1410 | { |
1427 | // Implement in server's QPEApplication subclass | 1411 | // Implement in server's QPEApplication subclass |
1428 | } | 1412 | } |
1429 | 1413 | ||
1430 | static QPtrDict<void>* stylusDict = 0; | 1414 | static QPtrDict<void>* stylusDict = 0; |
1431 | static void createDict() | 1415 | static void createDict() |
1432 | { | 1416 | { |
1433 | if ( !stylusDict ) | 1417 | if ( !stylusDict ) |
1434 | stylusDict = new QPtrDict<void>; | 1418 | stylusDict = new QPtrDict<void>; |
1435 | } | 1419 | } |
1436 | 1420 | ||
1437 | /*! | 1421 | /*! |
1438 | Returns the current StylusMode for widget \a w. | 1422 | Returns the current StylusMode for widget \a w. |
1439 | 1423 | ||
1440 | \sa setStylusOperation() StylusMode | 1424 | \sa setStylusOperation() StylusMode |
1441 | */ | 1425 | */ |
1442 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1426 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1443 | { | 1427 | { |
1444 | if ( stylusDict ) | 1428 | if ( stylusDict ) |
1445 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1429 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1446 | return LeftOnly; | 1430 | return LeftOnly; |
1447 | } | 1431 | } |
1448 | 1432 | ||
1449 | /*! | 1433 | /*! |
1450 | \enum QPEApplication::StylusMode | 1434 | \enum QPEApplication::StylusMode |
1451 | 1435 | ||
1452 | \value LeftOnly the stylus only generates LeftButton | 1436 | \value LeftOnly the stylus only generates LeftButton |
1453 | events (the default). | 1437 | events (the default). |
1454 | \value RightOnHold the stylus generates RightButton events | 1438 | \value RightOnHold the stylus generates RightButton events |
1455 | if the user uses the press-and-hold gesture. | 1439 | if the user uses the press-and-hold gesture. |
1456 | 1440 | ||
1457 | \sa setStylusOperation() stylusOperation() | 1441 | \sa setStylusOperation() stylusOperation() |
1458 | */ | 1442 | */ |
1459 | 1443 | ||
1460 | /*! | 1444 | /*! |
1461 | Causes widget \a w to receive mouse events according to the stylus | 1445 | Causes widget \a w to receive mouse events according to the stylus |
1462 | \a mode. | 1446 | \a mode. |
1463 | 1447 | ||
1464 | \sa stylusOperation() StylusMode | 1448 | \sa stylusOperation() StylusMode |
1465 | */ | 1449 | */ |
1466 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1450 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1467 | { | 1451 | { |
1468 | createDict(); | 1452 | createDict(); |
1469 | if ( mode == LeftOnly ) { | 1453 | if ( mode == LeftOnly ) { |
1470 | stylusDict->remove | 1454 | stylusDict->remove |
1471 | ( w ); | 1455 | ( w ); |
1472 | w->removeEventFilter( qApp ); | 1456 | w->removeEventFilter( qApp ); |
1473 | } | 1457 | } |
1474 | else { | 1458 | else { |
1475 | stylusDict->insert( w, ( void* ) mode ); | 1459 | stylusDict->insert( w, ( void* ) mode ); |
1476 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1460 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1477 | w->installEventFilter( qApp ); | 1461 | w->installEventFilter( qApp ); |
1478 | } | 1462 | } |
1479 | } | 1463 | } |
1480 | 1464 | ||
1481 | 1465 | ||
1482 | /*! | 1466 | /*! |
1483 | \reimp | 1467 | \reimp |
1484 | */ | 1468 | */ |
1485 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1469 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1486 | { | 1470 | { |
1487 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1471 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1488 | QMouseEvent * me = ( QMouseEvent* ) e; | 1472 | QMouseEvent * me = ( QMouseEvent* ) e; |
1489 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1473 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1490 | switch (mode) { | 1474 | switch (mode) { |
1491 | case RightOnHold: | 1475 | case RightOnHold: |
1492 | switch ( me->type() ) { | 1476 | switch ( me->type() ) { |
1493 | case QEvent::MouseButtonPress: | 1477 | case QEvent::MouseButtonPress: |
1494 | if ( me->button() == LeftButton ) { | 1478 | if ( me->button() == LeftButton ) { |
1495 | d->presstimer = startTimer(500); // #### pref. | 1479 | d->presstimer = startTimer(500); // #### pref. |
1496 | d->presswidget = (QWidget*)o; | 1480 | d->presswidget = (QWidget*)o; |
1497 | d->presspos = me->pos(); | 1481 | d->presspos = me->pos(); |
1498 | d->rightpressed = FALSE; | 1482 | d->rightpressed = FALSE; |
1499 | } | 1483 | } |
1500 | break; | 1484 | break; |
1501 | case QEvent::MouseMove: | 1485 | case QEvent::MouseMove: |
1502 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1486 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1503 | killTimer(d->presstimer); | 1487 | killTimer(d->presstimer); |
1504 | d->presstimer = 0; | 1488 | d->presstimer = 0; |
1505 | } | 1489 | } |
1506 | break; | 1490 | break; |
1507 | case QEvent::MouseButtonRelease: | 1491 | case QEvent::MouseButtonRelease: |
1508 | if ( me->button() == LeftButton ) { | 1492 | if ( me->button() == LeftButton ) { |
1509 | if ( d->presstimer ) { | 1493 | if ( d->presstimer ) { |
1510 | killTimer(d->presstimer); | 1494 | killTimer(d->presstimer); |
1511 | d->presstimer = 0; | 1495 | d->presstimer = 0; |
1512 | } | 1496 | } |
1513 | if ( d->rightpressed && d->presswidget ) { | 1497 | if ( d->rightpressed && d->presswidget ) { |
1514 | // Right released | 1498 | // Right released |
1515 | postEvent( d->presswidget, | 1499 | postEvent( d->presswidget, |
1516 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1500 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1517 | RightButton, LeftButton + RightButton ) ); | 1501 | RightButton, LeftButton + RightButton ) ); |
1518 | // Left released, off-widget | 1502 | // Left released, off-widget |
1519 | postEvent( d->presswidget, | 1503 | postEvent( d->presswidget, |
1520 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1504 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1521 | LeftButton, LeftButton ) ); | 1505 | LeftButton, LeftButton ) ); |
1522 | postEvent( d->presswidget, | 1506 | postEvent( d->presswidget, |
1523 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1507 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1524 | LeftButton, LeftButton ) ); | 1508 | LeftButton, LeftButton ) ); |
1525 | d->rightpressed = FALSE; | 1509 | d->rightpressed = FALSE; |
1526 | return TRUE; // don't send the real Left release | 1510 | return TRUE; // don't send the real Left release |
1527 | } | 1511 | } |
1528 | } | 1512 | } |
1529 | break; | 1513 | break; |
1530 | default: | 1514 | default: |
1531 | break; | 1515 | break; |
1532 | } | 1516 | } |
1533 | break; | 1517 | break; |
1534 | default: | 1518 | default: |
1535 | ; | 1519 | ; |
1536 | } | 1520 | } |
1537 | } | 1521 | } |
1538 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1522 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1539 | QKeyEvent *ke = (QKeyEvent *)e; | 1523 | QKeyEvent *ke = (QKeyEvent *)e; |
1540 | if ( ke->key() == Key_Enter ) { | 1524 | if ( ke->key() == Key_Enter ) { |
1541 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1525 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1542 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1526 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1543 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1527 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1544 | return TRUE; | 1528 | return TRUE; |
1545 | } | 1529 | } |
1546 | } | 1530 | } |
1547 | } | 1531 | } |
1548 | return FALSE; | 1532 | return FALSE; |
1549 | } | 1533 | } |
1550 | 1534 | ||
1551 | /*! | 1535 | /*! |
1552 | \reimp | 1536 | \reimp |
1553 | */ | 1537 | */ |
1554 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1538 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1555 | { | 1539 | { |
1556 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1540 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1557 | // Right pressed | 1541 | // Right pressed |
1558 | postEvent( d->presswidget, | 1542 | postEvent( d->presswidget, |
1559 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1543 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1560 | RightButton, LeftButton ) ); | 1544 | RightButton, LeftButton ) ); |
1561 | killTimer( d->presstimer ); | 1545 | killTimer( d->presstimer ); |
1562 | d->presstimer = 0; | 1546 | d->presstimer = 0; |
1563 | d->rightpressed = TRUE; | 1547 | d->rightpressed = TRUE; |
1564 | } | 1548 | } |
1565 | } | 1549 | } |
1566 | 1550 | ||
1567 | void QPEApplication::removeSenderFromStylusDict() | 1551 | void QPEApplication::removeSenderFromStylusDict() |
1568 | { | 1552 | { |
1569 | stylusDict->remove | 1553 | stylusDict->remove |
1570 | ( ( void* ) sender() ); | 1554 | ( ( void* ) sender() ); |
1571 | if ( d->presswidget == sender() ) | 1555 | if ( d->presswidget == sender() ) |
1572 | d->presswidget = 0; | 1556 | d->presswidget = 0; |
1573 | } | 1557 | } |
1574 | 1558 | ||
1575 | /*! | 1559 | /*! |
1576 | \internal | 1560 | \internal |
1577 | */ | 1561 | */ |
1578 | bool QPEApplication::keyboardGrabbed() const | 1562 | bool QPEApplication::keyboardGrabbed() const |
1579 | { | 1563 | { |
1580 | return d->kbgrabber; | 1564 | return d->kbgrabber; |
1581 | } | 1565 | } |
1582 | 1566 | ||
1583 | 1567 | ||
1584 | /*! | 1568 | /*! |
1585 | Reverses the effect of grabKeyboard(). This is called automatically | 1569 | Reverses the effect of grabKeyboard(). This is called automatically |
1586 | on program exit. | 1570 | on program exit. |
1587 | */ | 1571 | */ |
1588 | void QPEApplication::ungrabKeyboard() | 1572 | void QPEApplication::ungrabKeyboard() |
1589 | { | 1573 | { |
1590 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1574 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1591 | if ( d->kbgrabber == 2 ) { | 1575 | if ( d->kbgrabber == 2 ) { |
1592 | #ifndef QT_NO_COP | 1576 | #ifndef QT_NO_COP |
1593 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1577 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1594 | e << QString::null; | 1578 | e << QString::null; |
1595 | #endif | 1579 | #endif |
1596 | 1580 | ||
1597 | d->kbregrab = FALSE; | 1581 | d->kbregrab = FALSE; |
1598 | d->kbgrabber = 0; | 1582 | d->kbgrabber = 0; |
1599 | } | 1583 | } |
1600 | } | 1584 | } |
1601 | 1585 | ||
1602 | /*! | 1586 | /*! |
1603 | Grabs the physical keyboard keys, e.g. the application's launching | 1587 | Grabs the physical keyboard keys, e.g. the application's launching |
1604 | keys. Instead of launching applications when these keys are pressed | 1588 | keys. Instead of launching applications when these keys are pressed |
1605 | the signals emitted are sent to this application instead. Some games | 1589 | the signals emitted are sent to this application instead. Some games |
1606 | programs take over the launch keys in this way to make interaction | 1590 | programs take over the launch keys in this way to make interaction |
1607 | easier. | 1591 | easier. |
1608 | 1592 | ||
1609 | \sa ungrabKeyboard() | 1593 | \sa ungrabKeyboard() |
1610 | */ | 1594 | */ |
1611 | void QPEApplication::grabKeyboard() | 1595 | void QPEApplication::grabKeyboard() |
1612 | { | 1596 | { |
1613 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1597 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1614 | if ( qApp->type() == QApplication::GuiServer ) | 1598 | if ( qApp->type() == QApplication::GuiServer ) |
1615 | d->kbgrabber = 0; | 1599 | d->kbgrabber = 0; |
1616 | else { | 1600 | else { |
1617 | #ifndef QT_NO_COP | 1601 | #ifndef QT_NO_COP |
1618 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1602 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1619 | e << d->appName; | 1603 | e << d->appName; |
1620 | #endif | 1604 | #endif |
1621 | 1605 | ||
1622 | d->kbgrabber = 2; // me | 1606 | d->kbgrabber = 2; // me |
1623 | } | 1607 | } |
1624 | } | 1608 | } |
1625 | 1609 | ||
1626 | /*! | 1610 | /*! |
1627 | \reimp | 1611 | \reimp |
1628 | */ | 1612 | */ |
1629 | int QPEApplication::exec() | 1613 | int QPEApplication::exec() |
1630 | { | 1614 | { |
1631 | #ifndef QT_NO_COP | 1615 | #ifndef QT_NO_COP |
1632 | d->sendQCopQ(); | 1616 | d->sendQCopQ(); |
1633 | #endif | 1617 | #endif |
1634 | 1618 | ||
1635 | if ( d->keep_running ) | 1619 | if ( d->keep_running ) |
1636 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1620 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1637 | return QApplication::exec(); | 1621 | return QApplication::exec(); |
1638 | 1622 | ||
1639 | #ifndef QT_NO_COP | 1623 | #ifndef QT_NO_COP |
1640 | 1624 | ||
1641 | { | 1625 | { |
1642 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1626 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1643 | e << d->appName; | 1627 | e << d->appName; |
1644 | } | 1628 | } |
1645 | #endif | 1629 | #endif |
1646 | processEvents(); | 1630 | processEvents(); |
1647 | return 0; | 1631 | return 0; |
1648 | } | 1632 | } |
1649 | 1633 | ||
1650 | /*! | 1634 | /*! |
1651 | \internal | 1635 | \internal |
1652 | External request for application to quit. Quits if possible without | 1636 | External request for application to quit. Quits if possible without |
1653 | loosing state. | 1637 | loosing state. |
1654 | */ | 1638 | */ |
1655 | void QPEApplication::tryQuit() | 1639 | void QPEApplication::tryQuit() |
1656 | { | 1640 | { |
1657 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1641 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1658 | return ; // Inside modal loop or konsole. Too hard to save state. | 1642 | return ; // Inside modal loop or konsole. Too hard to save state. |
1659 | #ifndef QT_NO_COP | 1643 | #ifndef QT_NO_COP |
1660 | 1644 | ||
1661 | { | 1645 | { |
1662 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1646 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1663 | e << d->appName; | 1647 | e << d->appName; |
1664 | } | 1648 | } |
1665 | #endif | 1649 | #endif |
1666 | processEvents(); | 1650 | processEvents(); |
1667 | 1651 | ||
1668 | quit(); | 1652 | quit(); |
1669 | } | 1653 | } |
1670 | 1654 | ||
1671 | /*! | 1655 | /*! |
1672 | \internal | 1656 | \internal |
1673 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1657 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1674 | hiding the window. If not it means quitting the application. | 1658 | hiding the window. If not it means quitting the application. |
1675 | As this is user initiated we don't need to check state. | 1659 | As this is user initiated we don't need to check state. |
1676 | */ | 1660 | */ |
1677 | void QPEApplication::hideOrQuit() | 1661 | void QPEApplication::hideOrQuit() |
1678 | { | 1662 | { |
1679 | processEvents(); | 1663 | processEvents(); |
1680 | 1664 | ||
1681 | // If we are a preloaded application we don't actually quit, so emit | 1665 | // If we are a preloaded application we don't actually quit, so emit |
1682 | // a System message indicating we're quasi-closing. | 1666 | // a System message indicating we're quasi-closing. |
1683 | if ( d->preloaded && d->qpe_main_widget ) | 1667 | if ( d->preloaded && d->qpe_main_widget ) |
1684 | #ifndef QT_NO_COP | 1668 | #ifndef QT_NO_COP |
1685 | 1669 | ||
1686 | { | 1670 | { |
1687 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1671 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1688 | e << d->appName; | 1672 | e << d->appName; |
1689 | d->qpe_main_widget->hide(); | 1673 | d->qpe_main_widget->hide(); |
1690 | } | 1674 | } |
1691 | #endif | 1675 | #endif |
1692 | else | 1676 | else |
1693 | quit(); | 1677 | quit(); |
1694 | } | 1678 | } |
1695 | 1679 | ||
1680 | |||
1681 | // These 6 stubs below need 1.5K in the binary and besides that - | ||
1682 | // we are not using ancient toolchains anymore - sandman | ||
1683 | |||
1696 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) | 1684 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) |
1697 | 1685 | ||
1698 | // The libraries with the skiff package (and possibly others) have | 1686 | // The libraries with the skiff package (and possibly others) have |
1699 | // completely useless implementations of builtin new and delete that | 1687 | // completely useless implementations of builtin new and delete that |
1700 | // use about 50% of your CPU. Here we revert to the simple libc | 1688 | // use about 50% of your CPU. Here we revert to the simple libc |
1701 | // functions. | 1689 | // functions. |
1702 | 1690 | ||
1703 | void* operator new[]( size_t size ) | 1691 | void* operator new[]( size_t size ) |
1704 | { | 1692 | { |
1705 | return malloc( size ); | 1693 | return malloc( size ); |
1706 | } | 1694 | } |
1707 | 1695 | ||
1708 | void* operator new( size_t size ) | 1696 | void* operator new( size_t size ) |
1709 | { | 1697 | { |
1710 | return malloc( size ); | 1698 | return malloc( size ); |
1711 | } | 1699 | } |
1712 | 1700 | ||
1713 | void operator delete[]( void* p ) | 1701 | void operator delete[]( void* p ) |
1714 | { | 1702 | { |
1715 | free( p ); | 1703 | free( p ); |
1716 | } | 1704 | } |
1717 | 1705 | ||
1718 | void operator delete[]( void* p, size_t /*size*/ ) | 1706 | void operator delete[]( void* p, size_t /*size*/ ) |
1719 | { | 1707 | { |
1720 | free( p ); | 1708 | free( p ); |
1721 | } | 1709 | } |
1722 | 1710 | ||
1723 | void operator delete( void* p ) | 1711 | void operator delete( void* p ) |
1724 | { | 1712 | { |
1725 | free( p ); | 1713 | free( p ); |
1726 | } | 1714 | } |
1727 | 1715 | ||
1728 | void operator delete( void* p, size_t /*size*/ ) | 1716 | void operator delete( void* p, size_t /*size*/ ) |
1729 | { | 1717 | { |
1730 | free( p ); | 1718 | free( p ); |
1731 | } | 1719 | } |
1732 | 1720 | ||
1733 | #endif | 1721 | #endif |
1734 | 1722 | ||
1735 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1723 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1736 | #include <qwidgetlist.h> | 1724 | #include <qwidgetlist.h> |
1737 | #ifdef QWS | 1725 | #ifdef QWS |
1738 | #include <qgfx_qws.h> | 1726 | #include <qgfx_qws.h> |
1739 | extern QRect qt_maxWindowRect; | 1727 | extern QRect qt_maxWindowRect; |
1740 | void qt_setMaxWindowRect(const QRect& r ) | 1728 | void qt_setMaxWindowRect(const QRect& r ) |
1741 | { | 1729 | { |
1742 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1730 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1743 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1731 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
1744 | // Re-resize any maximized windows | 1732 | // Re-resize any maximized windows |
1745 | QWidgetList* l = QApplication::topLevelWidgets(); | 1733 | QWidgetList* l = QApplication::topLevelWidgets(); |
1746 | if ( l ) { | 1734 | if ( l ) { |
1747 | QWidget * w = l->first(); | 1735 | QWidget * w = l->first(); |
1748 | while ( w ) { | 1736 | while ( w ) { |
1749 | if ( w->isVisible() && w->isMaximized() ) { | 1737 | if ( w->isVisible() && w->isMaximized() ) { |
1750 | w->showMaximized(); | 1738 | w->showMaximized(); |
1751 | } | 1739 | } |
1752 | w = l->next(); | 1740 | w = l->next(); |
1753 | } | 1741 | } |
1754 | delete l; | 1742 | delete l; |
1755 | } | 1743 | } |
1756 | } | 1744 | } |
1757 | #endif | 1745 | #endif |
1758 | #endif | 1746 | #endif |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 2515f1b..86affa6 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -1,156 +1,158 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
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 | 23 | ||
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 26 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
27 | #define Q_WS_QWS | 27 | #define Q_WS_QWS |
28 | #endif | 28 | #endif |
29 | #include "qpedecoration_qws.h" | 29 | #include "qpedecoration_qws.h" |
30 | #include "timestring.h" | 30 | #include "timestring.h" |
31 | 31 | ||
32 | class QCopChannel; | 32 | class QCopChannel; |
33 | class QPEApplicationData; | 33 | class QPEApplicationData; |
34 | class QWSEvent; | 34 | class QWSEvent; |
35 | class QWSKeyEvent; | 35 | class QWSKeyEvent; |
36 | 36 | ||
37 | class QPEApplication : public QApplication | 37 | class QPEApplication : public QApplication |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 41 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
42 | ~QPEApplication(); | 42 | ~QPEApplication(); |
43 | 43 | ||
44 | static QString qpeDir(); | 44 | static QString qpeDir(); |
45 | static QString documentDir(); | 45 | static QString documentDir(); |
46 | void applyStyle(); | 46 | void applyStyle(); |
47 | static int defaultRotation(); | 47 | static int defaultRotation(); |
48 | static void setDefaultRotation(int r); | 48 | static void setDefaultRotation(int r); |
49 | static void grabKeyboard(); | 49 | static void grabKeyboard(); |
50 | static void ungrabKeyboard(); | 50 | static void ungrabKeyboard(); |
51 | 51 | ||
52 | enum StylusMode { | 52 | enum StylusMode { |
53 | LeftOnly, | 53 | LeftOnly, |
54 | RightOnHold | 54 | RightOnHold |
55 | // RightOnHoldLeftDelayed, etc. | 55 | // RightOnHoldLeftDelayed, etc. |
56 | }; | 56 | }; |
57 | static void setStylusOperation( QWidget*, StylusMode ); | 57 | static void setStylusOperation( QWidget*, StylusMode ); |
58 | static StylusMode stylusOperation( QWidget* ); | 58 | static StylusMode stylusOperation( QWidget* ); |
59 | 59 | ||
60 | enum InputMethodHint { | 60 | enum InputMethodHint { |
61 | Normal, | 61 | Normal, |
62 | AlwaysOff, | 62 | AlwaysOff, |
63 | AlwaysOn | 63 | AlwaysOn |
64 | }; | 64 | }; |
65 | 65 | ||
66 | enum screenSaverHint { | 66 | enum screenSaverHint { |
67 | Disable = 0, | 67 | Disable = 0, |
68 | DisableLightOff = 1, | 68 | DisableLightOff = 1, |
69 | DisableSuspend = 2, | 69 | DisableSuspend = 2, |
70 | Enable = 100 | 70 | Enable = 100 |
71 | }; | 71 | }; |
72 | 72 | ||
73 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 73 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
74 | static InputMethodHint inputMethodHint( QWidget * ); | 74 | static InputMethodHint inputMethodHint( QWidget * ); |
75 | 75 | ||
76 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 76 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
77 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 77 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
78 | static void showDialog( QDialog*, bool nomax=FALSE ); | 78 | static void showDialog( QDialog*, bool nomax=FALSE ); |
79 | static int execDialog( QDialog*, bool nomax=FALSE ); | 79 | static int execDialog( QDialog*, bool nomax=FALSE ); |
80 | 80 | ||
81 | static void setKeepRunning(); | 81 | static void setKeepRunning(); |
82 | bool keepRunning() const; | 82 | bool keepRunning() const; |
83 | 83 | ||
84 | bool keyboardGrabbed() const; | 84 | bool keyboardGrabbed() const; |
85 | 85 | ||
86 | int exec(); | 86 | int exec(); |
87 | 87 | ||
88 | signals: | 88 | signals: |
89 | void clientMoused(); | 89 | void clientMoused(); |
90 | void timeChanged(); | 90 | void timeChanged(); |
91 | void clockChanged( bool pm ); | 91 | void clockChanged( bool pm ); |
92 | void micChanged( bool muted ); | 92 | void micChanged( bool muted ); |
93 | void volumeChanged( bool muted ); | 93 | void volumeChanged( bool muted ); |
94 | void appMessage( const QCString& msg, const QByteArray& data); | 94 | void appMessage( const QCString& msg, const QByteArray& data); |
95 | void weekChanged( bool startOnMonday ); | 95 | void weekChanged( bool startOnMonday ); |
96 | void dateFormatChanged( DateFormat ); | 96 | void dateFormatChanged( DateFormat ); |
97 | void flush(); | 97 | void flush(); |
98 | void reload(); | 98 | void reload(); |
99 | 99 | ||
100 | private slots: | 100 | private slots: |
101 | void systemMessage( const QCString &msg, const QByteArray &data ); | 101 | void systemMessage( const QCString &msg, const QByteArray &data ); |
102 | void pidMessage( const QCString &msg, const QByteArray &data ); | 102 | void pidMessage( const QCString &msg, const QByteArray &data ); |
103 | void removeSenderFromStylusDict(); | 103 | void removeSenderFromStylusDict(); |
104 | void hideOrQuit(); | 104 | void hideOrQuit(); |
105 | 105 | ||
106 | protected: | 106 | protected: |
107 | bool qwsEventFilter( QWSEvent * ); | 107 | bool qwsEventFilter( QWSEvent * ); |
108 | void internalSetStyle( const QString &style ); | 108 | void internalSetStyle( const QString &style ); |
109 | void prepareForTermination(bool willrestart); | 109 | void prepareForTermination(bool willrestart); |
110 | virtual void restart(); | 110 | virtual void restart(); |
111 | virtual void shutdown(); | 111 | virtual void shutdown(); |
112 | bool eventFilter( QObject *, QEvent * ); | 112 | bool eventFilter( QObject *, QEvent * ); |
113 | void timerEvent( QTimerEvent * ); | 113 | void timerEvent( QTimerEvent * ); |
114 | bool raiseAppropriateWindow(); | 114 | bool raiseAppropriateWindow(); |
115 | virtual void tryQuit(); | 115 | virtual void tryQuit(); |
116 | 116 | ||
117 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) | ||
118 | |||
117 | private: | 119 | private: |
118 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 120 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
119 | 121 | ||
120 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 122 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
121 | QCopChannel *sysChannel; | 123 | QCopChannel *sysChannel; |
122 | QCopChannel *pidChannel; | 124 | QCopChannel *pidChannel; |
123 | #endif | 125 | #endif |
124 | QPEApplicationData *d; | 126 | QPEApplicationData *d; |
125 | 127 | ||
126 | bool reserved_sh; | 128 | bool reserved_sh; |
127 | 129 | ||
128 | 130 | ||
129 | 131 | ||
130 | }; | 132 | }; |
131 | 133 | ||
132 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) | 134 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) |
133 | { | 135 | { |
134 | QSize sh = d->sizeHint(); | 136 | QSize sh = d->sizeHint(); |
135 | int w = QMAX(sh.width(),d->width()); | 137 | int w = QMAX(sh.width(),d->width()); |
136 | int h = QMAX(sh.height(),d->height()); | 138 | int h = QMAX(sh.height(),d->height()); |
137 | if ( !nomax | 139 | if ( !nomax |
138 | && ( w > qApp->desktop()->width()*3/4 | 140 | && ( w > qApp->desktop()->width()*3/4 |
139 | || h > qApp->desktop()->height()*3/4 ) ) | 141 | || h > qApp->desktop()->height()*3/4 ) ) |
140 | { | 142 | { |
141 | d->showMaximized(); | 143 | d->showMaximized(); |
142 | } else { | 144 | } else { |
143 | d->resize(w,h); | 145 | d->resize(w,h); |
144 | d->show(); | 146 | d->show(); |
145 | } | 147 | } |
146 | } | 148 | } |
147 | 149 | ||
148 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) | 150 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) |
149 | { | 151 | { |
150 | showDialog(d,nomax); | 152 | showDialog(d,nomax); |
151 | return d->exec(); | 153 | return d->exec(); |
152 | } | 154 | } |
153 | 155 | ||
154 | 156 | ||
155 | #endif | 157 | #endif |
156 | 158 | ||
diff --git a/library/qt_override.cpp b/library/qt_override.cpp new file mode 100644 index 0000000..0d783bd --- a/dev/null +++ b/library/qt_override.cpp | |||
@@ -0,0 +1,166 @@ | |||
1 | |||
2 | #include <qpe/qpeapplication.h> | ||
3 | #include <qwsdecoration_qws.h> | ||
4 | #include <qcommonstyle.h> | ||
5 | #include <qfontdatabase.h> | ||
6 | |||
7 | #include <unistd.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <stdio.h> | ||
10 | |||
11 | #include "qt_override_p.h" | ||
12 | |||
13 | |||
14 | |||
15 | struct color_fix_t { | ||
16 | char *m_app; | ||
17 | char *m_class; | ||
18 | char *m_name; | ||
19 | QColorGroup::ColorRole m_set; | ||
20 | QColorGroup::ColorRole m_get; | ||
21 | }; | ||
22 | |||
23 | |||
24 | |||
25 | static const color_fix_t apps_that_need_special_colors [] = { | ||
26 | { "HancomMobileWord", "HTextEdit", 0, QColorGroup::Background, QColorGroup::Base }, | ||
27 | { "neocal", "Display", 0, QColorGroup::Background, QColorGroup::Base }, | ||
28 | |||
29 | { 0, 0, 0, QColorGroup::Base, QColorGroup::Base } | ||
30 | }; | ||
31 | |||
32 | static const char * const apps_that_need_pointsizes_times_10 [] = { | ||
33 | "HancomMobileWord", | ||
34 | |||
35 | 0 | ||
36 | }; | ||
37 | |||
38 | |||
39 | |||
40 | |||
41 | int Opie::force_appearance = 0; | ||
42 | |||
43 | |||
44 | // Return the *real* name of the binary - not just a quick guess | ||
45 | // by looking at argv [0] (which could be anything) | ||
46 | |||
47 | static void binaryNameFree ( ) | ||
48 | { | ||
49 | ::free ((void *) Opie::binaryName ( )); // we need to cast away the const here | ||
50 | } | ||
51 | |||
52 | const char *Opie::binaryName ( ) | ||
53 | { | ||
54 | static const char *appname = 0; | ||
55 | |||
56 | if ( !appname ) { | ||
57 | char dst [PATH_MAX + 1]; | ||
58 | int l = ::readlink ( "/proc/self/exe", dst, PATH_MAX ); | ||
59 | |||
60 | if ( l <= 0 ) | ||
61 | l = 0; | ||
62 | |||
63 | dst [l] = 0; | ||
64 | const char *b = ::strrchr ( dst, '/' ); | ||
65 | appname = ::strdup ( b ? b + 1 : dst ); | ||
66 | |||
67 | ::atexit ( binaryNameFree ); | ||
68 | } | ||
69 | return appname; | ||
70 | } | ||
71 | |||
72 | |||
73 | // Fix for a toolchain incompatibility (binaries compiled with | ||
74 | // old tcs using shared libs compiled with newer tcs) | ||
75 | |||
76 | extern "C" { | ||
77 | |||
78 | extern void __gmon_start__ ( ) __attribute__(( weak )); | ||
79 | |||
80 | extern void __gmon_start__ ( ) | ||
81 | { | ||
82 | } | ||
83 | |||
84 | } | ||
85 | |||
86 | |||
87 | // Fix for apps, that use QPainter::eraseRect() which doesn't work with styles | ||
88 | // that set a background pixmap (it would be easier to fix eraseRect(), but | ||
89 | // TT made it an inline ...) | ||
90 | |||
91 | void QPEApplication::polish ( QWidget *w ) | ||
92 | { | ||
93 | qDebug ( "QPEApplication::polish()" ); | ||
94 | |||
95 | for ( const color_fix_t *ptr = apps_that_need_special_colors; ptr-> m_app; ptr++ ) { | ||
96 | if (( ::strcmp ( Opie::binaryName ( ), ptr-> m_app ) == 0 ) && | ||
97 | ( ptr-> m_class ? w-> inherits ( ptr-> m_class ) : true ) && | ||
98 | ( ptr-> m_name ? ( ::strcmp ( w-> name ( ), ptr-> m_name ) == 0 ) : true )) { | ||
99 | QPalette pal = w-> palette ( ); | ||
100 | pal. setColor ( ptr-> m_set, pal. color ( QPalette::Active, ptr-> m_get )); | ||
101 | w-> setPalette ( pal ); | ||
102 | } | ||
103 | } | ||
104 | QApplication::polish ( w ); | ||
105 | } | ||
106 | |||
107 | |||
108 | // Fix for the binary incompatibility that TT introduced in Qt/E 2.3.4 -- point sizes | ||
109 | // were multiplied by 10 (which was incorrect) | ||
110 | |||
111 | QValueList <int> QFontDatabase::pointSizes ( QString const &family, QString const &style, QString const &charset ) | ||
112 | { | ||
113 | qDebug ( "QFontDatabase::pointSizes()" ); | ||
114 | |||
115 | QValueList <int> sl = pointSizes_NonWeak ( family, style, charset ); | ||
116 | |||
117 | for ( const char * const *ptr = apps_that_need_pointsizes_times_10; *ptr; ptr++ ) { | ||
118 | if ( ::strcmp ( Opie::binaryName ( ), *ptr ) == 0 ) { | ||
119 | for ( QValueList <int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | ||
120 | *it *= 10; | ||
121 | } | ||
122 | } | ||
123 | return sl; | ||
124 | } | ||
125 | |||
126 | |||
127 | // Various style/font/color related overrides for weak symbols in Qt/E, | ||
128 | // which allows us to force the usage of the global Opie appearance. | ||
129 | |||
130 | void QApplication::setStyle ( QStyle *style ) | ||
131 | { | ||
132 | qDebug ( "QApplication::setStyle()" ); | ||
133 | |||
134 | if ( Opie::force_appearance & Opie::Force_Style ) | ||
135 | delete style; | ||
136 | else | ||
137 | QApplication::setStyle_NonWeak ( style ); | ||
138 | } | ||
139 | |||
140 | void QApplication::setPalette ( const QPalette &pal, bool informWidgets, const char *className ) | ||
141 | { | ||
142 | qDebug ( "QApplication::setPalette()" ); | ||
143 | |||
144 | if (!( Opie::force_appearance & Opie::Force_Style )) | ||
145 | QApplication::setPalette_NonWeak ( pal, informWidgets, className ); | ||
146 | } | ||
147 | |||
148 | void QApplication::setFont ( const QFont &fnt, bool informWidgets, const char *className ) | ||
149 | { | ||
150 | qDebug ( "QApplication::setFont()" ); | ||
151 | |||
152 | if (!( Opie::force_appearance & Opie::Force_Font )) | ||
153 | QApplication::setFont_NonWeak ( fnt, informWidgets, className ); | ||
154 | } | ||
155 | |||
156 | |||
157 | void QApplication::qwsSetDecoration ( QWSDecoration *deco ) | ||
158 | { | ||
159 | qDebug ( "QApplication::qwsSetDecoration()" ); | ||
160 | |||
161 | if ( Opie::force_appearance & Opie::Force_Decoration ) | ||
162 | delete deco; | ||
163 | else | ||
164 | QApplication::qwsSetDecoration_NonWeak ( deco ); | ||
165 | } | ||
166 | |||
diff --git a/library/qt_override_p.h b/library/qt_override_p.h new file mode 100644 index 0000000..d11917c --- a/dev/null +++ b/library/qt_override_p.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef __QT_OVERRIDE_H__ | ||
2 | #define __QT_OVERRIDE_H__ | ||
3 | |||
4 | namespace Opie { | ||
5 | |||
6 | enum ForceAppearance { | ||
7 | Force_Style = 0x01, | ||
8 | Force_Font = 0x02, | ||
9 | Force_Decoration = 0x04, | ||
10 | |||
11 | Force_All = 0xff, | ||
12 | Force_None = 0x00, | ||
13 | }; | ||
14 | |||
15 | extern const char *binaryName ( ); | ||
16 | |||
17 | extern int force_appearance; | ||
18 | |||
19 | } | ||
20 | |||
21 | #endif | ||