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 | |
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 | |||
@@ -374,4 +374,56 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp() | |||
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 ); |
@@ -388,4 +440,5 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp() | |||
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( " " ); |