-rw-r--r-- | core/launcher/launcher.cpp | 1 | ||||
-rw-r--r-- | core/launcher/launcher.h | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 222592b..b26bd8b 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -334,384 +334,385 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | |||
334 | { | 334 | { |
335 | #if QT_VERSION >= 300 | 335 | #if QT_VERSION >= 300 |
336 | QStyle::SFlags flags = QStyle::Style_Default; | 336 | QStyle::SFlags flags = QStyle::Style_Default; |
337 | if ( selected ) | 337 | if ( selected ) |
338 | flags |= QStyle::Style_Selected; | 338 | flags |= QStyle::Style_Selected; |
339 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 339 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
340 | colorGroup(), flags, QStyleOption(t) ); | 340 | colorGroup(), flags, QStyleOption(t) ); |
341 | #else | 341 | #else |
342 | style().drawTab( p, this, t, selected ); | 342 | style().drawTab( p, this, t, selected ); |
343 | #endif | 343 | #endif |
344 | 344 | ||
345 | QRect r( t->rect() ); | 345 | QRect r( t->rect() ); |
346 | QFont f( font() ); | 346 | QFont f( font() ); |
347 | if ( selected ) | 347 | if ( selected ) |
348 | f.setBold( TRUE ); | 348 | f.setBold( TRUE ); |
349 | p->setFont( f ); | 349 | p->setFont( f ); |
350 | 350 | ||
351 | int iw = 0; | 351 | int iw = 0; |
352 | int ih = 0; | 352 | int ih = 0; |
353 | if ( t->iconSet() != 0 ) { | 353 | if ( t->iconSet() != 0 ) { |
354 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 354 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
355 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 355 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
356 | } | 356 | } |
357 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 357 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
358 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 358 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
359 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 359 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
360 | r.top() + (r.height()-h)/2, w, h ), t, | 360 | r.top() + (r.height()-h)/2, w, h ), t, |
361 | #if QT_VERSION >= 300 | 361 | #if QT_VERSION >= 300 |
362 | t->identifier() == keyboardFocusTab() | 362 | t->identifier() == keyboardFocusTab() |
363 | #else | 363 | #else |
364 | t->identitifer() == keyboardFocusTab() | 364 | t->identitifer() == keyboardFocusTab() |
365 | #endif | 365 | #endif |
366 | ); | 366 | ); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 370 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
371 | QTab* t, bool has_focus ) const | 371 | QTab* t, bool has_focus ) const |
372 | { | 372 | { |
373 | QRect r = t->rect(); | 373 | QRect r = t->rect(); |
374 | // if ( t->id != currentTab() ) | 374 | // if ( t->id != currentTab() ) |
375 | //r.moveBy( 1, 1 ); | 375 | //r.moveBy( 1, 1 ); |
376 | // | 376 | // |
377 | if ( t->iconSet() ) { | 377 | if ( t->iconSet() ) { |
378 | // the tab has an iconset, draw it in the right mode | 378 | // the tab has an iconset, draw it in the right mode |
379 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 379 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
380 | if ( mode == QIconSet::Normal && has_focus ) | 380 | if ( mode == QIconSet::Normal && has_focus ) |
381 | mode = QIconSet::Active; | 381 | mode = QIconSet::Active; |
382 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 382 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
383 | int pixw = pixmap.width(); | 383 | int pixw = pixmap.width(); |
384 | int pixh = pixmap.height(); | 384 | int pixh = pixmap.height(); |
385 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 385 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
386 | r.setLeft( r.left() + pixw + 5 ); | 386 | r.setLeft( r.left() + pixw + 5 ); |
387 | } | 387 | } |
388 | 388 | ||
389 | QRect tr = r; | 389 | QRect tr = r; |
390 | 390 | ||
391 | if ( r.width() < 20 ) | 391 | if ( r.width() < 20 ) |
392 | return; | 392 | return; |
393 | 393 | ||
394 | if ( t->isEnabled() && isEnabled() ) { | 394 | if ( t->isEnabled() && isEnabled() ) { |
395 | #if defined(_WS_WIN32_) | 395 | #if defined(_WS_WIN32_) |
396 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 396 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
397 | p->setPen( colorGroup().buttonText() ); | 397 | p->setPen( colorGroup().buttonText() ); |
398 | else | 398 | else |
399 | p->setPen( colorGroup().foreground() ); | 399 | p->setPen( colorGroup().foreground() ); |
400 | #else | 400 | #else |
401 | p->setPen( colorGroup().foreground() ); | 401 | p->setPen( colorGroup().foreground() ); |
402 | #endif | 402 | #endif |
403 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 403 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
404 | } else { | 404 | } else { |
405 | p->setPen( palette().disabled().foreground() ); | 405 | p->setPen( palette().disabled().foreground() ); |
406 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 406 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | //--------------------------------------------------------------------------- | 410 | //--------------------------------------------------------------------------- |
411 | 411 | ||
412 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 412 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
413 | : QMainWindow( parent, name, fl ) | 413 | : QMainWindow( parent, name, fl ) |
414 | { | 414 | { |
415 | setCaption( tr("Launcher") ); | 415 | setCaption( tr("Launcher") ); |
416 | 416 | ||
417 | syncDialog = 0; | 417 | syncDialog = 0; |
418 | 418 | ||
419 | // we have a pretty good idea how big we'll be | 419 | // we have a pretty good idea how big we'll be |
420 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 420 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
421 | 421 | ||
422 | tabs = 0; | 422 | tabs = 0; |
423 | rootFolder = 0; | 423 | rootFolder = 0; |
424 | docsFolder = 0; | 424 | docsFolder = 0; |
425 | m_timeStamp = QDateTime::currentDateTime().toString(); | 425 | m_timeStamp = QDateTime::currentDateTime().toString(); |
426 | 426 | ||
427 | tabs = new CategoryTabWidget( this ); | 427 | tabs = new CategoryTabWidget( this ); |
428 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 428 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
429 | setCentralWidget( tabs ); | 429 | setCentralWidget( tabs ); |
430 | 430 | ||
431 | connect( tabs, SIGNAL(selected(const QString&)), | 431 | connect( tabs, SIGNAL(selected(const QString&)), |
432 | this, SLOT(viewSelected(const QString&)) ); | 432 | this, SLOT(viewSelected(const QString&)) ); |
433 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 433 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
434 | this, SLOT(select(const AppLnk*))); | 434 | this, SLOT(select(const AppLnk*))); |
435 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 435 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
436 | this, SLOT(properties(AppLnk*))); | 436 | this, SLOT(properties(AppLnk*))); |
437 | 437 | ||
438 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 438 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
439 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 439 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
440 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 440 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
441 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 441 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
442 | #endif | 442 | #endif |
443 | 443 | ||
444 | storage = new StorageInfo( this ); | 444 | storage = new StorageInfo( this ); |
445 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 445 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
446 | 446 | ||
447 | updateTabs(); | 447 | updateTabs(); |
448 | 448 | ||
449 | preloadApps(); | 449 | preloadApps(); |
450 | 450 | ||
451 | in_lnk_props = FALSE; | 451 | in_lnk_props = FALSE; |
452 | got_lnk_change = FALSE; | 452 | got_lnk_change = FALSE; |
453 | } | 453 | } |
454 | 454 | ||
455 | Launcher::~Launcher() | 455 | Launcher::~Launcher() |
456 | { | 456 | { |
457 | } | 457 | } |
458 | 458 | ||
459 | static bool isVisibleWindow(int wid) | 459 | static bool isVisibleWindow(int wid) |
460 | { | 460 | { |
461 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 461 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
462 | QWSWindow* w; | 462 | QWSWindow* w; |
463 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 463 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
464 | if ( w->winId() == wid ) | 464 | if ( w->winId() == wid ) |
465 | return !w->isFullyObscured(); | 465 | return !w->isFullyObscured(); |
466 | } | 466 | } |
467 | return FALSE; | 467 | return FALSE; |
468 | } | 468 | } |
469 | 469 | ||
470 | void Launcher::showMaximized() | 470 | void Launcher::showMaximized() |
471 | { | 471 | { |
472 | if ( isVisibleWindow( winId() ) ) | 472 | if ( isVisibleWindow( winId() ) ) |
473 | doMaximize(); | 473 | doMaximize(); |
474 | else | 474 | else |
475 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 475 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
476 | } | 476 | } |
477 | 477 | ||
478 | void Launcher::doMaximize() | 478 | void Launcher::doMaximize() |
479 | { | 479 | { |
480 | QMainWindow::showMaximized(); | 480 | QMainWindow::showMaximized(); |
481 | } | 481 | } |
482 | 482 | ||
483 | void Launcher::updateMimeTypes() | 483 | void Launcher::updateMimeTypes() |
484 | { | 484 | { |
485 | MimeType::clear(); | 485 | MimeType::clear(); |
486 | updateMimeTypes(rootFolder); | 486 | updateMimeTypes(rootFolder); |
487 | } | 487 | } |
488 | 488 | ||
489 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 489 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
490 | { | 490 | { |
491 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 491 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
492 | AppLnk *app = it.current(); | 492 | AppLnk *app = it.current(); |
493 | if ( app->type() == "Folder" ) | 493 | if ( app->type() == "Folder" ) |
494 | updateMimeTypes((AppLnkSet *)app); | 494 | updateMimeTypes((AppLnkSet *)app); |
495 | else { | 495 | else { |
496 | MimeType::registerApp(*app); | 496 | MimeType::registerApp(*app); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 501 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
502 | { | 502 | { |
503 | delete docsFolder; | 503 | delete docsFolder; |
504 | docsFolder = new DocLnkSet; | 504 | docsFolder = new DocLnkSet; |
505 | // find out wich filesystems are new in this round | 505 | // find out wich filesystems are new in this round |
506 | // We will do this by having a timestamp inside each mountpoint | 506 | // We will do this by having a timestamp inside each mountpoint |
507 | // if the current timestamp doesn't match this is a new file system and | 507 | // if the current timestamp doesn't match this is a new file system and |
508 | // come up with our MediumMountGui :) let the hacking begin | 508 | // come up with our MediumMountGui :) let the hacking begin |
509 | QString newStamp = QDateTime::currentDateTime().toString(); | 509 | QString newStamp = QDateTime::currentDateTime().toString(); |
510 | StorageInfo storage; | 510 | StorageInfo storage; |
511 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 511 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
512 | QListIterator<FileSystem> it ( fileSystems ); | 512 | QListIterator<FileSystem> it ( fileSystems ); |
513 | for ( ; it.current(); ++it ) { | 513 | for ( ; it.current(); ++it ) { |
514 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 514 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
515 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); | 515 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); |
516 | cfg.setGroup("main"); | 516 | cfg.setGroup("main"); |
517 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 517 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
518 | if( stamp == m_timeStamp ){ // ok we know this card | 518 | if( stamp == m_timeStamp ){ // ok we know this card |
519 | cfg.writeEntry("timestamp", newStamp ); | 519 | cfg.writeEntry("timestamp", newStamp ); |
520 | // we need to scan the list now. Hopefully the cache will be there | 520 | // we need to scan the list now. Hopefully the cache will be there |
521 | }else{ // come up with the gui | 521 | }else{ // come up with the gui |
522 | MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); | 522 | MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); |
523 | if( medium.check() ){ | 523 | if( medium.check() ){ |
524 | if( medium.exec() ){ //ok | 524 | if( medium.exec() ){ //ok |
525 | // speicher | 525 | // speicher |
526 | cfg.writeEntry("timestamp", newStamp ); | ||
526 | } | 527 | } |
527 | }else{ | 528 | }else{ |
528 | // do something different see what we need to do | 529 | // do something different see what we need to do |
529 | } | 530 | } |
530 | } | 531 | } |
531 | } | 532 | } |
532 | } | 533 | } |
533 | Global::findDocuments(docsFolder); // get rid of this call later | 534 | Global::findDocuments(docsFolder); // get rid of this call later |
534 | m_timeStamp = newStamp; | 535 | m_timeStamp = newStamp; |
535 | } | 536 | } |
536 | 537 | ||
537 | void Launcher::updateTabs() | 538 | void Launcher::updateTabs() |
538 | { | 539 | { |
539 | MimeType::updateApplications(); // ### reads all applnks twice | 540 | MimeType::updateApplications(); // ### reads all applnks twice |
540 | 541 | ||
541 | delete rootFolder; | 542 | delete rootFolder; |
542 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 543 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
543 | 544 | ||
544 | loadDocs(); | 545 | loadDocs(); |
545 | 546 | ||
546 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 547 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
547 | } | 548 | } |
548 | 549 | ||
549 | void Launcher::updateDocs() | 550 | void Launcher::updateDocs() |
550 | { | 551 | { |
551 | loadDocs(); | 552 | loadDocs(); |
552 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 553 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
553 | } | 554 | } |
554 | 555 | ||
555 | void Launcher::viewSelected(const QString& s) | 556 | void Launcher::viewSelected(const QString& s) |
556 | { | 557 | { |
557 | setCaption( s + tr(" - Launcher") ); | 558 | setCaption( s + tr(" - Launcher") ); |
558 | } | 559 | } |
559 | 560 | ||
560 | void Launcher::nextView() | 561 | void Launcher::nextView() |
561 | { | 562 | { |
562 | tabs->nextTab(); | 563 | tabs->nextTab(); |
563 | } | 564 | } |
564 | 565 | ||
565 | 566 | ||
566 | void Launcher::select( const AppLnk *appLnk ) | 567 | void Launcher::select( const AppLnk *appLnk ) |
567 | { | 568 | { |
568 | if ( appLnk->type() == "Folder" ) { | 569 | if ( appLnk->type() == "Folder" ) { |
569 | // Not supported: flat is simpler for the user | 570 | // Not supported: flat is simpler for the user |
570 | } else { | 571 | } else { |
571 | if ( appLnk->exec().isNull() ) { | 572 | if ( appLnk->exec().isNull() ) { |
572 | QMessageBox::information(this,tr("No application"), | 573 | QMessageBox::information(this,tr("No application"), |
573 | tr("<p>No application is defined for this document." | 574 | tr("<p>No application is defined for this document." |
574 | "<p>Type is %1.").arg(appLnk->type())); | 575 | "<p>Type is %1.").arg(appLnk->type())); |
575 | return; | 576 | return; |
576 | } | 577 | } |
577 | tabs->setBusy(TRUE); | 578 | tabs->setBusy(TRUE); |
578 | emit executing( appLnk ); | 579 | emit executing( appLnk ); |
579 | appLnk->execute(); | 580 | appLnk->execute(); |
580 | } | 581 | } |
581 | } | 582 | } |
582 | 583 | ||
583 | void Launcher::externalSelected(const AppLnk *appLnk) | 584 | void Launcher::externalSelected(const AppLnk *appLnk) |
584 | { | 585 | { |
585 | tabs->setBusy(TRUE); | 586 | tabs->setBusy(TRUE); |
586 | emit executing( appLnk ); | 587 | emit executing( appLnk ); |
587 | } | 588 | } |
588 | 589 | ||
589 | void Launcher::properties( AppLnk *appLnk ) | 590 | void Launcher::properties( AppLnk *appLnk ) |
590 | { | 591 | { |
591 | if ( appLnk->type() == "Folder" ) { | 592 | if ( appLnk->type() == "Folder" ) { |
592 | // Not supported: flat is simpler for the user | 593 | // Not supported: flat is simpler for the user |
593 | } else { | 594 | } else { |
594 | in_lnk_props = TRUE; | 595 | in_lnk_props = TRUE; |
595 | got_lnk_change = FALSE; | 596 | got_lnk_change = FALSE; |
596 | LnkProperties prop(appLnk); | 597 | LnkProperties prop(appLnk); |
597 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 598 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
598 | prop.showMaximized(); | 599 | prop.showMaximized(); |
599 | prop.exec(); | 600 | prop.exec(); |
600 | in_lnk_props = FALSE; | 601 | in_lnk_props = FALSE; |
601 | if ( got_lnk_change ) { | 602 | if ( got_lnk_change ) { |
602 | updateLink(lnk_change); | 603 | updateLink(lnk_change); |
603 | } | 604 | } |
604 | } | 605 | } |
605 | } | 606 | } |
606 | 607 | ||
607 | void Launcher::updateLink(const QString& link) | 608 | void Launcher::updateLink(const QString& link) |
608 | { | 609 | { |
609 | if (link.isNull()) | 610 | if (link.isNull()) |
610 | updateTabs(); | 611 | updateTabs(); |
611 | else if (link.isEmpty()) | 612 | else if (link.isEmpty()) |
612 | updateDocs(); | 613 | updateDocs(); |
613 | else | 614 | else |
614 | tabs->updateLink(link); | 615 | tabs->updateLink(link); |
615 | } | 616 | } |
616 | 617 | ||
617 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 618 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
618 | { | 619 | { |
619 | QDataStream stream( data, IO_ReadOnly ); | 620 | QDataStream stream( data, IO_ReadOnly ); |
620 | if ( msg == "linkChanged(QString)" ) { | 621 | if ( msg == "linkChanged(QString)" ) { |
621 | QString link; | 622 | QString link; |
622 | stream >> link; | 623 | stream >> link; |
623 | if ( in_lnk_props ) { | 624 | if ( in_lnk_props ) { |
624 | got_lnk_change = TRUE; | 625 | got_lnk_change = TRUE; |
625 | lnk_change = link; | 626 | lnk_change = link; |
626 | } else { | 627 | } else { |
627 | updateLink(link); | 628 | updateLink(link); |
628 | } | 629 | } |
629 | } else if ( msg == "busy()" ) { | 630 | } else if ( msg == "busy()" ) { |
630 | emit busy(); | 631 | emit busy(); |
631 | } else if ( msg == "notBusy(QString)" ) { | 632 | } else if ( msg == "notBusy(QString)" ) { |
632 | QString app; | 633 | QString app; |
633 | stream >> app; | 634 | stream >> app; |
634 | tabs->setBusy(FALSE); | 635 | tabs->setBusy(FALSE); |
635 | emit notBusy(app); | 636 | emit notBusy(app); |
636 | } else if ( msg == "mkdir(QString)" ) { | 637 | } else if ( msg == "mkdir(QString)" ) { |
637 | QString dir; | 638 | QString dir; |
638 | stream >> dir; | 639 | stream >> dir; |
639 | if ( !dir.isEmpty() ) | 640 | if ( !dir.isEmpty() ) |
640 | mkdir( dir ); | 641 | mkdir( dir ); |
641 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 642 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
642 | QString baseFile, sigFile; | 643 | QString baseFile, sigFile; |
643 | stream >> baseFile >> sigFile; | 644 | stream >> baseFile >> sigFile; |
644 | QRsync::generateSignature( baseFile, sigFile ); | 645 | QRsync::generateSignature( baseFile, sigFile ); |
645 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 646 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
646 | QString baseFile, sigFile, deltaFile; | 647 | QString baseFile, sigFile, deltaFile; |
647 | stream >> baseFile >> sigFile >> deltaFile; | 648 | stream >> baseFile >> sigFile >> deltaFile; |
648 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 649 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
649 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 650 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
650 | QString baseFile, deltaFile; | 651 | QString baseFile, deltaFile; |
651 | stream >> baseFile >> deltaFile; | 652 | stream >> baseFile >> deltaFile; |
652 | if ( !QFile::exists( baseFile ) ) { | 653 | if ( !QFile::exists( baseFile ) ) { |
653 | QFile f( baseFile ); | 654 | QFile f( baseFile ); |
654 | f.open( IO_WriteOnly ); | 655 | f.open( IO_WriteOnly ); |
655 | f.close(); | 656 | f.close(); |
656 | } | 657 | } |
657 | QRsync::applyDiff( baseFile, deltaFile ); | 658 | QRsync::applyDiff( baseFile, deltaFile ); |
658 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 659 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
659 | e << baseFile; | 660 | e << baseFile; |
660 | } else if ( msg == "rdiffCleanup()" ) { | 661 | } else if ( msg == "rdiffCleanup()" ) { |
661 | mkdir( "/tmp/rdiff" ); | 662 | mkdir( "/tmp/rdiff" ); |
662 | QDir dir; | 663 | QDir dir; |
663 | dir.setPath( "/tmp/rdiff" ); | 664 | dir.setPath( "/tmp/rdiff" ); |
664 | QStringList entries = dir.entryList(); | 665 | QStringList entries = dir.entryList(); |
665 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 666 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
666 | dir.remove( *it ); | 667 | dir.remove( *it ); |
667 | } else if ( msg == "sendHandshakeInfo()" ) { | 668 | } else if ( msg == "sendHandshakeInfo()" ) { |
668 | QString home = getenv( "HOME" ); | 669 | QString home = getenv( "HOME" ); |
669 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 670 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
670 | e << home; | 671 | e << home; |
671 | int locked = (int) Desktop::screenLocked(); | 672 | int locked = (int) Desktop::screenLocked(); |
672 | e << locked; | 673 | e << locked; |
673 | // register an app for autostart | 674 | // register an app for autostart |
674 | // if clear is send the list is cleared. | 675 | // if clear is send the list is cleared. |
675 | } else if ( msg == "autoStart(QString)" ) { | 676 | } else if ( msg == "autoStart(QString)" ) { |
676 | QString appName; | 677 | QString appName; |
677 | stream >> appName; | 678 | stream >> appName; |
678 | Config cfg( "autostart" ); | 679 | Config cfg( "autostart" ); |
679 | cfg.setGroup( "AutoStart" ); | 680 | cfg.setGroup( "AutoStart" ); |
680 | if ( appName.compare("clear") == 0){ | 681 | if ( appName.compare("clear") == 0){ |
681 | cfg.writeEntry("Apps", ""); | 682 | cfg.writeEntry("Apps", ""); |
682 | } | 683 | } |
683 | } else if ( msg == "autoStart(QString,QString)" ) { | 684 | } else if ( msg == "autoStart(QString,QString)" ) { |
684 | QString modifier, appName; | 685 | QString modifier, appName; |
685 | stream >> modifier >> appName; | 686 | stream >> modifier >> appName; |
686 | Config cfg( "autostart" ); | 687 | Config cfg( "autostart" ); |
687 | cfg.setGroup( "AutoStart" ); | 688 | cfg.setGroup( "AutoStart" ); |
688 | if ( modifier.compare("add") == 0 ){ | 689 | if ( modifier.compare("add") == 0 ){ |
689 | // only add it appname is entered | 690 | // only add it appname is entered |
690 | if (!appName.isEmpty()) { | 691 | if (!appName.isEmpty()) { |
691 | cfg.writeEntry("Apps", appName); | 692 | cfg.writeEntry("Apps", appName); |
692 | } | 693 | } |
693 | } else if (modifier.compare("remove") == 0 ) { | 694 | } else if (modifier.compare("remove") == 0 ) { |
694 | // need to change for multiple entries | 695 | // need to change for multiple entries |
695 | // actually remove is right now simular to clear, but in future there | 696 | // actually remove is right now simular to clear, but in future there |
696 | // should be multiple apps in autostart possible. | 697 | // should be multiple apps in autostart possible. |
697 | QString checkName; | 698 | QString checkName; |
698 | checkName = cfg.readEntry("Apps", ""); | 699 | checkName = cfg.readEntry("Apps", ""); |
699 | if (checkName == appName) { | 700 | if (checkName == appName) { |
700 | cfg.writeEntry("Apps", ""); | 701 | cfg.writeEntry("Apps", ""); |
701 | } | 702 | } |
702 | } | 703 | } |
703 | } else if ( msg == "sendCardInfo()" ) { | 704 | } else if ( msg == "sendCardInfo()" ) { |
704 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 705 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
705 | const QList<FileSystem> &fs = storage->fileSystems(); | 706 | const QList<FileSystem> &fs = storage->fileSystems(); |
706 | QListIterator<FileSystem> it ( fs ); | 707 | QListIterator<FileSystem> it ( fs ); |
707 | QString s; | 708 | QString s; |
708 | QString homeDir = getenv("HOME"); | 709 | QString homeDir = getenv("HOME"); |
709 | QString hardDiskHome; | 710 | QString hardDiskHome; |
710 | for ( ; it.current(); ++it ) { | 711 | for ( ; it.current(); ++it ) { |
711 | if ( (*it)->isRemovable() ) | 712 | if ( (*it)->isRemovable() ) |
712 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 713 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
713 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 714 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
714 | + " " + (*it)->options() + ";"; | 715 | + " " + (*it)->options() + ";"; |
715 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 716 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
716 | (*it)->disk() == "/dev/mtdblock/1" ) | 717 | (*it)->disk() == "/dev/mtdblock/1" ) |
717 | s += (*it)->name() + "=" + homeDir + "/Documents " | 718 | s += (*it)->name() + "=" + homeDir + "/Documents " |
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index 00ae980..197bd19 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h | |||
@@ -1,136 +1,138 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 LAUNCHER_H | 20 | #ifndef LAUNCHER_H |
21 | #define LAUNCHER_H | 21 | #define LAUNCHER_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qtabbar.h> | 24 | #include <qtabbar.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include "launcherview.h" | 28 | #include "launcherview.h" |
29 | 29 | ||
30 | class AppLnk; | 30 | class AppLnk; |
31 | class AppLnkSet; | 31 | class AppLnkSet; |
32 | class DocLnkSet; | 32 | class DocLnkSet; |
33 | class QWidgetStack; | 33 | class QWidgetStack; |
34 | class StorageInfo; | 34 | class StorageInfo; |
35 | class SyncDialog; | 35 | class SyncDialog; |
36 | 36 | ||
37 | class CategoryTabBar : public QTabBar | 37 | class CategoryTabBar : public QTabBar |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); | 41 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); |
42 | ~CategoryTabBar(); | 42 | ~CategoryTabBar(); |
43 | 43 | ||
44 | protected slots: | 44 | protected slots: |
45 | virtual void layoutTabs(); | 45 | virtual void layoutTabs(); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | void paint ( QPainter *p, QTab *t, bool f ) const; | 48 | void paint ( QPainter *p, QTab *t, bool f ) const; |
49 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; | 49 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | class CategoryTabWidget : public QVBox { | 52 | class CategoryTabWidget : public QVBox { |
53 | // can't use a QTabWidget, since it won't let us set the frame style. | 53 | // can't use a QTabWidget, since it won't let us set the frame style. |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | CategoryTabWidget( QWidget* parent ); | 56 | CategoryTabWidget( QWidget* parent ); |
57 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, | 57 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, |
58 | const QList<FileSystem> &); | 58 | const QList<FileSystem> &); |
59 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); | 59 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); |
60 | void updateLink(const QString& linkfile); | 60 | void updateLink(const QString& linkfile); |
61 | void setBusy(bool on); | 61 | void setBusy(bool on); |
62 | 62 | ||
63 | signals: | 63 | signals: |
64 | void selected(const QString&); | 64 | void selected(const QString&); |
65 | void clicked(const AppLnk*); | 65 | void clicked(const AppLnk*); |
66 | void rightPressed(AppLnk*); | 66 | void rightPressed(AppLnk*); |
67 | 67 | ||
68 | public slots: | 68 | public slots: |
69 | void nextTab(); | 69 | void nextTab(); |
70 | void prevTab(); | 70 | void prevTab(); |
71 | 71 | ||
72 | protected: | 72 | protected: |
73 | void paletteChange( const QPalette &p ); | 73 | void paletteChange( const QPalette &p ); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | CategoryTabBar* categoryBar; | 76 | CategoryTabBar* categoryBar; |
77 | QWidgetStack* stack; | 77 | QWidgetStack* stack; |
78 | LauncherView* docview; | 78 | LauncherView* docview; |
79 | QStringList ids; | 79 | QStringList ids; |
80 | int tabs; | 80 | int tabs; |
81 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); | 81 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); |
82 | void addItem( const QString& ); | 82 | void addItem( const QString& ); |
83 | }; | 83 | }; |
84 | 84 | ||
85 | class Launcher : public QMainWindow | 85 | class Launcher : public QMainWindow |
86 | { | 86 | { |
87 | Q_OBJECT | 87 | Q_OBJECT |
88 | friend class LauncherPrivate; | 88 | friend class LauncherPrivate; |
89 | public: | 89 | public: |
90 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 90 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
91 | ~Launcher(); | 91 | ~Launcher(); |
92 | 92 | ||
93 | static QString appsFolderName(); | 93 | static QString appsFolderName(); |
94 | 94 | ||
95 | virtual void showMaximized(); | 95 | virtual void showMaximized(); |
96 | static bool mkdir(const QString &path); | 96 | static bool mkdir(const QString &path); |
97 | 97 | ||
98 | public slots: | 98 | public slots: |
99 | void viewSelected(const QString&); | 99 | void viewSelected(const QString&); |
100 | void select( const AppLnk * ); | 100 | void select( const AppLnk * ); |
101 | void externalSelected( const AppLnk *); | 101 | void externalSelected( const AppLnk *); |
102 | void properties( AppLnk * ); | 102 | void properties( AppLnk * ); |
103 | void nextView(); | 103 | void nextView(); |
104 | 104 | ||
105 | signals: | 105 | signals: |
106 | void executing( const AppLnk * ); | 106 | void executing( const AppLnk * ); |
107 | void busy(); | 107 | void busy(); |
108 | void notBusy(const QString&); | 108 | void notBusy(const QString&); |
109 | 109 | ||
110 | private slots: | 110 | private slots: |
111 | void doMaximize(); | 111 | void doMaximize(); |
112 | void systemMessage( const QCString &, const QByteArray &); | 112 | void systemMessage( const QCString &, const QByteArray &); |
113 | void storageChanged(); | 113 | void storageChanged(); |
114 | void cancelSync(); | 114 | void cancelSync(); |
115 | 115 | ||
116 | private: | 116 | private: |
117 | void updateApps(); | 117 | void updateApps(); |
118 | void loadDocs(); | 118 | void loadDocs(); |
119 | void updateDocs(); | 119 | void updateDocs(); |
120 | void updateTabs(); | 120 | void updateTabs(); |
121 | void updateMimeTypes(); | 121 | void updateMimeTypes(); |
122 | void updateMimeTypes(AppLnkSet*); | 122 | void updateMimeTypes(AppLnkSet*); |
123 | void preloadApps(); | 123 | void preloadApps(); |
124 | AppLnkSet *rootFolder; | 124 | AppLnkSet *rootFolder; |
125 | DocLnkSet *docsFolder; | 125 | DocLnkSet *docsFolder; |
126 | CategoryTabWidget *tabs; | 126 | CategoryTabWidget *tabs; |
127 | StorageInfo *storage; | 127 | StorageInfo *storage; |
128 | SyncDialog *syncDialog; | 128 | SyncDialog *syncDialog; |
129 | 129 | ||
130 | void updateLink(const QString& link); | 130 | void updateLink(const QString& link); |
131 | bool in_lnk_props; | 131 | bool in_lnk_props; |
132 | bool got_lnk_change; | 132 | bool got_lnk_change; |
133 | QString lnk_change; | 133 | QString lnk_change; |
134 | QString m_timeStamp; | ||
134 | }; | 135 | }; |
135 | 136 | ||
136 | #endif // LAUNCHERVIEW_H | 137 | #endif // LAUNCHERVIEW_H |
138 | |||