author | zautrix <zautrix> | 2004-08-30 23:18:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-30 23:18:58 (UTC) |
commit | def659747d354789f84a992f18df2c3f80f12d01 (patch) (unidiff) | |
tree | 9ee66d8e8ef7ab81c9b5e8a32b417746b6cdf8a0 /kalarmd | |
parent | cec54f6e21264341191e4f94f9dd7bd19b2eea8d (diff) | |
download | kdepimpi-def659747d354789f84a992f18df2c3f80f12d01.zip kdepimpi-def659747d354789f84a992f18df2c3f80f12d01.tar.gz kdepimpi-def659747d354789f84a992f18df2c3f80f12d01.tar.bz2 |
Made timer configurable
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index 471836b..18e4299 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -184,371 +184,424 @@ void SimpleAlarmDaemonImpl::saveSlot( int load ) | |||
184 | val = line.mid( 4,len-5).toInt( &ok ); | 184 | val = line.mid( 4,len-5).toInt( &ok ); |
185 | if ( ok ) | 185 | if ( ok ) |
186 | slotPlayBeep( val ); | 186 | slotPlayBeep( val ); |
187 | 187 | ||
188 | } | 188 | } |
189 | if ( line.left(4 ) == "CUTE" ) { | 189 | if ( line.left(4 ) == "CUTE" ) { |
190 | mCustomText = line.mid( 5,len-6); | 190 | mCustomText = line.mid( 5,len-6); |
191 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | 191 | // qDebug("text ***%s*** ",mCustomText.latin1() ); |
192 | 192 | ||
193 | } | 193 | } |
194 | if ( line.left(4 ) == "CUMI" ) { | 194 | if ( line.left(4 ) == "CUMI" ) { |
195 | val = line.mid( 4,len-5).toInt( &ok ); | 195 | val = line.mid( 4,len-5).toInt( &ok ); |
196 | if ( ok ) | 196 | if ( ok ) |
197 | mCustomMinutes = val; | 197 | mCustomMinutes = val; |
198 | 198 | ||
199 | } | 199 | } |
200 | if ( line.left(4 ) == "SUTI" ) { | 200 | if ( line.left(4 ) == "SUTI" ) { |
201 | val = line.mid( 4,len-5).toInt( &ok ); | 201 | val = line.mid( 4,len-5).toInt( &ok ); |
202 | if ( ok ) | 202 | if ( ok ) |
203 | mAlarmDialog->setSuspendTime( val );; | 203 | mAlarmDialog->setSuspendTime( val );; |
204 | 204 | ||
205 | } | 205 | } |
206 | } | 206 | } |
207 | file.close(); | 207 | file.close(); |
208 | } else { | 208 | } else { |
209 | if (!file.open( IO_WriteOnly ) ) { | 209 | if (!file.open( IO_WriteOnly ) ) { |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | QString configString ; | 212 | QString configString ; |
213 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | 213 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; |
214 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | 214 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; |
215 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 215 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
216 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 216 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
217 | configString += "CUTE " + mCustomText + "\n"; | 217 | configString += "CUTE " + mCustomText + "\n"; |
218 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 218 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
219 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 219 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
220 | QTextStream ts( &file ); | 220 | QTextStream ts( &file ); |
221 | ts << configString ; | 221 | ts << configString ; |
222 | file.close(); | 222 | file.close(); |
223 | } | 223 | } |
224 | 224 | ||
225 | } | 225 | } |
226 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 226 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
227 | { | 227 | { |
228 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 228 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
229 | mSuspend = num; | 229 | mSuspend = num; |
230 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 230 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
231 | } | 231 | } |
232 | void SimpleAlarmDaemonImpl::confPause( int num ) | 232 | void SimpleAlarmDaemonImpl::confPause( int num ) |
233 | { | 233 | { |
234 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 234 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
235 | mPausePlay = num; | 235 | mPausePlay = num; |
236 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 236 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
237 | } | 237 | } |
238 | void SimpleAlarmDaemonImpl::confSound( int num ) | 238 | void SimpleAlarmDaemonImpl::confSound( int num ) |
239 | { | 239 | { |
240 | if ( num == 0 ) { | 240 | if ( num == 0 ) { |
241 | wavAlarm = false; | 241 | wavAlarm = false; |
242 | mSoundPopUp->setItemChecked ( 0, true ); | 242 | mSoundPopUp->setItemChecked ( 0, true ); |
243 | mSoundPopUp->setItemChecked ( 1, false ); | 243 | mSoundPopUp->setItemChecked ( 1, false ); |
244 | } else { | 244 | } else { |
245 | wavAlarm = true; | 245 | wavAlarm = true; |
246 | mSoundPopUp->setItemChecked ( 0, false ); | 246 | mSoundPopUp->setItemChecked ( 0, false ); |
247 | mSoundPopUp->setItemChecked ( 1, true ); | 247 | mSoundPopUp->setItemChecked ( 1, true ); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 250 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
251 | { | 251 | { |
252 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 252 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
253 | mPlayBeeps = num; | 253 | mPlayBeeps = num; |
254 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 254 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
255 | } | 255 | } |
256 | 256 | ||
257 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 257 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
258 | { | 258 | { |
259 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 259 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
260 | QString mess = msg; | 260 | QString mess = msg; |
261 | mAlarmMessage = mess.mid( 9 ); | 261 | mAlarmMessage = mess.mid( 9 ); |
262 | QString filename = getenv("QPEDIR") ; | 262 | QString filename = getenv("QPEDIR") ; |
263 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 263 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
264 | QString tempfilename; | 264 | QString tempfilename; |
265 | if ( mess.left( 13 ) == "suspend_alarm") { | 265 | if ( mess.left( 13 ) == "suspend_alarm") { |
266 | bool error = false; | 266 | bool error = false; |
267 | int len = mess.mid( 13 ).find("+++"); | 267 | int len = mess.mid( 13 ).find("+++"); |
268 | if ( len < 2 ) | 268 | if ( len < 2 ) |
269 | error = true; | 269 | error = true; |
270 | else { | 270 | else { |
271 | tempfilename = mess.mid( 13, len ); | 271 | tempfilename = mess.mid( 13, len ); |
272 | if ( !QFile::exists( tempfilename ) ) | 272 | if ( !QFile::exists( tempfilename ) ) |
273 | error = true; | 273 | error = true; |
274 | } | 274 | } |
275 | if ( ! error ) { | 275 | if ( ! error ) { |
276 | filename = tempfilename; | 276 | filename = tempfilename; |
277 | } | 277 | } |
278 | mAlarmMessage = mess.mid( 13+len+3 ); | 278 | mAlarmMessage = mess.mid( 13+len+3 ); |
279 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 279 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
280 | startAlarm( mAlarmMessage, filename); | 280 | startAlarm( mAlarmMessage, filename); |
281 | return; | 281 | return; |
282 | } | 282 | } |
283 | if ( mess.left( 11 ) == "timer_alarm") { | 283 | if ( mess.left( 11 ) == "timer_alarm") { |
284 | mTimerTime = 0; | 284 | mTimerTime = 0; |
285 | startAlarm( mess.mid( 11 ), filename ); | 285 | startAlarm( mess.mid( 11 ), filename ); |
286 | return; | 286 | return; |
287 | } | 287 | } |
288 | if ( mess.left( 10 ) == "proc_alarm") { | 288 | if ( mess.left( 10 ) == "proc_alarm") { |
289 | bool error = false; | 289 | bool error = false; |
290 | int len = mess.mid( 10 ).find("+++"); | 290 | int len = mess.mid( 10 ).find("+++"); |
291 | if ( len < 2 ) | 291 | if ( len < 2 ) |
292 | error = true; | 292 | error = true; |
293 | else { | 293 | else { |
294 | tempfilename = mess.mid( 10, len ); | 294 | tempfilename = mess.mid( 10, len ); |
295 | if ( !QFile::exists( tempfilename ) ) | 295 | if ( !QFile::exists( tempfilename ) ) |
296 | error = true; | 296 | error = true; |
297 | } | 297 | } |
298 | if ( error ) { | 298 | if ( error ) { |
299 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 299 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
300 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 300 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
301 | } else { | 301 | } else { |
302 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 302 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
303 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 303 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
304 | if ( vfork () == 0 ) { | 304 | if ( vfork () == 0 ) { |
305 | execl ( tempfilename.latin1(), 0 ); | 305 | execl ( tempfilename.latin1(), 0 ); |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | return; | 308 | return; |
309 | } | 309 | } |
310 | 310 | ||
311 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 311 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
312 | } | 312 | } |
313 | if ( mess.left( 11 ) == "audio_alarm") { | 313 | if ( mess.left( 11 ) == "audio_alarm") { |
314 | bool error = false; | 314 | bool error = false; |
315 | int len = mess.mid( 11 ).find("+++"); | 315 | int len = mess.mid( 11 ).find("+++"); |
316 | if ( len < 2 ) | 316 | if ( len < 2 ) |
317 | error = true; | 317 | error = true; |
318 | else { | 318 | else { |
319 | tempfilename = mess.mid( 11, len ); | 319 | tempfilename = mess.mid( 11, len ); |
320 | if ( !QFile::exists( tempfilename ) ) | 320 | if ( !QFile::exists( tempfilename ) ) |
321 | error = true; | 321 | error = true; |
322 | } | 322 | } |
323 | if ( ! error ) { | 323 | if ( ! error ) { |
324 | filename = tempfilename; | 324 | filename = tempfilename; |
325 | } | 325 | } |
326 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 326 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
327 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 327 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
328 | } | 328 | } |
329 | if ( mess.left( 9 ) == "cal_alarm") { | 329 | if ( mess.left( 9 ) == "cal_alarm") { |
330 | mAlarmMessage = mess.mid( 9 ) ; | 330 | mAlarmMessage = mess.mid( 9 ) ; |
331 | } | 331 | } |
332 | 332 | ||
333 | writeFile(); | 333 | writeFile(); |
334 | startAlarm( mAlarmMessage, filename ); | 334 | startAlarm( mAlarmMessage, filename ); |
335 | 335 | ||
336 | } | 336 | } |
337 | 337 | ||
338 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 338 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
339 | { | 339 | { |
340 | return 0; | 340 | return 0; |
341 | } | 341 | } |
342 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 342 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
343 | { | 343 | { |
344 | //mAlarmDialog->show(); | 344 | //mAlarmDialog->show(); |
345 | //mAlarmDialog->raise(); | 345 | //mAlarmDialog->raise(); |
346 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 346 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 350 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
351 | { | 351 | { |
352 | 352 | ||
353 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 353 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
354 | if ( mTimerPopupConf == mTimerTime ) { | 354 | if ( mTimerPopupConf == mTimerTime ) { |
355 | if ( mTimerTime ) { | 355 | if ( mTimerTime ) { |
356 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 356 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
357 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 357 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
358 | mTimerPopUp->changeItem ( 1 , t.toString()); | 358 | mTimerPopUp->changeItem ( 1 , t.toString()); |
359 | } | 359 | } |
360 | else { | 360 | else { |
361 | QString text = mCustomText.stripWhiteSpace (); | 361 | QString text = mCustomText.stripWhiteSpace (); |
362 | int in = text.find( " " ); | 362 | int in = text.find( " " ); |
363 | text = text.left ( in ); | 363 | text = text.left ( in ); |
364 | mTimerPopUp->changeItem ( 3, text ); | 364 | mTimerPopUp->changeItem ( 3, text ); |
365 | } | 365 | } |
366 | return; | 366 | return; |
367 | } | 367 | } |
368 | mTimerPopupConf = mTimerTime; | 368 | mTimerPopupConf = mTimerTime; |
369 | mTimerPopUp->clear(); | 369 | mTimerPopUp->clear(); |
370 | if ( mTimerTime ) { | 370 | if ( mTimerTime ) { |
371 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 371 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
372 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 372 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
373 | mTimerPopUp->insertItem( "Stop", 0 ); | 373 | mTimerPopUp->insertItem( "Stop", 0 ); |
374 | mTimerPopUp->insertItem( t.toString(),1); | 374 | mTimerPopUp->insertItem( t.toString(),1); |
375 | } else { | 375 | } else { |
376 | |||
377 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | ||
378 | QFile file( fileName ); | ||
379 | if( !QFile::exists( fileName) ) { | ||
380 | // write defaults | ||
381 | if (!file.open( IO_WriteOnly ) ) { | ||
382 | return; | ||
383 | } | ||
384 | QString configString ; | ||
385 | configString += "#config file for kopi alarm timer\n"; | ||
386 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | ||
387 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; | ||
388 | configString += "24 h; 1440\n"; | ||
389 | configString += " 8 h; 480\n"; | ||
390 | configString += " 5 h; 300\n"; | ||
391 | configString += " 1 h; 60\n"; | ||
392 | configString += "30 min; 30\n"; | ||
393 | configString += "15 min; 15\n"; | ||
394 | configString += "SEPARATOR\n"; | ||
395 | configString += "Pizza; 22\n"; | ||
396 | configString += "Nap; 45\n"; | ||
397 | configString += "Tea; 5\n"; | ||
398 | QTextStream ts( &file ); | ||
399 | ts << configString ; | ||
400 | file.close(); | ||
401 | } | ||
402 | |||
403 | if (!file.open( IO_ReadOnly ) ) { | ||
404 | return ; | ||
405 | } | ||
406 | QString line; | ||
407 | bool ok; | ||
408 | while ( file.readLine( line, 1024 ) > 0 ) { | ||
409 | //qDebug("read %s ", line.latin1()); | ||
410 | if ( line.left(1 ) != "#" ) { | ||
411 | // no comment | ||
412 | if ( line.left(9 ) == "SEPARATOR" ) { | ||
413 | mTimerPopUp->insertSeparator(); | ||
414 | } else { | ||
415 | QStringList li = QStringList::split(";",line); | ||
416 | ok = false; | ||
417 | if ( li.count() == 2 ) { | ||
418 | int val = li[1].toInt( &ok ); | ||
419 | if ( ok && val > 2 ) { | ||
420 | mTimerPopUp->insertItem( li[0], val); | ||
421 | } | ||
422 | } | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | file.close(); | ||
427 | #if 0 | ||
376 | mTimerPopUp->insertItem( "24 h", 1440 ); | 428 | mTimerPopUp->insertItem( "24 h", 1440 ); |
377 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 429 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
378 | mTimerPopUp->insertItem( " 8 h", 480 ); | 430 | mTimerPopUp->insertItem( " 8 h", 480 ); |
379 | mTimerPopUp->insertItem( " 5 h", 300 ); | 431 | mTimerPopUp->insertItem( " 5 h", 300 ); |
380 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 432 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
381 | mTimerPopUp->insertItem( " 1 h", 60 ); | 433 | mTimerPopUp->insertItem( " 1 h", 60 ); |
382 | mTimerPopUp->insertItem( "30 min", 30 ); | 434 | mTimerPopUp->insertItem( "30 min", 30 ); |
383 | mTimerPopUp->insertItem( "15 min", 15 ); | 435 | mTimerPopUp->insertItem( "15 min", 15 ); |
384 | mTimerPopUp->insertItem( "10 min", 10 ); | 436 | mTimerPopUp->insertItem( "10 min", 10 ); |
385 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 437 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
386 | mTimerPopUp->insertSeparator(); | 438 | mTimerPopUp->insertSeparator(); |
387 | mTimerPopUp->insertItem( "Pizza", 22 ); | 439 | mTimerPopUp->insertItem( "Pizza", 22 ); |
388 | mTimerPopUp->insertItem( "Nap", 45 ); | 440 | mTimerPopUp->insertItem( "Nap", 45 ); |
389 | mTimerPopUp->insertItem( "Tea", 5 ); | 441 | mTimerPopUp->insertItem( "Tea", 5 ); |
442 | #endif | ||
390 | QString text = mCustomText.stripWhiteSpace (); | 443 | QString text = mCustomText.stripWhiteSpace (); |
391 | int in = text.find( " " ); | 444 | int in = text.find( " " ); |
392 | text = text.left ( in ); | 445 | text = text.left ( in ); |
393 | mTimerPopUp->insertItem( text, 3 ); | 446 | mTimerPopUp->insertItem( text, 3 ); |
394 | mTimerPopUp->insertSeparator(); | 447 | mTimerPopUp->insertSeparator(); |
395 | mTimerPopUp->insertItem( "Customize", 2 ); | 448 | mTimerPopUp->insertItem( "Customize", 2 ); |
396 | } | 449 | } |
397 | 450 | ||
398 | } | 451 | } |
399 | 452 | ||
400 | void SimpleAlarmDaemonImpl::showTimer() | 453 | void SimpleAlarmDaemonImpl::showTimer() |
401 | { | 454 | { |
402 | fillTimerPopUp(); | 455 | fillTimerPopUp(); |
403 | } | 456 | } |
404 | 457 | ||
405 | void SimpleAlarmDaemonImpl::confTimer( int time ) | 458 | void SimpleAlarmDaemonImpl::confTimer( int time ) |
406 | { | 459 | { |
407 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 460 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
408 | int minutes = time; | 461 | int minutes = time; |
409 | if ( minutes == 0 ) { | 462 | if ( minutes == 0 ) { |
410 | if ( ! mTimerTime ) | 463 | if ( ! mTimerTime ) |
411 | return; | 464 | return; |
412 | 465 | ||
413 | QDialog dia ( 0, ("Stop Timer" ), true ); | 466 | QDialog dia ( 0, ("Stop Timer" ), true ); |
414 | QLabel lab (("Really stop the timer?"), &dia ); | 467 | QLabel lab (("Really stop the timer?"), &dia ); |
415 | dia.setCaption(("KO/Pi Timer Stop" )); | 468 | dia.setCaption(("KO/Pi Timer Stop" )); |
416 | QVBoxLayout lay( &dia ); | 469 | QVBoxLayout lay( &dia ); |
417 | lay.setMargin(5); | 470 | lay.setMargin(5); |
418 | lay.setSpacing(5); | 471 | lay.setSpacing(5); |
419 | lay.addWidget( &lab); | 472 | lay.addWidget( &lab); |
420 | dia.resize( 200, dia.sizeHint().height() ); | 473 | dia.resize( 200, dia.sizeHint().height() ); |
421 | 474 | ||
422 | if ( !dia.exec() ) | 475 | if ( !dia.exec() ) |
423 | return; | 476 | return; |
424 | 477 | ||
425 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 478 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); |
426 | mTimerTime = 0; | 479 | mTimerTime = 0; |
427 | return; | 480 | return; |
428 | } | 481 | } |
429 | if ( mTimerTime ) | 482 | if ( mTimerTime ) |
430 | return; | 483 | return; |
431 | if ( minutes == 1 ) { | 484 | if ( minutes == 1 ) { |
432 | return; | 485 | return; |
433 | } | 486 | } |
434 | QString mess = "timer_alarm"; | 487 | QString mess = "timer_alarm"; |
435 | mess += ("Timer Alarm!\n"); | 488 | mess += ("Timer Alarm!\n"); |
436 | if ( minutes == 22 ) | 489 | if ( minutes == 22 ) |
437 | mess += ( "Pizza is ready"); | 490 | mess += ( "Pizza is ready"); |
438 | else if ( minutes == 45 ) | 491 | else if ( minutes == 45 ) |
439 | mess += ( "Please wake up!"); | 492 | mess += ( "Please wake up!"); |
440 | else if ( minutes == 5 ) | 493 | else if ( minutes == 5 ) |
441 | mess += ( "Tea is ready"); | 494 | mess += ( "Tea is ready"); |
442 | else if ( minutes == 3 ) { | 495 | else if ( minutes == 3 ) { |
443 | mess += mCustomText; | 496 | mess += mCustomText; |
444 | minutes = mCustomMinutes ; | 497 | minutes = mCustomMinutes ; |
445 | } | 498 | } |
446 | else { | 499 | else { |
447 | if ( minutes == 2 ) { | 500 | if ( minutes == 2 ) { |
448 | // ask time | 501 | // ask time |
449 | QDialog dia ( 0, ("Customize Timer" ), true ); | 502 | QDialog dia ( 0, ("Customize Timer" ), true ); |
450 | QLabel lab (("Message Text:"), &dia ); | 503 | QLabel lab (("Message Text:"), &dia ); |
451 | dia.setCaption(("KO/Pi Timer" )); | 504 | dia.setCaption(("KO/Pi Timer" )); |
452 | QVBoxLayout lay( &dia ); | 505 | QVBoxLayout lay( &dia ); |
453 | lay.setMargin(5); | 506 | lay.setMargin(5); |
454 | lay.setSpacing(5); | 507 | lay.setSpacing(5); |
455 | lay.addWidget( &lab); | 508 | lay.addWidget( &lab); |
456 | QLineEdit lEdit( mCustomText, &dia ); | 509 | QLineEdit lEdit( mCustomText, &dia ); |
457 | lay.addWidget( &lEdit); | 510 | lay.addWidget( &lEdit); |
458 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 511 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
459 | lay.addWidget( &lab2); | 512 | lay.addWidget( &lab2); |
460 | QHBox hbox ( &dia ); | 513 | QHBox hbox ( &dia ); |
461 | QLabel lab3 (("h:"), &hbox ); | 514 | QLabel lab3 (("h:"), &hbox ); |
462 | QSpinBox spinh( 0, 24, 1,& hbox ); | 515 | QSpinBox spinh( 0, 24, 1,& hbox ); |
463 | QLabel lab4 ((" min:"), &hbox ); | 516 | QLabel lab4 ((" min:"), &hbox ); |
464 | QSpinBox spinm( 0, 59, 1,&hbox ); | 517 | QSpinBox spinm( 0, 59, 1,&hbox ); |
465 | spinh.setValue( mCustomMinutes/60 ); | 518 | spinh.setValue( mCustomMinutes/60 ); |
466 | spinm.setValue( mCustomMinutes%60 ); | 519 | spinm.setValue( mCustomMinutes%60 ); |
467 | lay.addWidget( &hbox); | 520 | lay.addWidget( &hbox); |
468 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 521 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
469 | if ( !dia.exec() ) | 522 | if ( !dia.exec() ) |
470 | return; | 523 | return; |
471 | mCustomText = lEdit.text(); | 524 | mCustomText = lEdit.text(); |
472 | mCustomMinutes = spinh.value()*60+spinm.value(); | 525 | mCustomMinutes = spinh.value()*60+spinm.value(); |
473 | if ( mCustomMinutes == 0 ) | 526 | if ( mCustomMinutes == 0 ) |
474 | mCustomMinutes = 1; | 527 | mCustomMinutes = 1; |
475 | if ( mCustomMinutes > 1440 ) | 528 | if ( mCustomMinutes > 1440 ) |
476 | mCustomMinutes = 1440; | 529 | mCustomMinutes = 1440; |
477 | mess += mCustomText; | 530 | mess += mCustomText; |
478 | minutes = mCustomMinutes; | 531 | minutes = mCustomMinutes; |
479 | } | 532 | } |
480 | else | 533 | else |
481 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | 534 | mess+= QString::number ( minutes ) + ( " minutes are past!"); |
482 | } | 535 | } |
483 | //minutes = 1; | 536 | //minutes = 1; |
484 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 537 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
485 | timerMesssage = mess; | 538 | timerMesssage = mess; |
486 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); | 539 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); |
487 | mTimerTime = 1; | 540 | mTimerTime = 1; |
488 | } | 541 | } |
489 | 542 | ||
490 | void SimpleAlarmDaemonImpl::writeFile() | 543 | void SimpleAlarmDaemonImpl::writeFile() |
491 | { | 544 | { |
492 | QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 545 | QCopEnvelope e("QPE/Application/kopi", "-writeFile"); |
493 | } | 546 | } |
494 | void SimpleAlarmDaemonImpl::showWN() | 547 | void SimpleAlarmDaemonImpl::showWN() |
495 | { | 548 | { |
496 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 549 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
497 | } | 550 | } |
498 | void SimpleAlarmDaemonImpl::newTodo() | 551 | void SimpleAlarmDaemonImpl::newTodo() |
499 | { | 552 | { |
500 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 553 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
501 | } | 554 | } |
502 | 555 | ||
503 | void SimpleAlarmDaemonImpl::newEvent() | 556 | void SimpleAlarmDaemonImpl::newEvent() |
504 | { | 557 | { |
505 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 558 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
506 | 559 | ||
507 | } | 560 | } |
508 | void SimpleAlarmDaemonImpl::newMail() | 561 | void SimpleAlarmDaemonImpl::newMail() |
509 | { | 562 | { |
510 | QCopEnvelope e("QPE/Application/kmpi", "newMail()"); | 563 | QCopEnvelope e("QPE/Application/kmpi", "newMail()"); |
511 | } | 564 | } |
512 | void SimpleAlarmDaemonImpl::showAdd() | 565 | void SimpleAlarmDaemonImpl::showAdd() |
513 | { | 566 | { |
514 | QCopEnvelope e("QPE/Application/kapi", " "); | 567 | QCopEnvelope e("QPE/Application/kapi", " "); |
515 | } | 568 | } |
516 | void SimpleAlarmDaemonImpl::ringSync() | 569 | void SimpleAlarmDaemonImpl::ringSync() |
517 | { | 570 | { |
518 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 571 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
519 | 572 | ||
520 | } | 573 | } |
521 | void SimpleAlarmDaemonImpl::newCountdown() | 574 | void SimpleAlarmDaemonImpl::newCountdown() |
522 | { | 575 | { |
523 | //recieve("cal_alarm", 10 ); | 576 | //recieve("cal_alarm", 10 ); |
524 | } | 577 | } |
525 | void SimpleAlarmDaemonImpl::simulate() | 578 | void SimpleAlarmDaemonImpl::simulate() |
526 | { | 579 | { |
527 | writeFile(); | 580 | writeFile(); |
528 | QString filename = getenv("QPEDIR") ; | 581 | QString filename = getenv("QPEDIR") ; |
529 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 582 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
530 | startAlarm("Alarm simulation", filename ); | 583 | startAlarm("Alarm simulation", filename ); |
531 | } | 584 | } |
532 | void SimpleAlarmDaemonImpl::showKO() | 585 | void SimpleAlarmDaemonImpl::showKO() |
533 | { | 586 | { |
534 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 587 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
535 | 588 | ||
536 | } | 589 | } |
537 | void SimpleAlarmDaemonImpl::showTodo() | 590 | void SimpleAlarmDaemonImpl::showTodo() |
538 | { | 591 | { |
539 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 592 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
540 | 593 | ||
541 | } | 594 | } |
542 | void SimpleAlarmDaemonImpl::writeJournal() | 595 | void SimpleAlarmDaemonImpl::writeJournal() |
543 | { | 596 | { |
544 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 597 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
545 | 598 | ||
546 | } | 599 | } |
547 | 600 | ||
548 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 601 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
549 | { | 602 | { |
550 | 603 | ||
551 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 604 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
552 | 605 | ||
553 | } | 606 | } |
554 | 607 | ||