author | harlekin <harlekin> | 2003-04-18 21:15:41 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-04-18 21:15:41 (UTC) |
commit | c667951bfeaa17136bc828380e38062e150b2762 (patch) (unidiff) | |
tree | f9f9e5c9dbad7a91977f78b3ad413e8d8266e523 | |
parent | 486db3bff8680e22bade85c348a7673f847a6f37 (diff) | |
download | opie-c667951bfeaa17136bc828380e38062e150b2762.zip opie-c667951bfeaa17136bc828380e38062e150b2762.tar.gz opie-c667951bfeaa17136bc828380e38062e150b2762.tar.bz2 |
removed exerimental stuff I accidently commited
-rw-r--r-- | core/launcher/launcher.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 3eb561a..bcc2495 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -291,1029 +291,1029 @@ void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) | |||
291 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 291 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
292 | if ( bgType == "Image" ) { // No tr | 292 | if ( bgType == "Image" ) { // No tr |
293 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 293 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
294 | v->setBackgroundType( LauncherView::Image, pm ); | 294 | v->setBackgroundType( LauncherView::Image, pm ); |
295 | } else if ( bgType == "SolidColor" ) { | 295 | } else if ( bgType == "SolidColor" ) { |
296 | QString c = cfg.readEntry( "BackgroundColor" ); | 296 | QString c = cfg.readEntry( "BackgroundColor" ); |
297 | v->setBackgroundType( LauncherView::SolidColor, c ); | 297 | v->setBackgroundType( LauncherView::SolidColor, c ); |
298 | } | 298 | } |
299 | QString textCol = cfg.readEntry( "TextColor" ); | 299 | QString textCol = cfg.readEntry( "TextColor" ); |
300 | if ( textCol.isEmpty() ) | 300 | if ( textCol.isEmpty() ) |
301 | v->setTextColor( QColor() ); | 301 | v->setTextColor( QColor() ); |
302 | else | 302 | else |
303 | v->setTextColor( QColor(textCol) ); | 303 | v->setTextColor( QColor(textCol) ); |
304 | QStringList font = cfg.readListEntry( "Font", ',' ); | 304 | QStringList font = cfg.readListEntry( "Font", ',' ); |
305 | if ( font.count() == 4 ) | 305 | if ( font.count() == 4 ) |
306 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 306 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
307 | 307 | ||
308 | // Tabs | 308 | // Tabs |
309 | QString tabCol = cfg.readEntry( "TabColor" ); | 309 | QString tabCol = cfg.readEntry( "TabColor" ); |
310 | if ( tabCol.isEmpty() ) | 310 | if ( tabCol.isEmpty() ) |
311 | tab->bgColor = QColor(); | 311 | tab->bgColor = QColor(); |
312 | else | 312 | else |
313 | tab->bgColor = QColor(tabCol); | 313 | tab->bgColor = QColor(tabCol); |
314 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 314 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
315 | if ( tabTextCol.isEmpty() ) | 315 | if ( tabTextCol.isEmpty() ) |
316 | tab->fgColor = QColor(); | 316 | tab->fgColor = QColor(); |
317 | else | 317 | else |
318 | tab->fgColor = QColor(tabTextCol); | 318 | tab->fgColor = QColor(tabTextCol); |
319 | } | 319 | } |
320 | 320 | ||
321 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 321 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
322 | { | 322 | { |
323 | docview->populate( docFolder, QString::null ); | 323 | docview->populate( docFolder, QString::null ); |
324 | docFolder->detachChildren(); | 324 | docFolder->detachChildren(); |
325 | docview->setFileSystems(fs); | 325 | docview->setFileSystems(fs); |
326 | docview->updateTools(); | 326 | docview->updateTools(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void CategoryTabWidget::tabProperties() | 329 | void CategoryTabWidget::tabProperties() |
330 | { | 330 | { |
331 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); | 331 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); |
332 | QPopupMenu *m = new QPopupMenu( this ); | 332 | QPopupMenu *m = new QPopupMenu( this ); |
333 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 333 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
334 | m->insertItem( tr("List View"), LauncherView::List ); | 334 | m->insertItem( tr("List View"), LauncherView::List ); |
335 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 335 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
336 | int rv = m->exec( QCursor::pos() ); | 336 | int rv = m->exec( QCursor::pos() ); |
337 | if ( rv >= 0 && rv != view->viewMode() ) { | 337 | if ( rv >= 0 && rv != view->viewMode() ) { |
338 | view->setViewMode( (LauncherView::ViewMode)rv ); | 338 | view->setViewMode( (LauncherView::ViewMode)rv ); |
339 | } | 339 | } |
340 | 340 | ||
341 | delete m; | 341 | delete m; |
342 | } | 342 | } |
343 | 343 | ||
344 | QString CategoryTabWidget::getAllDocLinkInfo() const | 344 | QString CategoryTabWidget::getAllDocLinkInfo() const |
345 | { | 345 | { |
346 | return docview->getAllDocLinkInfo(); | 346 | return docview->getAllDocLinkInfo(); |
347 | } | 347 | } |
348 | 348 | ||
349 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 349 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
350 | { | 350 | { |
351 | LauncherView* view = new LauncherView( stack ); | 351 | LauncherView* view = new LauncherView( stack ); |
352 | connect( view, SIGNAL(clicked(const AppLnk*)), | 352 | connect( view, SIGNAL(clicked(const AppLnk*)), |
353 | this, SIGNAL(clicked(const AppLnk*))); | 353 | this, SIGNAL(clicked(const AppLnk*))); |
354 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 354 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
355 | this, SIGNAL(rightPressed(AppLnk*))); | 355 | this, SIGNAL(rightPressed(AppLnk*))); |
356 | ids.append(id); | 356 | ids.append(id); |
357 | categoryBar->addTab( new CategoryTab( pm, label ) ); | 357 | categoryBar->addTab( new CategoryTab( pm, label ) ); |
358 | stack->addWidget( view, tabs++ ); | 358 | stack->addWidget( view, tabs++ ); |
359 | return view; | 359 | return view; |
360 | } | 360 | } |
361 | 361 | ||
362 | void CategoryTabWidget::updateLink(const QString& linkfile) | 362 | void CategoryTabWidget::updateLink(const QString& linkfile) |
363 | { | 363 | { |
364 | int i=0; | 364 | int i=0; |
365 | LauncherView* view; | 365 | LauncherView* view; |
366 | qApp->processEvents(); | 366 | qApp->processEvents(); |
367 | while ((view = (LauncherView*)stack->widget(i++))) { | 367 | while ((view = (LauncherView*)stack->widget(i++))) { |
368 | if ( view->removeLink(linkfile) ) | 368 | if ( view->removeLink(linkfile) ) |
369 | break; | 369 | break; |
370 | } | 370 | } |
371 | addItem(linkfile); | 371 | addItem(linkfile); |
372 | docview->updateTools(); | 372 | docview->updateTools(); |
373 | } | 373 | } |
374 | 374 | ||
375 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 375 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
376 | { | 376 | { |
377 | QVBox::paletteChange( p ); | 377 | QVBox::paletteChange( p ); |
378 | QPalette pal = palette(); | 378 | QPalette pal = palette(); |
379 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 379 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
380 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 380 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
381 | categoryBar->setPalette( pal ); | 381 | categoryBar->setPalette( pal ); |
382 | categoryBar->update(); | 382 | categoryBar->update(); |
383 | } | 383 | } |
384 | 384 | ||
385 | void CategoryTabWidget::setBusy(bool on) | 385 | void CategoryTabWidget::setBusy(bool on) |
386 | { | 386 | { |
387 | if ( on ) | 387 | if ( on ) |
388 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 388 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
389 | else | 389 | else |
390 | for (int i=0; i<tabs; i++) | 390 | for (int i=0; i<tabs; i++) |
391 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 391 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
392 | } | 392 | } |
393 | 393 | ||
394 | LauncherView *CategoryTabWidget::view( const QString &id ) | 394 | LauncherView *CategoryTabWidget::view( const QString &id ) |
395 | { | 395 | { |
396 | int idx = ids.findIndex( id ); | 396 | int idx = ids.findIndex( id ); |
397 | return (LauncherView *)stack->widget(idx); | 397 | return (LauncherView *)stack->widget(idx); |
398 | } | 398 | } |
399 | 399 | ||
400 | void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) | 400 | void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) |
401 | { | 401 | { |
402 | for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) | 402 | for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) |
403 | view ( *it )-> setBusyIndicatorType ( type ); | 403 | view ( *it )-> setBusyIndicatorType ( type ); |
404 | } | 404 | } |
405 | 405 | ||
406 | //=========================================================================== | 406 | //=========================================================================== |
407 | 407 | ||
408 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 408 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
409 | : QTabBar( parent, name ) | 409 | : QTabBar( parent, name ) |
410 | { | 410 | { |
411 | setFocusPolicy( NoFocus ); | 411 | setFocusPolicy( NoFocus ); |
412 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 412 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
413 | } | 413 | } |
414 | 414 | ||
415 | CategoryTabBar::~CategoryTabBar() | 415 | CategoryTabBar::~CategoryTabBar() |
416 | { | 416 | { |
417 | } | 417 | } |
418 | 418 | ||
419 | void CategoryTabBar::layoutTabs() | 419 | void CategoryTabBar::layoutTabs() |
420 | { | 420 | { |
421 | if ( !count() ) | 421 | if ( !count() ) |
422 | return; | 422 | return; |
423 | 423 | ||
424 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 424 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
425 | int available = width()-1; | 425 | int available = width()-1; |
426 | QFontMetrics fm = fontMetrics(); | 426 | QFontMetrics fm = fontMetrics(); |
427 | int hiddenTabWidth = -7; | 427 | int hiddenTabWidth = -7; |
428 | int middleTab = currentTab(); | 428 | int middleTab = currentTab(); |
429 | int hframe, vframe, overlap; | 429 | int hframe, vframe, overlap; |
430 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 430 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
431 | int x = 0; | 431 | int x = 0; |
432 | QRect r; | 432 | QRect r; |
433 | QTab *t; | 433 | QTab *t; |
434 | int required = 0; | 434 | int required = 0; |
435 | int eventabwidth = (width()-1)/count(); | 435 | int eventabwidth = (width()-1)/count(); |
436 | enum Mode { HideBackText, Pack, Even } mode=Even; | 436 | enum Mode { HideBackText, Pack, Even } mode=Even; |
437 | for ( int i = 0; i < count(); i++ ) { | 437 | for ( int i = 0; i < count(); i++ ) { |
438 | t = tab(i); | 438 | t = tab(i); |
439 | int iw = fm.width( t->text() ) + hframe - overlap; | 439 | int iw = fm.width( t->text() ) + hframe - overlap; |
440 | if ( i != middleTab ) { | 440 | if ( i != middleTab ) { |
441 | available -= hiddenTabWidth + hframe - overlap; | 441 | available -= hiddenTabWidth + hframe - overlap; |
442 | if ( t->iconSet() != 0 ) | 442 | if ( t->iconSet() != 0 ) |
443 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 443 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
444 | } | 444 | } |
445 | if ( t->iconSet() != 0 ) | 445 | if ( t->iconSet() != 0 ) |
446 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 446 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
447 | required += iw; | 447 | required += iw; |
448 | // As space gets tight, packed looks better than even. "10" must be at least 0. | 448 | // As space gets tight, packed looks better than even. "10" must be at least 0. |
449 | if ( iw >= eventabwidth-10 ) | 449 | if ( iw >= eventabwidth-10 ) |
450 | mode = Pack; | 450 | mode = Pack; |
451 | } | 451 | } |
452 | if ( mode == Pack && required > width()-1 ) | 452 | if ( mode == Pack && required > width()-1 ) |
453 | mode = HideBackText; | 453 | mode = HideBackText; |
454 | for ( int i = 0; i < count(); i++ ) { | 454 | for ( int i = 0; i < count(); i++ ) { |
455 | t = tab(i); | 455 | t = tab(i); |
456 | if ( mode != HideBackText ) { | 456 | if ( mode != HideBackText ) { |
457 | int w = fm.width( t->text() ); | 457 | int w = fm.width( t->text() ); |
458 | int ih = 0; | 458 | int ih = 0; |
459 | if ( t->iconSet() != 0 ) { | 459 | if ( t->iconSet() != 0 ) { |
460 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 460 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
461 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 461 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
462 | } | 462 | } |
463 | int h = QMAX( fm.height(), ih ); | 463 | int h = QMAX( fm.height(), ih ); |
464 | h = QMAX( h, QApplication::globalStrut().height() ); | 464 | h = QMAX( h, QApplication::globalStrut().height() ); |
465 | 465 | ||
466 | h += vframe; | 466 | h += vframe; |
467 | w += hframe; | 467 | w += hframe; |
468 | 468 | ||
469 | QRect tr(x, 0, | 469 | QRect tr(x, 0, |
470 | mode == Even ? eventabwidth : w * (width()-1)/required, h); | 470 | mode == Even ? eventabwidth : w * (width()-1)/required, h); |
471 | t->setRect(tr); | 471 | t->setRect(tr); |
472 | x += tr.width() - overlap; | 472 | x += tr.width() - overlap; |
473 | r = r.unite(tr); | 473 | r = r.unite(tr); |
474 | } else if ( i != middleTab ) { | 474 | } else if ( i != middleTab ) { |
475 | int w = hiddenTabWidth; | 475 | int w = hiddenTabWidth; |
476 | int ih = 0; | 476 | int ih = 0; |
477 | if ( t->iconSet() != 0 ) { | 477 | if ( t->iconSet() != 0 ) { |
478 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 478 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
479 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 479 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
480 | } | 480 | } |
481 | int h = QMAX( fm.height(), ih ); | 481 | int h = QMAX( fm.height(), ih ); |
482 | h = QMAX( h, QApplication::globalStrut().height() ); | 482 | h = QMAX( h, QApplication::globalStrut().height() ); |
483 | 483 | ||
484 | h += vframe; | 484 | h += vframe; |
485 | w += hframe; | 485 | w += hframe; |
486 | 486 | ||
487 | t->setRect( QRect(x, 0, w, h) ); | 487 | t->setRect( QRect(x, 0, w, h) ); |
488 | x += t->rect().width() - overlap; | 488 | x += t->rect().width() - overlap; |
489 | r = r.unite( t->rect() ); | 489 | r = r.unite( t->rect() ); |
490 | } else { | 490 | } else { |
491 | int ih = 0; | 491 | int ih = 0; |
492 | if ( t->iconSet() != 0 ) { | 492 | if ( t->iconSet() != 0 ) { |
493 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 493 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
494 | } | 494 | } |
495 | int h = QMAX( fm.height(), ih ); | 495 | int h = QMAX( fm.height(), ih ); |
496 | h = QMAX( h, QApplication::globalStrut().height() ); | 496 | h = QMAX( h, QApplication::globalStrut().height() ); |
497 | 497 | ||
498 | h += vframe; | 498 | h += vframe; |
499 | 499 | ||
500 | t->setRect( QRect(x, 0, available, h) ); | 500 | t->setRect( QRect(x, 0, available, h) ); |
501 | x += t->rect().width() - overlap; | 501 | x += t->rect().width() - overlap; |
502 | r = r.unite( t->rect() ); | 502 | r = r.unite( t->rect() ); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | QRect rr = tab(count()-1)->rect(); | 506 | QRect rr = tab(count()-1)->rect(); |
507 | rr.setRight(width()-1); | 507 | rr.setRight(width()-1); |
508 | tab(count()-1)->setRect( rr ); | 508 | tab(count()-1)->setRect( rr ); |
509 | 509 | ||
510 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 510 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
511 | QRect tr = t->rect(); | 511 | QRect tr = t->rect(); |
512 | tr.setHeight( r.height() ); | 512 | tr.setHeight( r.height() ); |
513 | t->setRect( tr ); | 513 | t->setRect( tr ); |
514 | } | 514 | } |
515 | 515 | ||
516 | update(); | 516 | update(); |
517 | } | 517 | } |
518 | 518 | ||
519 | 519 | ||
520 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 520 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
521 | { | 521 | { |
522 | CategoryTabBar *that = (CategoryTabBar *) this; | 522 | CategoryTabBar *that = (CategoryTabBar *) this; |
523 | CategoryTab *ct = (CategoryTab *)t; | 523 | CategoryTab *ct = (CategoryTab *)t; |
524 | QPalette pal = palette(); | 524 | QPalette pal = palette(); |
525 | bool setPal = FALSE; | 525 | bool setPal = FALSE; |
526 | if ( ct->bgColor.isValid() ) { | 526 | if ( ct->bgColor.isValid() ) { |
527 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); | 527 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); |
528 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); | 528 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); |
529 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); | 529 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); |
530 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); | 530 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); |
531 | that->setUpdatesEnabled( FALSE ); | 531 | that->setUpdatesEnabled( FALSE ); |
532 | that->setPalette( pal ); | 532 | that->setPalette( pal ); |
533 | setPal = TRUE; | 533 | setPal = TRUE; |
534 | } | 534 | } |
535 | #if QT_VERSION >= 300 | 535 | #if QT_VERSION >= 300 |
536 | QStyle::SFlags flags = QStyle::Style_Default; | 536 | QStyle::SFlags flags = QStyle::Style_Default; |
537 | if ( selected ) | 537 | if ( selected ) |
538 | flags |= QStyle::Style_Selected; | 538 | flags |= QStyle::Style_Selected; |
539 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 539 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
540 | colorGroup(), flags, QStyleOption(t) ); | 540 | colorGroup(), flags, QStyleOption(t) ); |
541 | #else | 541 | #else |
542 | style().drawTab( p, this, t, selected ); | 542 | style().drawTab( p, this, t, selected ); |
543 | #endif | 543 | #endif |
544 | 544 | ||
545 | QRect r( t->rect() ); | 545 | QRect r( t->rect() ); |
546 | QFont f( font() ); | 546 | QFont f( font() ); |
547 | if ( selected ) | 547 | if ( selected ) |
548 | f.setBold( TRUE ); | 548 | f.setBold( TRUE ); |
549 | p->setFont( f ); | 549 | p->setFont( f ); |
550 | 550 | ||
551 | if ( ct->fgColor.isValid() ) { | 551 | if ( ct->fgColor.isValid() ) { |
552 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); | 552 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); |
553 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); | 553 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); |
554 | that->setUpdatesEnabled( FALSE ); | 554 | that->setUpdatesEnabled( FALSE ); |
555 | that->setPalette( pal ); | 555 | that->setPalette( pal ); |
556 | setPal = TRUE; | 556 | setPal = TRUE; |
557 | } | 557 | } |
558 | int iw = 0; | 558 | int iw = 0; |
559 | int ih = 0; | 559 | int ih = 0; |
560 | if ( t->iconSet() != 0 ) { | 560 | if ( t->iconSet() != 0 ) { |
561 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 561 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
562 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 562 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
563 | } | 563 | } |
564 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 564 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
565 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 565 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
566 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 566 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
567 | r.top() + (r.height()-h)/2, w, h ), t, | 567 | r.top() + (r.height()-h)/2, w, h ), t, |
568 | #if QT_VERSION >= 300 | 568 | #if QT_VERSION >= 300 |
569 | t->identifier() == keyboardFocusTab() | 569 | t->identifier() == keyboardFocusTab() |
570 | #else | 570 | #else |
571 | t->identitifer() == keyboardFocusTab() | 571 | t->identitifer() == keyboardFocusTab() |
572 | #endif | 572 | #endif |
573 | ); | 573 | ); |
574 | if ( setPal ) { | 574 | if ( setPal ) { |
575 | that->unsetPalette(); | 575 | that->unsetPalette(); |
576 | that->setUpdatesEnabled( TRUE ); | 576 | that->setUpdatesEnabled( TRUE ); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | 580 | ||
581 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 581 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
582 | QTab* t, bool has_focus ) const | 582 | QTab* t, bool has_focus ) const |
583 | { | 583 | { |
584 | QRect r = t->rect(); | 584 | QRect r = t->rect(); |
585 | // if ( t->id != currentTab() ) | 585 | // if ( t->id != currentTab() ) |
586 | //r.moveBy( 1, 1 ); | 586 | //r.moveBy( 1, 1 ); |
587 | // | 587 | // |
588 | if ( t->iconSet() ) { | 588 | if ( t->iconSet() ) { |
589 | // the tab has an iconset, draw it in the right mode | 589 | // the tab has an iconset, draw it in the right mode |
590 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 590 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
591 | if ( mode == QIconSet::Normal && has_focus ) | 591 | if ( mode == QIconSet::Normal && has_focus ) |
592 | mode = QIconSet::Active; | 592 | mode = QIconSet::Active; |
593 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 593 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
594 | int pixw = pixmap.width(); | 594 | int pixw = pixmap.width(); |
595 | int pixh = pixmap.height(); | 595 | int pixh = pixmap.height(); |
596 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 596 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
597 | r.setLeft( r.left() + pixw + 5 ); | 597 | r.setLeft( r.left() + pixw + 5 ); |
598 | } | 598 | } |
599 | 599 | ||
600 | QRect tr = r; | 600 | QRect tr = r; |
601 | 601 | ||
602 | if ( r.width() < 20 ) | 602 | if ( r.width() < 20 ) |
603 | return; | 603 | return; |
604 | 604 | ||
605 | if ( t->isEnabled() && isEnabled() ) { | 605 | if ( t->isEnabled() && isEnabled() ) { |
606 | #if defined(_WS_WIN32_) | 606 | #if defined(_WS_WIN32_) |
607 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 607 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
608 | p->setPen( colorGroup().buttonText() ); | 608 | p->setPen( colorGroup().buttonText() ); |
609 | else | 609 | else |
610 | p->setPen( colorGroup().foreground() ); | 610 | p->setPen( colorGroup().foreground() ); |
611 | #else | 611 | #else |
612 | p->setPen( colorGroup().foreground() ); | 612 | p->setPen( colorGroup().foreground() ); |
613 | #endif | 613 | #endif |
614 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 614 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
615 | } else { | 615 | } else { |
616 | p->setPen( palette().disabled().foreground() ); | 616 | p->setPen( palette().disabled().foreground() ); |
617 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 617 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | //--------------------------------------------------------------------------- | 621 | //--------------------------------------------------------------------------- |
622 | 622 | ||
623 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 623 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
624 | : QMainWindow( parent, name, fl ) | 624 | : QMainWindow( parent, name, fl ) |
625 | { | 625 | { |
626 | setCaption( tr("Launcher") ); | 626 | setCaption( tr("Launcher") ); |
627 | 627 | ||
628 | syncDialog = 0; | 628 | syncDialog = 0; |
629 | 629 | ||
630 | // we have a pretty good idea how big we'll be | 630 | // we have a pretty good idea how big we'll be |
631 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 631 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
632 | 632 | ||
633 | tabs = 0; | 633 | tabs = 0; |
634 | rootFolder = 0; | 634 | rootFolder = 0; |
635 | docsFolder = 0; | 635 | docsFolder = 0; |
636 | 636 | ||
637 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know | 637 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
638 | //uidgen.store( stamp ); | 638 | //uidgen.store( stamp ); |
639 | m_timeStamp = QString::number( stamp ); | 639 | m_timeStamp = QString::number( stamp ); |
640 | 640 | ||
641 | tabs = new CategoryTabWidget( this ); | 641 | tabs = new CategoryTabWidget( this ); |
642 | setCentralWidget( tabs ); | 642 | setCentralWidget( tabs ); |
643 | 643 | ||
644 | connect( tabs, SIGNAL(selected(const QString&)), | 644 | connect( tabs, SIGNAL(selected(const QString&)), |
645 | this, SLOT(viewSelected(const QString&)) ); | 645 | this, SLOT(viewSelected(const QString&)) ); |
646 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 646 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
647 | this, SLOT(select(const AppLnk*))); | 647 | this, SLOT(select(const AppLnk*))); |
648 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 648 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
649 | this, SLOT(properties(AppLnk*))); | 649 | this, SLOT(properties(AppLnk*))); |
650 | 650 | ||
651 | #if !defined(QT_NO_COP) | 651 | #if !defined(QT_NO_COP) |
652 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 652 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
653 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 653 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
654 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 654 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
655 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 655 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
656 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 656 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
657 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); | 657 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); |
658 | #endif | 658 | #endif |
659 | 659 | ||
660 | storage = new StorageInfo( this ); | 660 | storage = new StorageInfo( this ); |
661 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 661 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
662 | 662 | ||
663 | updateTabs(); | 663 | updateTabs(); |
664 | 664 | ||
665 | preloadApps(); | 665 | preloadApps(); |
666 | 666 | ||
667 | in_lnk_props = FALSE; | 667 | in_lnk_props = FALSE; |
668 | got_lnk_change = FALSE; | 668 | got_lnk_change = FALSE; |
669 | } | 669 | } |
670 | 670 | ||
671 | Launcher::~Launcher() | 671 | Launcher::~Launcher() |
672 | { | 672 | { |
673 | delete rootFolder; | 673 | delete rootFolder; |
674 | delete docsFolder; | 674 | delete docsFolder; |
675 | } | 675 | } |
676 | 676 | ||
677 | static bool isVisibleWindow(int wid) | 677 | static bool isVisibleWindow(int wid) |
678 | { | 678 | { |
679 | #ifdef QWS | 679 | #ifdef QWS |
680 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 680 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
681 | QWSWindow* w; | 681 | QWSWindow* w; |
682 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 682 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
683 | if ( w->winId() == wid ) | 683 | if ( w->winId() == wid ) |
684 | return !w->isFullyObscured(); | 684 | return !w->isFullyObscured(); |
685 | } | 685 | } |
686 | #endif | 686 | #endif |
687 | return FALSE; | 687 | return FALSE; |
688 | } | 688 | } |
689 | 689 | ||
690 | void Launcher::showMaximized() | 690 | void Launcher::showMaximized() |
691 | { | 691 | { |
692 | if ( isVisibleWindow( winId() ) ) | 692 | if ( isVisibleWindow( winId() ) ) |
693 | doMaximize(); | 693 | doMaximize(); |
694 | else | 694 | else |
695 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 695 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
696 | } | 696 | } |
697 | 697 | ||
698 | void Launcher::doMaximize() | 698 | void Launcher::doMaximize() |
699 | { | 699 | { |
700 | QMainWindow::showMaximized(); | 700 | QMainWindow::showMaximized(); |
701 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 701 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
702 | } | 702 | } |
703 | 703 | ||
704 | void Launcher::updateMimeTypes() | 704 | void Launcher::updateMimeTypes() |
705 | { | 705 | { |
706 | MimeType::clear(); | 706 | MimeType::clear(); |
707 | updateMimeTypes(rootFolder); | 707 | updateMimeTypes(rootFolder); |
708 | } | 708 | } |
709 | 709 | ||
710 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 710 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
711 | { | 711 | { |
712 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 712 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
713 | AppLnk *app = it.current(); | 713 | AppLnk *app = it.current(); |
714 | if ( app->type() == "Folder" ) // No tr | 714 | if ( app->type() == "Folder" ) // No tr |
715 | updateMimeTypes((AppLnkSet *)app); | 715 | updateMimeTypes((AppLnkSet *)app); |
716 | else { | 716 | else { |
717 | MimeType::registerApp(*app); | 717 | MimeType::registerApp(*app); |
718 | } | 718 | } |
719 | } | 719 | } |
720 | } | 720 | } |
721 | 721 | ||
722 | /** This is a HACK.... | 722 | /** This is a HACK.... |
723 | * Reason: scanning huge mediums, microdirvers for examples | 723 | * Reason: scanning huge mediums, microdirvers for examples |
724 | * consomes time. To avoid that we invented the MediumMountCheck | 724 | * consomes time. To avoid that we invented the MediumMountCheck |
725 | * | 725 | * |
726 | * a) the user globally disabled medium checking. We can ignore | 726 | * a) the user globally disabled medium checking. We can ignore |
727 | * all removable medium | 727 | * all removable medium |
728 | * b) the user enabled medium checking globally and we need to use this mimefilter | 728 | * b) the user enabled medium checking globally and we need to use this mimefilter |
729 | * c) the user enabled medium checking on a per medium bases | 729 | * c) the user enabled medium checking on a per medium bases |
730 | * c1) we already checked and its not ask again turns | 730 | * c1) we already checked and its not ask again turns |
731 | * c2) we need to ask and then apply the mimefilter | 731 | * c2) we need to ask and then apply the mimefilter |
732 | */ | 732 | */ |
733 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 733 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
734 | { | 734 | { |
735 | 735 | ||
736 | OWait *owait = new OWait(); | 736 | OWait *owait = new OWait(); |
737 | Global::statusMessage( tr( "Finding documents" ) ); | 737 | Global::statusMessage( tr( "Finding documents" ) ); |
738 | 738 | ||
739 | owait->show(); | 739 | owait->show(); |
740 | qApp->processEvents(); | 740 | qApp->processEvents(); |
741 | 741 | ||
742 | delete docsFolder; | 742 | delete docsFolder; |
743 | docsFolder = new DocLnkSet; | 743 | docsFolder = new DocLnkSet; |
744 | 744 | ||
745 | DocLnkSet *tmp = 0; | 745 | DocLnkSet *tmp = 0; |
746 | QString home = QString(getenv("HOME")) + "/Documents"; | 746 | QString home = QString(getenv("HOME")) + "/Documents"; |
747 | tmp = new DocLnkSet( home , QString::null); | 747 | tmp = new DocLnkSet( home , QString::null); |
748 | docsFolder->appendFrom( *tmp ); | 748 | docsFolder->appendFrom( *tmp ); |
749 | delete tmp; | 749 | delete tmp; |
750 | 750 | ||
751 | // RAM documents | 751 | // RAM documents |
752 | StorageInfo storage; | 752 | StorageInfo storage; |
753 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 753 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
754 | QListIterator<FileSystem> it ( fileSystems ); | 754 | QListIterator<FileSystem> it ( fileSystems ); |
755 | 755 | ||
756 | for ( ; it.current(); ++it ) { | 756 | for ( ; it.current(); ++it ) { |
757 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 757 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
758 | tmp = new DocLnkSet( (*it)->path(), QString::null ); | 758 | tmp = new DocLnkSet( (*it)->path(), QString::null ); |
759 | docsFolder->appendFrom( *tmp ); | 759 | docsFolder->appendFrom( *tmp ); |
760 | delete tmp; | 760 | delete tmp; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | Config mediumCfg( "medium"); | 764 | Config mediumCfg( "medium"); |
765 | mediumCfg.setGroup("main"); | 765 | mediumCfg.setGroup("main"); |
766 | // a) -zecke we don't want to check | 766 | // a) -zecke we don't want to check |
767 | if(!mediumCfg.readBoolEntry("use", true ) ) | 767 | if(!mediumCfg.readBoolEntry("use", true ) ) |
768 | return; | 768 | return; |
769 | 769 | ||
770 | // find out wich filesystems are new in this round | 770 | // find out wich filesystems are new in this round |
771 | // We will do this by having a timestamp inside each mountpoint | 771 | // We will do this by having a timestamp inside each mountpoint |
772 | // if the current timestamp doesn't match this is a new file system and | 772 | // if the current timestamp doesn't match this is a new file system and |
773 | // come up with our MediumMountGui :) let the hacking begin | 773 | // come up with our MediumMountGui :) let the hacking begin |
774 | int stamp = uidgen.generate(); | 774 | int stamp = uidgen.generate(); |
775 | 775 | ||
776 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 776 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
777 | 777 | ||
778 | // b) | 778 | // b) |
779 | if( mediumCfg.readBoolEntry("global", true ) ){ | 779 | if( mediumCfg.readBoolEntry("global", true ) ){ |
780 | QString mime = configToMime(&mediumCfg).join(";"); | 780 | QString mime = configToMime(&mediumCfg).join(";"); |
781 | for( it.toFirst(); it.current(); ++it ){ | 781 | for( it.toFirst(); it.current(); ++it ){ |
782 | if( (*it)->isRemovable() ){ | 782 | if( (*it)->isRemovable() ){ |
783 | tmp = new DocLnkSet( (*it)->path(), mime ); | 783 | tmp = new DocLnkSet( (*it)->path(), mime ); |
784 | docsFolder->appendFrom( *tmp ); | 784 | docsFolder->appendFrom( *tmp ); |
785 | delete tmp; | 785 | delete tmp; |
786 | } | 786 | } |
787 | } // done | 787 | } // done |
788 | return; // save the else | 788 | return; // save the else |
789 | } | 789 | } |
790 | // c) zecke | 790 | // c) zecke |
791 | for ( it.toFirst(); it.current(); ++it ) { | 791 | for ( it.toFirst(); it.current(); ++it ) { |
792 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 792 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
793 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); | 793 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); |
794 | cfg.setGroup("main"); | 794 | cfg.setGroup("main"); |
795 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 795 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
796 | /** This medium is uptodate | 796 | /** This medium is uptodate |
797 | */ | 797 | */ |
798 | if( stamp == m_timeStamp ){ // ok we know this card | 798 | if( stamp == m_timeStamp ){ // ok we know this card |
799 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp | 799 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
800 | // we need to scan the list now. Hopefully the cache will be there | 800 | // we need to scan the list now. Hopefully the cache will be there |
801 | // read the mimetypes from the config and search for documents | 801 | // read the mimetypes from the config and search for documents |
802 | QStringList mimetypes = configToMime( &cfg); | 802 | QStringList mimetypes = configToMime( &cfg); |
803 | qApp->processEvents(); | 803 | //qApp->processEvents(); |
804 | Global::statusMessage( tr( "Searching documents" ) ); | 804 | Global::statusMessage( tr( "Searching documents" ) ); |
805 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | 805 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); |
806 | docsFolder->appendFrom( *tmp ); | 806 | docsFolder->appendFrom( *tmp ); |
807 | delete tmp; | 807 | delete tmp; |
808 | 808 | ||
809 | }else{ // come up with the gui cause this a new card | 809 | }else{ // come up with the gui cause this a new card |
810 | MediumMountGui medium(&cfg, (*it)->path() ); | 810 | MediumMountGui medium(&cfg, (*it)->path() ); |
811 | if( medium.check() ){ // we did not ask before or ask again is off | 811 | if( medium.check() ){ // we did not ask before or ask again is off |
812 | /** c2) */ | 812 | /** c2) */ |
813 | if( medium.exec() ){ // he clicked yes so search it | 813 | if( medium.exec() ){ // he clicked yes so search it |
814 | // speicher | 814 | // speicher |
815 | //cfg.read(); // cause of a race we need to reread - fixed | 815 | //cfg.read(); // cause of a race we need to reread - fixed |
816 | cfg.setGroup("main"); | 816 | cfg.setGroup("main"); |
817 | cfg.writeEntry("timestamp", newStamp ); | 817 | cfg.writeEntry("timestamp", newStamp ); |
818 | cfg.write(); | 818 | cfg.write(); |
819 | 819 | ||
820 | qApp->processEvents(); | 820 | //qApp->processEvents(); |
821 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); | 821 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); |
822 | docsFolder->appendFrom( *tmp ); | 822 | docsFolder->appendFrom( *tmp ); |
823 | delete tmp; | 823 | delete tmp; |
824 | }// no else | 824 | }// no else |
825 | /** c1) */ | 825 | /** c1) */ |
826 | }else{ // we checked | 826 | }else{ // we checked |
827 | // do something different see what we need to do | 827 | // do something different see what we need to do |
828 | // let's see if we should check the device | 828 | // let's see if we should check the device |
829 | cfg.setGroup("main" ); | 829 | cfg.setGroup("main" ); |
830 | bool check = cfg.readBoolEntry("autocheck", true ); | 830 | bool check = cfg.readBoolEntry("autocheck", true ); |
831 | if( check ){ // find the documents | 831 | if( check ){ // find the documents |
832 | 832 | ||
833 | qApp->processEvents(); | 833 | //qApp->processEvents(); |
834 | Global::statusMessage( tr( "Searching documents" ) ); | 834 | Global::statusMessage( tr( "Searching documents" ) ); |
835 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 835 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
836 | docsFolder->appendFrom( *tmp ); | 836 | docsFolder->appendFrom( *tmp ); |
837 | delete tmp; | 837 | delete tmp; |
838 | } | 838 | } |
839 | } | 839 | } |
840 | } | 840 | } |
841 | } | 841 | } |
842 | } | 842 | } |
843 | m_timeStamp = newStamp; | 843 | m_timeStamp = newStamp; |
844 | owait->hide(); | 844 | owait->hide(); |
845 | delete owait; | 845 | delete owait; |
846 | } | 846 | } |
847 | 847 | ||
848 | void Launcher::updateTabs() | 848 | void Launcher::updateTabs() |
849 | { | 849 | { |
850 | MimeType::updateApplications(); // ### reads all applnks twice | 850 | MimeType::updateApplications(); // ### reads all applnks twice |
851 | 851 | ||
852 | delete rootFolder; | 852 | delete rootFolder; |
853 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 853 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
854 | 854 | ||
855 | loadDocs(); | 855 | loadDocs(); |
856 | 856 | ||
857 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 857 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
858 | } | 858 | } |
859 | 859 | ||
860 | void Launcher::updateDocs() | 860 | void Launcher::updateDocs() |
861 | { | 861 | { |
862 | loadDocs(); | 862 | loadDocs(); |
863 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 863 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
864 | } | 864 | } |
865 | 865 | ||
866 | void Launcher::viewSelected(const QString& s) | 866 | void Launcher::viewSelected(const QString& s) |
867 | { | 867 | { |
868 | setCaption( s + tr(" - Launcher") ); | 868 | setCaption( s + tr(" - Launcher") ); |
869 | } | 869 | } |
870 | 870 | ||
871 | void Launcher::nextView() | 871 | void Launcher::nextView() |
872 | { | 872 | { |
873 | tabs->nextTab(); | 873 | tabs->nextTab(); |
874 | } | 874 | } |
875 | 875 | ||
876 | void Launcher::showTab(const QString& id) | 876 | void Launcher::showTab(const QString& id) |
877 | { | 877 | { |
878 | tabs->showTab(id); | 878 | tabs->showTab(id); |
879 | raise(); | 879 | raise(); |
880 | } | 880 | } |
881 | 881 | ||
882 | void Launcher::select( const AppLnk *appLnk ) | 882 | void Launcher::select( const AppLnk *appLnk ) |
883 | { | 883 | { |
884 | if ( appLnk->type() == "Folder" ) { // No tr | 884 | if ( appLnk->type() == "Folder" ) { // No tr |
885 | // Not supported: flat is simpler for the user | 885 | // Not supported: flat is simpler for the user |
886 | } else { | 886 | } else { |
887 | if ( appLnk->exec().isNull() ) { | 887 | if ( appLnk->exec().isNull() ) { |
888 | QMessageBox::information(this,tr("No application"), | 888 | QMessageBox::information(this,tr("No application"), |
889 | tr("<p>No application is defined for this document." | 889 | tr("<p>No application is defined for this document." |
890 | "<p>Type is %1.").arg(appLnk->type())); | 890 | "<p>Type is %1.").arg(appLnk->type())); |
891 | return; | 891 | return; |
892 | } | 892 | } |
893 | tabs->setBusy(TRUE); | 893 | tabs->setBusy(TRUE); |
894 | emit executing( appLnk ); | 894 | emit executing( appLnk ); |
895 | appLnk->execute(); | 895 | appLnk->execute(); |
896 | } | 896 | } |
897 | } | 897 | } |
898 | 898 | ||
899 | void Launcher::externalSelected(const AppLnk *appLnk) | 899 | void Launcher::externalSelected(const AppLnk *appLnk) |
900 | { | 900 | { |
901 | tabs->setBusy(TRUE); | 901 | tabs->setBusy(TRUE); |
902 | emit executing( appLnk ); | 902 | emit executing( appLnk ); |
903 | } | 903 | } |
904 | 904 | ||
905 | void Launcher::properties( AppLnk *appLnk ) | 905 | void Launcher::properties( AppLnk *appLnk ) |
906 | { | 906 | { |
907 | if ( appLnk->type() == "Folder" ) { // No tr | 907 | if ( appLnk->type() == "Folder" ) { // No tr |
908 | // Not supported: flat is simpler for the user | 908 | // Not supported: flat is simpler for the user |
909 | } else { | 909 | } else { |
910 | in_lnk_props = TRUE; | 910 | in_lnk_props = TRUE; |
911 | got_lnk_change = FALSE; | 911 | got_lnk_change = FALSE; |
912 | LnkProperties prop(appLnk); | 912 | LnkProperties prop(appLnk); |
913 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 913 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
914 | prop.showMaximized(); | 914 | prop.showMaximized(); |
915 | prop.exec(); | 915 | prop.exec(); |
916 | in_lnk_props = FALSE; | 916 | in_lnk_props = FALSE; |
917 | if ( got_lnk_change ) { | 917 | if ( got_lnk_change ) { |
918 | updateLink(lnk_change); | 918 | updateLink(lnk_change); |
919 | } | 919 | } |
920 | } | 920 | } |
921 | } | 921 | } |
922 | 922 | ||
923 | void Launcher::updateLink(const QString& link) | 923 | void Launcher::updateLink(const QString& link) |
924 | { | 924 | { |
925 | bool notify_sm = false; | 925 | bool notify_sm = false; |
926 | 926 | ||
927 | if (link.isNull()) { | 927 | if (link.isNull()) { |
928 | updateTabs(); | 928 | updateTabs(); |
929 | notify_sm = true; | 929 | notify_sm = true; |
930 | } | 930 | } |
931 | else if (link.isEmpty()) { | 931 | else if (link.isEmpty()) { |
932 | updateDocs(); | 932 | updateDocs(); |
933 | } | 933 | } |
934 | else { | 934 | else { |
935 | tabs->updateLink(link); | 935 | tabs->updateLink(link); |
936 | notify_sm = true; | 936 | notify_sm = true; |
937 | } | 937 | } |
938 | 938 | ||
939 | if ( notify_sm ) | 939 | if ( notify_sm ) |
940 | QCopEnvelope e ( "QPE/TaskBar", "reloadApps()" ); | 940 | QCopEnvelope e ( "QPE/TaskBar", "reloadApps()" ); |
941 | } | 941 | } |
942 | 942 | ||
943 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 943 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
944 | { | 944 | { |
945 | QDataStream stream( data, IO_ReadOnly ); | 945 | QDataStream stream( data, IO_ReadOnly ); |
946 | if ( msg == "linkChanged(QString)" ) { | 946 | if ( msg == "linkChanged(QString)" ) { |
947 | QString link; | 947 | QString link; |
948 | stream >> link; | 948 | stream >> link; |
949 | if ( in_lnk_props ) { | 949 | if ( in_lnk_props ) { |
950 | got_lnk_change = TRUE; | 950 | got_lnk_change = TRUE; |
951 | lnk_change = link; | 951 | lnk_change = link; |
952 | } else { | 952 | } else { |
953 | updateLink(link); | 953 | updateLink(link); |
954 | } | 954 | } |
955 | } else if ( msg == "busy()" ) { | 955 | } else if ( msg == "busy()" ) { |
956 | emit busy(); | 956 | emit busy(); |
957 | } else if ( msg == "notBusy(QString)" ) { | 957 | } else if ( msg == "notBusy(QString)" ) { |
958 | QString app; | 958 | QString app; |
959 | stream >> app; | 959 | stream >> app; |
960 | tabs->setBusy(FALSE); | 960 | tabs->setBusy(FALSE); |
961 | emit notBusy(app); | 961 | emit notBusy(app); |
962 | } else if ( msg == "mkdir(QString)" ) { | 962 | } else if ( msg == "mkdir(QString)" ) { |
963 | QString dir; | 963 | QString dir; |
964 | stream >> dir; | 964 | stream >> dir; |
965 | if ( !dir.isEmpty() ) | 965 | if ( !dir.isEmpty() ) |
966 | mkdir( dir ); | 966 | mkdir( dir ); |
967 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 967 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
968 | QString baseFile, sigFile; | 968 | QString baseFile, sigFile; |
969 | stream >> baseFile >> sigFile; | 969 | stream >> baseFile >> sigFile; |
970 | QRsync::generateSignature( baseFile, sigFile ); | 970 | QRsync::generateSignature( baseFile, sigFile ); |
971 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 971 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
972 | QString baseFile, sigFile, deltaFile; | 972 | QString baseFile, sigFile, deltaFile; |
973 | stream >> baseFile >> sigFile >> deltaFile; | 973 | stream >> baseFile >> sigFile >> deltaFile; |
974 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 974 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
975 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 975 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
976 | QString baseFile, deltaFile; | 976 | QString baseFile, deltaFile; |
977 | stream >> baseFile >> deltaFile; | 977 | stream >> baseFile >> deltaFile; |
978 | if ( !QFile::exists( baseFile ) ) { | 978 | if ( !QFile::exists( baseFile ) ) { |
979 | QFile f( baseFile ); | 979 | QFile f( baseFile ); |
980 | f.open( IO_WriteOnly ); | 980 | f.open( IO_WriteOnly ); |
981 | f.close(); | 981 | f.close(); |
982 | } | 982 | } |
983 | QRsync::applyDiff( baseFile, deltaFile ); | 983 | QRsync::applyDiff( baseFile, deltaFile ); |
984 | #ifndef QT_NO_COP | 984 | #ifndef QT_NO_COP |
985 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 985 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
986 | e << baseFile; | 986 | e << baseFile; |
987 | #endif | 987 | #endif |
988 | } else if ( msg == "rdiffCleanup()" ) { | 988 | } else if ( msg == "rdiffCleanup()" ) { |
989 | mkdir( "/tmp/rdiff" ); | 989 | mkdir( "/tmp/rdiff" ); |
990 | QDir dir; | 990 | QDir dir; |
991 | dir.setPath( "/tmp/rdiff" ); | 991 | dir.setPath( "/tmp/rdiff" ); |
992 | QStringList entries = dir.entryList(); | 992 | QStringList entries = dir.entryList(); |
993 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 993 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
994 | dir.remove( *it ); | 994 | dir.remove( *it ); |
995 | } else if ( msg == "sendHandshakeInfo()" ) { | 995 | } else if ( msg == "sendHandshakeInfo()" ) { |
996 | QString home = getenv( "HOME" ); | 996 | QString home = getenv( "HOME" ); |
997 | #ifndef QT_NO_COP | 997 | #ifndef QT_NO_COP |
998 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 998 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
999 | e << home; | 999 | e << home; |
1000 | int locked = (int) Desktop::screenLocked(); | 1000 | int locked = (int) Desktop::screenLocked(); |
1001 | e << locked; | 1001 | e << locked; |
1002 | #endif | 1002 | #endif |
1003 | } else if ( msg == "autoStart(QString)" ) { | 1003 | } else if ( msg == "autoStart(QString)" ) { |
1004 | QString appName; | 1004 | QString appName; |
1005 | stream >> appName; | 1005 | stream >> appName; |
1006 | Config cfg( "autostart" ); | 1006 | Config cfg( "autostart" ); |
1007 | cfg.setGroup( "AutoStart" ); | 1007 | cfg.setGroup( "AutoStart" ); |
1008 | if ( appName.compare("clear") == 0){ | 1008 | if ( appName.compare("clear") == 0){ |
1009 | cfg.writeEntry("Apps", ""); | 1009 | cfg.writeEntry("Apps", ""); |
1010 | } | 1010 | } |
1011 | } else if ( msg == "autoStart(QString,QString)" ) { | 1011 | } else if ( msg == "autoStart(QString,QString)" ) { |
1012 | QString modifier, appName; | 1012 | QString modifier, appName; |
1013 | stream >> modifier >> appName; | 1013 | stream >> modifier >> appName; |
1014 | Config cfg( "autostart" ); | 1014 | Config cfg( "autostart" ); |
1015 | cfg.setGroup( "AutoStart" ); | 1015 | cfg.setGroup( "AutoStart" ); |
1016 | if ( modifier.compare("add") == 0 ){ | 1016 | if ( modifier.compare("add") == 0 ){ |
1017 | // only add if appname is entered | 1017 | // only add if appname is entered |
1018 | if (!appName.isEmpty()) { | 1018 | if (!appName.isEmpty()) { |
1019 | cfg.writeEntry("Apps", appName); | 1019 | cfg.writeEntry("Apps", appName); |
1020 | } | 1020 | } |
1021 | } else if (modifier.compare("remove") == 0 ) { | 1021 | } else if (modifier.compare("remove") == 0 ) { |
1022 | // need to change for multiple entries | 1022 | // need to change for multiple entries |
1023 | // actually remove is right now simular to clear, but in future there | 1023 | // actually remove is right now simular to clear, but in future there |
1024 | // should be multiple apps in autostart possible. | 1024 | // should be multiple apps in autostart possible. |
1025 | QString checkName; | 1025 | QString checkName; |
1026 | checkName = cfg.readEntry("Apps", ""); | 1026 | checkName = cfg.readEntry("Apps", ""); |
1027 | if (checkName == appName) { | 1027 | if (checkName == appName) { |
1028 | cfg.writeEntry("Apps", ""); | 1028 | cfg.writeEntry("Apps", ""); |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | // case the autostart feature should be delayed | 1031 | // case the autostart feature should be delayed |
1032 | } else if ( msg == "autoStart(QString,QString,QString)") { | 1032 | } else if ( msg == "autoStart(QString,QString,QString)") { |
1033 | QString modifier, appName, delay; | 1033 | QString modifier, appName, delay; |
1034 | stream >> modifier >> appName >> delay; | 1034 | stream >> modifier >> appName >> delay; |
1035 | Config cfg( "autostart" ); | 1035 | Config cfg( "autostart" ); |
1036 | cfg.setGroup( "AutoStart" ); | 1036 | cfg.setGroup( "AutoStart" ); |
1037 | if ( modifier.compare("add") == 0 ){ | 1037 | if ( modifier.compare("add") == 0 ){ |
1038 | // only add it appname is entered | 1038 | // only add it appname is entered |
1039 | if (!appName.isEmpty()) { | 1039 | if (!appName.isEmpty()) { |
1040 | cfg.writeEntry("Apps", appName); | 1040 | cfg.writeEntry("Apps", appName); |
1041 | cfg.writeEntry("Delay", delay); | 1041 | cfg.writeEntry("Delay", delay); |
1042 | } | 1042 | } |
1043 | } else { | 1043 | } else { |
1044 | } | 1044 | } |
1045 | } | 1045 | } |
1046 | /* | 1046 | /* |
1047 | * QtopiaDesktop relies on the major number | 1047 | * QtopiaDesktop relies on the major number |
1048 | * to start with 1. We're at 0.9 | 1048 | * to start with 1. We're at 0.9 |
1049 | * so wee need to fake at least 1.4 to be able | 1049 | * so wee need to fake at least 1.4 to be able |
1050 | * to sync with QtopiaDesktop1.6 | 1050 | * to sync with QtopiaDesktop1.6 |
1051 | */ | 1051 | */ |
1052 | else if ( msg == "sendVersionInfo()" ) { | 1052 | else if ( msg == "sendVersionInfo()" ) { |
1053 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); | 1053 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); |
1054 | QString v2 = QString::fromLatin1("1.4"); | 1054 | QString v2 = QString::fromLatin1("1.4"); |
1055 | e << v2; | 1055 | e << v2; |
1056 | //qDebug("version %s\n", line.latin1()); | 1056 | //qDebug("version %s\n", line.latin1()); |
1057 | } else if ( msg == "sendCardInfo()" ) { | 1057 | } else if ( msg == "sendCardInfo()" ) { |
1058 | #ifndef QT_NO_COP | 1058 | #ifndef QT_NO_COP |
1059 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 1059 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
1060 | #endif | 1060 | #endif |
1061 | const QList<FileSystem> &fs = storage->fileSystems(); | 1061 | const QList<FileSystem> &fs = storage->fileSystems(); |
1062 | QListIterator<FileSystem> it ( fs ); | 1062 | QListIterator<FileSystem> it ( fs ); |
1063 | QString s; | 1063 | QString s; |
1064 | QString homeDir = getenv("HOME"); | 1064 | QString homeDir = getenv("HOME"); |
1065 | QString hardDiskHome, hardDiskHomePath; | 1065 | QString hardDiskHome, hardDiskHomePath; |
1066 | for ( ; it.current(); ++it ) { | 1066 | for ( ; it.current(); ++it ) { |
1067 | int k4 = (*it)->blockSize()/256; | 1067 | int k4 = (*it)->blockSize()/256; |
1068 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { | 1068 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { |
1069 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 1069 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
1070 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1070 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1071 | + "K " + (*it)->options() + ";"; | 1071 | + "K " + (*it)->options() + ";"; |
1072 | } else if ( (*it)->disk() == "/dev/mtdblock1" || | 1072 | } else if ( (*it)->disk() == "/dev/mtdblock1" || |
1073 | (*it)->disk() == "/dev/mtdblock/1" ) { | 1073 | (*it)->disk() == "/dev/mtdblock/1" ) { |
1074 | s += (*it)->name() + "=" + homeDir + "/Documents " | 1074 | s += (*it)->name() + "=" + homeDir + "/Documents " |
1075 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1075 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1076 | + "K " + (*it)->options() + ";"; | 1076 | + "K " + (*it)->options() + ";"; |
1077 | } else if ( (*it)->name().contains( "Hard Disk") && | 1077 | } else if ( (*it)->name().contains( "Hard Disk") && |
1078 | homeDir.contains( (*it)->path() ) && | 1078 | homeDir.contains( (*it)->path() ) && |
1079 | (*it)->path().length() > hardDiskHomePath.length() ) { | 1079 | (*it)->path().length() > hardDiskHomePath.length() ) { |
1080 | hardDiskHomePath = (*it)->path(); | 1080 | hardDiskHomePath = (*it)->path(); |
1081 | hardDiskHome = | 1081 | hardDiskHome = |
1082 | (*it)->name() + "=" + homeDir + "/Documents " | 1082 | (*it)->name() + "=" + homeDir + "/Documents " |
1083 | + QString::number( (*it)->availBlocks() * k4/4 ) | 1083 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1084 | + "K " + (*it)->options() + ";"; | 1084 | + "K " + (*it)->options() + ";"; |
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | if ( !hardDiskHome.isEmpty() ) | 1087 | if ( !hardDiskHome.isEmpty() ) |
1088 | s += hardDiskHome; | 1088 | s += hardDiskHome; |
1089 | 1089 | ||
1090 | #ifndef QT_NO_COP | 1090 | #ifndef QT_NO_COP |
1091 | e << s; | 1091 | e << s; |
1092 | #endif | 1092 | #endif |
1093 | } else if ( msg == "sendSyncDate(QString)" ) { | 1093 | } else if ( msg == "sendSyncDate(QString)" ) { |
1094 | QString app; | 1094 | QString app; |
1095 | stream >> app; | 1095 | stream >> app; |
1096 | Config cfg( "qpe" ); | 1096 | Config cfg( "qpe" ); |
1097 | cfg.setGroup("SyncDate"); | 1097 | cfg.setGroup("SyncDate"); |
1098 | #ifndef QT_NO_COP | 1098 | #ifndef QT_NO_COP |
1099 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 1099 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
1100 | e << app << cfg.readEntry( app ); | 1100 | e << app << cfg.readEntry( app ); |
1101 | #endif | 1101 | #endif |
1102 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 1102 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
1103 | //cfg.readEntry( app ).latin1() ); | 1103 | //cfg.readEntry( app ).latin1() ); |
1104 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 1104 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
1105 | QString app, date; | 1105 | QString app, date; |
1106 | stream >> app >> date; | 1106 | stream >> app >> date; |
1107 | Config cfg( "qpe" ); | 1107 | Config cfg( "qpe" ); |
1108 | cfg.setGroup("SyncDate"); | 1108 | cfg.setGroup("SyncDate"); |
1109 | cfg.writeEntry( app, date ); | 1109 | cfg.writeEntry( app, date ); |
1110 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 1110 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
1111 | } else if ( msg == "startSync(QString)" ) { | 1111 | } else if ( msg == "startSync(QString)" ) { |
1112 | QString what; | 1112 | QString what; |
1113 | stream >> what; | 1113 | stream >> what; |
1114 | delete syncDialog; syncDialog = 0; | 1114 | delete syncDialog; syncDialog = 0; |
1115 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 1115 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
1116 | WStyle_Tool | WStyle_Customize | | 1116 | WStyle_Tool | WStyle_Customize | |
1117 | Qt::WStyle_StaysOnTop ); | 1117 | Qt::WStyle_StaysOnTop ); |
1118 | syncDialog->showMaximized(); | 1118 | syncDialog->showMaximized(); |
1119 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 1119 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
1120 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 1120 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
1121 | SLOT( cancelSync() ) ); | 1121 | SLOT( cancelSync() ) ); |
1122 | } else if ( msg == "stopSync()") { | 1122 | } else if ( msg == "stopSync()") { |
1123 | delete syncDialog; syncDialog = 0; | 1123 | delete syncDialog; syncDialog = 0; |
1124 | } else if ( msg == "getAllDocLinks()" ) { | 1124 | } else if ( msg == "getAllDocLinks()" ) { |
1125 | loadDocs(); | 1125 | loadDocs(); |
1126 | 1126 | ||
1127 | // directly show updated docs in document tab | 1127 | // directly show updated docs in document tab |
1128 | updateDocs(); | 1128 | updateDocs(); |
1129 | 1129 | ||
1130 | QString contents; | 1130 | QString contents; |
1131 | 1131 | ||
1132 | //Categories cats; | 1132 | //Categories cats; |
1133 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 1133 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
1134 | DocLnk *doc = it.current(); | 1134 | DocLnk *doc = it.current(); |
1135 | QFileInfo fi( doc->file() ); | 1135 | QFileInfo fi( doc->file() ); |
1136 | if ( !fi.exists() ) | 1136 | if ( !fi.exists() ) |
1137 | continue; | 1137 | continue; |
1138 | 1138 | ||
1139 | bool fake = !doc->linkFileKnown(); | 1139 | bool fake = !doc->linkFileKnown(); |
1140 | if ( !fake ) { | 1140 | if ( !fake ) { |
1141 | QFile f( doc->linkFile() ); | 1141 | QFile f( doc->linkFile() ); |
1142 | if ( f.open( IO_ReadOnly ) ) { | 1142 | if ( f.open( IO_ReadOnly ) ) { |
1143 | QTextStream ts( &f ); | 1143 | QTextStream ts( &f ); |
1144 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 1144 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
1145 | contents += ts.read(); | 1145 | contents += ts.read(); |
1146 | f.close(); | 1146 | f.close(); |
1147 | } else | 1147 | } else |
1148 | fake = TRUE; | 1148 | fake = TRUE; |
1149 | } | 1149 | } |
1150 | if (fake) { | 1150 | if (fake) { |
1151 | contents += "[Desktop Entry]\n"; | 1151 | contents += "[Desktop Entry]\n"; |
1152 | contents += "Categories = " + // No tr | 1152 | contents += "Categories = " + // No tr |
1153 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 1153 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
1154 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 1154 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
1155 | contents += "Name = "+doc->name()+"\n"; // No tr | 1155 | contents += "Name = "+doc->name()+"\n"; // No tr |
1156 | contents += "Type = "+doc->type()+"\n"; // No tr | 1156 | contents += "Type = "+doc->type()+"\n"; // No tr |
1157 | } | 1157 | } |
1158 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 1158 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
1159 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 1159 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | //qDebug( "sending length %d", contents.length() ); | 1162 | //qDebug( "sending length %d", contents.length() ); |
1163 | #ifndef QT_NO_COP | 1163 | #ifndef QT_NO_COP |
1164 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 1164 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
1165 | e << contents; | 1165 | e << contents; |
1166 | #endif | 1166 | #endif |
1167 | 1167 | ||
1168 | //qDebug( "================ \n\n%s\n\n===============", | 1168 | //qDebug( "================ \n\n%s\n\n===============", |
1169 | //contents.latin1() ); | 1169 | //contents.latin1() ); |
1170 | 1170 | ||
1171 | delete docsFolder; | 1171 | delete docsFolder; |
1172 | docsFolder = 0; | 1172 | docsFolder = 0; |
1173 | #ifdef QWS | 1173 | #ifdef QWS |
1174 | } else if ( msg == "setMouseProto(QString)" ) { | 1174 | } else if ( msg == "setMouseProto(QString)" ) { |
1175 | QString mice; | 1175 | QString mice; |
1176 | stream >> mice; | 1176 | stream >> mice; |
1177 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 1177 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
1178 | qwsServer->openMouse(); | 1178 | qwsServer->openMouse(); |
1179 | } else if ( msg == "setKeyboard(QString)" ) { | 1179 | } else if ( msg == "setKeyboard(QString)" ) { |
1180 | QString kb; | 1180 | QString kb; |
1181 | stream >> kb; | 1181 | stream >> kb; |
1182 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 1182 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
1183 | qwsServer->openKeyboard(); | 1183 | qwsServer->openKeyboard(); |
1184 | #endif | 1184 | #endif |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void Launcher::cancelSync() | 1188 | void Launcher::cancelSync() |
1189 | { | 1189 | { |
1190 | #ifndef QT_NO_COP | 1190 | #ifndef QT_NO_COP |
1191 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 1191 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
1192 | #endif | 1192 | #endif |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) | 1195 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) |
1196 | { | 1196 | { |
1197 | QDataStream stream( data, IO_ReadOnly ); | 1197 | QDataStream stream( data, IO_ReadOnly ); |
1198 | if ( msg == "setTabView(QString,int)" ) { | 1198 | if ( msg == "setTabView(QString,int)" ) { |
1199 | QString id; | 1199 | QString id; |
1200 | stream >> id; | 1200 | stream >> id; |
1201 | int mode; | 1201 | int mode; |
1202 | stream >> mode; | 1202 | stream >> mode; |
1203 | if ( tabs->view(id) ) | 1203 | if ( tabs->view(id) ) |
1204 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 1204 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
1205 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 1205 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
1206 | QString id; | 1206 | QString id; |
1207 | stream >> id; | 1207 | stream >> id; |
1208 | int mode; | 1208 | int mode; |
1209 | stream >> mode; | 1209 | stream >> mode; |
1210 | QString pixmapOrColor; | 1210 | QString pixmapOrColor; |
1211 | stream >> pixmapOrColor; | 1211 | stream >> pixmapOrColor; |
1212 | if ( tabs->view(id) ) | 1212 | if ( tabs->view(id) ) |
1213 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 1213 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
1214 | } else if ( msg == "setTextColor(QString,QString)" ) { | 1214 | } else if ( msg == "setTextColor(QString,QString)" ) { |
1215 | QString id; | 1215 | QString id; |
1216 | stream >> id; | 1216 | stream >> id; |
1217 | QString color; | 1217 | QString color; |
1218 | stream >> color; | 1218 | stream >> color; |
1219 | if ( tabs->view(id) ) | 1219 | if ( tabs->view(id) ) |
1220 | tabs->view(id)->setTextColor( QColor(color) ); | 1220 | tabs->view(id)->setTextColor( QColor(color) ); |
1221 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 1221 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
1222 | QString id; | 1222 | QString id; |
1223 | stream >> id; | 1223 | stream >> id; |
1224 | QString fam; | 1224 | QString fam; |
1225 | stream >> fam; | 1225 | stream >> fam; |
1226 | int size; | 1226 | int size; |
1227 | stream >> size; | 1227 | stream >> size; |
1228 | int weight; | 1228 | int weight; |
1229 | stream >> weight; | 1229 | stream >> weight; |
1230 | int italic; | 1230 | int italic; |
1231 | stream >> italic; | 1231 | stream >> italic; |
1232 | if ( tabs->view(id) ) | 1232 | if ( tabs->view(id) ) |
1233 | if ( !fam. isEmpty ( )) | 1233 | if ( !fam. isEmpty ( )) |
1234 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 1234 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
1235 | else | 1235 | else |
1236 | tabs->view(id)->unsetViewFont(); | 1236 | tabs->view(id)->unsetViewFont(); |
1237 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 1237 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
1238 | } | 1238 | } |
1239 | else if ( msg == "setBusyIndicatorType(QString)" ) { | 1239 | else if ( msg == "setBusyIndicatorType(QString)" ) { |
1240 | QString type; | 1240 | QString type; |
1241 | stream >> type; | 1241 | stream >> type; |
1242 | tabs->setBusyIndicatorType(type); | 1242 | tabs->setBusyIndicatorType(type); |
1243 | } | 1243 | } |
1244 | else if ( msg == "home()" ) { | 1244 | else if ( msg == "home()" ) { |
1245 | if ( isVisibleWindow( winId ( ))) | 1245 | if ( isVisibleWindow( winId ( ))) |
1246 | nextView ( ); | 1246 | nextView ( ); |
1247 | else | 1247 | else |
1248 | raise ( ); | 1248 | raise ( ); |
1249 | 1249 | ||
1250 | } | 1250 | } |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | void Launcher::storageChanged() | 1253 | void Launcher::storageChanged() |
1254 | { | 1254 | { |
1255 | if ( in_lnk_props ) { | 1255 | if ( in_lnk_props ) { |
1256 | got_lnk_change = TRUE; | 1256 | got_lnk_change = TRUE; |
1257 | lnk_change = QString::null; | 1257 | lnk_change = QString::null; |
1258 | } else { | 1258 | } else { |
1259 | updateLink( QString::null ); | 1259 | updateLink( QString::null ); |
1260 | } | 1260 | } |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | 1263 | ||
1264 | bool Launcher::mkdir(const QString &localPath) | 1264 | bool Launcher::mkdir(const QString &localPath) |
1265 | { | 1265 | { |
1266 | QDir fullDir(localPath); | 1266 | QDir fullDir(localPath); |
1267 | if (fullDir.exists()) | 1267 | if (fullDir.exists()) |
1268 | return true; | 1268 | return true; |
1269 | 1269 | ||
1270 | // at this point the directory doesn't exist | 1270 | // at this point the directory doesn't exist |
1271 | // go through the directory tree and start creating the direcotories | 1271 | // go through the directory tree and start creating the direcotories |
1272 | // that don't exist; if we can't create the directories, return false | 1272 | // that don't exist; if we can't create the directories, return false |
1273 | 1273 | ||
1274 | QString dirSeps = "/"; | 1274 | QString dirSeps = "/"; |
1275 | int dirIndex = localPath.find(dirSeps); | 1275 | int dirIndex = localPath.find(dirSeps); |
1276 | QString checkedPath; | 1276 | QString checkedPath; |
1277 | 1277 | ||
1278 | // didn't find any seps; weird, use the cur dir instead | 1278 | // didn't find any seps; weird, use the cur dir instead |
1279 | if (dirIndex == -1) { | 1279 | if (dirIndex == -1) { |
1280 | //qDebug("No seperators found in path %s", localPath.latin1()); | 1280 | //qDebug("No seperators found in path %s", localPath.latin1()); |
1281 | checkedPath = QDir::currentDirPath(); | 1281 | checkedPath = QDir::currentDirPath(); |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | while (checkedPath != localPath) { | 1284 | while (checkedPath != localPath) { |
1285 | // no more seperators found, use the local path | 1285 | // no more seperators found, use the local path |
1286 | if (dirIndex == -1) | 1286 | if (dirIndex == -1) |
1287 | checkedPath = localPath; | 1287 | checkedPath = localPath; |
1288 | else { | 1288 | else { |
1289 | // the next directory to check | 1289 | // the next directory to check |
1290 | checkedPath = localPath.left(dirIndex) + "/"; | 1290 | checkedPath = localPath.left(dirIndex) + "/"; |
1291 | // advance the iterator; the next dir seperator | 1291 | // advance the iterator; the next dir seperator |
1292 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 1292 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | QDir checkDir(checkedPath); | 1295 | QDir checkDir(checkedPath); |
1296 | if (!checkDir.exists()) { | 1296 | if (!checkDir.exists()) { |
1297 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 1297 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
1298 | 1298 | ||
1299 | if (!checkDir.mkdir(checkedPath)) { | 1299 | if (!checkDir.mkdir(checkedPath)) { |
1300 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 1300 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
1301 | return FALSE; | 1301 | return FALSE; |
1302 | } | 1302 | } |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | } | 1305 | } |
1306 | return TRUE; | 1306 | return TRUE; |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | void Launcher::preloadApps() | 1309 | void Launcher::preloadApps() |
1310 | { | 1310 | { |
1311 | Config cfg("Launcher"); | 1311 | Config cfg("Launcher"); |
1312 | cfg.setGroup("Preload"); | 1312 | cfg.setGroup("Preload"); |
1313 | QStringList apps = cfg.readListEntry("Apps",','); | 1313 | QStringList apps = cfg.readListEntry("Apps",','); |
1314 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1314 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1315 | #ifndef QT_NO_COP | 1315 | #ifndef QT_NO_COP |
1316 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1316 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
1317 | #endif | 1317 | #endif |
1318 | } | 1318 | } |
1319 | } | 1319 | } |