summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-25 20:17:29 (UTC)
committer zecke <zecke>2002-03-25 20:17:29 (UTC)
commitb001d834cd1259ea17fd1faf82111a1efdf607db (patch) (unidiff)
tree35da1df30a27e18837d317d949db234015cfdf32
parent56f2a47633046a7b08fe59acfe646a648c006230 (diff)
downloadopie-b001d834cd1259ea17fd1faf82111a1efdf607db.zip
opie-b001d834cd1259ea17fd1faf82111a1efdf607db.tar.gz
opie-b001d834cd1259ea17fd1faf82111a1efdf607db.tar.bz2
- remove old Icons from the taskbar (only when you start a new app )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp2
-rw-r--r--core/launcher/mrulist.cpp42
2 files changed, 38 insertions, 6 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index cf1a3c8..17a30e6 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -339,513 +339,513 @@ void CategoryTabBar::layoutTabs()
339 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 339 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
340 } 340 }
341 int h = QMAX( fm.height(), ih ); 341 int h = QMAX( fm.height(), ih );
342 h = QMAX( h, QApplication::globalStrut().height() ); 342 h = QMAX( h, QApplication::globalStrut().height() );
343 343
344 h += vframe; 344 h += vframe;
345 w += hframe; 345 w += hframe;
346 346
347 // t->setRect( QRect(x, 0, w * available/required, h) ); 347 // t->setRect( QRect(x, 0, w * available/required, h) );
348 t->setRect( QRect(x, 0, available, h) ); 348 t->setRect( QRect(x, 0, available, h) );
349 x += t->rect().width() - overlap; 349 x += t->rect().width() - overlap;
350 r = r.unite( t->rect() ); 350 r = r.unite( t->rect() );
351 } 351 }
352 } 352 }
353 353
354 QRect rr = tab(count()-1)->rect(); 354 QRect rr = tab(count()-1)->rect();
355 rr.setRight(width()-1); 355 rr.setRight(width()-1);
356 tab(count()-1)->setRect( rr ); 356 tab(count()-1)->setRect( rr );
357 357
358 for ( t = tabList()->first(); t; t = tabList()->next() ) { 358 for ( t = tabList()->first(); t; t = tabList()->next() ) {
359 QRect tr = t->rect(); 359 QRect tr = t->rect();
360 tr.setHeight( r.height() ); 360 tr.setHeight( r.height() );
361 t->setRect( tr ); 361 t->setRect( tr );
362 } 362 }
363 363
364 update(); 364 update();
365} 365}
366 366
367 367
368void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 368void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
369{ 369{
370#if QT_VERSION >= 300 370#if QT_VERSION >= 300
371 QStyle::SFlags flags = QStyle::Style_Default; 371 QStyle::SFlags flags = QStyle::Style_Default;
372 if ( selected ) 372 if ( selected )
373 flags |= QStyle::Style_Selected; 373 flags |= QStyle::Style_Selected;
374 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 374 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
375 colorGroup(), flags, QStyleOption(t) ); 375 colorGroup(), flags, QStyleOption(t) );
376#else 376#else
377 style().drawTab( p, this, t, selected ); 377 style().drawTab( p, this, t, selected );
378#endif 378#endif
379 379
380 QRect r( t->rect() ); 380 QRect r( t->rect() );
381 QFont f( font() ); 381 QFont f( font() );
382 if ( selected ) 382 if ( selected )
383 f.setBold( TRUE ); 383 f.setBold( TRUE );
384 p->setFont( f ); 384 p->setFont( f );
385 385
386 int iw = 0; 386 int iw = 0;
387 int ih = 0; 387 int ih = 0;
388 if ( t->iconSet() != 0 ) { 388 if ( t->iconSet() != 0 ) {
389 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 389 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
390 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 390 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
391 } 391 }
392 int w = iw + p->fontMetrics().width( t->text() ) + 4; 392 int w = iw + p->fontMetrics().width( t->text() ) + 4;
393 int h = QMAX(p->fontMetrics().height() + 4, ih ); 393 int h = QMAX(p->fontMetrics().height() + 4, ih );
394 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 394 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
395 r.top() + (r.height()-h)/2, w, h ), t, 395 r.top() + (r.height()-h)/2, w, h ), t,
396#if QT_VERSION >= 300 396#if QT_VERSION >= 300
397 t->identifier() == keyboardFocusTab() 397 t->identifier() == keyboardFocusTab()
398#else 398#else
399 t->identitifer() == keyboardFocusTab() 399 t->identitifer() == keyboardFocusTab()
400#endif 400#endif
401 ); 401 );
402} 402}
403 403
404 404
405void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 405void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
406 QTab* t, bool has_focus ) const 406 QTab* t, bool has_focus ) const
407{ 407{
408 QRect r = t->rect(); 408 QRect r = t->rect();
409 // if ( t->id != currentTab() ) 409 // if ( t->id != currentTab() )
410 //r.moveBy( 1, 1 ); 410 //r.moveBy( 1, 1 );
411 // 411 //
412 if ( t->iconSet() ) { 412 if ( t->iconSet() ) {
413 // the tab has an iconset, draw it in the right mode 413 // the tab has an iconset, draw it in the right mode
414 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 414 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
415 if ( mode == QIconSet::Normal && has_focus ) 415 if ( mode == QIconSet::Normal && has_focus )
416 mode = QIconSet::Active; 416 mode = QIconSet::Active;
417 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 417 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
418 int pixw = pixmap.width(); 418 int pixw = pixmap.width();
419 int pixh = pixmap.height(); 419 int pixh = pixmap.height();
420 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 420 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
421 r.setLeft( r.left() + pixw + 5 ); 421 r.setLeft( r.left() + pixw + 5 );
422 } 422 }
423 423
424 QRect tr = r; 424 QRect tr = r;
425 425
426 if ( r.width() < 20 ) 426 if ( r.width() < 20 )
427 return; 427 return;
428 428
429 if ( t->isEnabled() && isEnabled() ) { 429 if ( t->isEnabled() && isEnabled() ) {
430#if defined(_WS_WIN32_) 430#if defined(_WS_WIN32_)
431 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 431 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
432 p->setPen( colorGroup().buttonText() ); 432 p->setPen( colorGroup().buttonText() );
433 else 433 else
434 p->setPen( colorGroup().foreground() ); 434 p->setPen( colorGroup().foreground() );
435#else 435#else
436 p->setPen( colorGroup().foreground() ); 436 p->setPen( colorGroup().foreground() );
437#endif 437#endif
438 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 438 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
439 } else { 439 } else {
440 p->setPen( palette().disabled().foreground() ); 440 p->setPen( palette().disabled().foreground() );
441 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 441 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
442 } 442 }
443} 443}
444 444
445//--------------------------------------------------------------------------- 445//---------------------------------------------------------------------------
446 446
447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
448 : QMainWindow( parent, name, fl ) 448 : QMainWindow( parent, name, fl )
449{ 449{
450 setCaption( tr("Launcher") ); 450 setCaption( tr("Launcher") );
451 451
452 syncDialog = 0; 452 syncDialog = 0;
453 453
454 // we have a pretty good idea how big we'll be 454 // we have a pretty good idea how big we'll be
455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
456 456
457 tabs = 0; 457 tabs = 0;
458 rootFolder = 0; 458 rootFolder = 0;
459 docsFolder = 0; 459 docsFolder = 0;
460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
461 //uidgen.store( stamp ); 461 //uidgen.store( stamp );
462 m_timeStamp = QString::number( stamp ); 462 m_timeStamp = QString::number( stamp );
463 463
464 tabs = new CategoryTabWidget( this ); 464 tabs = new CategoryTabWidget( this );
465 tabs->setMaximumWidth( qApp->desktop()->width() ); 465 tabs->setMaximumWidth( qApp->desktop()->width() );
466 setCentralWidget( tabs ); 466 setCentralWidget( tabs );
467 467
468 connect( tabs, SIGNAL(selected(const QString&)), 468 connect( tabs, SIGNAL(selected(const QString&)),
469 this, SLOT(viewSelected(const QString&)) ); 469 this, SLOT(viewSelected(const QString&)) );
470 connect( tabs, SIGNAL(clicked(const AppLnk*)), 470 connect( tabs, SIGNAL(clicked(const AppLnk*)),
471 this, SLOT(select(const AppLnk*))); 471 this, SLOT(select(const AppLnk*)));
472 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 472 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
473 this, SLOT(properties(AppLnk*))); 473 this, SLOT(properties(AppLnk*)));
474 474
475#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 475#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
479#endif 479#endif
480 480
481 storage = new StorageInfo( this ); 481 storage = new StorageInfo( this );
482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
483 483
484 updateTabs(); 484 updateTabs();
485 485
486 preloadApps(); 486 preloadApps();
487 487
488 in_lnk_props = FALSE; 488 in_lnk_props = FALSE;
489 got_lnk_change = FALSE; 489 got_lnk_change = FALSE;
490} 490}
491 491
492Launcher::~Launcher() 492Launcher::~Launcher()
493{ 493{
494} 494}
495 495
496static bool isVisibleWindow(int wid) 496static bool isVisibleWindow(int wid)
497{ 497{
498 const QList<QWSWindow> &list = qwsServer->clientWindows(); 498 const QList<QWSWindow> &list = qwsServer->clientWindows();
499 QWSWindow* w; 499 QWSWindow* w;
500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
501 if ( w->winId() == wid ) 501 if ( w->winId() == wid )
502 return !w->isFullyObscured(); 502 return !w->isFullyObscured();
503 } 503 }
504 return FALSE; 504 return FALSE;
505} 505}
506 506
507void Launcher::showMaximized() 507void Launcher::showMaximized()
508{ 508{
509 if ( isVisibleWindow( winId() ) ) 509 if ( isVisibleWindow( winId() ) )
510 doMaximize(); 510 doMaximize();
511 else 511 else
512 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 512 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
513} 513}
514 514
515void Launcher::doMaximize() 515void Launcher::doMaximize()
516{ 516{
517 QMainWindow::showMaximized(); 517 QMainWindow::showMaximized();
518} 518}
519 519
520void Launcher::updateMimeTypes() 520void Launcher::updateMimeTypes()
521{ 521{
522 MimeType::clear(); 522 MimeType::clear();
523 updateMimeTypes(rootFolder); 523 updateMimeTypes(rootFolder);
524} 524}
525 525
526void Launcher::updateMimeTypes(AppLnkSet* folder) 526void Launcher::updateMimeTypes(AppLnkSet* folder)
527{ 527{
528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
529 AppLnk *app = it.current(); 529 AppLnk *app = it.current();
530 if ( app->type() == "Folder" ) 530 if ( app->type() == "Folder" )
531 updateMimeTypes((AppLnkSet *)app); 531 updateMimeTypes((AppLnkSet *)app);
532 else { 532 else {
533 MimeType::registerApp(*app); 533 MimeType::registerApp(*app);
534 } 534 }
535 } 535 }
536} 536}
537 537
538void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 538void Launcher::loadDocs() // ok here comes a hack belonging to Global::
539{ 539{
540 qWarning("loading Documents" ); 540 qWarning("loading Documents" );
541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); 541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
542 delete docsFolder; 542 delete docsFolder;
543 docsFolder = new DocLnkSet; 543 docsFolder = new DocLnkSet;
544 qWarning("new DocLnkSet" ); 544 qWarning("new DocLnkSet" );
545 DocLnkSet *tmp = 0; 545 DocLnkSet *tmp = 0;
546 QString home = QString(getenv("HOME")) + "/Documents"; 546 QString home = QString(getenv("HOME")) + "/Documents";
547 tmp = new DocLnkSet( home , QString::null); 547 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp ); 548 docsFolder->appendFrom( *tmp );
549 delete tmp; 549 delete tmp;
550 // find out wich filesystems are new in this round 550 // find out wich filesystems are new in this round
551 // We will do this by having a timestamp inside each mountpoint 551 // We will do this by having a timestamp inside each mountpoint
552 // if the current timestamp doesn't match this is a new file system and 552 // if the current timestamp doesn't match this is a new file system and
553 // come up with our MediumMountGui :) let the hacking begin 553 // come up with our MediumMountGui :) let the hacking begin
554 int stamp = uidgen.generate(); 554 int stamp = uidgen.generate();
555 555
556 QString newStamp = QString::number( stamp ); // generates newtime Stamp 556 QString newStamp = QString::number( stamp ); // generates newtime Stamp
557 StorageInfo storage; 557 StorageInfo storage;
558 const QList<FileSystem> &fileSystems = storage.fileSystems(); 558 const QList<FileSystem> &fileSystems = storage.fileSystems();
559 QListIterator<FileSystem> it ( fileSystems ); 559 QListIterator<FileSystem> it ( fileSystems );
560 for ( ; it.current(); ++it ) { 560 for ( ; it.current(); ++it ) {
561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
562 qWarning("%s is removeable", (*it)->path().latin1() ); 562 qWarning("%s is removeable", (*it)->path().latin1() );
563 OConfig cfg( (*it)->path() + "/.opiestorage.cf"); 563 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
564 cfg.setGroup("main"); 564 cfg.setGroup("main");
565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
566 if( stamp == m_timeStamp ){ // ok we know this card 566 if( stamp == m_timeStamp ){ // ok we know this card
567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
568 // we need to scan the list now. Hopefully the cache will be there 568 // we need to scan the list now. Hopefully the cache will be there
569 // read the mimetypes from the config and search for documents 569 // read the mimetypes from the config and search for documents
570 QStringList mimetypes = configToMime( &cfg); 570 QStringList mimetypes = configToMime( &cfg);
571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
572 docsFolder->appendFrom( *tmp ); 572 docsFolder->appendFrom( *tmp );
573 delete tmp; 573 delete tmp;
574 574
575 }else{ // come up with the gui cause this a new card 575 }else{ // come up with the gui cause this a new card
576 MediumMountGui medium((*it)->path() ); 576 MediumMountGui medium((*it)->path() );
577 if( medium.check() ){ // we did not ask before or ask again is off 577 if( medium.check() ){ // we did not ask before or ask again is off
578 if( medium.exec() ){ // he clicked yes so search it 578 if( medium.exec() ){ // he clicked yes so search it
579 // speicher 579 // speicher
580 cfg.read(); // cause of a race we need to reread 580 cfg.read(); // cause of a race we need to reread
581 cfg.writeEntry("timestamp", newStamp ); 581 cfg.writeEntry("timestamp", newStamp );
582 }// no else 582 }// no else
583 }else{ // we checked 583 }else{ // we checked
584 // do something different see what we need to do 584 // do something different see what we need to do
585 // let's see if we should check the device 585 // let's see if we should check the device
586 cfg.setGroup("main" ); 586 cfg.setGroup("main" );
587 bool check = cfg.readBoolEntry("autocheck", true ); 587 bool check = cfg.readBoolEntry("autocheck", true );
588 if( check ){ // find the documents 588 if( check ){ // find the documents
589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
590 docsFolder->appendFrom( *tmp ); 590 docsFolder->appendFrom( *tmp );
591 delete tmp; 591 delete tmp;
592 } 592 }
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
597 m_timeStamp = newStamp; 597 m_timeStamp = newStamp;
598} 598}
599 599
600void Launcher::updateTabs() 600void Launcher::updateTabs()
601{ 601{
602 MimeType::updateApplications(); // ### reads all applnks twice 602 MimeType::updateApplications(); // ### reads all applnks twice
603 603
604 delete rootFolder; 604 delete rootFolder;
605 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 605 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
606 606
607 loadDocs(); 607 loadDocs();
608 608
609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
610} 610}
611 611
612void Launcher::updateDocs() 612void Launcher::updateDocs()
613{ 613{
614 loadDocs(); 614 loadDocs();
615 tabs->updateDocs(docsFolder,storage->fileSystems()); 615 tabs->updateDocs(docsFolder,storage->fileSystems());
616} 616}
617 617
618void Launcher::viewSelected(const QString& s) 618void Launcher::viewSelected(const QString& s)
619{ 619{
620 setCaption( s + tr(" - Launcher") ); 620 setCaption( s + tr(" - Launcher") );
621} 621}
622 622
623void Launcher::nextView() 623void Launcher::nextView()
624{ 624{
625 tabs->nextTab(); 625 tabs->nextTab();
626} 626}
627 627
628 628
629void Launcher::select( const AppLnk *appLnk ) 629void Launcher::select( const AppLnk *appLnk )
630{ 630{
631 if ( appLnk->type() == "Folder" ) { 631 if ( appLnk->type() == "Folder" ) {
632 // Not supported: flat is simpler for the user 632 // Not supported: flat is simpler for the user
633 } else { 633 } else {
634 if ( appLnk->exec().isNull() ) { 634 if ( appLnk->exec().isNull() ) {
635 QMessageBox::information(this,tr("No application"), 635 QMessageBox::information(this,tr("No application"),
636 tr("<p>No application is defined for this document." 636 tr("<p>No application is defined for this document."
637 "<p>Type is %1.").arg(appLnk->type())); 637 "<p>Type is %1.").arg(appLnk->type()));
638 return; 638 return;
639 } 639 }
640 tabs->setBusy(TRUE); 640 tabs->setBusy(TRUE);
641 emit executing( appLnk ); 641 emit executing( appLnk );
642 appLnk->execute(); 642 appLnk->execute();
643 } 643 }
644} 644}
645 645
646void Launcher::externalSelected(const AppLnk *appLnk) 646void Launcher::externalSelected(const AppLnk *appLnk)
647{ 647{
648 tabs->setBusy(TRUE); 648 tabs->setBusy(TRUE);
649 emit executing( appLnk ); 649 emit executing( appLnk );
650} 650}
651 651
652void Launcher::properties( AppLnk *appLnk ) 652void Launcher::properties( AppLnk *appLnk )
653{ 653{
654 if ( appLnk->type() == "Folder" ) { 654 if ( appLnk->type() == "Folder" ) {
655 // Not supported: flat is simpler for the user 655 // Not supported: flat is simpler for the user
656 } else { 656 } else {
657 in_lnk_props = TRUE; 657 in_lnk_props = TRUE;
658 got_lnk_change = FALSE; 658 got_lnk_change = FALSE;
659 LnkProperties prop(appLnk); 659 LnkProperties prop(appLnk);
660 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 660 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
661 prop.showMaximized(); 661 prop.showMaximized();
662 prop.exec(); 662 prop.exec();
663 in_lnk_props = FALSE; 663 in_lnk_props = FALSE;
664 if ( got_lnk_change ) { 664 if ( got_lnk_change ) {
665 updateLink(lnk_change); 665 updateLink(lnk_change);
666 } 666 }
667 } 667 }
668} 668}
669 669
670void Launcher::updateLink(const QString& link) 670void Launcher::updateLink(const QString& link)
671{ 671{
672 if (link.isNull()) 672 if (link.isNull())
673 updateTabs(); 673 updateTabs();
674 else if (link.isEmpty()) 674 else if (link.isEmpty())
675 updateDocs(); 675 updateDocs();
676 else 676 else
677 tabs->updateLink(link); 677 tabs->updateLink(link);
678} 678}
679 679
680void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 680void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
681{ 681{
682 QDataStream stream( data, IO_ReadOnly ); 682 QDataStream stream( data, IO_ReadOnly );
683 if ( msg == "linkChanged(QString)" ) { 683 if ( msg == "linkChanged(QString)" ) {
684 QString link; 684 QString link;
685 stream >> link; 685 stream >> link;
686 if ( in_lnk_props ) { 686 if ( in_lnk_props ) {
687 got_lnk_change = TRUE; 687 got_lnk_change = TRUE;
688 lnk_change = link; 688 lnk_change = link;
689 } else { 689 } else {
690 updateLink(link); 690 updateLink(link);
691 } 691 }
692 } else if ( msg == "busy()" ) { 692 } else if ( msg == "busy()" ) {
693 emit busy(); 693 emit busy();
694 } else if ( msg == "notBusy(QString)" ) { 694 } else if ( msg == "notBusy(QString)" ) {
695 QString app; 695 QString app;
696 stream >> app; 696 stream >> app;
697 tabs->setBusy(FALSE); 697 tabs->setBusy(FALSE);
698 emit notBusy(app); 698 emit notBusy(app);
699 } else if ( msg == "mkdir(QString)" ) { 699 } else if ( msg == "mkdir(QString)" ) {
700 QString dir; 700 QString dir;
701 stream >> dir; 701 stream >> dir;
702 if ( !dir.isEmpty() ) 702 if ( !dir.isEmpty() )
703 mkdir( dir ); 703 mkdir( dir );
704 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 704 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
705 QString baseFile, sigFile; 705 QString baseFile, sigFile;
706 stream >> baseFile >> sigFile; 706 stream >> baseFile >> sigFile;
707 QRsync::generateSignature( baseFile, sigFile ); 707 QRsync::generateSignature( baseFile, sigFile );
708 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 708 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
709 QString baseFile, sigFile, deltaFile; 709 QString baseFile, sigFile, deltaFile;
710 stream >> baseFile >> sigFile >> deltaFile; 710 stream >> baseFile >> sigFile >> deltaFile;
711 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 711 QRsync::generateDiff( baseFile, sigFile, deltaFile );
712 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 712 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
713 QString baseFile, deltaFile; 713 QString baseFile, deltaFile;
714 stream >> baseFile >> deltaFile; 714 stream >> baseFile >> deltaFile;
715 if ( !QFile::exists( baseFile ) ) { 715 if ( !QFile::exists( baseFile ) ) {
716 QFile f( baseFile ); 716 QFile f( baseFile );
717 f.open( IO_WriteOnly ); 717 f.open( IO_WriteOnly );
718 f.close(); 718 f.close();
719 } 719 }
720 QRsync::applyDiff( baseFile, deltaFile ); 720 QRsync::applyDiff( baseFile, deltaFile );
721 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 721 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
722 e << baseFile; 722 e << baseFile;
723 } else if ( msg == "rdiffCleanup()" ) { 723 } else if ( msg == "rdiffCleanup()" ) {
724 mkdir( "/tmp/rdiff" ); 724 mkdir( "/tmp/rdiff" );
725 QDir dir; 725 QDir dir;
726 dir.setPath( "/tmp/rdiff" ); 726 dir.setPath( "/tmp/rdiff" );
727 QStringList entries = dir.entryList(); 727 QStringList entries = dir.entryList();
728 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 728 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
729 dir.remove( *it ); 729 dir.remove( *it );
730 } else if ( msg == "sendHandshakeInfo()" ) { 730 } else if ( msg == "sendHandshakeInfo()" ) {
731 QString home = getenv( "HOME" ); 731 QString home = getenv( "HOME" );
732 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 732 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
733 e << home; 733 e << home;
734 int locked = (int) Desktop::screenLocked(); 734 int locked = (int) Desktop::screenLocked();
735 e << locked; 735 e << locked;
736 // register an app for autostart 736 // register an app for autostart
737 // if clear is send the list is cleared. 737 // if clear is send the list is cleared.
738 } else if ( msg == "autoStart(QString)" ) { 738 } else if ( msg == "autoStart(QString)" ) {
739 QString appName; 739 QString appName;
740 stream >> appName; 740 stream >> appName;
741 Config cfg( "autostart" ); 741 Config cfg( "autostart" );
742 cfg.setGroup( "AutoStart" ); 742 cfg.setGroup( "AutoStart" );
743 if ( appName.compare("clear") == 0){ 743 if ( appName.compare("clear") == 0){
744 cfg.writeEntry("Apps", ""); 744 cfg.writeEntry("Apps", "");
745 } 745 }
746 } else if ( msg == "autoStart(QString,QString)" ) { 746 } else if ( msg == "autoStart(QString,QString)" ) {
747 QString modifier, appName; 747 QString modifier, appName;
748 stream >> modifier >> appName; 748 stream >> modifier >> appName;
749 Config cfg( "autostart" ); 749 Config cfg( "autostart" );
750 cfg.setGroup( "AutoStart" ); 750 cfg.setGroup( "AutoStart" );
751 if ( modifier.compare("add") == 0 ){ 751 if ( modifier.compare("add") == 0 ){
752 // only add it appname is entered 752 // only add it appname is entered
753 if (!appName.isEmpty()) { 753 if (!appName.isEmpty()) {
754 cfg.writeEntry("Apps", appName); 754 cfg.writeEntry("Apps", appName);
755 } 755 }
756 } else if (modifier.compare("remove") == 0 ) { 756 } else if (modifier.compare("remove") == 0 ) {
757 // need to change for multiple entries 757 // need to change for multiple entries
758 // actually remove is right now simular to clear, but in future there 758 // actually remove is right now simular to clear, but in future there
759 // should be multiple apps in autostart possible. 759 // should be multiple apps in autostart possible.
760 QString checkName; 760 QString checkName;
761 checkName = cfg.readEntry("Apps", ""); 761 checkName = cfg.readEntry("Apps", "");
762 if (checkName == appName) { 762 if (checkName == appName) {
763 cfg.writeEntry("Apps", ""); 763 cfg.writeEntry("Apps", "");
764 } 764 }
765 } 765 }
766 } else if ( msg == "sendCardInfo()" ) { 766 } else if ( msg == "sendCardInfo()" ) {
767 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 767 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
768 const QList<FileSystem> &fs = storage->fileSystems(); 768 const QList<FileSystem> &fs = storage->fileSystems();
769 QListIterator<FileSystem> it ( fs ); 769 QListIterator<FileSystem> it ( fs );
770 QString s; 770 QString s;
771 QString homeDir = getenv("HOME"); 771 QString homeDir = getenv("HOME");
772 QString hardDiskHome; 772 QString hardDiskHome;
773 for ( ; it.current(); ++it ) { 773 for ( ; it.current(); ++it ) {
774 if ( (*it)->isRemovable() ) 774 if ( (*it)->isRemovable() )
775 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 775 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
776 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 776 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
777 + " " + (*it)->options() + ";"; 777 + " " + (*it)->options() + ";";
778 else if ( (*it)->disk() == "/dev/mtdblock1" || 778 else if ( (*it)->disk() == "/dev/mtdblock1" ||
779 (*it)->disk() == "/dev/mtdblock/1" ) 779 (*it)->disk() == "/dev/mtdblock/1" )
780 s += (*it)->name() + "=" + homeDir + "/Documents " 780 s += (*it)->name() + "=" + homeDir + "/Documents "
781 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 781 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
782 + " " + (*it)->options() + ";"; 782 + " " + (*it)->options() + ";";
783 else if ( (*it)->name().contains( "Hard Disk") && 783 else if ( (*it)->name().contains( "Hard Disk") &&
784 homeDir.contains( (*it)->path() ) && 784 homeDir.contains( (*it)->path() ) &&
785 (*it)->path().length() > hardDiskHome.length() ) 785 (*it)->path().length() > hardDiskHome.length() )
786 hardDiskHome = 786 hardDiskHome =
787 (*it)->name() + "=" + homeDir + "/Documents " 787 (*it)->name() + "=" + homeDir + "/Documents "
788 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 788 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
789 + " " + (*it)->options() + ";"; 789 + " " + (*it)->options() + ";";
790 } 790 }
791 if ( !hardDiskHome.isEmpty() ) 791 if ( !hardDiskHome.isEmpty() )
792 s += hardDiskHome; 792 s += hardDiskHome;
793 793
794 e << s; 794 e << s;
795 } else if ( msg == "sendSyncDate(QString)" ) { 795 } else if ( msg == "sendSyncDate(QString)" ) {
796 QString app; 796 QString app;
797 stream >> app; 797 stream >> app;
798 Config cfg( "qpe" ); 798 Config cfg( "qpe" );
799 cfg.setGroup("SyncDate"); 799 cfg.setGroup("SyncDate");
800 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 800 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
801 e << app << cfg.readEntry( app ); 801 e << app << cfg.readEntry( app );
802 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 802 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
803 //cfg.readEntry( app ).latin1() ); 803 //cfg.readEntry( app ).latin1() );
804 } else if ( msg == "setSyncDate(QString,QString)" ) { 804 } else if ( msg == "setSyncDate(QString,QString)" ) {
805 QString app, date; 805 QString app, date;
806 stream >> app >> date; 806 stream >> app >> date;
807 Config cfg( "qpe" ); 807 Config cfg( "qpe" );
808 cfg.setGroup("SyncDate"); 808 cfg.setGroup("SyncDate");
809 cfg.writeEntry( app, date ); 809 cfg.writeEntry( app, date );
810 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 810 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
811 } else if ( msg == "startSync(QString)" ) { 811 } else if ( msg == "startSync(QString)" ) {
812 QString what; 812 QString what;
813 stream >> what; 813 stream >> what;
814 delete syncDialog; syncDialog = 0; 814 delete syncDialog; syncDialog = 0;
815 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 815 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
816 WStyle_Tool | WStyle_Customize | 816 WStyle_Tool | WStyle_Customize |
817 Qt::WStyle_StaysOnTop ); 817 Qt::WStyle_StaysOnTop );
818 syncDialog->showMaximized(); 818 syncDialog->showMaximized();
819 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 819 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
820 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 820 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
821 SLOT( cancelSync() ) ); 821 SLOT( cancelSync() ) );
822 } 822 }
823 else if ( msg == "stopSync()") { 823 else if ( msg == "stopSync()") {
824 delete syncDialog; syncDialog = 0; 824 delete syncDialog; syncDialog = 0;
825 } else if ( msg == "getAllDocLinks()" ) { 825 } else if ( msg == "getAllDocLinks()" ) {
826 loadDocs(); 826 loadDocs();
827 827
828 QString contents; 828 QString contents;
829 829
830 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 830 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
831 DocLnk *doc = it.current(); 831 DocLnk *doc = it.current();
832 QFileInfo fi( doc->file() ); 832 QFileInfo fi( doc->file() );
833 if ( !fi.exists() ) 833 if ( !fi.exists() )
834 continue; 834 continue;
835 835
836 bool fake = !doc->linkFileKnown(); 836 bool fake = !doc->linkFileKnown();
837 if ( !fake ) { 837 if ( !fake ) {
838 QFile f( doc->linkFile() ); 838 QFile f( doc->linkFile() );
839 if ( f.open( IO_ReadOnly ) ) { 839 if ( f.open( IO_ReadOnly ) ) {
840 QTextStream ts( &f ); 840 QTextStream ts( &f );
841 ts.setEncoding( QTextStream::UnicodeUTF8 ); 841 ts.setEncoding( QTextStream::UnicodeUTF8 );
842 contents += ts.read(); 842 contents += ts.read();
843 f.close(); 843 f.close();
844 } else 844 } else
845 fake = TRUE; 845 fake = TRUE;
846 } 846 }
847 if (fake) { 847 if (fake) {
848 contents += "[Desktop Entry]\n"; 848 contents += "[Desktop Entry]\n";
849 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; 849 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n";
850 contents += "File = "+doc->file()+"\n"; 850 contents += "File = "+doc->file()+"\n";
851 contents += "Name = "+doc->name()+"\n"; 851 contents += "Name = "+doc->name()+"\n";
diff --git a/core/launcher/mrulist.cpp b/core/launcher/mrulist.cpp
index 4daf7d2..6066dac 100644
--- a/core/launcher/mrulist.cpp
+++ b/core/launcher/mrulist.cpp
@@ -1,199 +1,231 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Holger 'zecke' Freyther
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 4**
4** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
5** 6**
6** This file may be distributed and/or modified under the terms of the 7** 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 8** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** 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. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21#include "mrulist.h" 22#include "mrulist.h"
22 23
23#include <qpe/global.h> 24#include <qpe/global.h>
24#include <qpe/applnk.h> 25#include <qpe/applnk.h>
25#include <qpe/resource.h> 26#include <qpe/resource.h>
26 27
27#include <qframe.h> 28#include <qframe.h>
28#include <qpushbutton.h> 29#include <qpushbutton.h>
29#include <qtoolbutton.h> 30#include <qtoolbutton.h>
30#include <qpopupmenu.h> 31#include <qpopupmenu.h>
31#include <qpainter.h> 32#include <qpainter.h>
32#include <qwindowsystem_qws.h> 33#include <qwindowsystem_qws.h>
33 34
34 35
35 QList<MRUList>*MRUList::MRUListWidgets = NULL; 36 QList<MRUList>*MRUList::MRUListWidgets = NULL;
36 QList<AppLnk>*MRUList::task = NULL; 37 QList<AppLnk>*MRUList::task = NULL;
37 38
38 39
39MRUList::MRUList( QWidget *parent ) 40MRUList::MRUList( QWidget *parent )
40 : QFrame( parent ), selected(-1), oldsel(-1) 41 : QFrame( parent ), selected(-1), oldsel(-1)
41{ 42{
42 setBackgroundMode( PaletteButton ); 43 setBackgroundMode( PaletteButton );
43 if (!MRUListWidgets) 44 if (!MRUListWidgets)
44 MRUListWidgets = new QList<MRUList>; 45 MRUListWidgets = new QList<MRUList>;
45 if (!task) 46 if (!task)
46 task = new QList<AppLnk>; 47 task = new QList<AppLnk>;
47 MRUListWidgets->append( this ); 48 MRUListWidgets->append( this );
48} 49}
49 50
50 51
51MRUList::~MRUList() 52MRUList::~MRUList()
52{ 53{
53 if (MRUListWidgets) 54 if (MRUListWidgets)
54 MRUListWidgets->remove( this ); 55 MRUListWidgets->remove( this );
55 if (task) 56 if (task)
56 task->setAutoDelete( TRUE ); 57 task->setAutoDelete( TRUE );
57} 58}
58 59
59 60
60QSize MRUList::sizeHint() const 61QSize MRUList::sizeHint() const
61{ 62{
62 return QSize( frameWidth(), 16 ); 63 return QSize( frameWidth(), 16 );
63} 64}
64 65
65 66
66void MRUList::addTask( const AppLnk *appLnk ) 67void MRUList::addTask( const AppLnk *appLnk )
67{ 68{
68 if ( !appLnk ) 69 if ( !appLnk )
69 return; 70 return;
70 unsigned int i = 0; 71 unsigned int i = 0;
71 72
72 if ( !task ) 73 if ( !task )
73 return; 74 return;
74 75 // ok we wan't to delete old icons from the taskbar
76 // get the window list and see which windows aren't there any more
77 QList<AppLnk> cleanUp;
78 cleanUp.setAutoDelete( TRUE );
79 const QList<QWSWindow> &list = qwsServer->clientWindows();
80 QWSWindow* w;
81 bool running = false; // to see what we should do
82 for ( ; i < task->count(); i++ ) {
83 AppLnk *t = task->at(i);
84 running = false;
85 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
86 QString app = w->client()->identity();
87 if( app == t->exec( ) ){
88 running = true;
89 break;
90 }
91 }
92 if(!running ) { // gues what we do now
93 cleanUp.append( t);
94 }
95 }
96 // no do a clean up of these old icons
97 AppLnk *lnk;
98 for( lnk = cleanUp.first(); lnk != 0; lnk = cleanUp.next() ){
99 task->remove( lnk );
100 }
101 cleanUp.clear(); // should be deleted too
102
103 i = 0;
75 for ( ; i < task->count(); i++ ) { 104 for ( ; i < task->count(); i++ ) {
76 AppLnk *t = task->at(i); 105 AppLnk *t = task->at(i);
77 if ( t->exec() == appLnk->exec() ) { 106 if ( t->exec() == appLnk->exec() ) {
78 if (i != 0) { 107 if (i != 0) {
79 task->remove(); 108 task->remove();
80 task->prepend( t ); 109 task->prepend( t );
81 } 110 }
82 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 111 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
83 MRUListWidgets->at(i)->update(); 112 MRUListWidgets->at(i)->update();
84 return; 113 return;
85 } 114 }
86 } 115 }
87 116 // check which tasks are running and delete them from the list
88 AppLnk *t = new AppLnk( *appLnk ); 117 AppLnk *t = new AppLnk( *appLnk );
89 // DocLnks have an overloaded virtual function exec() 118 // DocLnks have an overloaded virtual function exec()
90 t->setExec( appLnk->exec() ); 119 t->setExec( appLnk->exec() );
91 task->prepend( t ); 120 task->prepend( t );
92 121
93 if ( task->count() > 6 ) { 122 if ( task->count() > 6 ) {
94 t = task->last(); 123 t = task->last();
95 task->remove(); 124 task->remove();
96 Global::terminate(t); 125 Global::terminate(t);
97 delete t; 126 delete t;
98 } 127 }
99 128
100 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 129 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
101 MRUListWidgets->at(i)->update(); 130 MRUListWidgets->at(i)->update();
102} 131}
103 132
104bool MRUList::quitOldApps() 133bool MRUList::quitOldApps()
105{ 134{
106 QStringList appsstarted; 135 QStringList appsstarted;
107 QStringList appsrunning; 136 QStringList appsrunning;
108 for ( int i=task->count()-1; i>=0; --i ) { 137 for ( int i=task->count()-1; i>=0; --i ) {
109 AppLnk *t = task->at(i); 138 AppLnk *t = task->at(i);
110 appsstarted.append(t->exec()); 139 appsstarted.append(t->exec());
111 } 140 }
112 141
113 const QList<QWSWindow> &list = qwsServer->clientWindows(); 142 const QList<QWSWindow> &list = qwsServer->clientWindows();
114 QWSWindow* w; 143 QWSWindow* w;
115 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 144 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
116 QString app = w->client()->identity(); 145 QString app = w->client()->identity();
117 if ( appsstarted.contains(app) && !appsrunning.contains(app) ) 146 if ( appsstarted.contains(app) && !appsrunning.contains(app) )
118 appsrunning.append(app); 147 appsrunning.append(app);
119 } 148 }
120 149
121 if ( appsrunning.count() > 1 ) { 150 if ( appsrunning.count() > 1 ) {
122 QStringList::ConstIterator it = appsrunning.begin(); 151 QStringList::ConstIterator it = appsrunning.begin();
123 ++it; // top stays running! 152 ++it; // top stays running!
124 for (; it != appsrunning.end(); it++) { 153 for (; it != appsrunning.end(); it++) {
125 for ( int i=task->count()-1; i>=0; --i ) { 154 for ( int i=task->count()-1; i>=0; --i ) {
126 AppLnk *t = task->at(i); 155 AppLnk *t = task->at(i);
127 if ( t->exec() == *it ) 156 if ( t->exec() == *it ){
128 Global::terminate(t); 157 task->remove(i );
158 delete t;
159 Global::terminate(t);
160 }
129 } 161 }
130 } 162 }
131 return TRUE; 163 return TRUE;
132 } else { 164 } else {
133 return FALSE; 165 return FALSE;
134 } 166 }
135} 167}
136 168
137 169
138void MRUList::mousePressEvent(QMouseEvent *e) 170void MRUList::mousePressEvent(QMouseEvent *e)
139{ 171{
140 selected = 0; 172 selected = 0;
141 int x=0; 173 int x=0;
142 QListIterator<AppLnk> it( *task ); 174 QListIterator<AppLnk> it( *task );
143 for ( ; it.current(); ++it,++selected,x+=15 ) { 175 for ( ; it.current(); ++it,++selected,x+=15 ) {
144 if ( x + 15 <= width() ) { 176 if ( x + 15 <= width() ) {
145 if ( e->x() >= x && e->x() < x+15 ) { 177 if ( e->x() >= x && e->x() < x+15 ) {
146 if ( selected < (int)task->count() ) { 178 if ( selected < (int)task->count() ) {
147 repaint(FALSE); 179 repaint(FALSE);
148 return; 180 return;
149 } 181 }
150 } 182 }
151 } else { 183 } else {
152 break; 184 break;
153 } 185 }
154 } 186 }
155 selected = -1; 187 selected = -1;
156 repaint( FALSE ); 188 repaint( FALSE );
157} 189}
158 190
159 191
160void MRUList::mouseReleaseEvent(QMouseEvent *) 192void MRUList::mouseReleaseEvent(QMouseEvent *)
161{ 193{
162 if ( selected >= 0 ) { 194 if ( selected >= 0 ) {
163 if ( parentWidget() ) 195 if ( parentWidget() )
164 if ( parentWidget()->isA( "QPopupMenu" ) ) 196 if ( parentWidget()->isA( "QPopupMenu" ) )
165 parentWidget()->hide(); 197 parentWidget()->hide();
166 Global::execute( task->at(selected)->exec() ); 198 Global::execute( task->at(selected)->exec() );
167 selected = -1; 199 selected = -1;
168 oldsel = -1; 200 oldsel = -1;
169 update(); 201 update();
170 } 202 }
171} 203}
172 204
173 205
174void MRUList::paintEvent( QPaintEvent * ) 206void MRUList::paintEvent( QPaintEvent * )
175{ 207{
176 QPainter p( this ); 208 QPainter p( this );
177 AppLnk *t; 209 AppLnk *t;
178 int x = 0; 210 int x = 0;
179 int y = (height() - 14) / 2; 211 int y = (height() - 14) / 2;
180 int i = 0; 212 int i = 0;
181 213
182 p.fillRect( 0, 0, width(), height(), colorGroup().background() ); 214 p.fillRect( 0, 0, width(), height(), colorGroup().background() );
183 215
184 if ( task ) { 216 if ( task ) {
185 QListIterator<AppLnk> it( *task ); 217 QListIterator<AppLnk> it( *task );
186 for ( ; it.current(); i++, ++it ) { 218 for ( ; it.current(); i++, ++it ) {
187 if ( x + 15 <= width() ) { 219 if ( x + 15 <= width() ) {
188 t = it.current(); 220 t = it.current();
189 if ( (int)i == selected ) 221 if ( (int)i == selected )
190 p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() ); 222 p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() );
191 else if ( (int)i == oldsel ) 223 else if ( (int)i == oldsel )
192 p.eraseRect( x, y, 15, t->pixmap().height()+1 ); 224 p.eraseRect( x, y, 15, t->pixmap().height()+1 );
193 p.drawPixmap( x, y, t->pixmap() ); 225 p.drawPixmap( x, y, t->pixmap() );
194 x += 15; 226 x += 15;
195 } 227 }
196 } 228 }
197 } 229 }
198} 230}
199 231