author | zautrix <zautrix> | 2004-08-30 23:18:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-30 23:18:58 (UTC) |
commit | def659747d354789f84a992f18df2c3f80f12d01 (patch) (side-by-side diff) | |
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 @@ -373,6 +373,58 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp() mTimerPopUp->insertItem( "Stop", 0 ); mTimerPopUp->insertItem( t.toString(),1); } else { + + QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; + QFile file( fileName ); + if( !QFile::exists( fileName) ) { + // write defaults + if (!file.open( IO_WriteOnly ) ) { + return; + } + QString configString ; + configString += "#config file for kopi alarm timer\n"; + configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; + configString += "#NOTE: minimum value for timer are 3 minutes!\n"; + configString += "24 h; 1440\n"; + configString += " 8 h; 480\n"; + configString += " 5 h; 300\n"; + configString += " 1 h; 60\n"; + configString += "30 min; 30\n"; + configString += "15 min; 15\n"; + configString += "SEPARATOR\n"; + configString += "Pizza; 22\n"; + configString += "Nap; 45\n"; + configString += "Tea; 5\n"; + QTextStream ts( &file ); + ts << configString ; + file.close(); + } + + if (!file.open( IO_ReadOnly ) ) { + return ; + } + QString line; + bool ok; + while ( file.readLine( line, 1024 ) > 0 ) { + //qDebug("read %s ", line.latin1()); + if ( line.left(1 ) != "#" ) { + // no comment + if ( line.left(9 ) == "SEPARATOR" ) { + mTimerPopUp->insertSeparator(); + } else { + QStringList li = QStringList::split(";",line); + ok = false; + if ( li.count() == 2 ) { + int val = li[1].toInt( &ok ); + if ( ok && val > 2 ) { + mTimerPopUp->insertItem( li[0], val); + } + } + } + } + } + file.close(); +#if 0 mTimerPopUp->insertItem( "24 h", 1440 ); // mTimerPopUp->insertItem( i18n("12 h"), 720 ); mTimerPopUp->insertItem( " 8 h", 480 ); @@ -387,6 +439,7 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp() mTimerPopUp->insertItem( "Pizza", 22 ); mTimerPopUp->insertItem( "Nap", 45 ); mTimerPopUp->insertItem( "Tea", 5 ); +#endif QString text = mCustomText.stripWhiteSpace (); int in = text.find( " " ); text = text.left ( in ); |