summaryrefslogtreecommitdiffabout
path: root/kalarmd/simplealarmdaemonimpl.cpp
authorzautrix <zautrix>2004-08-30 23:18:58 (UTC)
committer zautrix <zautrix>2004-08-30 23:18:58 (UTC)
commitdef659747d354789f84a992f18df2c3f80f12d01 (patch) (unidiff)
tree9ee66d8e8ef7ab81c9b5e8a32b417746b6cdf8a0 /kalarmd/simplealarmdaemonimpl.cpp
parentcec54f6e21264341191e4f94f9dd7bd19b2eea8d (diff)
downloadkdepimpi-def659747d354789f84a992f18df2c3f80f12d01.zip
kdepimpi-def659747d354789f84a992f18df2c3f80f12d01.tar.gz
kdepimpi-def659747d354789f84a992f18df2c3f80f12d01.tar.bz2
Made timer configurable
Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore 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
@@ -368,30 +368,83 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
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