summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
Unidiff
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index e8ec033..b3da428 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -340,68 +340,68 @@ void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
340 startAlarm( mAlarmMessage, filename ); 340 startAlarm( mAlarmMessage, filename );
341 341
342} 342}
343 343
344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 344int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
345{ 345{
346 return 0; 346 return 0;
347} 347}
348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 348void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
349{ 349{
350 //mAlarmDialog->show(); 350 //mAlarmDialog->show();
351 //mAlarmDialog->raise(); 351 //mAlarmDialog->raise();
352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 352 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
353} 353}
354 354
355 355
356void SimpleAlarmDaemonImpl::fillTimerPopUp() 356void SimpleAlarmDaemonImpl::fillTimerPopUp()
357{ 357{
358 358
359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 359 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
360 if ( mTimerPopupConf == mTimerTime ) { 360 if ( mTimerPopupConf == mTimerTime ) {
361 if ( mTimerTime ) { 361 if ( mTimerTime ) {
362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 362 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
363 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 363 QTime t ( secs/3600, (secs/60)%60, secs%60 );
364 mTimerPopUp->changeItem ( 1 , t.toString() + " (remaining time)"); 364 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
365 } 365 }
366 else { 366 else {
367 QString text = mCustomText.stripWhiteSpace (); 367 QString text = mCustomText.stripWhiteSpace ();
368 int in = text.find( " " ); 368 int in = text.find( " " );
369 text = text.left ( in ); 369 text = text.left ( in );
370 mTimerPopUp->changeItem ( 3, text ); 370 mTimerPopUp->changeItem ( 3, text );
371 } 371 }
372 return; 372 return;
373 } 373 }
374 mTimerPopupConf = mTimerTime; 374 mTimerPopupConf = mTimerTime;
375 mTimerPopUp->clear(); 375 mTimerPopUp->clear();
376 if ( mTimerTime ) { 376 if ( mTimerTime ) {
377 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 377 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
378 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 378 QTime t ( secs/3600, (secs/60)%60, secs%60 );
379 379
380 380
381 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 381 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
382 mTimerPopUp->insertItem( t.toString() + " (remaining time)",1); 382 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
383 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm time)",2); 383 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
384 } else { 384 } else {
385 385
386 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 386 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
387 QFile file( fileName ); 387 QFile file( fileName );
388 if( !QFile::exists( fileName) ) { 388 if( !QFile::exists( fileName) ) {
389 // write defaults 389 // write defaults
390 if (!file.open( IO_WriteOnly ) ) { 390 if (!file.open( IO_WriteOnly ) ) {
391 return; 391 return;
392 } 392 }
393 QString configString ; 393 QString configString ;
394 configString += "#config file for kopi alarm timer\n"; 394 configString += "#config file for kopi alarm timer\n";
395 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 395 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
396 configString += "#NOTE: minimum value for timer are 3 minutes!\n"; 396 configString += "#NOTE: minimum value for timer are 3 minutes!\n";
397 configString += "24 h; 1440\n"; 397 configString += "24 h; 1440\n";
398 configString += " 8 h; 480\n"; 398 configString += " 8 h; 480\n";
399 configString += " 5 h; 300\n"; 399 configString += " 5 h; 300\n";
400 configString += " 1 h; 60\n"; 400 configString += " 1 h; 60\n";
401 configString += "30 min; 30\n"; 401 configString += "30 min; 30\n";
402 configString += "15 min; 15\n"; 402 configString += "15 min; 15\n";
403 configString += "SEPARATOR\n"; 403 configString += "SEPARATOR\n";
404 configString += "Pizza; 22\n"; 404 configString += "Pizza; 22\n";
405 configString += "Nap; 45\n"; 405 configString += "Nap; 45\n";
406 configString += "Tea; 5\n"; 406 configString += "Tea; 5\n";
407 QTextStream ts( &file ); 407 QTextStream ts( &file );
@@ -539,96 +539,99 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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.setDefault( true );
582 ok.setFont( fo ); 583 ok.setFont( fo );
584 spinh.setFocus();
583 lay.addWidget( &ok); 585 lay.addWidget( &ok);
584 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 586 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
585 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 587 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
586 588
587 if ( !dia.exec() ) 589 if ( !dia.exec() )
588 return; 590 return;
589 mCustomText = lEdit.text(); 591 mCustomText = lEdit.text();
590 mCustomMinutes = spinh.value()*60+spinm.value(); 592 mCustomMinutes = spinh.value()*60+spinm.value();
591 if ( mCustomMinutes == 0 ) 593 if ( mCustomMinutes == 0 )
592 mCustomMinutes = 1; 594 mCustomMinutes = 1;
593 if ( mCustomMinutes > 1440 ) 595 if ( mCustomMinutes > 1440 )
594 mCustomMinutes = 1440; 596 mCustomMinutes = 1440;
595 mess += mCustomText; 597 mess += mCustomText;
596 minutes = mCustomMinutes; 598 minutes = mCustomMinutes;
597 mRunningTimerText = mCustomText.stripWhiteSpace (); 599 mRunningTimerText = mCustomText.stripWhiteSpace ();
598 int in = mRunningTimerText.find( " " ); 600 int in = mRunningTimerText.find( " " );
599 mRunningTimerText = mRunningTimerText.left ( in ); 601 mRunningTimerText = mRunningTimerText.left ( in );
600 } 602 }
601 else { 603 else {
602 mess+= QString::number ( minutes ) + ( " minutes are past!"); 604 mess+= QString::number ( minutes ) + ( " minutes are past!");
603 int min = minutes; 605 int min = minutes;
604 if ( min % 60 == 0 ) 606 if ( min % 60 == 0 )
605 mRunningTimerText = QString::number ( min/60 ) + ( " hours"); 607 mRunningTimerText = QString::number ( min/60 ) + ( " hours");
606 else 608 else
607 mRunningTimerText = QString::number ( minutes ) + ( " minutes"); 609 mRunningTimerText = QString::number ( minutes ) + ( " minutes");
608 } 610 }
609 } 611 }
610 //minutes = 1; 612 //minutes = 1;
613
611 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 614 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
612 timerMesssage = mess; 615 timerMesssage = mess;
613 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 616 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
614 mTimerTime = 1; 617 mTimerTime = 1;
615} 618}
616 619
617void SimpleAlarmDaemonImpl::writeFile() 620void SimpleAlarmDaemonImpl::writeFile()
618{ 621{
619 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 622 QCopEnvelope e("QPE/Application/kopi", "-writeFile");
620} 623}
621void SimpleAlarmDaemonImpl::showWN() 624void SimpleAlarmDaemonImpl::showWN()
622{ 625{
623 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 626 QCopEnvelope e("QPE/Application/kopi", "-showWN");
624} 627}
625void SimpleAlarmDaemonImpl::newTodo() 628void SimpleAlarmDaemonImpl::newTodo()
626{ 629{
627 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 630 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
628} 631}
629 632
630void SimpleAlarmDaemonImpl::newEvent() 633void SimpleAlarmDaemonImpl::newEvent()
631{ 634{
632 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 635 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
633 636
634} 637}