summaryrefslogtreecommitdiff
authorbrad <brad>2004-06-17 12:03:55 (UTC)
committer brad <brad>2004-06-17 12:03:55 (UTC)
commit36c12db68a3caddee0c3385a1838222e9ab596aa (patch) (unidiff)
treec861d988d3e6e8754ae217c1e69420c7798f8675
parent9875d0391f21f4d7518dba946455d844f04c1668 (diff)
downloadopie-36c12db68a3caddee0c3385a1838222e9ab596aa.zip
opie-36c12db68a3caddee0c3385a1838222e9ab596aa.tar.gz
opie-36c12db68a3caddee0c3385a1838222e9ab596aa.tar.bz2
A hack workaround to prevent the launcher segfaulting after adding/removing
a launcher tab. This only appears to happen if you insert/remove removable media that contains apps that would insert a tab (like games perhaps). It has a deeper root cause but for the moment this works around it.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 779fe54..87a54bf 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -247,200 +247,215 @@ LauncherView *LauncherTabWidget::view( const QString &id )
247LauncherView *LauncherTabWidget::docView() 247LauncherView *LauncherTabWidget::docView()
248{ 248{
249 return docview; 249 return docview;
250} 250}
251 251
252void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 252void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
253{ 253{
254 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 254 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
255 docLoadingWidgetEnabled = v; 255 docLoadingWidgetEnabled = v;
256 raiseTabWidget(); 256 raiseTabWidget();
257 } 257 }
258} 258}
259 259
260void LauncherTabWidget::setLoadingProgress( int percent ) 260void LauncherTabWidget::setLoadingProgress( int percent )
261{ 261{
262 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 262 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
263} 263}
264 264
265// ### this function could more to LauncherView 265// ### this function could more to LauncherView
266void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 266void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
267{ 267{
268 // View 268 // View
269 QString view = cfg.readEntry( "View", "Icon" ); 269 QString view = cfg.readEntry( "View", "Icon" );
270 if ( view == "List" ) // No tr 270 if ( view == "List" ) // No tr
271 v->setViewMode( LauncherView::List ); 271 v->setViewMode( LauncherView::List );
272 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 272 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
273 if ( bgType == "Image" ) { // No tr 273 if ( bgType == "Image" ) { // No tr
274 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 274 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
275 v->setBackgroundType( LauncherView::Image, pm ); 275 v->setBackgroundType( LauncherView::Image, pm );
276 } else if ( bgType == "SolidColor" ) { 276 } else if ( bgType == "SolidColor" ) {
277 QString c = cfg.readEntry( "BackgroundColor" ); 277 QString c = cfg.readEntry( "BackgroundColor" );
278 v->setBackgroundType( LauncherView::SolidColor, c ); 278 v->setBackgroundType( LauncherView::SolidColor, c );
279 } else { 279 } else {
280 v->setBackgroundType( LauncherView::Ruled, QString::null ); 280 v->setBackgroundType( LauncherView::Ruled, QString::null );
281 } 281 }
282 QString textCol = cfg.readEntry( "TextColor" ); 282 QString textCol = cfg.readEntry( "TextColor" );
283 if ( textCol.isEmpty() ) 283 if ( textCol.isEmpty() )
284 v->setTextColor( QColor() ); 284 v->setTextColor( QColor() );
285 else 285 else
286 v->setTextColor( QColor(textCol) ); 286 v->setTextColor( QColor(textCol) );
287// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 287// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
288 288
289 289
290 QStringList font = cfg.readListEntry( "Font", ',' ); 290 QStringList font = cfg.readListEntry( "Font", ',' );
291 if ( font.count() == 4 ) 291 if ( font.count() == 4 )
292 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 292 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
293 293
294 // ### FIXME TabColor TabTextColor 294 // ### FIXME TabColor TabTextColor
295 295
296} 296}
297 297
298// ### Could move to LauncherTab 298// ### Could move to LauncherTab
299void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 299void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
300{ 300{
301 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 301 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
302 302
303 setTabViewAppearance( tab->view, cfg ); 303 setTabViewAppearance( tab->view, cfg );
304 304
305 // Tabs 305 // Tabs
306 QString tabCol = cfg.readEntry( "TabColor" ); 306 QString tabCol = cfg.readEntry( "TabColor" );
307 if ( tabCol.isEmpty() ) 307 if ( tabCol.isEmpty() )
308 tab->bgColor = QColor(); 308 tab->bgColor = QColor();
309 else 309 else
310 tab->bgColor = QColor(tabCol); 310 tab->bgColor = QColor(tabCol);
311 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 311 QString tabTextCol = cfg.readEntry( "TabTextColor" );
312 if ( tabTextCol.isEmpty() ) 312 if ( tabTextCol.isEmpty() )
313 tab->fgColor = QColor(); 313 tab->fgColor = QColor();
314 else 314 else
315 tab->fgColor = QColor(tabTextCol); 315 tab->fgColor = QColor(tabTextCol);
316} 316}
317 317
318void LauncherTabWidget::paletteChange( const QPalette &p ) 318void LauncherTabWidget::paletteChange( const QPalette &p )
319{ 319{
320 QVBox::paletteChange( p ); 320 QVBox::paletteChange( p );
321 QPalette pal = palette(); 321 QPalette pal = palette();
322 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 322 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
323 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 323 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
324 categoryBar->setPalette( pal ); 324 categoryBar->setPalette( pal );
325 categoryBar->update(); 325 categoryBar->update();
326} 326}
327 327
328void LauncherTabWidget::styleChange( QStyle & ) 328void LauncherTabWidget::styleChange( QStyle & )
329{ 329{
330 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 330 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
331} 331}
332 332
333void LauncherTabWidget::setProgressStyle() 333void LauncherTabWidget::setProgressStyle()
334{ 334{
335 if (docLoadingWidgetProgress) { 335 if (docLoadingWidgetProgress) {
336 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 336 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
337 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 337 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
338 docLoadingWidgetProgress->setMargin( 1 ); 338 docLoadingWidgetProgress->setMargin( 1 );
339 docLoadingWidgetProgress->setLineWidth( 1 ); 339 docLoadingWidgetProgress->setLineWidth( 1 );
340 } 340 }
341} 341}
342 342
343/*
344 * FIXME
345 * The following NULL check is triggered by inserting, then removing a tab on the fly
346 * as you would if you had removable media (which I do). Without this check
347 * the first app launched after a tab removal causes qpe to Segfault.
348 * This obviously has a more sinister cause, but this works around it with no
349 * obvious adverse effects. Please FIXME
350 * bkc - 17/6/2004
351 *
352 */
353
343void LauncherTabWidget::setBusy(bool on) 354void LauncherTabWidget::setBusy(bool on)
344{ 355{
345 if ( on ) 356 if ( on )
346 currentView()->setBusy(TRUE); 357 currentView()->setBusy(TRUE);
347 else { 358 else {
348 for ( int i = 0; i < categoryBar->count(); i++ ) { 359 for ( int i = 0; i < categoryBar->count(); i++ ) {
349 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 360 if (categoryBar->tab(i)) {
350 view->setBusy( FALSE ); 361 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
362 view->setBusy( FALSE );
363 } else {
364 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
365 }
351 } 366 }
352 } 367 }
353} 368}
354 369
355void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 370void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
356 for (int i = 0; i < categoryBar->count(); i++ ) { 371 for (int i = 0; i < categoryBar->count(); i++ ) {
357 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 372 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
358 view->setBusyIndicatorType( str ); 373 view->setBusyIndicatorType( str );
359 } 374 }
360} 375}
361 376
362LauncherView *LauncherTabWidget::currentView(void) 377LauncherView *LauncherTabWidget::currentView(void)
363{ 378{
364 return (LauncherView*)stack->visibleWidget(); 379 return (LauncherView*)stack->visibleWidget();
365} 380}
366 381
367 382
368 383
369void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 384void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
370{ 385{
371 QDataStream stream( data, IO_ReadOnly ); 386 QDataStream stream( data, IO_ReadOnly );
372 if ( msg == "setTabView(QString,int)" ) { 387 if ( msg == "setTabView(QString,int)" ) {
373 QString id; 388 QString id;
374 stream >> id; 389 stream >> id;
375 int mode; 390 int mode;
376 stream >> mode; 391 stream >> mode;
377 if ( view(id) ) 392 if ( view(id) )
378 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 393 view(id)->setViewMode( (LauncherView::ViewMode)mode );
379 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 394 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
380 QString id; 395 QString id;
381 stream >> id; 396 stream >> id;
382 int mode; 397 int mode;
383 stream >> mode; 398 stream >> mode;
384 QString pixmapOrColor; 399 QString pixmapOrColor;
385 stream >> pixmapOrColor; 400 stream >> pixmapOrColor;
386 if ( view(id) ) 401 if ( view(id) )
387 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 402 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
388 if ( id == "Documents" ) 403 if ( id == "Documents" )
389 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 404 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
390 } else if ( msg == "setTextColor(QString,QString)" ) { 405 } else if ( msg == "setTextColor(QString,QString)" ) {
391 QString id; 406 QString id;
392 stream >> id; 407 stream >> id;
393 QString color; 408 QString color;
394 stream >> color; 409 stream >> color;
395 if ( view(id) ) 410 if ( view(id) )
396 view(id)->setTextColor( QColor(color) ); 411 view(id)->setTextColor( QColor(color) );
397 if ( id == "Documents" ) 412 if ( id == "Documents" )
398 docLoadingWidget->setTextColor( QColor(color) ); 413 docLoadingWidget->setTextColor( QColor(color) );
399 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 414 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
400 QString id; 415 QString id;
401 stream >> id; 416 stream >> id;
402 QString fam; 417 QString fam;
403 stream >> fam; 418 stream >> fam;
404 int size; 419 int size;
405 stream >> size; 420 stream >> size;
406 int weight; 421 int weight;
407 stream >> weight; 422 stream >> weight;
408 int italic; 423 int italic;
409 stream >> italic; 424 stream >> italic;
410 if ( view(id) ) { 425 if ( view(id) ) {
411 if ( !fam.isEmpty() ) { 426 if ( !fam.isEmpty() ) {
412 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 427 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
413 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; 428 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
414 } else { 429 } else {
415 view(id)->clearViewFont(); 430 view(id)->clearViewFont();
416 } 431 }
417 } 432 }
418 }else if ( msg == "setBusyIndicatorType(QString)" ) { 433 }else if ( msg == "setBusyIndicatorType(QString)" ) {
419 QString type; 434 QString type;
420 stream >> type; 435 stream >> type;
421 setBusyIndicatorType( type ); 436 setBusyIndicatorType( type );
422 }else if ( msg == "home()" ) { 437 }else if ( msg == "home()" ) {
423 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 438 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
424 if (categoryBar) 439 if (categoryBar)
425 categoryBar->nextTab(); 440 categoryBar->nextTab();
426 }else 441 }else
427 static_cast<QWidget*>(parent())->raise(); 442 static_cast<QWidget*>(parent())->raise();
428 } 443 }
429} 444}
430 445
431 446
432 447
433//--------------------------------------------------------------------------- 448//---------------------------------------------------------------------------
434 449
435Launcher::Launcher() 450Launcher::Launcher()
436 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 451 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
437{ 452{
438 tabs = 0; 453 tabs = 0;
439 tb = 0; 454 tb = 0;
440 Config cfg( "Launcher" ); 455 Config cfg( "Launcher" );
441 cfg.setGroup( "DocTab" ); 456 cfg.setGroup( "DocTab" );
442 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 457 docTabEnabled = cfg.readBoolEntry( "Enable", true );
443} 458}
444 459
445void Launcher::createGUI() 460void Launcher::createGUI()
446{ 461{