summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 141a9ce..15eff28 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -257,478 +257,491 @@ void SimpleAlarmDaemonImpl::saveSlot( int load )
257 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 257 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
258 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 258 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
259 QTextStream ts( &file ); 259 QTextStream ts( &file );
260 ts << configString ; 260 ts << configString ;
261 file.close(); 261 file.close();
262 } 262 }
263 263
264} 264}
265void SimpleAlarmDaemonImpl::confSuspend( int num ) 265void SimpleAlarmDaemonImpl::confSuspend( int num )
266{ 266{
267 mSuspendPopUp->setItemChecked ( mSuspend,false ); 267 mSuspendPopUp->setItemChecked ( mSuspend,false );
268 mSuspend = num; 268 mSuspend = num;
269 mSuspendPopUp->setItemChecked ( mSuspend,true ); 269 mSuspendPopUp->setItemChecked ( mSuspend,true );
270} 270}
271void SimpleAlarmDaemonImpl::confPause( int num ) 271void SimpleAlarmDaemonImpl::confPause( int num )
272{ 272{
273 mPausePopUp->setItemChecked ( mPausePlay,false ); 273 mPausePopUp->setItemChecked ( mPausePlay,false );
274 mPausePlay = num; 274 mPausePlay = num;
275 mPausePopUp->setItemChecked ( mPausePlay,true ); 275 mPausePopUp->setItemChecked ( mPausePlay,true );
276} 276}
277void SimpleAlarmDaemonImpl::confSound( int num ) 277void SimpleAlarmDaemonImpl::confSound( int num )
278{ 278{
279 if ( num == 0 ) { 279 if ( num == 0 ) {
280 wavAlarm = false; 280 wavAlarm = false;
281 mSoundPopUp->setItemChecked ( 0, true ); 281 mSoundPopUp->setItemChecked ( 0, true );
282 mSoundPopUp->setItemChecked ( 1, false ); 282 mSoundPopUp->setItemChecked ( 1, false );
283 } else { 283 } else {
284 wavAlarm = true; 284 wavAlarm = true;
285 mSoundPopUp->setItemChecked ( 0, false ); 285 mSoundPopUp->setItemChecked ( 0, false );
286 mSoundPopUp->setItemChecked ( 1, true ); 286 mSoundPopUp->setItemChecked ( 1, true );
287 } 287 }
288} 288}
289void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 289void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
290{ 290{
291 if ( num == 1000 ) { 291 if ( num == 1000 ) {
292 simulate(); 292 simulate();
293 return; 293 return;
294 } 294 }
295 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 295 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
296 mPlayBeeps = num; 296 mPlayBeeps = num;
297 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 297 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
298} 298}
299 299
300void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 300void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
301{ 301{
302 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 302 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
303 QString mess = QString::fromUtf8(msg.data()); 303 QString mess = QString::fromUtf8(msg.data());
304 mAlarmMessage = mess.mid( 9 ); 304 mAlarmMessage = mess.mid( 9 );
305 QString filename = getenv("QPEDIR") ; 305 QString filename = getenv("QPEDIR") ;
306 filename += "/pics/kdepim/korganizer/koalarm.wav"; 306 filename += "/pics/kdepim/korganizer/koalarm.wav";
307 QString tempfilename; 307 QString tempfilename;
308 if ( mess.left( 13 ) == "suspend_alarm") { 308 if ( mess.left( 13 ) == "suspend_alarm") {
309 bool error = false; 309 bool error = false;
310 int len = mess.mid( 13 ).find("+++"); 310 int len = mess.mid( 13 ).find("+++");
311 if ( len < 2 ) 311 if ( len < 2 )
312 error = true; 312 error = true;
313 else { 313 else {
314 tempfilename = mess.mid( 13, len ); 314 tempfilename = mess.mid( 13, len );
315 if ( !QFile::exists( tempfilename ) ) 315 if ( !QFile::exists( tempfilename ) )
316 error = true; 316 error = true;
317 } 317 }
318 if ( ! error ) { 318 if ( ! error ) {
319 filename = tempfilename; 319 filename = tempfilename;
320 } 320 }
321 mAlarmMessage = mess.mid( 13+len+3 ); 321 mAlarmMessage = mess.mid( 13+len+3 );
322 //qDebug("suspend file %s ",tempfilename.latin1() ); 322 //qDebug("suspend file %s ",tempfilename.latin1() );
323 startAlarm( mAlarmMessage, filename); 323 startAlarm( mAlarmMessage, filename);
324 return; 324 return;
325 } 325 }
326 if ( mess.left( 11 ) == "timer_alarm") { 326 if ( mess.left( 11 ) == "timer_alarm") {
327 mTimerTime = 0; 327 mTimerTime = 0;
328 startAlarm( mess.mid( 11 ), filename ); 328 startAlarm( mess.mid( 11 ), filename );
329 return; 329 return;
330 } 330 }
331 if ( mess.left( 10 ) == "proc_alarm") { 331 if ( mess.left( 10 ) == "proc_alarm") {
332 bool error = false; 332 bool error = false;
333 int len = mess.mid( 10 ).find("+++"); 333 int len = mess.mid( 10 ).find("+++");
334 if ( len < 2 ) 334 if ( len < 2 )
335 error = true; 335 error = true;
336 else { 336 else {
337 tempfilename = mess.mid( 10, len ); 337 tempfilename = mess.mid( 10, len );
338 if ( !QFile::exists( tempfilename ) ) 338 if ( !QFile::exists( tempfilename ) )
339 error = true; 339 error = true;
340 } 340 }
341 if ( error ) { 341 if ( error ) {
342 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 342 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
343 mAlarmMessage += mess.mid( 10+len+3+9 ); 343 mAlarmMessage += mess.mid( 10+len+3+9 );
344 } else { 344 } else {
345 //qDebug("-----system command %s ",tempfilename.latin1() ); 345 //qDebug("-----system command %s ",tempfilename.latin1() );
346 if ( vfork () == 0 ) { 346 if ( vfork () == 0 ) {
347 execl ( tempfilename.latin1(), 0 ); 347 execl ( tempfilename.latin1(), 0 );
348 return; 348 return;
349 } 349 }
350 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 350 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
351 return; 351 return;
352 } 352 }
353 353
354 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 354 //qDebug("+++++++system command %s ",tempfilename.latin1() );
355 } 355 }
356 if ( mess.left( 11 ) == "audio_alarm") { 356 if ( mess.left( 11 ) == "audio_alarm") {
357 bool error = false; 357 bool error = false;
358 int len = mess.mid( 11 ).find("+++"); 358 int len = mess.mid( 11 ).find("+++");
359 if ( len < 2 ) 359 if ( len < 2 )
360 error = true; 360 error = true;
361 else { 361 else {
362 tempfilename = mess.mid( 11, len ); 362 tempfilename = mess.mid( 11, len );
363 if ( !QFile::exists( tempfilename ) ) 363 if ( !QFile::exists( tempfilename ) )
364 error = true; 364 error = true;
365 } 365 }
366 if ( ! error ) { 366 if ( ! error ) {
367 filename = tempfilename; 367 filename = tempfilename;
368 } 368 }
369 mAlarmMessage = mess.mid( 11+len+3+9 ); 369 mAlarmMessage = mess.mid( 11+len+3+9 );
370 //qDebug("audio file command %s ",tempfilename.latin1() ); 370 //qDebug("audio file command %s ",tempfilename.latin1() );
371 } 371 }
372 if ( mess.left( 9 ) == "cal_alarm") { 372 if ( mess.left( 9 ) == "cal_alarm") {
373 mAlarmMessage = mess.mid( 9 ) ; 373 mAlarmMessage = mess.mid( 9 ) ;
374 } 374 }
375 375
376 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 376 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
377 startAlarm( mAlarmMessage, filename ); 377 startAlarm( mAlarmMessage, filename );
378 378
379} 379}
380 380
381int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 381int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
382{ 382{
383 return 0; 383 return 0;
384} 384}
385void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 385void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
386{ 386{
387 //mAlarmDialog->show(); 387 //mAlarmDialog->show();
388 //mAlarmDialog->raise(); 388 //mAlarmDialog->raise();
389 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 389 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
390} 390}
391 391
392 392
393void SimpleAlarmDaemonImpl::fillTimerPopUp() 393void SimpleAlarmDaemonImpl::fillTimerPopUp()
394{ 394{
395 395
396 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 396 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
397 if ( mTimerPopupConf == mTimerTime ) { 397 if ( mTimerPopupConf == mTimerTime ) {
398 if ( mTimerTime ) { 398 if ( mTimerTime ) {
399 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 399 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
400 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 400 QTime t ( secs/3600, (secs/60)%60, secs%60 );
401 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 401 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
402 } 402 }
403 else { 403 else {
404 QString text = mCustomText.stripWhiteSpace (); 404 QString text = mCustomText.stripWhiteSpace ();
405 int in = text.find( " " ); 405 int in = text.find( " " );
406 text = text.left ( in ); 406 text = text.left ( in );
407 mTimerPopUp->changeItem ( 3, text ); 407 mTimerPopUp->changeItem ( 3, text );
408 } 408 }
409 return; 409 return;
410 } 410 }
411 mTimerPopupConf = mTimerTime; 411 mTimerPopupConf = mTimerTime;
412 mTimerPopUp->clear(); 412 mTimerPopUp->clear();
413 if ( mTimerTime ) { 413 if ( mTimerTime ) {
414 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 414 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
415 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 415 QTime t ( secs/3600, (secs/60)%60, secs%60 );
416 416
417 417
418 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 418 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
419 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 419 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
420 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 420 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
421 } else { 421 } else {
422 422
423 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 423 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
424 QFile file( fileName ); 424 QFile file( fileName );
425 if( !QFile::exists( fileName) ) { 425 if( !QFile::exists( fileName) ) {
426 // write defaults 426 // write defaults
427 if (!file.open( IO_WriteOnly ) ) { 427 if (!file.open( IO_WriteOnly ) ) {
428 return; 428 return;
429 } 429 }
430 QString configString ; 430 QString configString ;
431 configString += "#config file for kopi alarm timer\n"; 431 configString += "#config file for kopi alarm timer\n";
432 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 432 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
433 configString += "24 hours; 1440\n"; 433 configString += "24 hours; 1440\n";
434 configString += "9 hours; 540\n"; 434 configString += "9 hours; 540\n";
435 configString += "8 hours; 480\n"; 435 configString += "8 hours; 480\n";
436 configString += "1 hour; 60\n"; 436 configString += "1 hour; 60\n";
437 configString += "30 min; 30\n"; 437 configString += "30 min; 30\n";
438 configString += "15 min; 15\n"; 438 configString += "15 min; 15\n";
439 configString += "SEPARATOR\n"; 439 configString += "SEPARATOR\n";
440 configString += "Pizza; 22\n"; 440 configString += "Pizza; 22\n";
441 configString += "Nap; 45\n"; 441 configString += "Nap; 45\n";
442 configString += "Tea; 5\n"; 442 configString += "Tea; 5\n";
443 QTextStream ts( &file ); 443 QTextStream ts( &file );
444 ts << configString ; 444 ts << configString ;
445 file.close(); 445 file.close();
446 } 446 }
447 447
448 if (!file.open( IO_ReadOnly ) ) { 448 if (!file.open( IO_ReadOnly ) ) {
449 return ; 449 return ;
450 } 450 }
451 QString line; 451 QString line;
452 bool ok; 452 bool ok;
453 while ( file.readLine( line, 1024 ) > 0 ) { 453 while ( file.readLine( line, 1024 ) > 0 ) {
454 //qDebug("read %s ", line.latin1()); 454 //qDebug("read %s ", line.latin1());
455 if ( line.left(1 ) != "#" ) { 455 if ( line.left(1 ) != "#" ) {
456 // no comment 456 // no comment
457 if ( line.left(9 ) == "SEPARATOR" ) { 457 if ( line.left(9 ) == "SEPARATOR" ) {
458 mTimerPopUp->insertSeparator(); 458 mTimerPopUp->insertSeparator();
459 } else { 459 } else {
460 QStringList li = QStringList::split(";",line); 460 QStringList li = QStringList::split(";",line);
461 ok = false; 461 ok = false;
462 if ( li.count() == 2 ) { 462 if ( li.count() == 2 ) {
463 int val = li[1].toInt( &ok ); 463 int val = li[1].toInt( &ok );
464 if ( ok && val > 0 ) { 464 if ( ok && val > 0 ) {
465 mTimerPopUp->insertItem( li[0], val+10); 465 mTimerPopUp->insertItem( li[0], val+10);
466 } 466 }
467 } 467 }
468 } 468 }
469 } 469 }
470 } 470 }
471 file.close(); 471 file.close();
472#if 0 472#if 0
473 mTimerPopUp->insertItem( "24 hours", 1440 ); 473 mTimerPopUp->insertItem( "24 hours", 1440 );
474 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 474 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
475 mTimerPopUp->insertItem( " 8 hours", 480 ); 475 mTimerPopUp->insertItem( " 8 hours", 480 );
476 mTimerPopUp->insertItem( " 5 hours", 300 ); 476 mTimerPopUp->insertItem( " 5 hours", 300 );
477 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 477 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
478 mTimerPopUp->insertItem( " 1 hour", 60 ); 478 mTimerPopUp->insertItem( " 1 hour", 60 );
479 mTimerPopUp->insertItem( "30 min", 30 ); 479 mTimerPopUp->insertItem( "30 min", 30 );
480 mTimerPopUp->insertItem( "15 min", 15 ); 480 mTimerPopUp->insertItem( "15 min", 15 );
481 mTimerPopUp->insertItem( "10 min", 10 ); 481 mTimerPopUp->insertItem( "10 min", 10 );
482 //mTimerPopUp->insertItem( " 5 min", 5 ); 482 //mTimerPopUp->insertItem( " 5 min", 5 );
483 mTimerPopUp->insertSeparator(); 483 mTimerPopUp->insertSeparator();
484 mTimerPopUp->insertItem( "Pizza", 22 ); 484 mTimerPopUp->insertItem( "Pizza", 22 );
485 mTimerPopUp->insertItem( "Nap", 45 ); 485 mTimerPopUp->insertItem( "Nap", 45 );
486 mTimerPopUp->insertItem( "Tea", 5 ); 486 mTimerPopUp->insertItem( "Tea", 5 );
487#endif 487#endif
488 QString text = mCustomText.stripWhiteSpace (); 488 QString text = mCustomText.stripWhiteSpace ();
489 int in = text.find( " " ); 489 int in = text.find( " " );
490 text = text.left ( in ); 490 text = text.left ( in );
491 mTimerPopUp->insertItem( text, 3 ); 491 mTimerPopUp->insertItem( text, 3 );
492 mTimerPopUp->insertSeparator(); 492 mTimerPopUp->insertSeparator();
493 mTimerPopUp->insertItem( "Customize", 2 ); 493 mTimerPopUp->insertItem( "Customize", 2 );
494 } 494 }
495 495
496} 496}
497 497
498void SimpleAlarmDaemonImpl::showTimer() 498void SimpleAlarmDaemonImpl::showTimer()
499{ 499{
500 fillTimerPopUp(); 500 fillTimerPopUp();
501} 501}
502 502
503void SimpleAlarmDaemonImpl::confTimer( int time ) 503void SimpleAlarmDaemonImpl::confTimer( int time )
504{ 504{
505 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 505 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
506 int minutes = time; 506 int minutes = time;
507 if ( minutes == 0 ) { 507 if ( minutes == 0 ) {
508 if ( ! mTimerTime ) 508 if ( ! mTimerTime )
509 return; 509 return;
510 510
511 QDialog dia ( 0, ("Stop Timer" ), true ); 511 QDialog dia ( 0, ("Stop Timer" ), true );
512 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 512 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
513 lab.setAlignment( AlignCenter ); 513 lab.setAlignment( AlignCenter );
514 dia.setCaption(("KO/Pi Timer Stop" )); 514 dia.setCaption(("KO/Pi Timer Stop" ));
515 QVBoxLayout lay( &dia ); 515 QVBoxLayout lay( &dia );
516 lay.addWidget( &lab); 516 lay.addWidget( &lab);
517 QPushButton ok ( "Stop timer!", &dia); 517 QPushButton ok ( "Stop timer!", &dia);
518 QFont fo = dia.font(); 518 QFont fo = dia.font();
519 fo.setPointSize( 36 ); 519 fo.setPointSize( 36 );
520 ok.setFont( fo ); 520 ok.setFont( fo );
521 lay.addWidget( &ok); 521 lay.addWidget( &ok);
522 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 522 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
523 QPushButton con ( "Continue timer!", &dia); 523 QPushButton con ( "Continue timer!", &dia);
524 fo.setPointSize( 36 ); 524 fo.setPointSize( 36 );
525 con.setFont( fo ); 525 con.setFont( fo );
526 lay.addWidget( &con); 526 lay.addWidget( &con);
527 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 527 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
528 lay.setMargin(5); 528 lay.setMargin(5);
529 lay.setSpacing(5); 529 lay.setSpacing(5);
530 dia.resize(dia.sizeHint() ); 530 dia.resize(dia.sizeHint() );
531 531
532 if ( !dia.exec() ) 532 if ( !dia.exec() )
533 return; 533 return;
534 534
535 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 535 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
536 mTimerTime = 0; 536 mTimerTime = 0;
537 return; 537 return;
538 } 538 }
539 if ( mTimerTime ) 539 if ( mTimerTime )
540 return; 540 return;
541 if ( minutes == 1 ) { 541 if ( minutes == 1 ) {
542 return; 542 return;
543 } 543 }
544 QString mess = "timer_alarm"; 544 QString mess = "timer_alarm";
545 QString disp; 545 QString disp;
546 mess += ("Timer Alarm!\n"); 546 mess += ("Timer Alarm!\n");
547 if ( minutes == 3 ) { 547 if ( minutes == 3 ) {
548 mess += mCustomText; 548 mess += mCustomText;
549 minutes = mCustomMinutes ; 549 minutes = mCustomMinutes ;
550 mRunningTimerText = mCustomText.stripWhiteSpace (); 550 mRunningTimerText = mCustomText.stripWhiteSpace ();
551 int in = mRunningTimerText.find( " " ); 551 int in = mRunningTimerText.find( " " );
552 mRunningTimerText = mRunningTimerText.left ( in ); 552 mRunningTimerText = mRunningTimerText.left ( in );
553 disp = mCustomText; 553 disp = mCustomText;
554 } 554 }
555 else { 555 else {
556 if ( minutes == 2 ) { 556 if ( minutes == 2 ) {
557 // ask time 557 // ask time
558 QDialog dia ( 0, ("Customize Timer" ), true ); 558 QDialog dia ( 0, ("Customize Timer" ), true );
559 QLabel lab (("Message Text:"), &dia ); 559 QLabel lab (("Message Text:"), &dia );
560 dia.setCaption(("KO/Pi Timer" )); 560 dia.setCaption(("KO/Pi Timer" ));
561 QVBoxLayout lay( &dia ); 561 QVBoxLayout lay( &dia );
562 lay.setMargin(5); 562 lay.setMargin(5);
563 lay.setSpacing(5); 563 lay.setSpacing(5);
564 lay.addWidget( &lab); 564 lay.addWidget( &lab);
565 QLineEdit lEdit( mCustomText, &dia ); 565 QLineEdit lEdit( mCustomText, &dia );
566 lay.addWidget( &lEdit); 566 lay.addWidget( &lEdit);
567 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 567 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
568 lay.addWidget( &lab2); 568 lay.addWidget( &lab2);
569 QHBox hbox1 ( &dia ); 569 QHBox hbox1 ( &dia );
570 lay.addWidget( &hbox1); 570 lay.addWidget( &hbox1);
571 QLabel lab3 (("Hours"), &hbox1 ); 571 QLabel lab3 (("Hours"), &hbox1 );
572 QLabel lab4 (("Minutes"), &hbox1 ); 572 QLabel lab4 (("Minutes"), &hbox1 );
573 QHBox hbox ( &dia ); 573 QHBox hbox ( &dia );
574 QSpinBox spinh( 0, 24, 1,& hbox ); 574 QSpinBox spinh( 0, 24, 1,& hbox );
575 QFont fo = dia.font(); 575 QFont fo = dia.font();
576 fo.setPointSize( 36 ); 576 fo.setPointSize( 36 );
577 QSpinBox spinm( 0, 59, 1,&hbox ); 577 QSpinBox spinm( 0, 59, 1,&hbox );
578 spinm.setFont( fo ); 578 spinm.setFont( fo );
579 spinh.setFont( fo ); 579 spinh.setFont( fo );
580 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 580 spinh.setButtonSymbols( QSpinBox::PlusMinus );
581 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 581 spinm.setButtonSymbols( QSpinBox::PlusMinus );
582 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 582 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
583 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 583 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
584 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 584 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
585 spinh.setFixedSize( 100,62 ); 585 spinh.setFixedSize( 100,62 );
586 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 586 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
587 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 587 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
588 spinm.downButton ()->setGeometry( 50,50,50,50); 588 spinm.downButton ()->setGeometry( 50,50,50,50);
589 // spinm.setSuffix( " m" ); 589 // spinm.setSuffix( " m" );
590 //spinh.setSuffix( " h" ); 590 //spinh.setSuffix( " h" );
591 spinm.setWrapping ( true ); 591 spinm.setWrapping ( true );
592 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 592 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
593 spinm.setLineStep( 1 ); 593 spinm.setLineStep( 1 );
594 spinm.setFixedSize( 110,62 ); 594 spinm.setFixedSize( 110,62 );
595 lay.addWidget( &hbox); 595 lay.addWidget( &hbox);
596 QLabel lab5 ("Timer fires at:", &dia ); 596 QLabel lab5 ("Timer fires at:", &dia );
597 lab5.setAlignment( AlignCenter ); 597 lab5.setAlignment( AlignCenter );
598 lay.addWidget( &lab5); 598 lay.addWidget( &lab5);
599 KODateLabel dl ( &dia ); 599 KODateLabel dl ( &dia );
600 dl.setAlignment( AlignCenter ); 600 dl.setAlignment( AlignCenter );
601 dl.setFont( fo ); 601 dl.setFont( fo );
602 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 602 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
603 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 603 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
604 lay.addWidget( &dl); 604 lay.addWidget( &dl);
605 spinh.setValue( mCustomMinutes/60 ); 605 spinh.setValue( mCustomMinutes/60 );
606 spinm.setValue( mCustomMinutes%60 ); 606 spinm.setValue( mCustomMinutes%60 );
607 QPushButton ok ( "Start timer", &dia); 607 QPushButton ok ( "Start timer", &dia);
608 ok.setDefault( true ); 608 ok.setDefault( true );
609 ok.setFont( fo ); 609 ok.setFont( fo );
610 spinh.setFocus(); 610 spinh.setFocus();
611 lay.addWidget( &ok); 611 lay.addWidget( &ok);
612 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 612 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
613 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 613 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
614 614
615 if ( !dia.exec() ) 615 if ( !dia.exec() )
616 return; 616 return;
617 mCustomText = lEdit.text(); 617 mCustomText = lEdit.text();
618 mCustomMinutes = spinh.value()*60+spinm.value(); 618 mCustomMinutes = spinh.value()*60+spinm.value();
619 if ( mCustomMinutes == 0 ) 619 if ( mCustomMinutes == 0 )
620 mCustomMinutes = 1; 620 mCustomMinutes = 1;
621 if ( mCustomMinutes > 1440 ) 621 if ( mCustomMinutes > 1440 )
622 mCustomMinutes = 1440; 622 mCustomMinutes = 1440;
623 mess += mCustomText; 623 mess += mCustomText;
624 disp = mCustomText; 624 disp = mCustomText;
625 minutes = mCustomMinutes; 625 minutes = mCustomMinutes;
626 mRunningTimerText = mCustomText.stripWhiteSpace (); 626 mRunningTimerText = mCustomText.stripWhiteSpace ();
627 int in = mRunningTimerText.find( " " ); 627 int in = mRunningTimerText.find( " " );
628 mRunningTimerText = mRunningTimerText.left ( in ); 628 mRunningTimerText = mRunningTimerText.left ( in );
629 } 629 }
630 else { 630 else {
631 mess += mTimerPopUp->text( minutes ); 631 mess += mTimerPopUp->text( minutes );
632 disp = mTimerPopUp->text( minutes ); 632 disp = mTimerPopUp->text( minutes );
633 mRunningTimerText = mTimerPopUp->text( minutes ); 633 mRunningTimerText = mTimerPopUp->text( minutes );
634 minutes -= 10; 634 minutes -= 10;
635 } 635 }
636 } 636 }
637 //minutes = 1; 637 //minutes = 1;
638 638
639 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 639 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
640 timerMesssage = mess; 640 timerMesssage = mess;
641 QString timerDuration ;
642 if ( minutes < 60 ) {
643 timerDuration = QString::number( minutes ) + " min";
644 } else {
645 if ( minutes % 60 ) {
646 timerDuration = QString::number( minutes/60 ) +":";
647 minutes = minutes%60;
648 if ( minutes < 10 ) timerDuration += "0";
649 timerDuration += QString::number( minutes ) + " h";
650 }
651 else
652 timerDuration = QString::number( minutes / 60 )+ " hours";
653 }
641 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 654 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
642 mTimerStartLabel->setText( disp + "\n\nTimer started!" ); 655 mTimerStartLabel->setText( disp + "\n\n" + timerDuration +"\n\nTimer started!" );
643 int w = mTimerStartLabel->sizeHint().width()+20; 656 int w = mTimerStartLabel->sizeHint().width()+20;
644 int h = mTimerStartLabel->sizeHint().height()+40 ; 657 int h = mTimerStartLabel->sizeHint().height()+40 ;
645 int dw = QApplication::desktop()->width(); 658 int dw = QApplication::desktop()->width();
646 int dh = QApplication::desktop()->height(); 659 int dh = QApplication::desktop()->height();
647 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 660 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
648 mTimerStartLabel->show(); 661 mTimerStartLabel->show();
649 QTimer::singleShot( 4000, mTimerStartLabel, SLOT ( hide() ) ); 662 QTimer::singleShot( 4000, mTimerStartLabel, SLOT ( hide() ) );
650 mTimerTime = 1; 663 mTimerTime = 1;
651} 664}
652 665
653void SimpleAlarmDaemonImpl::confFontSize( int size ) 666void SimpleAlarmDaemonImpl::confFontSize( int size )
654{ 667{
655 668
656 mFontsizePopup->setItemChecked( mPopupFontSize, false ); 669 mFontsizePopup->setItemChecked( mPopupFontSize, false );
657 mPopupFontSize = size; 670 mPopupFontSize = size;
658 mFontsizePopup->setItemChecked( mPopupFontSize, true ); 671 mFontsizePopup->setItemChecked( mPopupFontSize, true );
659 QFont fon = mTimerPopUp->font(); 672 QFont fon = mTimerPopUp->font();
660 fon.setPointSize( mPopupFontSize ); 673 fon.setPointSize( mPopupFontSize );
661 mTimerPopUp->setFont( fon ); 674 mTimerPopUp->setFont( fon );
662 mPopUp->setFont( fon ); 675 mPopUp->setFont( fon );
663 fon.setBold( true ); 676 fon.setBold( true );
664 fon.setPointSize( mPopupFontSize * 2 ); 677 fon.setPointSize( mPopupFontSize * 2 );
665 mTimerStartLabel->setFont( fon ); 678 mTimerStartLabel->setFont( fon );
666} 679}
667void SimpleAlarmDaemonImpl::writeFile() 680void SimpleAlarmDaemonImpl::writeFile()
668{ 681{
669 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 682 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
670 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 683 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
671} 684}
672void SimpleAlarmDaemonImpl::showWN() 685void SimpleAlarmDaemonImpl::showWN()
673{ 686{
674 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 687 QCopEnvelope e("QPE/Application/kopi", "-showWN");
675} 688}
676void SimpleAlarmDaemonImpl::newTodo() 689void SimpleAlarmDaemonImpl::newTodo()
677{ 690{
678 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 691 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
679} 692}
680 693
681void SimpleAlarmDaemonImpl::newEvent() 694void SimpleAlarmDaemonImpl::newEvent()
682{ 695{
683 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 696 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
684 697
685} 698}
686void SimpleAlarmDaemonImpl::newMail() 699void SimpleAlarmDaemonImpl::newMail()
687{ 700{
688 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 701 QCopEnvelope e("QPE/Application/ompi", "newMail()");
689} 702}
690void SimpleAlarmDaemonImpl::showAdd() 703void SimpleAlarmDaemonImpl::showAdd()
691{ 704{
692 QCopEnvelope e("QPE/Application/kapi", "raise()"); 705 QCopEnvelope e("QPE/Application/kapi", "raise()");
693} 706}
694void SimpleAlarmDaemonImpl::ringSync() 707void SimpleAlarmDaemonImpl::ringSync()
695{ 708{
696 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 709 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
697 710
698} 711}
699void SimpleAlarmDaemonImpl::newCountdown() 712void SimpleAlarmDaemonImpl::newCountdown()
700{ 713{
701 //recieve("cal_alarm", 10 ); 714 //recieve("cal_alarm", 10 );
702} 715}
703void SimpleAlarmDaemonImpl::simulate() 716void SimpleAlarmDaemonImpl::simulate()
704{ 717{
705 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); 718 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
706 QString filename = getenv("QPEDIR") ; 719 QString filename = getenv("QPEDIR") ;
707 filename += "/pics/kdepim/korganizer/koalarm.wav"; 720 filename += "/pics/kdepim/korganizer/koalarm.wav";
708 startAlarm("Alarm simulation", filename ); 721 startAlarm("Alarm simulation", filename );
709} 722}
710void SimpleAlarmDaemonImpl::showKO() 723void SimpleAlarmDaemonImpl::showKO()
711{ 724{
712 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 725 QCopEnvelope e("QPE/Application/kopi", "-showKO");
713 // testing only 726 // testing only
714 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 727 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
715 728
716} 729}
717void SimpleAlarmDaemonImpl::showTodo() 730void SimpleAlarmDaemonImpl::showTodo()
718{ 731{
719 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 732 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
720 733
721} 734}
722void SimpleAlarmDaemonImpl::writeJournal() 735void SimpleAlarmDaemonImpl::writeJournal()
723{ 736{
724 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 737 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
725 738
726} 739}
727 740
728void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 741void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
729{ 742{
730 743
731 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 744 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
732 745
733} 746}
734 747