summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
authorzautrix <zautrix>2005-03-26 22:32:32 (UTC)
committer zautrix <zautrix>2005-03-26 22:32:32 (UTC)
commit46b94158f6b115e175516a8432ec5b71f1403834 (patch) (unidiff)
treeb075219da97f93d4e09863fda822722872f8b94b /kalarmd/simplealarmdaemonimpl.cpp
parent7177e62052b732f901eca6627825d0b38d8438be (diff)
downloadkdepimpi-46b94158f6b115e175516a8432ec5b71f1403834.zip
kdepimpi-46b94158f6b115e175516a8432ec5b71f1403834.tar.gz
kdepimpi-46b94158f6b115e175516a8432ec5b71f1403834.tar.bz2
fixes
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
@@ -352,44 +352,44 @@ void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
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";
@@ -551,44 +551,46 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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;
@@ -599,24 +601,25 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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{