summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-18 01:46:28 (UTC)
committer zecke <zecke>2002-10-18 01:46:28 (UTC)
commit218bc4583c545db50f3475930d61b1c76aca3fbd (patch) (unidiff)
tree5ddd0dbca5a42d3f00914968150147c85b4da837
parent0457c48c165abef8afa2ac73c8f66d20e289681a (diff)
downloadopie-218bc4583c545db50f3475930d61b1c76aca3fbd.zip
opie-218bc4583c545db50f3475930d61b1c76aca3fbd.tar.gz
opie-218bc4583c545db50f3475930d61b1c76aca3fbd.tar.bz2
Remove some more #ifdefs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp4
-rw-r--r--core/launcher/launcher.cpp2
2 files changed, 1 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 1fd3f6a..3546e28 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -250,306 +250,302 @@ public:
250 v [ 3 ] = 0; 250 v [ 3 ] = 0;
251 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); 251 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false );
252 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); 252 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false );
253 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); 253 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 );
254 254
255 if ( !i1 && !i2 && !i3 ) 255 if ( !i1 && !i2 && !i3 )
256 QWSServer::setScreenSaverInterval( 0 ); 256 QWSServer::setScreenSaverInterval( 0 );
257 else 257 else
258 QWSServer::setScreenSaverIntervals( v ); 258 QWSServer::setScreenSaverIntervals( v );
259 } 259 }
260 260
261 void setInterval ( int interval ) 261 void setInterval ( int interval )
262 { 262 {
263 setIntervals ( -1, -1, interval ); 263 setIntervals ( -1, -1, interval );
264 } 264 }
265 265
266 void setMode ( int mode ) 266 void setMode ( int mode )
267 { 267 {
268 if ( mode > m_disable_suspend ) 268 if ( mode > m_disable_suspend )
269 setInterval( -1 ); 269 setInterval( -1 );
270 m_disable_suspend = mode; 270 m_disable_suspend = mode;
271 } 271 }
272 272
273 int backlight ( ) 273 int backlight ( )
274 { 274 {
275 if ( m_backlight_bright == -1 ) { 275 if ( m_backlight_bright == -1 ) {
276 // Read from config 276 // Read from config
277 Config config ( "qpe" ); 277 Config config ( "qpe" );
278 config. setGroup ( "Screensaver" ); 278 config. setGroup ( "Screensaver" );
279 m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); 279 m_backlight_bright = config. readNumEntry ( "Brightness", 255 );
280 } 280 }
281 return m_backlight_bright; 281 return m_backlight_bright;
282 } 282 }
283 283
284 void setBacklight ( int bright ) 284 void setBacklight ( int bright )
285 { 285 {
286 if ( bright == -3 ) { 286 if ( bright == -3 ) {
287 // Forced on 287 // Forced on
288 m_backlight_forcedoff = false; 288 m_backlight_forcedoff = false;
289 bright = -1; 289 bright = -1;
290 } 290 }
291 if ( m_backlight_forcedoff && bright != -2 ) 291 if ( m_backlight_forcedoff && bright != -2 )
292 return ; 292 return ;
293 if ( bright == -2 ) { 293 if ( bright == -2 ) {
294 // Toggle between off and on 294 // Toggle between off and on
295 bright = m_backlight_bright ? 0 : -1; 295 bright = m_backlight_bright ? 0 : -1;
296 m_backlight_forcedoff = !bright; 296 m_backlight_forcedoff = !bright;
297 } 297 }
298 298
299 m_backlight_bright = bright; 299 m_backlight_bright = bright;
300 300
301 bright = backlight ( ); 301 bright = backlight ( );
302 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 302 ODevice::inst ( ) -> setDisplayBrightness ( bright );
303 303
304 m_backlight_bright = bright; 304 m_backlight_bright = bright;
305 } 305 }
306 306
307 void setDisplayState ( bool on ) 307 void setDisplayState ( bool on )
308 { 308 {
309 if ( m_lcd_status != on ) { 309 if ( m_lcd_status != on ) {
310 ODevice::inst ( ) -> setDisplayStatus ( on ); 310 ODevice::inst ( ) -> setDisplayStatus ( on );
311 m_lcd_status = on; 311 m_lcd_status = on;
312 } 312 }
313 } 313 }
314 314
315private: 315private:
316 int m_disable_suspend; 316 int m_disable_suspend;
317 bool m_enable_dim; 317 bool m_enable_dim;
318 bool m_enable_lightoff; 318 bool m_enable_lightoff;
319 bool m_enable_onlylcdoff; 319 bool m_enable_onlylcdoff;
320 320
321 bool m_lcd_status; 321 bool m_lcd_status;
322 322
323 int m_backlight_bright; 323 int m_backlight_bright;
324 bool m_backlight_forcedoff; 324 bool m_backlight_forcedoff;
325}; 325};
326 326
327void DesktopApplication::switchLCD ( bool on ) 327void DesktopApplication::switchLCD ( bool on )
328{ 328{
329 if ( qApp ) { 329 if ( qApp ) {
330 DesktopApplication *dapp = (DesktopApplication *) qApp; 330 DesktopApplication *dapp = (DesktopApplication *) qApp;
331 331
332 if ( dapp-> m_screensaver ) { 332 if ( dapp-> m_screensaver ) {
333 if ( on ) { 333 if ( on ) {
334 dapp-> m_screensaver-> setDisplayState ( true ); 334 dapp-> m_screensaver-> setDisplayState ( true );
335 dapp-> m_screensaver-> setBacklight ( -3 ); 335 dapp-> m_screensaver-> setBacklight ( -3 );
336 } 336 }
337 else { 337 else {
338 dapp-> m_screensaver-> setDisplayState ( false ); 338 dapp-> m_screensaver-> setDisplayState ( false );
339 } 339 }
340 } 340 }
341 } 341 }
342} 342}
343 343
344 344
345DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 345DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
346 : QPEApplication( argc, argv, appType ) 346 : QPEApplication( argc, argv, appType )
347{ 347{
348 348
349 QTimer * t = new QTimer( this ); 349 QTimer * t = new QTimer( this );
350 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); 350 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
351 t->start( 10000 ); 351 t->start( 10000 );
352 ps = new PowerStatus; 352 ps = new PowerStatus;
353 pa = new DesktopPowerAlerter( 0 ); 353 pa = new DesktopPowerAlerter( 0 );
354 354
355 channel = new QCopChannel( "QPE/Desktop", this ); 355 channel = new QCopChannel( "QPE/Desktop", this );
356 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 356 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
357 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 357 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
358 358
359 channel = new QCopChannel( "QPE/System", this ); 359 channel = new QCopChannel( "QPE/System", this );
360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
361 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 361 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
362 362
363 m_screensaver = new QPEScreenSaver; 363 m_screensaver = new QPEScreenSaver;
364 364
365 m_screensaver-> setInterval ( -1 ); 365 m_screensaver-> setInterval ( -1 );
366 QWSServer::setScreenSaver( m_screensaver ); 366 QWSServer::setScreenSaver( m_screensaver );
367} 367}
368 368
369 369
370DesktopApplication::~DesktopApplication() 370DesktopApplication::~DesktopApplication()
371{ 371{
372 delete ps; 372 delete ps;
373 delete pa; 373 delete pa;
374} 374}
375 375
376void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 376void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
377{ 377{
378#ifdef Q_WS_QWS
379 QDataStream stream( data, IO_ReadOnly ); 378 QDataStream stream( data, IO_ReadOnly );
380 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 379 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
381 int k; 380 int k;
382 QString c, m; 381 QString c, m;
383 stream >> k; 382 stream >> k;
384 stream >> c; 383 stream >> c;
385 stream >> m; 384 stream >> m;
386 385
387 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 386 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
388 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 387 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
389 } 388 }
390#endif
391} 389}
392 390
393 391
394void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 392void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
395{ 393{
396#ifdef Q_WS_QWS
397 QDataStream stream ( data, IO_ReadOnly ); 394 QDataStream stream ( data, IO_ReadOnly );
398 395
399 if ( msg == "setScreenSaverInterval(int)" ) { 396 if ( msg == "setScreenSaverInterval(int)" ) {
400 int time; 397 int time;
401 stream >> time; 398 stream >> time;
402 m_screensaver-> setInterval( time ); 399 m_screensaver-> setInterval( time );
403 } 400 }
404 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 401 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
405 int t1, t2, t3; 402 int t1, t2, t3;
406 stream >> t1 >> t2 >> t3; 403 stream >> t1 >> t2 >> t3;
407 m_screensaver-> setIntervals( t1, t2, t3 ); 404 m_screensaver-> setIntervals( t1, t2, t3 );
408 } 405 }
409 else if ( msg == "setBacklight(int)" ) { 406 else if ( msg == "setBacklight(int)" ) {
410 int bright; 407 int bright;
411 stream >> bright; 408 stream >> bright;
412 m_screensaver-> setBacklight( bright ); 409 m_screensaver-> setBacklight( bright );
413 } 410 }
414 else if ( msg == "setScreenSaverMode(int)" ) { 411 else if ( msg == "setScreenSaverMode(int)" ) {
415 int mode; 412 int mode;
416 stream >> mode; 413 stream >> mode;
417 m_screensaver-> setMode ( mode ); 414 m_screensaver-> setMode ( mode );
418 } 415 }
419 else if ( msg == "setDisplayState(int)" ) { 416 else if ( msg == "setDisplayState(int)" ) {
420 int state; 417 int state;
421 stream >> state; 418 stream >> state;
422 m_screensaver-> setDisplayState ( state != 0 ); 419 m_screensaver-> setDisplayState ( state != 0 );
423 } 420 }
424 else if ( msg == "suspend()" ) { 421 else if ( msg == "suspend()" ) {
425 emit power(); 422 emit power();
426 } 423 }
427#endif
428} 424}
429 425
430enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 426enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
431 427
432#ifdef Q_WS_QWS 428#ifdef Q_WS_QWS
433bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 429bool DesktopApplication::qwsEventFilter( QWSEvent *e )
434{ 430{
435 qpedesktop->checkMemory(); 431 qpedesktop->checkMemory();
436 432
437 if ( e->type == QWSEvent::Key ) { 433 if ( e->type == QWSEvent::Key ) {
438 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 434 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
439 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 435 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
440 return TRUE; 436 return TRUE;
441 bool press = ke->simpleData.is_press; 437 bool press = ke->simpleData.is_press;
442 bool autoRepeat = ke->simpleData.is_auto_repeat; 438 bool autoRepeat = ke->simpleData.is_auto_repeat;
443 439
444 /* 440 /*
445 app that registers key/message to be sent back to the app, when it doesn't have focus, 441 app that registers key/message to be sent back to the app, when it doesn't have focus,
446 when user presses key, unless keyboard has been requested from app. 442 when user presses key, unless keyboard has been requested from app.
447 will not send multiple repeats if user holds key 443 will not send multiple repeats if user holds key
448 i.e. one shot 444 i.e. one shot
449 */ 445 */
450 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { 446 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) {
451// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); 447// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode);
452 KeyRegisterList::Iterator it; 448 KeyRegisterList::Iterator it;
453 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 449 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
454 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { 450 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) {
455 if ( press ) 451 if ( press )
456 qDebug( "press" ); 452 qDebug( "press" );
457 else 453 else
458 qDebug( "release" ); 454 qDebug( "release" );
459 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); 455 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
460 } 456 }
461 } 457 }
462 } 458 }
463 459
464 if ( !keyboardGrabbed() ) { 460 if ( !keyboardGrabbed() ) {
465 if ( ke->simpleData.keycode == Key_F9 ) { 461 if ( ke->simpleData.keycode == Key_F9 ) {
466 if ( press ) 462 if ( press )
467 emit datebook(); 463 emit datebook();
468 return TRUE; 464 return TRUE;
469 } 465 }
470 if ( ke->simpleData.keycode == Key_F10 ) { 466 if ( ke->simpleData.keycode == Key_F10 ) {
471 if ( !press && cardSendTimer ) { 467 if ( !press && cardSendTimer ) {
472 emit contacts(); 468 emit contacts();
473 delete cardSendTimer; 469 delete cardSendTimer;
474 } 470 }
475 else if ( press ) { 471 else if ( press ) {
476 cardSendTimer = new QTimer(); 472 cardSendTimer = new QTimer();
477 cardSendTimer->start( 2000, TRUE ); 473 cardSendTimer->start( 2000, TRUE );
478 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 474 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
479 } 475 }
480 return TRUE; 476 return TRUE;
481 } 477 }
482 /* menu key now opens application menu/toolbar 478 /* menu key now opens application menu/toolbar
483 if ( ke->simpleData.keycode == Key_F11 ) { 479 if ( ke->simpleData.keycode == Key_F11 ) {
484 if ( press ) emit menu(); 480 if ( press ) emit menu();
485 return TRUE; 481 return TRUE;
486 } 482 }
487 */ 483 */
488 if ( ke->simpleData.keycode == Key_F12 ) { 484 if ( ke->simpleData.keycode == Key_F12 ) {
489 while ( activePopupWidget() ) 485 while ( activePopupWidget() )
490 activePopupWidget() ->close(); 486 activePopupWidget() ->close();
491 if ( press ) 487 if ( press )
492 emit launch(); 488 emit launch();
493 return TRUE; 489 return TRUE;
494 } 490 }
495 if ( ke->simpleData.keycode == Key_F13 ) { 491 if ( ke->simpleData.keycode == Key_F13 ) {
496 if ( press ) 492 if ( press )
497 emit email(); 493 emit email();
498 return TRUE; 494 return TRUE;
499 } 495 }
500 } 496 }
501 497
502 if ( ke->simpleData.keycode == Key_F34 ) { 498 if ( ke->simpleData.keycode == Key_F34 ) {
503 if ( press ) 499 if ( press )
504 emit power(); 500 emit power();
505 return TRUE; 501 return TRUE;
506 } 502 }
507 // This was used for the iPAQ PowerButton 503 // This was used for the iPAQ PowerButton
508 // See main.cpp for new KeyboardFilter 504 // See main.cpp for new KeyboardFilter
509 // 505 //
510 // if ( ke->simpleData.keycode == Key_SysReq ) { 506 // if ( ke->simpleData.keycode == Key_SysReq ) {
511 // if ( press ) emit power(); 507 // if ( press ) emit power();
512 // return TRUE; 508 // return TRUE;
513 // } 509 // }
514 if ( ke->simpleData.keycode == Key_F35 ) { 510 if ( ke->simpleData.keycode == Key_F35 ) {
515 if ( press ) 511 if ( press )
516 emit backlight(); 512 emit backlight();
517 return TRUE; 513 return TRUE;
518 } 514 }
519 if ( ke->simpleData.keycode == Key_F32 ) { 515 if ( ke->simpleData.keycode == Key_F32 ) {
520 if ( press ) 516 if ( press )
521 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 517 QCopEnvelope e( "QPE/Desktop", "startSync()" );
522 return TRUE; 518 return TRUE;
523 } 519 }
524 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 520 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
525 if ( press ) 521 if ( press )
526 emit symbol(); 522 emit symbol();
527 return TRUE; 523 return TRUE;
528 } 524 }
529 if ( ke->simpleData.keycode == Key_NumLock ) { 525 if ( ke->simpleData.keycode == Key_NumLock ) {
530 if ( press ) 526 if ( press )
531 emit numLockStateToggle(); 527 emit numLockStateToggle();
532 } 528 }
533 if ( ke->simpleData.keycode == Key_CapsLock ) { 529 if ( ke->simpleData.keycode == Key_CapsLock ) {
534 if ( press ) 530 if ( press )
535 emit capsLockStateToggle(); 531 emit capsLockStateToggle();
536 } 532 }
537 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) 533 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) )
538 qpedesktop->keyClick(); 534 qpedesktop->keyClick();
539 } 535 }
540 else { 536 else {
541 if ( e->type == QWSEvent::Mouse ) { 537 if ( e->type == QWSEvent::Mouse ) {
542 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 538 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
543 static bool up = TRUE; 539 static bool up = TRUE;
544 if ( me->simpleData.state & LeftButton ) { 540 if ( me->simpleData.state & LeftButton ) {
545 if ( up ) { 541 if ( up ) {
546 up = FALSE; 542 up = FALSE;
547 qpedesktop->screenClick(); 543 qpedesktop->screenClick();
548 } 544 }
549 } 545 }
550 else { 546 else {
551 up = TRUE; 547 up = TRUE;
552 } 548 }
553 } 549 }
554 } 550 }
555 551
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index a5955a4..5a9ee1b 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -499,257 +499,257 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
499 QPalette pal = palette(); 499 QPalette pal = palette();
500 bool setPal = FALSE; 500 bool setPal = FALSE;
501 if ( ct->bgColor.isValid() ) { 501 if ( ct->bgColor.isValid() ) {
502 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); 502 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
503 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); 503 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
504 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); 504 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
505 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); 505 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
506 that->setUpdatesEnabled( FALSE ); 506 that->setUpdatesEnabled( FALSE );
507 that->setPalette( pal ); 507 that->setPalette( pal );
508 setPal = TRUE; 508 setPal = TRUE;
509 } 509 }
510#if QT_VERSION >= 300 510#if QT_VERSION >= 300
511 QStyle::SFlags flags = QStyle::Style_Default; 511 QStyle::SFlags flags = QStyle::Style_Default;
512 if ( selected ) 512 if ( selected )
513 flags |= QStyle::Style_Selected; 513 flags |= QStyle::Style_Selected;
514 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 514 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
515 colorGroup(), flags, QStyleOption(t) ); 515 colorGroup(), flags, QStyleOption(t) );
516#else 516#else
517 style().drawTab( p, this, t, selected ); 517 style().drawTab( p, this, t, selected );
518#endif 518#endif
519 519
520 QRect r( t->rect() ); 520 QRect r( t->rect() );
521 QFont f( font() ); 521 QFont f( font() );
522 if ( selected ) 522 if ( selected )
523 f.setBold( TRUE ); 523 f.setBold( TRUE );
524 p->setFont( f ); 524 p->setFont( f );
525 525
526 if ( ct->fgColor.isValid() ) { 526 if ( ct->fgColor.isValid() ) {
527 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); 527 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
528 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); 528 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
529 that->setUpdatesEnabled( FALSE ); 529 that->setUpdatesEnabled( FALSE );
530 that->setPalette( pal ); 530 that->setPalette( pal );
531 setPal = TRUE; 531 setPal = TRUE;
532 } 532 }
533 int iw = 0; 533 int iw = 0;
534 int ih = 0; 534 int ih = 0;
535 if ( t->iconSet() != 0 ) { 535 if ( t->iconSet() != 0 ) {
536 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 536 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
537 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 537 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
538 } 538 }
539 int w = iw + p->fontMetrics().width( t->text() ) + 4; 539 int w = iw + p->fontMetrics().width( t->text() ) + 4;
540 int h = QMAX(p->fontMetrics().height() + 4, ih ); 540 int h = QMAX(p->fontMetrics().height() + 4, ih );
541 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 541 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
542 r.top() + (r.height()-h)/2, w, h ), t, 542 r.top() + (r.height()-h)/2, w, h ), t,
543#if QT_VERSION >= 300 543#if QT_VERSION >= 300
544 t->identifier() == keyboardFocusTab() 544 t->identifier() == keyboardFocusTab()
545#else 545#else
546 t->identitifer() == keyboardFocusTab() 546 t->identitifer() == keyboardFocusTab()
547#endif 547#endif
548 ); 548 );
549 if ( setPal ) { 549 if ( setPal ) {
550 that->unsetPalette(); 550 that->unsetPalette();
551 that->setUpdatesEnabled( TRUE ); 551 that->setUpdatesEnabled( TRUE );
552 } 552 }
553} 553}
554 554
555 555
556void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 556void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
557 QTab* t, bool has_focus ) const 557 QTab* t, bool has_focus ) const
558{ 558{
559 QRect r = t->rect(); 559 QRect r = t->rect();
560 // if ( t->id != currentTab() ) 560 // if ( t->id != currentTab() )
561 //r.moveBy( 1, 1 ); 561 //r.moveBy( 1, 1 );
562 // 562 //
563 if ( t->iconSet() ) { 563 if ( t->iconSet() ) {
564 // the tab has an iconset, draw it in the right mode 564 // the tab has an iconset, draw it in the right mode
565 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 565 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
566 if ( mode == QIconSet::Normal && has_focus ) 566 if ( mode == QIconSet::Normal && has_focus )
567 mode = QIconSet::Active; 567 mode = QIconSet::Active;
568 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 568 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
569 int pixw = pixmap.width(); 569 int pixw = pixmap.width();
570 int pixh = pixmap.height(); 570 int pixh = pixmap.height();
571 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 571 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
572 r.setLeft( r.left() + pixw + 5 ); 572 r.setLeft( r.left() + pixw + 5 );
573 } 573 }
574 574
575 QRect tr = r; 575 QRect tr = r;
576 576
577 if ( r.width() < 20 ) 577 if ( r.width() < 20 )
578 return; 578 return;
579 579
580 if ( t->isEnabled() && isEnabled() ) { 580 if ( t->isEnabled() && isEnabled() ) {
581#if defined(_WS_WIN32_) 581#if defined(_WS_WIN32_)
582 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 582 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
583 p->setPen( colorGroup().buttonText() ); 583 p->setPen( colorGroup().buttonText() );
584 else 584 else
585 p->setPen( colorGroup().foreground() ); 585 p->setPen( colorGroup().foreground() );
586#else 586#else
587 p->setPen( colorGroup().foreground() ); 587 p->setPen( colorGroup().foreground() );
588#endif 588#endif
589 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 589 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
590 } else { 590 } else {
591 p->setPen( palette().disabled().foreground() ); 591 p->setPen( palette().disabled().foreground() );
592 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 592 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
593 } 593 }
594} 594}
595 595
596//--------------------------------------------------------------------------- 596//---------------------------------------------------------------------------
597 597
598Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 598Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
599 : QMainWindow( parent, name, fl ) 599 : QMainWindow( parent, name, fl )
600{ 600{
601 setCaption( tr("Launcher") ); 601 setCaption( tr("Launcher") );
602 602
603 syncDialog = 0; 603 syncDialog = 0;
604 604
605 // we have a pretty good idea how big we'll be 605 // we have a pretty good idea how big we'll be
606 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 606 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
607 607
608 tabs = 0; 608 tabs = 0;
609 rootFolder = 0; 609 rootFolder = 0;
610 docsFolder = 0; 610 docsFolder = 0;
611 611
612 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 612 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
613 //uidgen.store( stamp ); 613 //uidgen.store( stamp );
614 m_timeStamp = QString::number( stamp ); 614 m_timeStamp = QString::number( stamp );
615 615
616 tabs = new CategoryTabWidget( this ); 616 tabs = new CategoryTabWidget( this );
617 tabs->setMaximumWidth( qApp->desktop()->width() ); 617 tabs->setMaximumWidth( qApp->desktop()->width() );
618 setCentralWidget( tabs ); 618 setCentralWidget( tabs );
619 619
620 connect( tabs, SIGNAL(selected(const QString&)), 620 connect( tabs, SIGNAL(selected(const QString&)),
621 this, SLOT(viewSelected(const QString&)) ); 621 this, SLOT(viewSelected(const QString&)) );
622 connect( tabs, SIGNAL(clicked(const AppLnk*)), 622 connect( tabs, SIGNAL(clicked(const AppLnk*)),
623 this, SLOT(select(const AppLnk*))); 623 this, SLOT(select(const AppLnk*)));
624 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 624 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
625 this, SLOT(properties(AppLnk*))); 625 this, SLOT(properties(AppLnk*)));
626 626
627#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 627#if !defined(QT_NO_COP)
628 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 628 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
629 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 629 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
630 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 630 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
631 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 631 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
632 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 632 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
633 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); 633 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
634#endif 634#endif
635 635
636 storage = new StorageInfo( this ); 636 storage = new StorageInfo( this );
637 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 637 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
638 638
639 updateTabs(); 639 updateTabs();
640 640
641 preloadApps(); 641 preloadApps();
642 642
643 in_lnk_props = FALSE; 643 in_lnk_props = FALSE;
644 got_lnk_change = FALSE; 644 got_lnk_change = FALSE;
645} 645}
646 646
647Launcher::~Launcher() 647Launcher::~Launcher()
648{ 648{
649 delete rootFolder; 649 delete rootFolder;
650 delete docsFolder; 650 delete docsFolder;
651} 651}
652 652
653static bool isVisibleWindow(int wid) 653static bool isVisibleWindow(int wid)
654{ 654{
655#ifdef QWS 655#ifdef QWS
656 const QList<QWSWindow> &list = qwsServer->clientWindows(); 656 const QList<QWSWindow> &list = qwsServer->clientWindows();
657 QWSWindow* w; 657 QWSWindow* w;
658 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 658 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
659 if ( w->winId() == wid ) 659 if ( w->winId() == wid )
660 return !w->isFullyObscured(); 660 return !w->isFullyObscured();
661 } 661 }
662#endif 662#endif
663 return FALSE; 663 return FALSE;
664} 664}
665 665
666void Launcher::showMaximized() 666void Launcher::showMaximized()
667{ 667{
668 if ( isVisibleWindow( winId() ) ) 668 if ( isVisibleWindow( winId() ) )
669 doMaximize(); 669 doMaximize();
670 else 670 else
671 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 671 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
672} 672}
673 673
674void Launcher::doMaximize() 674void Launcher::doMaximize()
675{ 675{
676 QMainWindow::showMaximized(); 676 QMainWindow::showMaximized();
677} 677}
678 678
679void Launcher::updateMimeTypes() 679void Launcher::updateMimeTypes()
680{ 680{
681 MimeType::clear(); 681 MimeType::clear();
682 updateMimeTypes(rootFolder); 682 updateMimeTypes(rootFolder);
683} 683}
684 684
685void Launcher::updateMimeTypes(AppLnkSet* folder) 685void Launcher::updateMimeTypes(AppLnkSet* folder)
686{ 686{
687 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 687 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
688 AppLnk *app = it.current(); 688 AppLnk *app = it.current();
689 if ( app->type() == "Folder" ) // No tr 689 if ( app->type() == "Folder" ) // No tr
690 updateMimeTypes((AppLnkSet *)app); 690 updateMimeTypes((AppLnkSet *)app);
691 else { 691 else {
692 MimeType::registerApp(*app); 692 MimeType::registerApp(*app);
693 } 693 }
694 } 694 }
695} 695}
696 696
697/** This is a HACK.... 697/** This is a HACK....
698 * Reason: scanning huge mediums, microdirvers for examples 698 * Reason: scanning huge mediums, microdirvers for examples
699 * consomes time. To avoid that we invented the MediumMountCheck 699 * consomes time. To avoid that we invented the MediumMountCheck
700 * 700 *
701 * a) the user globally disabled medium checking. We can ignore 701 * a) the user globally disabled medium checking. We can ignore
702 * all removable medium 702 * all removable medium
703 * b) the user enabled medium checking globally and we need to use this mimefilter 703 * b) the user enabled medium checking globally and we need to use this mimefilter
704 * c) the user enabled medium checking on a per medium bases 704 * c) the user enabled medium checking on a per medium bases
705 * c1) we already checked and its not ask again turns 705 * c1) we already checked and its not ask again turns
706 * c2) we need to ask and then apply the mimefilter 706 * c2) we need to ask and then apply the mimefilter
707 */ 707 */
708void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 708void Launcher::loadDocs() // ok here comes a hack belonging to Global::
709{ 709{
710 delete docsFolder; 710 delete docsFolder;
711 docsFolder = new DocLnkSet; 711 docsFolder = new DocLnkSet;
712 712
713 DocLnkSet *tmp = 0; 713 DocLnkSet *tmp = 0;
714 QString home = QString(getenv("HOME")) + "/Documents"; 714 QString home = QString(getenv("HOME")) + "/Documents";
715 tmp = new DocLnkSet( home , QString::null); 715 tmp = new DocLnkSet( home , QString::null);
716 docsFolder->appendFrom( *tmp ); 716 docsFolder->appendFrom( *tmp );
717 delete tmp; 717 delete tmp;
718 718
719 // RAM documents 719 // RAM documents
720 StorageInfo storage; 720 StorageInfo storage;
721 const QList<FileSystem> &fileSystems = storage.fileSystems(); 721 const QList<FileSystem> &fileSystems = storage.fileSystems();
722 QListIterator<FileSystem> it ( fileSystems ); 722 QListIterator<FileSystem> it ( fileSystems );
723 723
724 for ( ; it.current(); ++it ) { 724 for ( ; it.current(); ++it ) {
725 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { 725 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
726 tmp = new DocLnkSet( (*it)->path(), QString::null ); 726 tmp = new DocLnkSet( (*it)->path(), QString::null );
727 docsFolder->appendFrom( *tmp ); 727 docsFolder->appendFrom( *tmp );
728 delete tmp; 728 delete tmp;
729 } 729 }
730 } 730 }
731 731
732 Config mediumCfg( "medium"); 732 Config mediumCfg( "medium");
733 mediumCfg.setGroup("main"); 733 mediumCfg.setGroup("main");
734 // a) -zecke we don't want to check 734 // a) -zecke we don't want to check
735 if(!mediumCfg.readBoolEntry("use", true ) ) 735 if(!mediumCfg.readBoolEntry("use", true ) )
736 return; 736 return;
737 737
738 // find out wich filesystems are new in this round 738 // find out wich filesystems are new in this round
739 // We will do this by having a timestamp inside each mountpoint 739 // We will do this by having a timestamp inside each mountpoint
740 // if the current timestamp doesn't match this is a new file system and 740 // if the current timestamp doesn't match this is a new file system and
741 // come up with our MediumMountGui :) let the hacking begin 741 // come up with our MediumMountGui :) let the hacking begin
742 int stamp = uidgen.generate(); 742 int stamp = uidgen.generate();
743 743
744 QString newStamp = QString::number( stamp ); // generates newtime Stamp 744 QString newStamp = QString::number( stamp ); // generates newtime Stamp
745 745
746 // b) 746 // b)
747 if( mediumCfg.readBoolEntry("global", true ) ){ 747 if( mediumCfg.readBoolEntry("global", true ) ){
748 QString mime = configToMime(&mediumCfg).join(";"); 748 QString mime = configToMime(&mediumCfg).join(";");
749 for( it.toFirst(); it.current(); ++it ){ 749 for( it.toFirst(); it.current(); ++it ){
750 if( (*it)->isRemovable() ){ 750 if( (*it)->isRemovable() ){
751 tmp = new DocLnkSet( (*it)->path(), mime ); 751 tmp = new DocLnkSet( (*it)->path(), mime );
752 docsFolder->appendFrom( *tmp ); 752 docsFolder->appendFrom( *tmp );
753 delete tmp; 753 delete tmp;
754 } 754 }
755 } // done 755 } // done