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