summaryrefslogtreecommitdiffabout
path: root/kalarmd
Unidiff
Diffstat (limited to 'kalarmd') (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp53
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
@@ -373,6 +373,58 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
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 );
@@ -387,6 +439,7 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
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 );