-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index 553e377..82873e1 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -235,219 +235,219 @@ void SimpleAlarmDaemonImpl::saveSlot( int load ) | |||
235 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 235 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
236 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 236 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
237 | configString += "CUTE " + mCustomText + "\n"; | 237 | configString += "CUTE " + mCustomText + "\n"; |
238 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 238 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
239 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 239 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
240 | QTextStream ts( &file ); | 240 | QTextStream ts( &file ); |
241 | ts << configString ; | 241 | ts << configString ; |
242 | file.close(); | 242 | file.close(); |
243 | } | 243 | } |
244 | 244 | ||
245 | } | 245 | } |
246 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 246 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
247 | { | 247 | { |
248 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 248 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
249 | mSuspend = num; | 249 | mSuspend = num; |
250 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 250 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
251 | } | 251 | } |
252 | void SimpleAlarmDaemonImpl::confPause( int num ) | 252 | void SimpleAlarmDaemonImpl::confPause( int num ) |
253 | { | 253 | { |
254 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 254 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
255 | mPausePlay = num; | 255 | mPausePlay = num; |
256 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 256 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
257 | } | 257 | } |
258 | void SimpleAlarmDaemonImpl::confSound( int num ) | 258 | void SimpleAlarmDaemonImpl::confSound( int num ) |
259 | { | 259 | { |
260 | if ( num == 0 ) { | 260 | if ( num == 0 ) { |
261 | wavAlarm = false; | 261 | wavAlarm = false; |
262 | mSoundPopUp->setItemChecked ( 0, true ); | 262 | mSoundPopUp->setItemChecked ( 0, true ); |
263 | mSoundPopUp->setItemChecked ( 1, false ); | 263 | mSoundPopUp->setItemChecked ( 1, false ); |
264 | } else { | 264 | } else { |
265 | wavAlarm = true; | 265 | wavAlarm = true; |
266 | mSoundPopUp->setItemChecked ( 0, false ); | 266 | mSoundPopUp->setItemChecked ( 0, false ); |
267 | mSoundPopUp->setItemChecked ( 1, true ); | 267 | mSoundPopUp->setItemChecked ( 1, true ); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 270 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
271 | { | 271 | { |
272 | if ( num == 1000 ) { | 272 | if ( num == 1000 ) { |
273 | simulate(); | 273 | simulate(); |
274 | return; | 274 | return; |
275 | } | 275 | } |
276 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 276 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
277 | mPlayBeeps = num; | 277 | mPlayBeeps = num; |
278 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 278 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 281 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
282 | { | 282 | { |
283 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 283 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
284 | QString mess = QString::fromUtf8(msg.data()); | 284 | QString mess = QString::fromUtf8(msg.data()); |
285 | mAlarmMessage = mess.mid( 9 ); | 285 | mAlarmMessage = mess.mid( 9 ); |
286 | QString filename = getenv("QPEDIR") ; | 286 | QString filename = getenv("QPEDIR") ; |
287 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 287 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
288 | QString tempfilename; | 288 | QString tempfilename; |
289 | if ( mess.left( 13 ) == "suspend_alarm") { | 289 | if ( mess.left( 13 ) == "suspend_alarm") { |
290 | bool error = false; | 290 | bool error = false; |
291 | int len = mess.mid( 13 ).find("+++"); | 291 | int len = mess.mid( 13 ).find("+++"); |
292 | if ( len < 2 ) | 292 | if ( len < 2 ) |
293 | error = true; | 293 | error = true; |
294 | else { | 294 | else { |
295 | tempfilename = mess.mid( 13, len ); | 295 | tempfilename = mess.mid( 13, len ); |
296 | if ( !QFile::exists( tempfilename ) ) | 296 | if ( !QFile::exists( tempfilename ) ) |
297 | error = true; | 297 | error = true; |
298 | } | 298 | } |
299 | if ( ! error ) { | 299 | if ( ! error ) { |
300 | filename = tempfilename; | 300 | filename = tempfilename; |
301 | } | 301 | } |
302 | mAlarmMessage = mess.mid( 13+len+3 ); | 302 | mAlarmMessage = mess.mid( 13+len+3 ); |
303 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 303 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
304 | startAlarm( mAlarmMessage, filename); | 304 | startAlarm( mAlarmMessage, filename); |
305 | return; | 305 | return; |
306 | } | 306 | } |
307 | if ( mess.left( 11 ) == "timer_alarm") { | 307 | if ( mess.left( 11 ) == "timer_alarm") { |
308 | mTimerTime = 0; | 308 | mTimerTime = 0; |
309 | startAlarm( mess.mid( 11 ), filename ); | 309 | startAlarm( mess.mid( 11 ), filename ); |
310 | return; | 310 | return; |
311 | } | 311 | } |
312 | if ( mess.left( 10 ) == "proc_alarm") { | 312 | if ( mess.left( 10 ) == "proc_alarm") { |
313 | bool error = false; | 313 | bool error = false; |
314 | int len = mess.mid( 10 ).find("+++"); | 314 | int len = mess.mid( 10 ).find("+++"); |
315 | if ( len < 2 ) | 315 | if ( len < 2 ) |
316 | error = true; | 316 | error = true; |
317 | else { | 317 | else { |
318 | tempfilename = mess.mid( 10, len ); | 318 | tempfilename = mess.mid( 10, len ); |
319 | if ( !QFile::exists( tempfilename ) ) | 319 | if ( !QFile::exists( tempfilename ) ) |
320 | error = true; | 320 | error = true; |
321 | } | 321 | } |
322 | if ( error ) { | 322 | if ( error ) { |
323 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 323 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
324 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 324 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
325 | } else { | 325 | } else { |
326 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 326 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
327 | if ( vfork () == 0 ) { | 327 | if ( vfork () == 0 ) { |
328 | execl ( tempfilename.latin1(), 0 ); | 328 | execl ( tempfilename.latin1(), 0 ); |
329 | return; | 329 | return; |
330 | } | 330 | } |
331 | QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); | 331 | QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | 334 | ||
335 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 335 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
336 | } | 336 | } |
337 | if ( mess.left( 11 ) == "audio_alarm") { | 337 | if ( mess.left( 11 ) == "audio_alarm") { |
338 | bool error = false; | 338 | bool error = false; |
339 | int len = mess.mid( 11 ).find("+++"); | 339 | int len = mess.mid( 11 ).find("+++"); |
340 | if ( len < 2 ) | 340 | if ( len < 2 ) |
341 | error = true; | 341 | error = true; |
342 | else { | 342 | else { |
343 | tempfilename = mess.mid( 11, len ); | 343 | tempfilename = mess.mid( 11, len ); |
344 | if ( !QFile::exists( tempfilename ) ) | 344 | if ( !QFile::exists( tempfilename ) ) |
345 | error = true; | 345 | error = true; |
346 | } | 346 | } |
347 | if ( ! error ) { | 347 | if ( ! error ) { |
348 | filename = tempfilename; | 348 | filename = tempfilename; |
349 | } | 349 | } |
350 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 350 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
351 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 351 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
352 | } | 352 | } |
353 | if ( mess.left( 9 ) == "cal_alarm") { | 353 | if ( mess.left( 9 ) == "cal_alarm") { |
354 | mAlarmMessage = mess.mid( 9 ) ; | 354 | mAlarmMessage = mess.mid( 9 ) ; |
355 | } | 355 | } |
356 | 356 | ||
357 | QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); | 357 | QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); |
358 | startAlarm( mAlarmMessage, filename ); | 358 | startAlarm( mAlarmMessage, filename ); |
359 | 359 | ||
360 | } | 360 | } |
361 | 361 | ||
362 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 362 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
363 | { | 363 | { |
364 | return 0; | 364 | return 0; |
365 | } | 365 | } |
366 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 366 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
367 | { | 367 | { |
368 | //mAlarmDialog->show(); | 368 | //mAlarmDialog->show(); |
369 | //mAlarmDialog->raise(); | 369 | //mAlarmDialog->raise(); |
370 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 370 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 374 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
375 | { | 375 | { |
376 | 376 | ||
377 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 377 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
378 | if ( mTimerPopupConf == mTimerTime ) { | 378 | if ( mTimerPopupConf == mTimerTime ) { |
379 | if ( mTimerTime ) { | 379 | if ( mTimerTime ) { |
380 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 380 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
381 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 381 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
382 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 382 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
383 | } | 383 | } |
384 | else { | 384 | else { |
385 | QString text = mCustomText.stripWhiteSpace (); | 385 | QString text = mCustomText.stripWhiteSpace (); |
386 | int in = text.find( " " ); | 386 | int in = text.find( " " ); |
387 | text = text.left ( in ); | 387 | text = text.left ( in ); |
388 | mTimerPopUp->changeItem ( 3, text ); | 388 | mTimerPopUp->changeItem ( 3, text ); |
389 | } | 389 | } |
390 | return; | 390 | return; |
391 | } | 391 | } |
392 | mTimerPopupConf = mTimerTime; | 392 | mTimerPopupConf = mTimerTime; |
393 | mTimerPopUp->clear(); | 393 | mTimerPopUp->clear(); |
394 | if ( mTimerTime ) { | 394 | if ( mTimerTime ) { |
395 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 395 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
396 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 396 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
397 | 397 | ||
398 | 398 | ||
399 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); | 399 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); |
400 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); | 400 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); |
401 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); | 401 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); |
402 | } else { | 402 | } else { |
403 | 403 | ||
404 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 404 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
405 | QFile file( fileName ); | 405 | QFile file( fileName ); |
406 | if( !QFile::exists( fileName) ) { | 406 | if( !QFile::exists( fileName) ) { |
407 | // write defaults | 407 | // write defaults |
408 | if (!file.open( IO_WriteOnly ) ) { | 408 | if (!file.open( IO_WriteOnly ) ) { |
409 | return; | 409 | return; |
410 | } | 410 | } |
411 | QString configString ; | 411 | QString configString ; |
412 | configString += "#config file for kopi alarm timer\n"; | 412 | configString += "#config file for kopi alarm timer\n"; |
413 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 413 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
414 | configString += "24 hours; 1440\n"; | 414 | configString += "24 hours; 1440\n"; |
415 | configString += "9 hours; 540\n"; | 415 | configString += "9 hours; 540\n"; |
416 | configString += "8 hours; 480\n"; | 416 | configString += "8 hours; 480\n"; |
417 | configString += "1 hour; 60\n"; | 417 | configString += "1 hour; 60\n"; |
418 | configString += "30 min; 30\n"; | 418 | configString += "30 min; 30\n"; |
419 | configString += "15 min; 15\n"; | 419 | configString += "15 min; 15\n"; |
420 | configString += "SEPARATOR\n"; | 420 | configString += "SEPARATOR\n"; |
421 | configString += "Pizza; 22\n"; | 421 | configString += "Pizza; 22\n"; |
422 | configString += "Nap; 45\n"; | 422 | configString += "Nap; 45\n"; |
423 | configString += "Tea; 5\n"; | 423 | configString += "Tea; 5\n"; |
424 | QTextStream ts( &file ); | 424 | QTextStream ts( &file ); |
425 | ts << configString ; | 425 | ts << configString ; |
426 | file.close(); | 426 | file.close(); |
427 | } | 427 | } |
428 | 428 | ||
429 | if (!file.open( IO_ReadOnly ) ) { | 429 | if (!file.open( IO_ReadOnly ) ) { |
430 | return ; | 430 | return ; |
431 | } | 431 | } |
432 | QString line; | 432 | QString line; |
433 | bool ok; | 433 | bool ok; |
434 | while ( file.readLine( line, 1024 ) > 0 ) { | 434 | while ( file.readLine( line, 1024 ) > 0 ) { |
435 | //qDebug("read %s ", line.latin1()); | 435 | //qDebug("read %s ", line.latin1()); |
436 | if ( line.left(1 ) != "#" ) { | 436 | if ( line.left(1 ) != "#" ) { |
437 | // no comment | 437 | // no comment |
438 | if ( line.left(9 ) == "SEPARATOR" ) { | 438 | if ( line.left(9 ) == "SEPARATOR" ) { |
439 | mTimerPopUp->insertSeparator(); | 439 | mTimerPopUp->insertSeparator(); |
440 | } else { | 440 | } else { |
441 | QStringList li = QStringList::split(";",line); | 441 | QStringList li = QStringList::split(";",line); |
442 | ok = false; | 442 | ok = false; |
443 | if ( li.count() == 2 ) { | 443 | if ( li.count() == 2 ) { |
444 | int val = li[1].toInt( &ok ); | 444 | int val = li[1].toInt( &ok ); |
445 | if ( ok && val > 0 ) { | 445 | if ( ok && val > 0 ) { |
446 | mTimerPopUp->insertItem( li[0], val+10); | 446 | mTimerPopUp->insertItem( li[0], val+10); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | } | 449 | } |
450 | } | 450 | } |
451 | } | 451 | } |
452 | file.close(); | 452 | file.close(); |
453 | #if 0 | 453 | #if 0 |
@@ -534,168 +534,168 @@ void SimpleAlarmDaemonImpl::confTimer( int time ) | |||
534 | disp = mCustomText; | 534 | disp = mCustomText; |
535 | } | 535 | } |
536 | else { | 536 | else { |
537 | if ( minutes == 2 ) { | 537 | if ( minutes == 2 ) { |
538 | // ask time | 538 | // ask time |
539 | QDialog dia ( 0, ("Customize Timer" ), true ); | 539 | QDialog dia ( 0, ("Customize Timer" ), true ); |
540 | QLabel lab (("Message Text:"), &dia ); | 540 | QLabel lab (("Message Text:"), &dia ); |
541 | dia.setCaption(("KO/Pi Timer" )); | 541 | dia.setCaption(("KO/Pi Timer" )); |
542 | QVBoxLayout lay( &dia ); | 542 | QVBoxLayout lay( &dia ); |
543 | lay.setMargin(5); | 543 | lay.setMargin(5); |
544 | lay.setSpacing(5); | 544 | lay.setSpacing(5); |
545 | lay.addWidget( &lab); | 545 | lay.addWidget( &lab); |
546 | QLineEdit lEdit( mCustomText, &dia ); | 546 | QLineEdit lEdit( mCustomText, &dia ); |
547 | lay.addWidget( &lEdit); | 547 | lay.addWidget( &lEdit); |
548 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 548 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
549 | lay.addWidget( &lab2); | 549 | lay.addWidget( &lab2); |
550 | QHBox hbox1 ( &dia ); | 550 | QHBox hbox1 ( &dia ); |
551 | lay.addWidget( &hbox1); | 551 | lay.addWidget( &hbox1); |
552 | QLabel lab3 (("Hours"), &hbox1 ); | 552 | QLabel lab3 (("Hours"), &hbox1 ); |
553 | QLabel lab4 (("Minutes"), &hbox1 ); | 553 | QLabel lab4 (("Minutes"), &hbox1 ); |
554 | QHBox hbox ( &dia ); | 554 | QHBox hbox ( &dia ); |
555 | QSpinBox spinh( 0, 24, 1,& hbox ); | 555 | QSpinBox spinh( 0, 24, 1,& hbox ); |
556 | QFont fo = dia.font(); | 556 | QFont fo = dia.font(); |
557 | fo.setPointSize( 36 ); | 557 | fo.setPointSize( 36 ); |
558 | QSpinBox spinm( 0, 59, 1,&hbox ); | 558 | QSpinBox spinm( 0, 59, 1,&hbox ); |
559 | spinm.setFont( fo ); | 559 | spinm.setFont( fo ); |
560 | spinh.setFont( fo ); | 560 | spinh.setFont( fo ); |
561 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 561 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
562 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 562 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
563 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 563 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
564 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 564 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
565 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 565 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
566 | spinh.setFixedSize( 100,62 ); | 566 | spinh.setFixedSize( 100,62 ); |
567 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 567 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
568 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 568 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
569 | spinm.downButton ()->setGeometry( 50,50,50,50); | 569 | spinm.downButton ()->setGeometry( 50,50,50,50); |
570 | // spinm.setSuffix( " m" ); | 570 | // spinm.setSuffix( " m" ); |
571 | //spinh.setSuffix( " h" ); | 571 | //spinh.setSuffix( " h" ); |
572 | spinm.setWrapping ( true ); | 572 | spinm.setWrapping ( true ); |
573 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 573 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
574 | spinm.setLineStep( 1 ); | 574 | spinm.setLineStep( 1 ); |
575 | spinm.setFixedSize( 110,62 ); | 575 | spinm.setFixedSize( 110,62 ); |
576 | lay.addWidget( &hbox); | 576 | lay.addWidget( &hbox); |
577 | QLabel lab5 ("Timer fires at:", &dia ); | 577 | QLabel lab5 ("Timer fires at:", &dia ); |
578 | lab5.setAlignment( AlignCenter ); | 578 | lab5.setAlignment( AlignCenter ); |
579 | lay.addWidget( &lab5); | 579 | lay.addWidget( &lab5); |
580 | KODateLabel dl ( &dia ); | 580 | KODateLabel dl ( &dia ); |
581 | dl.setAlignment( AlignCenter ); | 581 | dl.setAlignment( AlignCenter ); |
582 | dl.setFont( fo ); | 582 | dl.setFont( fo ); |
583 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); | 583 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); |
584 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); | 584 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); |
585 | lay.addWidget( &dl); | 585 | lay.addWidget( &dl); |
586 | spinh.setValue( mCustomMinutes/60 ); | 586 | spinh.setValue( mCustomMinutes/60 ); |
587 | spinm.setValue( mCustomMinutes%60 ); | 587 | spinm.setValue( mCustomMinutes%60 ); |
588 | QPushButton ok ( "Start timer", &dia); | 588 | QPushButton ok ( "Start timer", &dia); |
589 | ok.setDefault( true ); | 589 | ok.setDefault( true ); |
590 | ok.setFont( fo ); | 590 | ok.setFont( fo ); |
591 | spinh.setFocus(); | 591 | spinh.setFocus(); |
592 | lay.addWidget( &ok); | 592 | lay.addWidget( &ok); |
593 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 593 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
594 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 594 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
595 | 595 | ||
596 | if ( !dia.exec() ) | 596 | if ( !dia.exec() ) |
597 | return; | 597 | return; |
598 | mCustomText = lEdit.text(); | 598 | mCustomText = lEdit.text(); |
599 | mCustomMinutes = spinh.value()*60+spinm.value(); | 599 | mCustomMinutes = spinh.value()*60+spinm.value(); |
600 | if ( mCustomMinutes == 0 ) | 600 | if ( mCustomMinutes == 0 ) |
601 | mCustomMinutes = 1; | 601 | mCustomMinutes = 1; |
602 | if ( mCustomMinutes > 1440 ) | 602 | if ( mCustomMinutes > 1440 ) |
603 | mCustomMinutes = 1440; | 603 | mCustomMinutes = 1440; |
604 | mess += mCustomText; | 604 | mess += mCustomText; |
605 | disp = mCustomText; | 605 | disp = mCustomText; |
606 | minutes = mCustomMinutes; | 606 | minutes = mCustomMinutes; |
607 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 607 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
608 | int in = mRunningTimerText.find( " " ); | 608 | int in = mRunningTimerText.find( " " ); |
609 | mRunningTimerText = mRunningTimerText.left ( in ); | 609 | mRunningTimerText = mRunningTimerText.left ( in ); |
610 | } | 610 | } |
611 | else { | 611 | else { |
612 | mess += mTimerPopUp->text( minutes ); | 612 | mess += mTimerPopUp->text( minutes ); |
613 | disp = mTimerPopUp->text( minutes ); | 613 | disp = mTimerPopUp->text( minutes ); |
614 | mRunningTimerText = mTimerPopUp->text( minutes ); | 614 | mRunningTimerText = mTimerPopUp->text( minutes ); |
615 | minutes -= 10; | 615 | minutes -= 10; |
616 | } | 616 | } |
617 | } | 617 | } |
618 | //minutes = 1; | 618 | //minutes = 1; |
619 | 619 | ||
620 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 620 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
621 | timerMesssage = mess; | 621 | timerMesssage = mess; |
622 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); | 622 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); |
623 | mTimerStartLabel->setText( disp + "\n\nTimer started!" ); | 623 | mTimerStartLabel->setText( disp + "\n\nTimer started!" ); |
624 | int w = mTimerStartLabel->sizeHint().width()+20; | 624 | int w = mTimerStartLabel->sizeHint().width()+20; |
625 | int h = mTimerStartLabel->sizeHint().height()+40 ; | 625 | int h = mTimerStartLabel->sizeHint().height()+40 ; |
626 | int dw = QApplication::desktop()->width(); | 626 | int dw = QApplication::desktop()->width(); |
627 | int dh = QApplication::desktop()->height(); | 627 | int dh = QApplication::desktop()->height(); |
628 | mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 628 | mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
629 | mTimerStartLabel->show(); | 629 | mTimerStartLabel->show(); |
630 | QTimer::singleShot( 3000, mTimerStartLabel, SLOT ( hide() ) ); | 630 | QTimer::singleShot( 5000, mTimerStartLabel, SLOT ( hide() ) ); |
631 | mTimerTime = 1; | 631 | mTimerTime = 1; |
632 | } | 632 | } |
633 | 633 | ||
634 | void SimpleAlarmDaemonImpl::writeFile() | 634 | void SimpleAlarmDaemonImpl::writeFile() |
635 | { | 635 | { |
636 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 636 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
637 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 637 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); |
638 | } | 638 | } |
639 | void SimpleAlarmDaemonImpl::showWN() | 639 | void SimpleAlarmDaemonImpl::showWN() |
640 | { | 640 | { |
641 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 641 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
642 | } | 642 | } |
643 | void SimpleAlarmDaemonImpl::newTodo() | 643 | void SimpleAlarmDaemonImpl::newTodo() |
644 | { | 644 | { |
645 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 645 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
646 | } | 646 | } |
647 | 647 | ||
648 | void SimpleAlarmDaemonImpl::newEvent() | 648 | void SimpleAlarmDaemonImpl::newEvent() |
649 | { | 649 | { |
650 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 650 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
651 | 651 | ||
652 | } | 652 | } |
653 | void SimpleAlarmDaemonImpl::newMail() | 653 | void SimpleAlarmDaemonImpl::newMail() |
654 | { | 654 | { |
655 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 655 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
656 | } | 656 | } |
657 | void SimpleAlarmDaemonImpl::showAdd() | 657 | void SimpleAlarmDaemonImpl::showAdd() |
658 | { | 658 | { |
659 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 659 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
660 | } | 660 | } |
661 | void SimpleAlarmDaemonImpl::ringSync() | 661 | void SimpleAlarmDaemonImpl::ringSync() |
662 | { | 662 | { |
663 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 663 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
664 | 664 | ||
665 | } | 665 | } |
666 | void SimpleAlarmDaemonImpl::newCountdown() | 666 | void SimpleAlarmDaemonImpl::newCountdown() |
667 | { | 667 | { |
668 | //recieve("cal_alarm", 10 ); | 668 | //recieve("cal_alarm", 10 ); |
669 | } | 669 | } |
670 | void SimpleAlarmDaemonImpl::simulate() | 670 | void SimpleAlarmDaemonImpl::simulate() |
671 | { | 671 | { |
672 | QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); | 672 | QTimer::singleShot( 2000, this, SLOT ( writeFile() ) ); |
673 | QString filename = getenv("QPEDIR") ; | 673 | QString filename = getenv("QPEDIR") ; |
674 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 674 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
675 | startAlarm("Alarm simulation", filename ); | 675 | startAlarm("Alarm simulation", filename ); |
676 | } | 676 | } |
677 | void SimpleAlarmDaemonImpl::showKO() | 677 | void SimpleAlarmDaemonImpl::showKO() |
678 | { | 678 | { |
679 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 679 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
680 | // testing only | 680 | // testing only |
681 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | 681 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); |
682 | 682 | ||
683 | } | 683 | } |
684 | void SimpleAlarmDaemonImpl::showTodo() | 684 | void SimpleAlarmDaemonImpl::showTodo() |
685 | { | 685 | { |
686 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 686 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
687 | 687 | ||
688 | } | 688 | } |
689 | void SimpleAlarmDaemonImpl::writeJournal() | 689 | void SimpleAlarmDaemonImpl::writeJournal() |
690 | { | 690 | { |
691 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 691 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
692 | 692 | ||
693 | } | 693 | } |
694 | 694 | ||
695 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 695 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
696 | { | 696 | { |
697 | 697 | ||
698 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 698 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
699 | 699 | ||
700 | } | 700 | } |
701 | 701 | ||