Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index ec7f730..e8ec033 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -469,213 +469,215 @@ void SimpleAlarmDaemonImpl::confTimer( int time ) | |||
469 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 469 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
470 | int minutes = time; | 470 | int minutes = time; |
471 | if ( minutes == 0 ) { | 471 | if ( minutes == 0 ) { |
472 | if ( ! mTimerTime ) | 472 | if ( ! mTimerTime ) |
473 | return; | 473 | return; |
474 | 474 | ||
475 | QDialog dia ( 0, ("Stop Timer" ), true ); | 475 | QDialog dia ( 0, ("Stop Timer" ), true ); |
476 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); | 476 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); |
477 | lab.setAlignment( AlignCenter ); | 477 | lab.setAlignment( AlignCenter ); |
478 | dia.setCaption(("KO/Pi Timer Stop" )); | 478 | dia.setCaption(("KO/Pi Timer Stop" )); |
479 | QVBoxLayout lay( &dia ); | 479 | QVBoxLayout lay( &dia ); |
480 | lay.addWidget( &lab); | 480 | lay.addWidget( &lab); |
481 | QPushButton ok ( "Stop timer!", &dia); | 481 | QPushButton ok ( "Stop timer!", &dia); |
482 | QFont fo = dia.font(); | 482 | QFont fo = dia.font(); |
483 | fo.setPointSize( 36 ); | 483 | fo.setPointSize( 36 ); |
484 | ok.setFont( fo ); | 484 | ok.setFont( fo ); |
485 | lay.addWidget( &ok); | 485 | lay.addWidget( &ok); |
486 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 486 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
487 | QPushButton con ( "Continue timer!", &dia); | 487 | QPushButton con ( "Continue timer!", &dia); |
488 | fo.setPointSize( 36 ); | 488 | fo.setPointSize( 36 ); |
489 | con.setFont( fo ); | 489 | con.setFont( fo ); |
490 | lay.addWidget( &con); | 490 | lay.addWidget( &con); |
491 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 491 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
492 | lay.setMargin(5); | 492 | lay.setMargin(5); |
493 | lay.setSpacing(5); | 493 | lay.setSpacing(5); |
494 | dia.resize(dia.sizeHint() ); | 494 | dia.resize(dia.sizeHint() ); |
495 | 495 | ||
496 | if ( !dia.exec() ) | 496 | if ( !dia.exec() ) |
497 | return; | 497 | return; |
498 | 498 | ||
499 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 499 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); |
500 | mTimerTime = 0; | 500 | mTimerTime = 0; |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | if ( mTimerTime ) | 503 | if ( mTimerTime ) |
504 | return; | 504 | return; |
505 | if ( minutes == 1 ) { | 505 | if ( minutes == 1 ) { |
506 | return; | 506 | return; |
507 | } | 507 | } |
508 | QString mess = "timer_alarm"; | 508 | QString mess = "timer_alarm"; |
509 | mess += ("Timer Alarm!\n"); | 509 | mess += ("Timer Alarm!\n"); |
510 | if ( minutes == 22 ) { | 510 | if ( minutes == 22 ) { |
511 | mess += ( "Pizza is ready"); | 511 | mess += ( "Pizza is ready"); |
512 | mRunningTimerText = "Pizza"; | 512 | mRunningTimerText = "Pizza"; |
513 | } | 513 | } |
514 | else if ( minutes == 45 ) { | 514 | else if ( minutes == 45 ) { |
515 | mess += ( "Please wake up!"); | 515 | mess += ( "Please wake up!"); |
516 | mRunningTimerText = "Nap"; | 516 | mRunningTimerText = "Nap"; |
517 | } | 517 | } |
518 | else if ( minutes == 5 ) { | 518 | else if ( minutes == 5 ) { |
519 | mess += ( "Tea is ready"); | 519 | mess += ( "Tea is ready"); |
520 | mRunningTimerText = "Tea"; | 520 | mRunningTimerText = "Tea"; |
521 | } | 521 | } |
522 | else if ( minutes == 3 ) { | 522 | else if ( minutes == 3 ) { |
523 | mess += mCustomText; | 523 | mess += mCustomText; |
524 | minutes = mCustomMinutes ; | 524 | minutes = mCustomMinutes ; |
525 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 525 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
526 | int in = mRunningTimerText.find( " " ); | 526 | int in = mRunningTimerText.find( " " ); |
527 | mRunningTimerText = mRunningTimerText.left ( in ); | 527 | mRunningTimerText = mRunningTimerText.left ( in ); |
528 | } | 528 | } |
529 | else { | 529 | else { |
530 | if ( minutes == 2 ) { | 530 | if ( minutes == 2 ) { |
531 | // ask time | 531 | // ask time |
532 | QDialog dia ( 0, ("Customize Timer" ), true ); | 532 | QDialog dia ( 0, ("Customize Timer" ), true ); |
533 | QLabel lab (("Message Text:"), &dia ); | 533 | QLabel lab (("Message Text:"), &dia ); |
534 | dia.setCaption(("KO/Pi Timer" )); | 534 | dia.setCaption(("KO/Pi Timer" )); |
535 | QVBoxLayout lay( &dia ); | 535 | QVBoxLayout lay( &dia ); |
536 | lay.setMargin(5); | 536 | lay.setMargin(5); |
537 | lay.setSpacing(5); | 537 | lay.setSpacing(5); |
538 | lay.addWidget( &lab); | 538 | lay.addWidget( &lab); |
539 | QLineEdit lEdit( mCustomText, &dia ); | 539 | QLineEdit lEdit( mCustomText, &dia ); |
540 | lay.addWidget( &lEdit); | 540 | lay.addWidget( &lEdit); |
541 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 541 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
542 | lay.addWidget( &lab2); | 542 | lay.addWidget( &lab2); |
543 | QHBox hbox1 ( &dia ); | 543 | QHBox hbox1 ( &dia ); |
544 | lay.addWidget( &hbox1); | 544 | lay.addWidget( &hbox1); |
545 | QLabel lab3 (("Hours"), &hbox1 ); | 545 | QLabel lab3 (("Hours"), &hbox1 ); |
546 | QLabel lab4 (("Minutes"), &hbox1 ); | 546 | QLabel lab4 (("Minutes"), &hbox1 ); |
547 | QHBox hbox ( &dia ); | 547 | QHBox hbox ( &dia ); |
548 | QSpinBox spinh( 0, 24, 1,& hbox ); | 548 | QSpinBox spinh( 0, 24, 1,& hbox ); |
549 | QFont fo = dia.font(); | 549 | QFont fo = dia.font(); |
550 | fo.setPointSize( 36 ); | 550 | fo.setPointSize( 36 ); |
551 | QSpinBox spinm( 0, 59, 1,&hbox ); | 551 | QSpinBox spinm( 0, 59, 1,&hbox ); |
552 | spinm.setFont( fo ); | 552 | spinm.setFont( fo ); |
553 | spinh.setFont( fo ); | 553 | spinh.setFont( fo ); |
554 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 554 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
555 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 555 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
556 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 556 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
557 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 557 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
558 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 558 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
559 | spinh.setFixedSize( 100,62 ); | 559 | spinh.setFixedSize( 100,62 ); |
560 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 560 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
561 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 561 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
562 | spinm.downButton ()->setGeometry( 50,50,50,50); | 562 | spinm.downButton ()->setGeometry( 50,50,50,50); |
563 | spinm.setSuffix( " m" ); | 563 | spinm.setSuffix( " m" ); |
564 | spinh.setSuffix( " h" ); | 564 | spinh.setSuffix( " h" ); |
565 | spinm.setWrapping ( true ); | 565 | spinm.setWrapping ( true ); |
566 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 566 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
567 | spinm.setLineStep( 1 ); | 567 | spinm.setLineStep( 1 ); |
568 | spinm.setFixedSize( 110,62 ); | 568 | spinm.setFixedSize( 110,62 ); |
569 | lay.addWidget( &hbox); | 569 | lay.addWidget( &hbox); |
570 | QLabel lab5 ("Timer fires at:", &dia ); | 570 | QLabel lab5 ("Timer fires at:", &dia ); |
571 | lab5.setAlignment( AlignCenter ); | 571 | lab5.setAlignment( AlignCenter ); |
572 | lay.addWidget( &lab5); | 572 | lay.addWidget( &lab5); |
573 | KODateLabel dl ( &dia ); | 573 | KODateLabel dl ( &dia ); |
574 | dl.setAlignment( AlignCenter ); | 574 | dl.setAlignment( AlignCenter ); |
575 | dl.setFont( fo ); | 575 | dl.setFont( fo ); |
576 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); | 576 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); |
577 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); | 577 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); |
578 | lay.addWidget( &dl); | 578 | lay.addWidget( &dl); |
579 | spinh.setValue( mCustomMinutes/60 ); | 579 | spinh.setValue( mCustomMinutes/60 ); |
580 | spinm.setValue( mCustomMinutes%60 ); | 580 | spinm.setValue( mCustomMinutes%60 ); |
581 | QPushButton ok ( "Start timer", &dia); | 581 | QPushButton ok ( "Start timer", &dia); |
582 | ok.setFont( fo ); | 582 | ok.setFont( fo ); |
583 | lay.addWidget( &ok); | 583 | lay.addWidget( &ok); |
584 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 584 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
585 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 585 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
586 | 586 | ||
587 | if ( !dia.exec() ) | 587 | if ( !dia.exec() ) |
588 | return; | 588 | return; |
589 | mCustomText = lEdit.text(); | 589 | mCustomText = lEdit.text(); |
590 | mCustomMinutes = spinh.value()*60+spinm.value(); | 590 | mCustomMinutes = spinh.value()*60+spinm.value(); |
591 | if ( mCustomMinutes == 0 ) | 591 | if ( mCustomMinutes == 0 ) |
592 | mCustomMinutes = 1; | 592 | mCustomMinutes = 1; |
593 | if ( mCustomMinutes > 1440 ) | 593 | if ( mCustomMinutes > 1440 ) |
594 | mCustomMinutes = 1440; | 594 | mCustomMinutes = 1440; |
595 | mess += mCustomText; | 595 | mess += mCustomText; |
596 | minutes = mCustomMinutes; | 596 | minutes = mCustomMinutes; |
597 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 597 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
598 | int in = mRunningTimerText.find( " " ); | 598 | int in = mRunningTimerText.find( " " ); |
599 | mRunningTimerText = mRunningTimerText.left ( in ); | 599 | mRunningTimerText = mRunningTimerText.left ( in ); |
600 | } | 600 | } |
601 | else { | 601 | else { |
602 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | 602 | mess+= QString::number ( minutes ) + ( " minutes are past!"); |
603 | int min = minutes; | 603 | int min = minutes; |
604 | if ( min % 60 == 0 ) | 604 | if ( min % 60 == 0 ) |
605 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); | 605 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); |
606 | else | 606 | else |
607 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); | 607 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | //minutes = 1; | 610 | //minutes = 1; |
611 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 611 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
612 | timerMesssage = mess; | 612 | timerMesssage = mess; |
613 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); | 613 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); |
614 | mTimerTime = 1; | 614 | mTimerTime = 1; |
615 | } | 615 | } |
616 | 616 | ||
617 | void SimpleAlarmDaemonImpl::writeFile() | 617 | void SimpleAlarmDaemonImpl::writeFile() |
618 | { | 618 | { |
619 | QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 619 | QCopEnvelope e("QPE/Application/kopi", "-writeFile"); |
620 | } | 620 | } |
621 | void SimpleAlarmDaemonImpl::showWN() | 621 | void SimpleAlarmDaemonImpl::showWN() |
622 | { | 622 | { |
623 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 623 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
624 | } | 624 | } |
625 | void SimpleAlarmDaemonImpl::newTodo() | 625 | void SimpleAlarmDaemonImpl::newTodo() |
626 | { | 626 | { |
627 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 627 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
628 | } | 628 | } |
629 | 629 | ||
630 | void SimpleAlarmDaemonImpl::newEvent() | 630 | void SimpleAlarmDaemonImpl::newEvent() |
631 | { | 631 | { |
632 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 632 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
633 | 633 | ||
634 | } | 634 | } |
635 | void SimpleAlarmDaemonImpl::newMail() | 635 | void SimpleAlarmDaemonImpl::newMail() |
636 | { | 636 | { |
637 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 637 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
638 | } | 638 | } |
639 | void SimpleAlarmDaemonImpl::showAdd() | 639 | void SimpleAlarmDaemonImpl::showAdd() |
640 | { | 640 | { |
641 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 641 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
642 | } | 642 | } |
643 | void SimpleAlarmDaemonImpl::ringSync() | 643 | void SimpleAlarmDaemonImpl::ringSync() |
644 | { | 644 | { |
645 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 645 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
646 | 646 | ||
647 | } | 647 | } |
648 | void SimpleAlarmDaemonImpl::newCountdown() | 648 | void SimpleAlarmDaemonImpl::newCountdown() |
649 | { | 649 | { |
650 | //recieve("cal_alarm", 10 ); | 650 | //recieve("cal_alarm", 10 ); |
651 | } | 651 | } |
652 | void SimpleAlarmDaemonImpl::simulate() | 652 | void SimpleAlarmDaemonImpl::simulate() |
653 | { | 653 | { |
654 | writeFile(); | 654 | writeFile(); |
655 | QString filename = getenv("QPEDIR") ; | 655 | QString filename = getenv("QPEDIR") ; |
656 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 656 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
657 | startAlarm("Alarm simulation", filename ); | 657 | startAlarm("Alarm simulation", filename ); |
658 | } | 658 | } |
659 | void SimpleAlarmDaemonImpl::showKO() | 659 | void SimpleAlarmDaemonImpl::showKO() |
660 | { | 660 | { |
661 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 661 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
662 | // testing only | ||
663 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | ||
662 | 664 | ||
663 | } | 665 | } |
664 | void SimpleAlarmDaemonImpl::showTodo() | 666 | void SimpleAlarmDaemonImpl::showTodo() |
665 | { | 667 | { |
666 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 668 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
667 | 669 | ||
668 | } | 670 | } |
669 | void SimpleAlarmDaemonImpl::writeJournal() | 671 | void SimpleAlarmDaemonImpl::writeJournal() |
670 | { | 672 | { |
671 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 673 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
672 | 674 | ||
673 | } | 675 | } |
674 | 676 | ||
675 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 677 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
676 | { | 678 | { |
677 | 679 | ||
678 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 680 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
679 | 681 | ||
680 | } | 682 | } |
681 | 683 | ||