author | zautrix <zautrix> | 2005-06-14 19:52:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-14 19:52:48 (UTC) |
commit | c50dea673d7bf65614e042a0e3c0c53c73c705a0 (patch) (unidiff) | |
tree | 04331039e86c4fa1976ba20b60acd2988dc8c19f | |
parent | d9df54411b01cabaf51fcae62b91f227f7eff5f5 (diff) | |
download | kdepimpi-c50dea673d7bf65614e042a0e3c0c53c73c705a0.zip kdepimpi-c50dea673d7bf65614e042a0e3c0c53c73c705a0.tar.gz kdepimpi-c50dea673d7bf65614e042a0e3c0c53c73c705a0.tar.bz2 |
fixx
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index d6e06c8..eff96eb 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -393,29 +393,28 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp() | |||
393 | } else { | 393 | } else { |
394 | 394 | ||
395 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 395 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
396 | QFile file( fileName ); | 396 | QFile file( fileName ); |
397 | if( !QFile::exists( fileName) ) { | 397 | if( !QFile::exists( fileName) ) { |
398 | // write defaults | 398 | // write defaults |
399 | if (!file.open( IO_WriteOnly ) ) { | 399 | if (!file.open( IO_WriteOnly ) ) { |
400 | return; | 400 | return; |
401 | } | 401 | } |
402 | QString configString ; | 402 | QString configString ; |
403 | configString += "#config file for kopi alarm timer\n"; | 403 | configString += "#config file for kopi alarm timer\n"; |
404 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 404 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
405 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; | 405 | configString += "24 hours; 1440\n"; |
406 | configString += "24 h; 1440\n"; | 406 | configString += "8 hours; 480\n"; |
407 | configString += " 8 h; 480\n"; | 407 | configString += "5 hours; 300\n"; |
408 | configString += " 5 h; 300\n"; | 408 | configString += "1 hour; 60\n"; |
409 | configString += " 1 h; 60\n"; | ||
410 | configString += "30 min; 30\n"; | 409 | configString += "30 min; 30\n"; |
411 | configString += "15 min; 15\n"; | 410 | configString += "15 min; 15\n"; |
412 | configString += "SEPARATOR\n"; | 411 | configString += "SEPARATOR\n"; |
413 | configString += "Pizza; 22\n"; | 412 | configString += "Pizza; 22\n"; |
414 | configString += "Nap; 45\n"; | 413 | configString += "Nap; 45\n"; |
415 | configString += "Tea; 5\n"; | 414 | configString += "Tea; 5\n"; |
416 | QTextStream ts( &file ); | 415 | QTextStream ts( &file ); |
417 | ts << configString ; | 416 | ts << configString ; |
418 | file.close(); | 417 | file.close(); |
419 | } | 418 | } |
420 | 419 | ||
421 | if (!file.open( IO_ReadOnly ) ) { | 420 | if (!file.open( IO_ReadOnly ) ) { |
@@ -425,39 +424,39 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp() | |||
425 | bool ok; | 424 | bool ok; |
426 | while ( file.readLine( line, 1024 ) > 0 ) { | 425 | while ( file.readLine( line, 1024 ) > 0 ) { |
427 | //qDebug("read %s ", line.latin1()); | 426 | //qDebug("read %s ", line.latin1()); |
428 | if ( line.left(1 ) != "#" ) { | 427 | if ( line.left(1 ) != "#" ) { |
429 | // no comment | 428 | // no comment |
430 | if ( line.left(9 ) == "SEPARATOR" ) { | 429 | if ( line.left(9 ) == "SEPARATOR" ) { |
431 | mTimerPopUp->insertSeparator(); | 430 | mTimerPopUp->insertSeparator(); |
432 | } else { | 431 | } else { |
433 | QStringList li = QStringList::split(";",line); | 432 | QStringList li = QStringList::split(";",line); |
434 | ok = false; | 433 | ok = false; |
435 | if ( li.count() == 2 ) { | 434 | if ( li.count() == 2 ) { |
436 | int val = li[1].toInt( &ok ); | 435 | int val = li[1].toInt( &ok ); |
437 | if ( ok && val > 2 ) { | 436 | if ( ok && val > 0 ) { |
438 | mTimerPopUp->insertItem( li[0], val); | 437 | mTimerPopUp->insertItem( li[0], val+10); |
439 | } | 438 | } |
440 | } | 439 | } |
441 | } | 440 | } |
442 | } | 441 | } |
443 | } | 442 | } |
444 | file.close(); | 443 | file.close(); |
445 | #if 0 | 444 | #if 0 |
446 | mTimerPopUp->insertItem( "24 h", 1440 ); | 445 | mTimerPopUp->insertItem( "24 hours", 1440 ); |
447 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 446 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
448 | mTimerPopUp->insertItem( " 8 h", 480 ); | 447 | mTimerPopUp->insertItem( " 8 hours", 480 ); |
449 | mTimerPopUp->insertItem( " 5 h", 300 ); | 448 | mTimerPopUp->insertItem( " 5 hours", 300 ); |
450 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 449 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
451 | mTimerPopUp->insertItem( " 1 h", 60 ); | 450 | mTimerPopUp->insertItem( " 1 hour", 60 ); |
452 | mTimerPopUp->insertItem( "30 min", 30 ); | 451 | mTimerPopUp->insertItem( "30 min", 30 ); |
453 | mTimerPopUp->insertItem( "15 min", 15 ); | 452 | mTimerPopUp->insertItem( "15 min", 15 ); |
454 | mTimerPopUp->insertItem( "10 min", 10 ); | 453 | mTimerPopUp->insertItem( "10 min", 10 ); |
455 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 454 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
456 | mTimerPopUp->insertSeparator(); | 455 | mTimerPopUp->insertSeparator(); |
457 | mTimerPopUp->insertItem( "Pizza", 22 ); | 456 | mTimerPopUp->insertItem( "Pizza", 22 ); |
458 | mTimerPopUp->insertItem( "Nap", 45 ); | 457 | mTimerPopUp->insertItem( "Nap", 45 ); |
459 | mTimerPopUp->insertItem( "Tea", 5 ); | 458 | mTimerPopUp->insertItem( "Tea", 5 ); |
460 | #endif | 459 | #endif |
461 | QString text = mCustomText.stripWhiteSpace (); | 460 | QString text = mCustomText.stripWhiteSpace (); |
462 | int in = text.find( " " ); | 461 | int in = text.find( " " ); |
463 | text = text.left ( in ); | 462 | text = text.left ( in ); |
@@ -496,48 +495,36 @@ void SimpleAlarmDaemonImpl::confTimer( int time ) | |||
496 | QPushButton con ( "Continue timer!", &dia); | 495 | QPushButton con ( "Continue timer!", &dia); |
497 | fo.setPointSize( 36 ); | 496 | fo.setPointSize( 36 ); |
498 | con.setFont( fo ); | 497 | con.setFont( fo ); |
499 | lay.addWidget( &con); | 498 | lay.addWidget( &con); |
500 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 499 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
501 | lay.setMargin(5); | 500 | lay.setMargin(5); |
502 | lay.setSpacing(5); | 501 | lay.setSpacing(5); |
503 | dia.resize(dia.sizeHint() ); | 502 | dia.resize(dia.sizeHint() ); |
504 | 503 | ||
505 | if ( !dia.exec() ) | 504 | if ( !dia.exec() ) |
506 | return; | 505 | return; |
507 | 506 | ||
508 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 507 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); |
509 | mTimerTime = 0; | 508 | mTimerTime = 0; |
510 | return; | 509 | return; |
511 | } | 510 | } |
512 | if ( mTimerTime ) | 511 | if ( mTimerTime ) |
513 | return; | 512 | return; |
514 | if ( minutes == 1 ) { | 513 | if ( minutes == 1 ) { |
515 | return; | 514 | return; |
516 | } | 515 | } |
517 | QString mess = "timer_alarm"; | 516 | QString mess = "timer_alarm"; |
518 | mess += ("Timer Alarm!\n"); | 517 | mess += ("Timer Alarm!\n"); |
519 | if ( minutes == 22 ) { | 518 | if ( minutes == 3 ) { |
520 | mess += ( "Pizza is ready"); | ||
521 | mRunningTimerText = "Pizza"; | ||
522 | } | ||
523 | else if ( minutes == 45 ) { | ||
524 | mess += ( "Please wake up!"); | ||
525 | mRunningTimerText = "Nap"; | ||
526 | } | ||
527 | else if ( minutes == 5 ) { | ||
528 | mess += ( "Tea is ready"); | ||
529 | mRunningTimerText = "Tea"; | ||
530 | } | ||
531 | else if ( minutes == 3 ) { | ||
532 | mess += mCustomText; | 519 | mess += mCustomText; |
533 | minutes = mCustomMinutes ; | 520 | minutes = mCustomMinutes ; |
534 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 521 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
535 | int in = mRunningTimerText.find( " " ); | 522 | int in = mRunningTimerText.find( " " ); |
536 | mRunningTimerText = mRunningTimerText.left ( in ); | 523 | mRunningTimerText = mRunningTimerText.left ( in ); |
537 | } | 524 | } |
538 | else { | 525 | else { |
539 | if ( minutes == 2 ) { | 526 | if ( minutes == 2 ) { |
540 | // ask time | 527 | // ask time |
541 | QDialog dia ( 0, ("Customize Timer" ), true ); | 528 | QDialog dia ( 0, ("Customize Timer" ), true ); |
542 | QLabel lab (("Message Text:"), &dia ); | 529 | QLabel lab (("Message Text:"), &dia ); |
543 | dia.setCaption(("KO/Pi Timer" )); | 530 | dia.setCaption(("KO/Pi Timer" )); |
@@ -601,30 +588,27 @@ void SimpleAlarmDaemonImpl::confTimer( int time ) | |||
601 | mCustomMinutes = spinh.value()*60+spinm.value(); | 588 | mCustomMinutes = spinh.value()*60+spinm.value(); |
602 | if ( mCustomMinutes == 0 ) | 589 | if ( mCustomMinutes == 0 ) |
603 | mCustomMinutes = 1; | 590 | mCustomMinutes = 1; |
604 | if ( mCustomMinutes > 1440 ) | 591 | if ( mCustomMinutes > 1440 ) |
605 | mCustomMinutes = 1440; | 592 | mCustomMinutes = 1440; |
606 | mess += mCustomText; | 593 | mess += mCustomText; |
607 | minutes = mCustomMinutes; | 594 | minutes = mCustomMinutes; |
608 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 595 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
609 | int in = mRunningTimerText.find( " " ); | 596 | int in = mRunningTimerText.find( " " ); |
610 | mRunningTimerText = mRunningTimerText.left ( in ); | 597 | mRunningTimerText = mRunningTimerText.left ( in ); |
611 | } | 598 | } |
612 | else { | 599 | else { |
613 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | 600 | mess += mTimerPopUp->text( minutes ); |
614 | int min = minutes; | 601 | mRunningTimerText = mTimerPopUp->text( minutes ); |
615 | if ( min % 60 == 0 ) | 602 | minutes -= 10; |
616 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); | ||
617 | else | ||
618 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); | ||
619 | } | 603 | } |
620 | } | 604 | } |
621 | //minutes = 1; | 605 | //minutes = 1; |
622 | 606 | ||
623 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 607 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
624 | timerMesssage = mess; | 608 | timerMesssage = mess; |
625 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); | 609 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); |
626 | mTimerTime = 1; | 610 | mTimerTime = 1; |
627 | } | 611 | } |
628 | 612 | ||
629 | void SimpleAlarmDaemonImpl::writeFile() | 613 | void SimpleAlarmDaemonImpl::writeFile() |
630 | { | 614 | { |