summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp6
-rw-r--r--noncore/tools/clock/clock.h5
-rw-r--r--pics/clock/bg.pngbin0 -> 14019 bytes
3 files changed, 9 insertions, 2 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 74b7147..41c99a8 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -263,392 +263,398 @@ void Clock::changeClock( bool a )
263void Clock::clearClock( void ) 263void Clock::clearClock( void )
264{ 264{
265 lcd->display( QTime( 0, 0, 0 ).toString() ); 265 lcd->display( QTime( 0, 0, 0 ).toString() );
266 aclock->display( QTime( 0, 0, 0 ) ); 266 aclock->display( QTime( 0, 0, 0 ) );
267} 267}
268 268
269void Clock::startSWatch() 269void Clock::startSWatch()
270{ 270{
271 if(swatch_running) { 271 if(swatch_running) {
272 stopSWatch(); 272 stopSWatch();
273 return; 273 return;
274 } 274 }
275 qDebug("startSWatch()"); 275 qDebug("startSWatch()");
276 swatch_start.start(); 276 swatch_start.start();
277 set->setText( tr( "Stop" ) ); 277 set->setText( tr( "Stop" ) );
278 t->start( 1000 ); 278 t->start( 1000 );
279 swatch_running = TRUE; 279 swatch_running = TRUE;
280 // disable screensaver while stop watch is running 280 // disable screensaver while stop watch is running
281 toggleScreenSaver( FALSE ); 281 toggleScreenSaver( FALSE );
282} 282}
283 283
284void Clock::stopSWatch() 284void Clock::stopSWatch()
285{ 285{
286 qDebug("stopSWatch()"); 286 qDebug("stopSWatch()");
287 swatch_totalms += swatch_start.elapsed(); 287 swatch_totalms += swatch_start.elapsed();
288 set->setText( tr( "Start" ) ); 288 set->setText( tr( "Start" ) );
289 t->stop(); 289 t->stop();
290 swatch_running = FALSE; 290 swatch_running = FALSE;
291 toggleScreenSaver( TRUE ); 291 toggleScreenSaver( TRUE );
292 updateClock(); 292 updateClock();
293} 293}
294 294
295 295
296void Clock::slotSet() 296void Clock::slotSet()
297{ 297{
298 if ( t->isActive() ) 298 if ( t->isActive() )
299 { 299 {
300 startSWatch(); 300 startSWatch();
301 } 301 }
302 else 302 else
303 { 303 {
304 stopSWatch(); 304 stopSWatch();
305 } 305 }
306} 306}
307 307
308void Clock::slotReset() 308void Clock::slotReset()
309{ 309{
310 t->stop(); 310 t->stop();
311 swatch_start.start(); 311 swatch_start.start();
312 swatch_totalms = 0; 312 swatch_totalms = 0;
313 313
314 if ( swatch_running ) 314 if ( swatch_running )
315 t->start( 1000 ); 315 t->start( 1000 );
316 316
317 updateClock(); 317 updateClock();
318} 318}
319 319
320void Clock::modeSelect( int m ) 320void Clock::modeSelect( int m )
321{ 321{
322 qDebug("Clock::modeSelect( %d) ", m); 322 qDebug("Clock::modeSelect( %d) ", m);
323 if ( m != 0 ) 323 if ( m != 0 )
324 { 324 {
325 lcd->setNumDigits( 8 + 1 + sw_prec ); 325 lcd->setNumDigits( 8 + 1 + sw_prec );
326 lcd->setMinimumWidth( lcd->sizeHint().width() ); 326 lcd->setMinimumWidth( lcd->sizeHint().width() );
327 set->setEnabled( TRUE ); 327 set->setEnabled( TRUE );
328 reset->setEnabled( TRUE ); 328 reset->setEnabled( TRUE );
329 ampmLabel->hide(); 329 ampmLabel->hide();
330 330
331// if(m == 2) { 331// if(m == 2) {
332 if ( !swatch_running ) { 332 if ( !swatch_running ) {
333 t->start( 1000 ); 333 t->start( 1000 );
334 } 334 }
335// else 335// else
336// { 336// {
337// stopSWatch(); 337// stopSWatch();
338// } 338// }
339// } 339// }
340 } 340 }
341 else //clock mode 341 else //clock mode
342 { 342 {
343 lcd->setNumDigits( 5 ); 343 lcd->setNumDigits( 5 );
344 lcd->setMinimumWidth( lcd->sizeHint().width() ); 344 lcd->setMinimumWidth( lcd->sizeHint().width() );
345 set->setEnabled( FALSE ); 345 set->setEnabled( FALSE );
346 reset->setEnabled( FALSE ); 346 reset->setEnabled( FALSE );
347 t->start( 1000 ); 347 t->start( 1000 );
348 } 348 }
349 349
350 Config config( "Clock" ); 350 Config config( "Clock" );
351 config.setGroup( "Mode" ); 351 config.setGroup( "Mode" );
352 config.writeEntry( "clockMode", m ); 352 config.writeEntry( "clockMode", m );
353 updateClock(); 353 updateClock();
354} 354}
355 355
356//this sets the alarm time 356//this sets the alarm time
357void Clock::slotSetAlarm() 357void Clock::slotSetAlarm()
358{ 358{
359 if ( !snoozeBtn->isHidden() ) 359 if ( !snoozeBtn->isHidden() )
360 slotToggleAlarm(); 360 slotToggleAlarm();
361 Set_Alarm *setAlarmDlg; 361 Set_Alarm *setAlarmDlg;
362 setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); 362 setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE );
363 int result = setAlarmDlg->exec(); 363 int result = setAlarmDlg->exec();
364 if ( result == 1 ) { 364 if ( result == 1 ) {
365 Config config( "qpe" ); 365 Config config( "qpe" );
366 config.setGroup( "Time" ); 366 config.setGroup( "Time" );
367 QString tmp; 367 QString tmp;
368 hour = setAlarmDlg->Hour_Slider->value(); 368 hour = setAlarmDlg->Hour_Slider->value();
369 minute = setAlarmDlg->Minute_Slider->value(); 369 minute = setAlarmDlg->Minute_Slider->value();
370 snoozeTime = setAlarmDlg->SnoozeSlider->value(); 370 snoozeTime = setAlarmDlg->SnoozeSlider->value();
371 if ( ampm ) { 371 if ( ampm ) {
372 if ( hour == 12 ) 372 if ( hour == 12 )
373 hour = 0; 373 hour = 0;
374 374
375 if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) 375 if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 )
376 hour += 12; 376 hour += 12;
377 } 377 }
378 config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); 378 config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 );
379 config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); 379 config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 );
380 config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); 380 config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 );
381 config.write(); 381 config.write();
382 } 382 }
383} 383}
384 384
385void Clock::slotSnooze() 385void Clock::slotSnooze()
386{ 386{
387 bSound = FALSE; 387 bSound = FALSE;
388 int warn = 0; 388 int warn = 0;
389 QTime t = QTime::currentTime(); 389 QTime t = QTime::currentTime();
390 QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); 390 QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) );
391 when = whenl; 391 when = whenl;
392 AlarmServer::addAlarm( when, 392 AlarmServer::addAlarm( when,
393 "QPE/Application/clock", 393 "QPE/Application/clock",
394 "alarm(QDateTime,int)", warn ); 394 "alarm(QDateTime,int)", warn );
395 395
396} 396}
397 397
398//toggles alarm on/off 398//toggles alarm on/off
399void Clock::slotToggleAlarm() 399void Clock::slotToggleAlarm()
400{ 400{
401 Config config( "qpe" ); 401 Config config( "qpe" );
402 config.setGroup( "Time" ); 402 config.setGroup( "Time" );
403 if ( alarmBool ) 403 if ( alarmBool )
404 { 404 {
405 config.writeEntry( "clockAlarmSet", "FALSE" ); 405 config.writeEntry( "clockAlarmSet", "FALSE" );
406 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 406 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
407 snoozeBtn->hide(); 407 snoozeBtn->hide();
408 alarmBool = FALSE; 408 alarmBool = FALSE;
409 alarmOff(); 409 alarmOff();
410 } 410 }
411 else 411 else
412 { 412 {
413 config.writeEntry( "clockAlarmSet", "TRUE" ); 413 config.writeEntry( "clockAlarmSet", "TRUE" );
414 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 414 alarmOffBtn->setText( tr( "Alarm Is On" ) );
415 snoozeBtn->show(); 415 snoozeBtn->show();
416 alarmBool = TRUE; 416 alarmBool = TRUE;
417 alarmOn(); 417 alarmOn();
418 } 418 }
419 config.write(); 419 config.write();
420} 420}
421 421
422void Clock::alarmOn() 422void Clock::alarmOn()
423{ 423{
424 QDate d = QDate::currentDate(); 424 QDate d = QDate::currentDate();
425 QTime tm( ( int ) hour, ( int ) minute, 0 ); 425 QTime tm( ( int ) hour, ( int ) minute, 0 );
426 qDebug( "Time set " + tm.toString() ); 426 qDebug( "Time set " + tm.toString() );
427 QTime t = QTime::currentTime(); 427 QTime t = QTime::currentTime();
428 if ( t > tm ) 428 if ( t > tm )
429 d = d.addDays( 1 ); 429 d = d.addDays( 1 );
430 int warn = 0; 430 int warn = 0;
431 QDateTime whenl( d, tm ); 431 QDateTime whenl( d, tm );
432 when = whenl; 432 when = whenl;
433 AlarmServer::addAlarm( when, 433 AlarmServer::addAlarm( when,
434 "QPE/Application/clock", 434 "QPE/Application/clock",
435 "alarm(QDateTime,int)", warn ); 435 "alarm(QDateTime,int)", warn );
436 setCaption( "Alarm set: " + whenl.toString() ); 436 setCaption( "Alarm set: " + whenl.toString() );
437} 437}
438 438
439void Clock::alarmOff() 439void Clock::alarmOff()
440{ 440{
441 int warn = 0; 441 int warn = 0;
442 bSound = FALSE; 442 bSound = FALSE;
443 AlarmServer::deleteAlarm( when, 443 AlarmServer::deleteAlarm( when,
444 "QPE/Application/clock", 444 "QPE/Application/clock",
445 "alarm(QDateTime,int)", warn ); 445 "alarm(QDateTime,int)", warn );
446 qDebug( "Alarm Off " + when.toString() ); 446 qDebug( "Alarm Off " + when.toString() );
447 setCaption( "Clock" ); 447 setCaption( "Clock" );
448} 448}
449 449
450void Clock::clearTimer() 450void Clock::clearTimer()
451{ 451{
452 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 452 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
453 alarmBool = FALSE; 453 alarmBool = FALSE;
454 snoozeBtn->hide(); 454 snoozeBtn->hide();
455 setCaption( "Clock" ); 455 setCaption( "Clock" );
456} 456}
457 457
458void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) 458void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
459{ 459{
460 int stopTimer = 0; 460 int stopTimer = 0;
461 int timerStay = 5000; 461 int timerStay = 5000;
462 bSound = TRUE; 462 bSound = TRUE;
463 qDebug( "Message received in clock" ); 463 qDebug( "Message received in clock" );
464 if ( msg == "alarm(QDateTime,int)" ) 464 if ( msg == "alarm(QDateTime,int)" )
465 { 465 {
466 Config config( "qpe" ); 466 Config config( "qpe" );
467 config.setGroup( "Time" ); 467 config.setGroup( "Time" );
468 if ( config.readBoolEntry( "mp3Alarm", 0 ) ) 468 if ( config.readBoolEntry( "mp3Alarm", 0 ) )
469 { 469 {
470 clearTimer(); 470 clearTimer();
471 pthread_t thread; 471 pthread_t thread;
472 pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); 472 pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/);
473 473
474 } 474 }
475 else 475 else
476 { 476 {
477 477
478 Sound::soundAlarm(); 478 Sound::soundAlarm();
479 stopTimer = startTimer( timerStay ); 479 stopTimer = startTimer( timerStay );
480 } 480 }
481 } 481 }
482 482
483 if ( msg == "timerStart()" ) 483 if ( msg == "timerStart()" )
484 { 484 {
485 slotStartTimer(); 485 slotStartTimer();
486 } 486 }
487 if ( msg == "timerStop()" ) 487 if ( msg == "timerStop()" )
488 { 488 {
489 slotStopTimer(); 489 slotStopTimer();
490 } 490 }
491 if ( msg == "timerReset()" ) 491 if ( msg == "timerReset()" )
492 { 492 {
493 slotResetTimer(); 493 slotResetTimer();
494 } 494 }
495 495
496 show(); 496 show();
497 raise(); 497 raise();
498 QPEApplication::setKeepRunning(); 498 QPEApplication::setKeepRunning();
499 setActiveWindow(); 499 setActiveWindow();
500} 500}
501 501
502void Clock::timerEvent( QTimerEvent *e ) 502void Clock::timerEvent( QTimerEvent *e )
503{ 503{
504 static int stop = 0; 504 static int stop = 0;
505 if ( stop < 120 && bSound ) 505 if ( stop < 120 && bSound )
506 { 506 {
507 Sound::soundAlarm(); 507 Sound::soundAlarm();
508 stop++; 508 stop++;
509 } 509 }
510 else 510 else
511 { 511 {
512 stop = 0; 512 stop = 0;
513 killTimer( e->timerId() ); 513 killTimer( e->timerId() );
514 clearTimer(); 514 clearTimer();
515 setCaption( tr( "Clock: Alarm was missed." ) ); 515 setCaption( tr( "Clock: Alarm was missed." ) );
516 } 516 }
517} 517}
518 518
519AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true)
520{
521 bg = Resource::loadPixmap("clock/bg");
522}
519 523
520QSizePolicy AnalogClock::sizePolicy() const 524QSizePolicy AnalogClock::sizePolicy() const
521{ 525{
522 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); 526 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
523} 527}
524 528
525void AnalogClock::drawContents( QPainter *p ) 529void AnalogClock::drawContents( QPainter *p )
526{ 530{
527 QRect r = contentsRect(); 531 QRect r = contentsRect();
528 QRect fr; 532 QRect fr;
529 533
534 p->drawPixmap(QPoint(0, 0), bg, r);
535
530 if ( r. width ( ) > r. height ( )) 536 if ( r. width ( ) > r. height ( ))
531 fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); 537 fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( ));
532 else 538 else
533 fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); 539 fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( ));
534 540
535 QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); 541 QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 );
536 QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); 542 QPoint l1 ( center. x ( ), fr. y ( ) + 2 );
537 QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); 543 QPoint l2 ( center. x ( ), fr. y ( ) + 8 );
538 544
539 545
540 546
541 if ( clear ) 547 if ( clear )
542 { 548 {
543 erase ( r ); 549 erase ( r );
544 p-> setPen ( NoPen ); 550 p-> setPen ( NoPen );
545 p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); 551 p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base ));
546 p-> drawEllipse ( fr ); 552 p-> drawEllipse ( fr );
547 p-> setBrush ( NoBrush ); 553 p-> setBrush ( NoBrush );
548 554
549 // draw ticks 555 // draw ticks
550 p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); 556 p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) );
551 for ( int i = 0; i < 12; i++ ) 557 for ( int i = 0; i < 12; i++ )
552 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); 558 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
553 } 559 }
554 else 560 else
555 { 561 {
556 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); 562 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime );
557 } 563 }
558 564
559 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); 565 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime );
560 566
561 prevTime = currTime; 567 prevTime = currTime;
562} 568}
563 569
564void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) 570void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 )
565{ 571{
566 QPoint center = r. center ( ); 572 QPoint center = r. center ( );
567 573
568 QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); 574 QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 );
569 QPoint h2( center. x ( ), center. y ( ) ); 575 QPoint h2( center. x ( ), center. y ( ) );
570 576
571 QPoint m1( center. x ( ), r.y() + r.height() / 8 ); 577 QPoint m1( center. x ( ), r.y() + r.height() / 8 );
572 QPoint m2( center. x ( ), center. y ( ) ); 578 QPoint m2( center. x ( ), center. y ( ) );
573 579
574 QPoint s1( center. x ( ), r. y ( ) + 8 ); 580 QPoint s1( center. x ( ), r. y ( ) + 8 );
575 QPoint s2( center. x ( ), center. y ( ) ); 581 QPoint s2( center. x ( ), center. y ( ) );
576 582
577 583
578 if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { 584 if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) {
579 // draw hour pointer 585 // draw hour pointer
580 h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); 586 h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 );
581 h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); 587 h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 );
582 p-> setPen ( QPen ( c, 3 )); 588 p-> setPen ( QPen ( c, 3 ));
583 p-> drawLine ( h1, h2 ); 589 p-> drawLine ( h1, h2 );
584 } 590 }
585 591
586 if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { 592 if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) {
587 // draw minute pointer 593 // draw minute pointer
588 m1 = rotate( center, m1, t.minute() * 6 ); 594 m1 = rotate( center, m1, t.minute() * 6 );
589 m2 = rotate( center, m2, t.minute() * 6 ); 595 m2 = rotate( center, m2, t.minute() * 6 );
590 p-> setPen ( QPen ( c, 2 )); 596 p-> setPen ( QPen ( c, 2 ));
591 p-> drawLine ( m1, m2 ); 597 p-> drawLine ( m1, m2 );
592 } 598 }
593 599
594 if ( !t2 || ( t. second ( ) != t2-> second ( ))) { 600 if ( !t2 || ( t. second ( ) != t2-> second ( ))) {
595 // draw second pointer 601 // draw second pointer
596 s1 = rotate( center, s1, t.second() * 6 ); 602 s1 = rotate( center, s1, t.second() * 6 );
597 s2 = rotate( center, s2, t.second() * 6 ); 603 s2 = rotate( center, s2, t.second() * 6 );
598 p-> setPen ( QPen ( c, 1 )); 604 p-> setPen ( QPen ( c, 1 ));
599 p-> drawLine ( s1, s2 ); 605 p-> drawLine ( s1, s2 );
600 } 606 }
601} 607}
602 608
603void AnalogClock::display( const QTime& t ) 609void AnalogClock::display( const QTime& t )
604{ 610{
605 currTime = t; 611 currTime = t;
606 clear = false; 612 clear = false;
607 repaint( false ); 613 repaint( false );
608 clear = true; 614 clear = true;
609} 615}
610 616
611QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) 617QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
612{ 618{
613 double angle = deg2rad * ( - a + 180 ); 619 double angle = deg2rad * ( - a + 180 );
614 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - 620 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
615 ( p.y() - c.y() ) * sin( angle ); 621 ( p.y() - c.y() ) * sin( angle );
616 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + 622 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
617 ( p.x() - c.x() ) * sin( angle ); 623 ( p.x() - c.x() ) * sin( angle );
618 return QPoint( nx, ny ); 624 return QPoint( nx, ny );
619} 625}
620 626
621void Clock::slotAdjustTime() 627void Clock::slotAdjustTime()
622{ 628{
623 QCopEnvelope e( "QPE/System", "execute(QString)" ); 629 QCopEnvelope e( "QPE/System", "execute(QString)" );
624 e << QString( "systemtime" ); 630 e << QString( "systemtime" );
625} 631}
626 632
627void Clock::slotStartTimer() 633void Clock::slotStartTimer()
628{ 634{
629 if ( clockRB->isChecked() ) 635 if ( clockRB->isChecked() )
630 setSwatchMode( 1); 636 setSwatchMode( 1);
631 startSWatch(); 637 startSWatch();
632} 638}
633 639
634void Clock::slotStopTimer() 640void Clock::slotStopTimer()
635{ 641{
636 if ( clockRB->isChecked() ) 642 if ( clockRB->isChecked() )
637 setSwatchMode( 1); 643 setSwatchMode( 1);
638 stopSWatch(); 644 stopSWatch();
639} 645}
640 646
641void Clock::slotResetTimer() 647void Clock::slotResetTimer()
642{ 648{
643 if ( clockRB->isChecked() ) 649 if ( clockRB->isChecked() )
644 setSwatchMode( 1); 650 setSwatchMode( 1);
645slotReset(); 651slotReset();
646} 652}
647 653
648void Clock::setSwatchMode(int mode) 654void Clock::setSwatchMode(int mode)
649{ 655{
650 qDebug("Clock::setSwatchMode( %d)", mode); 656 qDebug("Clock::setSwatchMode( %d)", mode);
651 swatchRB->setChecked( mode); 657 swatchRB->setChecked( mode);
652 clearClock( ); 658 clearClock( );
653 modeSelect( mode ); 659 modeSelect( mode );
654} 660}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index 1e5aa2c..fa12b61 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -1,108 +1,109 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef CLOCK_H 20#ifndef CLOCK_H
21#define CLOCK_H 21#define CLOCK_H
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qpixmap.h>
25 26
26class QLCDNumber; 27class QLCDNumber;
27class QLabel; 28class QLabel;
28class QTimer; 29class QTimer;
29class QRadioButton; 30class QRadioButton;
30class QPushButton; 31class QPushButton;
31class QDateTime; 32class QDateTime;
32 33
33class AnalogClock : public QFrame 34class AnalogClock : public QFrame
34{ 35{
35 Q_OBJECT 36 Q_OBJECT
36 37
37public: 38public:
38 AnalogClock( QWidget * parent = 0, const char * name = 0 ) 39 AnalogClock( QWidget * parent = 0, const char * name = 0 );
39 : QFrame( parent, name ), clear(true) {}
40 40
41 QSizePolicy sizePolicy() const; 41 QSizePolicy sizePolicy() const;
42 42
43 void display( const QTime& time ); 43 void display( const QTime& time );
44 44
45protected: 45protected:
46 void drawContents( QPainter *p ); 46 void drawContents( QPainter *p );
47 47
48private: 48private:
49 49
50 QPixmap bg;
50 QTime currTime; 51 QTime currTime;
51 QTime prevTime; 52 QTime prevTime;
52 bool clear; 53 bool clear;
53 54
54 QPoint rotate( QPoint center, QPoint p, int angle ); 55 QPoint rotate( QPoint center, QPoint p, int angle );
55 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); 56 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
56 57
57}; 58};
58 59
59class Clock : public QVBox 60class Clock : public QVBox
60{ 61{
61 Q_OBJECT 62 Q_OBJECT
62 63
63public: 64public:
64 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); 65 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 );
65 ~Clock(); 66 ~Clock();
66 QDateTime when; 67 QDateTime when;
67 bool bSound; 68 bool bSound;
68 int hour, minute, snoozeTime; 69 int hour, minute, snoozeTime;
69private slots: 70private slots:
70 void slotSet(); 71 void slotSet();
71 void slotReset(); 72 void slotReset();
72 void modeSelect(int); 73 void modeSelect(int);
73 void updateClock(); 74 void updateClock();
74 void changeClock( bool ); 75 void changeClock( bool );
75 void slotSetAlarm(); 76 void slotSetAlarm();
76 void slotSnooze(); 77 void slotSnooze();
77 void slotToggleAlarm(); 78 void slotToggleAlarm();
78 void alarmOn(); 79 void alarmOn();
79 void alarmOff(); 80 void alarmOff();
80 void appMessage(const QCString& msg, const QByteArray& data); 81 void appMessage(const QCString& msg, const QByteArray& data);
81 void timerEvent( QTimerEvent *e ); 82 void timerEvent( QTimerEvent *e );
82 void slotAdjustTime(); 83 void slotAdjustTime();
83 84
84 void slotStartTimer(); 85 void slotStartTimer();
85 void slotStopTimer(); 86 void slotStopTimer();
86 void slotResetTimer(); 87 void slotResetTimer();
87 void setSwatchMode( int ); 88 void setSwatchMode( int );
88private: 89private:
89 bool alarmBool; 90 bool alarmBool;
90 QTimer *t; 91 QTimer *t;
91 QLCDNumber *lcd; 92 QLCDNumber *lcd;
92 QLabel *date; 93 QLabel *date;
93 QLabel *ampmLabel; 94 QLabel *ampmLabel;
94 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; 95 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn;
95 QRadioButton *clockRB, *swatchRB; 96 QRadioButton *clockRB, *swatchRB;
96 AnalogClock *aclock; 97 AnalogClock *aclock;
97 QTime swatch_start; 98 QTime swatch_start;
98 int swatch_totalms; 99 int swatch_totalms;
99 bool swatch_running; 100 bool swatch_running;
100 bool ampm; 101 bool ampm;
101 void clearClock(); 102 void clearClock();
102 void clearTimer(); 103 void clearTimer();
103 void startSWatch(); 104 void startSWatch();
104 void stopSWatch(); 105 void stopSWatch();
105}; 106};
106 107
107#endif 108#endif
108 109
diff --git a/pics/clock/bg.png b/pics/clock/bg.png
new file mode 100644
index 0000000..0954ca6
--- a/dev/null
+++ b/pics/clock/bg.png
Binary files differ