summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 553e377..82873e1 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -139,563 +139,563 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
139 confPause( 1 ); 139 confPause( 1 );
140 mSuspend = 0; 140 mSuspend = 0;
141 confSuspend( 0 ); 141 confSuspend( 0 );
142 if ( QApplication::desktop()->width() < 480 ) { 142 if ( QApplication::desktop()->width() < 480 ) {
143 wavAlarm = false; 143 wavAlarm = false;
144 mSoundPopUp->setItemChecked ( 0, true ); 144 mSoundPopUp->setItemChecked ( 0, true );
145 } 145 }
146 else { 146 else {
147 wavAlarm = true; 147 wavAlarm = true;
148 mSoundPopUp->setItemChecked ( 1, true ); 148 mSoundPopUp->setItemChecked ( 1, true );
149 } 149 }
150 saveSlot( 1 ); 150 saveSlot( 1 );
151 mTimerStartLabel = new QLabel( 0, 0, WType_Popup ); 151 mTimerStartLabel = new QLabel( 0, 0, WType_Popup );
152 //mTimerStartLabel->setCaption( "Timer started!"); 152 //mTimerStartLabel->setCaption( "Timer started!");
153 mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ; 153 mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ;
154 fon = mTimerPopUp->font(); 154 fon = mTimerPopUp->font();
155 fon.setBold( true ); 155 fon.setBold( true );
156 points = (fon.pointSize()*2); 156 points = (fon.pointSize()*2);
157 fon.setPointSize( points ); 157 fon.setPointSize( points );
158 mTimerStartLabel->setFont( fon ); 158 mTimerStartLabel->setFont( fon );
159} 159}
160 160
161SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 161SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
162{ 162{
163 //delete mPopUp; 163 //delete mPopUp;
164 delete mAlarmDialog; 164 delete mAlarmDialog;
165 delete mTimerStartLabel; 165 delete mTimerStartLabel;
166} 166}
167 167
168void SimpleAlarmDaemonImpl::saveSlot( int load ) 168void SimpleAlarmDaemonImpl::saveSlot( int load )
169{ 169{
170 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 170 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
171 //qDebug("save %d ", load ); 171 //qDebug("save %d ", load );
172 QFile file( fileName ); 172 QFile file( fileName );
173 if ( load ) { 173 if ( load ) {
174 if( !QFile::exists( fileName) ) 174 if( !QFile::exists( fileName) )
175 return; 175 return;
176 if (!file.open( IO_ReadOnly ) ) { 176 if (!file.open( IO_ReadOnly ) ) {
177 return ; 177 return ;
178 } 178 }
179 QString line; 179 QString line;
180 bool ok; 180 bool ok;
181 int val; 181 int val;
182 int len; 182 int len;
183 while ( file.readLine( line, 1024 ) > 0 ) { 183 while ( file.readLine( line, 1024 ) > 0 ) {
184 //qDebug("read %s ", line.latin1()); 184 //qDebug("read %s ", line.latin1());
185 len = line.length(); 185 len = line.length();
186 if ( line.left(4 ) == "PPAU" ) { 186 if ( line.left(4 ) == "PPAU" ) {
187 val = line.mid( 4,len-5).toInt( &ok ); 187 val = line.mid( 4,len-5).toInt( &ok );
188 if ( ok ) { 188 if ( ok ) {
189 confPause( val ); 189 confPause( val );
190 } 190 }
191 } 191 }
192 if ( line.left(4 ) == "SUCO" ) { 192 if ( line.left(4 ) == "SUCO" ) {
193 val = line.mid( 4,len-5).toInt( &ok ); 193 val = line.mid( 4,len-5).toInt( &ok );
194 if ( ok ) 194 if ( ok )
195 confSuspend ( val ); 195 confSuspend ( val );
196 } 196 }
197 if ( line.left(4 ) == "WAAL" ) { 197 if ( line.left(4 ) == "WAAL" ) {
198 val = line.mid( 4,len-5).toInt( &ok ); 198 val = line.mid( 4,len-5).toInt( &ok );
199 if ( ok ) 199 if ( ok )
200 confSound( val ); 200 confSound( val );
201 201
202 } 202 }
203 if ( line.left(4 ) == "PLBE" ) { 203 if ( line.left(4 ) == "PLBE" ) {
204 val = line.mid( 4,len-5).toInt( &ok ); 204 val = line.mid( 4,len-5).toInt( &ok );
205 if ( ok ) 205 if ( ok )
206 slotPlayBeep( val ); 206 slotPlayBeep( val );
207 207
208 } 208 }
209 if ( line.left(4 ) == "CUTE" ) { 209 if ( line.left(4 ) == "CUTE" ) {
210 mCustomText = line.mid( 5,len-6); 210 mCustomText = line.mid( 5,len-6);
211 // qDebug("text ***%s*** ",mCustomText.latin1() ); 211 // qDebug("text ***%s*** ",mCustomText.latin1() );
212 212
213 } 213 }
214 if ( line.left(4 ) == "CUMI" ) { 214 if ( line.left(4 ) == "CUMI" ) {
215 val = line.mid( 4,len-5).toInt( &ok ); 215 val = line.mid( 4,len-5).toInt( &ok );
216 if ( ok ) 216 if ( ok )
217 mCustomMinutes = val; 217 mCustomMinutes = val;
218 218
219 } 219 }
220 if ( line.left(4 ) == "SUTI" ) { 220 if ( line.left(4 ) == "SUTI" ) {
221 val = line.mid( 4,len-5).toInt( &ok ); 221 val = line.mid( 4,len-5).toInt( &ok );
222 if ( ok ) 222 if ( ok )
223 mAlarmDialog->setSuspendTime( val );; 223 mAlarmDialog->setSuspendTime( val );;
224 224
225 } 225 }
226 } 226 }
227 file.close(); 227 file.close();
228 } else { 228 } else {
229 if (!file.open( IO_WriteOnly ) ) { 229 if (!file.open( IO_WriteOnly ) ) {
230 return; 230 return;
231 } 231 }
232 QString configString ; 232 QString configString ;
233 configString += "PPAU " + QString::number( mPausePlay ) + "\n"; 233 configString += "PPAU " + QString::number( mPausePlay ) + "\n";
234 configString += "SUCO " + QString::number( mSuspend ) + "\n"; 234 configString += "SUCO " + QString::number( mSuspend ) + "\n";
235 configString += "WAAL " + QString::number( wavAlarm ) + "\n"; 235 configString += "WAAL " + QString::number( wavAlarm ) + "\n";
236 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; 236 configString += "PLBE " + QString::number( mPlayBeeps ) + "\n";
237 configString += "CUTE " + mCustomText + "\n"; 237 configString += "CUTE " + mCustomText + "\n";
238 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; 238 configString += "CUMI " + QString::number( mCustomMinutes ) + "\n";
239 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; 239 configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n";
240 QTextStream ts( &file ); 240 QTextStream ts( &file );
241 ts << configString ; 241 ts << configString ;
242 file.close(); 242 file.close();
243 } 243 }
244 244
245} 245}
246void SimpleAlarmDaemonImpl::confSuspend( int num ) 246void SimpleAlarmDaemonImpl::confSuspend( int num )
247{ 247{
248 mSuspendPopUp->setItemChecked ( mSuspend,false ); 248 mSuspendPopUp->setItemChecked ( mSuspend,false );
249 mSuspend = num; 249 mSuspend = num;
250 mSuspendPopUp->setItemChecked ( mSuspend,true ); 250 mSuspendPopUp->setItemChecked ( mSuspend,true );
251} 251}
252void SimpleAlarmDaemonImpl::confPause( int num ) 252void SimpleAlarmDaemonImpl::confPause( int num )
253{ 253{
254 mPausePopUp->setItemChecked ( mPausePlay,false ); 254 mPausePopUp->setItemChecked ( mPausePlay,false );
255 mPausePlay = num; 255 mPausePlay = num;
256 mPausePopUp->setItemChecked ( mPausePlay,true ); 256 mPausePopUp->setItemChecked ( mPausePlay,true );
257} 257}
258void SimpleAlarmDaemonImpl::confSound( int num ) 258void SimpleAlarmDaemonImpl::confSound( int num )
259{ 259{
260 if ( num == 0 ) { 260 if ( num == 0 ) {
261 wavAlarm = false; 261 wavAlarm = false;
262 mSoundPopUp->setItemChecked ( 0, true ); 262 mSoundPopUp->setItemChecked ( 0, true );
263 mSoundPopUp->setItemChecked ( 1, false ); 263 mSoundPopUp->setItemChecked ( 1, false );
264 } else { 264 } else {
265 wavAlarm = true; 265 wavAlarm = true;
266 mSoundPopUp->setItemChecked ( 0, false ); 266 mSoundPopUp->setItemChecked ( 0, false );
267 mSoundPopUp->setItemChecked ( 1, true ); 267 mSoundPopUp->setItemChecked ( 1, true );
268 } 268 }
269} 269}
270void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) 270void SimpleAlarmDaemonImpl::slotPlayBeep( int num )
271{ 271{
272 if ( num == 1000 ) { 272 if ( num == 1000 ) {
273 simulate(); 273 simulate();
274 return; 274 return;
275 } 275 }
276 mBeepPopUp->setItemChecked ( mPlayBeeps,false ); 276 mBeepPopUp->setItemChecked ( mPlayBeeps,false );
277 mPlayBeeps = num; 277 mPlayBeeps = num;
278 mBeepPopUp->setItemChecked ( mPlayBeeps, true ); 278 mBeepPopUp->setItemChecked ( mPlayBeeps, true );
279} 279}
280 280
281void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) 281void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
282{ 282{
283 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); 283 //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data());
284 QString mess = QString::fromUtf8(msg.data()); 284 QString mess = QString::fromUtf8(msg.data());
285 mAlarmMessage = mess.mid( 9 ); 285 mAlarmMessage = mess.mid( 9 );
286 QString filename = getenv("QPEDIR") ; 286 QString filename = getenv("QPEDIR") ;
287 filename += "/pics/kdepim/korganizer/koalarm.wav"; 287 filename += "/pics/kdepim/korganizer/koalarm.wav";
288 QString tempfilename; 288 QString tempfilename;
289 if ( mess.left( 13 ) == "suspend_alarm") { 289 if ( mess.left( 13 ) == "suspend_alarm") {
290 bool error = false; 290 bool error = false;
291 int len = mess.mid( 13 ).find("+++"); 291 int len = mess.mid( 13 ).find("+++");
292 if ( len < 2 ) 292 if ( len < 2 )
293 error = true; 293 error = true;
294 else { 294 else {
295 tempfilename = mess.mid( 13, len ); 295 tempfilename = mess.mid( 13, len );
296 if ( !QFile::exists( tempfilename ) ) 296 if ( !QFile::exists( tempfilename ) )
297 error = true; 297 error = true;
298 } 298 }
299 if ( ! error ) { 299 if ( ! error ) {
300 filename = tempfilename; 300 filename = tempfilename;
301 } 301 }
302 mAlarmMessage = mess.mid( 13+len+3 ); 302 mAlarmMessage = mess.mid( 13+len+3 );
303 //qDebug("suspend file %s ",tempfilename.latin1() ); 303 //qDebug("suspend file %s ",tempfilename.latin1() );
304 startAlarm( mAlarmMessage, filename); 304 startAlarm( mAlarmMessage, filename);
305 return; 305 return;
306 } 306 }
307 if ( mess.left( 11 ) == "timer_alarm") { 307 if ( mess.left( 11 ) == "timer_alarm") {
308 mTimerTime = 0; 308 mTimerTime = 0;
309 startAlarm( mess.mid( 11 ), filename ); 309 startAlarm( mess.mid( 11 ), filename );
310 return; 310 return;
311 } 311 }
312 if ( mess.left( 10 ) == "proc_alarm") { 312 if ( mess.left( 10 ) == "proc_alarm") {
313 bool error = false; 313 bool error = false;
314 int len = mess.mid( 10 ).find("+++"); 314 int len = mess.mid( 10 ).find("+++");
315 if ( len < 2 ) 315 if ( len < 2 )
316 error = true; 316 error = true;
317 else { 317 else {
318 tempfilename = mess.mid( 10, len ); 318 tempfilename = mess.mid( 10, len );
319 if ( !QFile::exists( tempfilename ) ) 319 if ( !QFile::exists( tempfilename ) )
320 error = true; 320 error = true;
321 } 321 }
322 if ( error ) { 322 if ( error ) {
323 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 323 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
324 mAlarmMessage += mess.mid( 10+len+3+9 ); 324 mAlarmMessage += mess.mid( 10+len+3+9 );
325 } else { 325 } else {
326 //qDebug("-----system command %s ",tempfilename.latin1() ); 326 //qDebug("-----system command %s ",tempfilename.latin1() );
327 if ( vfork () == 0 ) { 327 if ( vfork () == 0 ) {
328 execl ( tempfilename.latin1(), 0 ); 328 execl ( tempfilename.latin1(), 0 );
329 return; 329 return;
330 } 330 }
331 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); 331 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
332 return; 332 return;
333 } 333 }
334 334
335 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 335 //qDebug("+++++++system command %s ",tempfilename.latin1() );
336 } 336 }
337 if ( mess.left( 11 ) == "audio_alarm") { 337 if ( mess.left( 11 ) == "audio_alarm") {
338 bool error = false; 338 bool error = false;
339 int len = mess.mid( 11 ).find("+++"); 339 int len = mess.mid( 11 ).find("+++");
340 if ( len < 2 ) 340 if ( len < 2 )
341 error = true; 341 error = true;
342 else { 342 else {
343 tempfilename = mess.mid( 11, len ); 343 tempfilename = mess.mid( 11, len );
344 if ( !QFile::exists( tempfilename ) ) 344 if ( !QFile::exists( tempfilename ) )
345 error = true; 345 error = true;
346 } 346 }
347 if ( ! error ) { 347 if ( ! error ) {
348 filename = tempfilename; 348 filename = tempfilename;
349 } 349 }
350 mAlarmMessage = mess.mid( 11+len+3+9 ); 350 mAlarmMessage = mess.mid( 11+len+3+9 );
351 //qDebug("audio file command %s ",tempfilename.latin1() ); 351 //qDebug("audio file command %s ",tempfilename.latin1() );
352 } 352 }
353 if ( mess.left( 9 ) == "cal_alarm") { 353 if ( mess.left( 9 ) == "cal_alarm") {
354 mAlarmMessage = mess.mid( 9 ) ; 354 mAlarmMessage = mess.mid( 9 ) ;
355 } 355 }
356 356
357 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); 357 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
358 startAlarm( mAlarmMessage, filename ); 358 startAlarm( mAlarmMessage, filename );
359 359
360} 360}
361 361
362int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) 362int SimpleAlarmDaemonImpl::getFileNameLen( QString mess )
363{ 363{
364 return 0; 364 return 0;
365} 365}
366void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) 366void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename )
367{ 367{
368 //mAlarmDialog->show(); 368 //mAlarmDialog->show();
369 //mAlarmDialog->raise(); 369 //mAlarmDialog->raise();
370 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); 370 mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend );
371} 371}
372 372
373 373
374void SimpleAlarmDaemonImpl::fillTimerPopUp() 374void SimpleAlarmDaemonImpl::fillTimerPopUp()
375{ 375{
376 376
377 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); 377 // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime );
378 if ( mTimerPopupConf == mTimerTime ) { 378 if ( mTimerPopupConf == mTimerTime ) {
379 if ( mTimerTime ) { 379 if ( mTimerTime ) {
380 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 380 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
381 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 381 QTime t ( secs/3600, (secs/60)%60, secs%60 );
382 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); 382 mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)");
383 } 383 }
384 else { 384 else {
385 QString text = mCustomText.stripWhiteSpace (); 385 QString text = mCustomText.stripWhiteSpace ();
386 int in = text.find( " " ); 386 int in = text.find( " " );
387 text = text.left ( in ); 387 text = text.left ( in );
388 mTimerPopUp->changeItem ( 3, text ); 388 mTimerPopUp->changeItem ( 3, text );
389 } 389 }
390 return; 390 return;
391 } 391 }
392 mTimerPopupConf = mTimerTime; 392 mTimerPopupConf = mTimerTime;
393 mTimerPopUp->clear(); 393 mTimerPopUp->clear();
394 if ( mTimerTime ) { 394 if ( mTimerTime ) {
395 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); 395 int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
396 QTime t ( secs/3600, (secs/60)%60, secs%60 ); 396 QTime t ( secs/3600, (secs/60)%60, secs%60 );
397 397
398 398
399 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 399 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
400 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 400 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
401 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 401 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
402 } else { 402 } else {
403 403
404 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 404 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
405 QFile file( fileName ); 405 QFile file( fileName );
406 if( !QFile::exists( fileName) ) { 406 if( !QFile::exists( fileName) ) {
407 // write defaults 407 // write defaults
408 if (!file.open( IO_WriteOnly ) ) { 408 if (!file.open( IO_WriteOnly ) ) {
409 return; 409 return;
410 } 410 }
411 QString configString ; 411 QString configString ;
412 configString += "#config file for kopi alarm timer\n"; 412 configString += "#config file for kopi alarm timer\n";
413 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 413 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
414 configString += "24 hours; 1440\n"; 414 configString += "24 hours; 1440\n";
415 configString += "9 hours; 540\n"; 415 configString += "9 hours; 540\n";
416 configString += "8 hours; 480\n"; 416 configString += "8 hours; 480\n";
417 configString += "1 hour; 60\n"; 417 configString += "1 hour; 60\n";
418 configString += "30 min; 30\n"; 418 configString += "30 min; 30\n";
419 configString += "15 min; 15\n"; 419 configString += "15 min; 15\n";
420 configString += "SEPARATOR\n"; 420 configString += "SEPARATOR\n";
421 configString += "Pizza; 22\n"; 421 configString += "Pizza; 22\n";
422 configString += "Nap; 45\n"; 422 configString += "Nap; 45\n";
423 configString += "Tea; 5\n"; 423 configString += "Tea; 5\n";
424 QTextStream ts( &file ); 424 QTextStream ts( &file );
425 ts << configString ; 425 ts << configString ;
426 file.close(); 426 file.close();
427 } 427 }
428 428
429 if (!file.open( IO_ReadOnly ) ) { 429 if (!file.open( IO_ReadOnly ) ) {
430 return ; 430 return ;
431 } 431 }
432 QString line; 432 QString line;
433 bool ok; 433 bool ok;
434 while ( file.readLine( line, 1024 ) > 0 ) { 434 while ( file.readLine( line, 1024 ) > 0 ) {
435 //qDebug("read %s ", line.latin1()); 435 //qDebug("read %s ", line.latin1());
436 if ( line.left(1 ) != "#" ) { 436 if ( line.left(1 ) != "#" ) {
437 // no comment 437 // no comment
438 if ( line.left(9 ) == "SEPARATOR" ) { 438 if ( line.left(9 ) == "SEPARATOR" ) {
439 mTimerPopUp->insertSeparator(); 439 mTimerPopUp->insertSeparator();
440 } else { 440 } else {
441 QStringList li = QStringList::split(";",line); 441 QStringList li = QStringList::split(";",line);
442 ok = false; 442 ok = false;
443 if ( li.count() == 2 ) { 443 if ( li.count() == 2 ) {
444 int val = li[1].toInt( &ok ); 444 int val = li[1].toInt( &ok );
445 if ( ok && val > 0 ) { 445 if ( ok && val > 0 ) {
446 mTimerPopUp->insertItem( li[0], val+10); 446 mTimerPopUp->insertItem( li[0], val+10);
447 } 447 }
448 } 448 }
449 } 449 }
450 } 450 }
451 } 451 }
452 file.close(); 452 file.close();
453#if 0 453#if 0
454 mTimerPopUp->insertItem( "24 hours", 1440 ); 454 mTimerPopUp->insertItem( "24 hours", 1440 );
455 // mTimerPopUp->insertItem( i18n("12 h"), 720 ); 455 // mTimerPopUp->insertItem( i18n("12 h"), 720 );
456 mTimerPopUp->insertItem( " 8 hours", 480 ); 456 mTimerPopUp->insertItem( " 8 hours", 480 );
457 mTimerPopUp->insertItem( " 5 hours", 300 ); 457 mTimerPopUp->insertItem( " 5 hours", 300 );
458 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); 458 // mTimerPopUp->insertItem( i18n(" 2 h"), 120 );
459 mTimerPopUp->insertItem( " 1 hour", 60 ); 459 mTimerPopUp->insertItem( " 1 hour", 60 );
460 mTimerPopUp->insertItem( "30 min", 30 ); 460 mTimerPopUp->insertItem( "30 min", 30 );
461 mTimerPopUp->insertItem( "15 min", 15 ); 461 mTimerPopUp->insertItem( "15 min", 15 );
462 mTimerPopUp->insertItem( "10 min", 10 ); 462 mTimerPopUp->insertItem( "10 min", 10 );
463 //mTimerPopUp->insertItem( " 5 min", 5 ); 463 //mTimerPopUp->insertItem( " 5 min", 5 );
464 mTimerPopUp->insertSeparator(); 464 mTimerPopUp->insertSeparator();
465 mTimerPopUp->insertItem( "Pizza", 22 ); 465 mTimerPopUp->insertItem( "Pizza", 22 );
466 mTimerPopUp->insertItem( "Nap", 45 ); 466 mTimerPopUp->insertItem( "Nap", 45 );
467 mTimerPopUp->insertItem( "Tea", 5 ); 467 mTimerPopUp->insertItem( "Tea", 5 );
468#endif 468#endif
469 QString text = mCustomText.stripWhiteSpace (); 469 QString text = mCustomText.stripWhiteSpace ();
470 int in = text.find( " " ); 470 int in = text.find( " " );
471 text = text.left ( in ); 471 text = text.left ( in );
472 mTimerPopUp->insertItem( text, 3 ); 472 mTimerPopUp->insertItem( text, 3 );
473 mTimerPopUp->insertSeparator(); 473 mTimerPopUp->insertSeparator();
474 mTimerPopUp->insertItem( "Customize", 2 ); 474 mTimerPopUp->insertItem( "Customize", 2 );
475 } 475 }
476 476
477} 477}
478 478
479void SimpleAlarmDaemonImpl::showTimer() 479void SimpleAlarmDaemonImpl::showTimer()
480{ 480{
481 fillTimerPopUp(); 481 fillTimerPopUp();
482} 482}
483 483
484void SimpleAlarmDaemonImpl::confTimer( int time ) 484void SimpleAlarmDaemonImpl::confTimer( int time )
485{ 485{
486 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); 486 //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time );
487 int minutes = time; 487 int minutes = time;
488 if ( minutes == 0 ) { 488 if ( minutes == 0 ) {
489 if ( ! mTimerTime ) 489 if ( ! mTimerTime )
490 return; 490 return;
491 491
492 QDialog dia ( 0, ("Stop Timer" ), true ); 492 QDialog dia ( 0, ("Stop Timer" ), true );
493 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); 493 QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
494 lab.setAlignment( AlignCenter ); 494 lab.setAlignment( AlignCenter );
495 dia.setCaption(("KO/Pi Timer Stop" )); 495 dia.setCaption(("KO/Pi Timer Stop" ));
496 QVBoxLayout lay( &dia ); 496 QVBoxLayout lay( &dia );
497 lay.addWidget( &lab); 497 lay.addWidget( &lab);
498 QPushButton ok ( "Stop timer!", &dia); 498 QPushButton ok ( "Stop timer!", &dia);
499 QFont fo = dia.font(); 499 QFont fo = dia.font();
500 fo.setPointSize( 36 ); 500 fo.setPointSize( 36 );
501 ok.setFont( fo ); 501 ok.setFont( fo );
502 lay.addWidget( &ok); 502 lay.addWidget( &ok);
503 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 503 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
504 QPushButton con ( "Continue timer!", &dia); 504 QPushButton con ( "Continue timer!", &dia);
505 fo.setPointSize( 36 ); 505 fo.setPointSize( 36 );
506 con.setFont( fo ); 506 con.setFont( fo );
507 lay.addWidget( &con); 507 lay.addWidget( &con);
508 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); 508 connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
509 lay.setMargin(5); 509 lay.setMargin(5);
510 lay.setSpacing(5); 510 lay.setSpacing(5);
511 dia.resize(dia.sizeHint() ); 511 dia.resize(dia.sizeHint() );
512 512
513 if ( !dia.exec() ) 513 if ( !dia.exec() )
514 return; 514 return;
515 515
516 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 516 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
517 mTimerTime = 0; 517 mTimerTime = 0;
518 return; 518 return;
519 } 519 }
520 if ( mTimerTime ) 520 if ( mTimerTime )
521 return; 521 return;
522 if ( minutes == 1 ) { 522 if ( minutes == 1 ) {
523 return; 523 return;
524 } 524 }
525 QString mess = "timer_alarm"; 525 QString mess = "timer_alarm";
526 QString disp; 526 QString disp;
527 mess += ("Timer Alarm!\n"); 527 mess += ("Timer Alarm!\n");
528 if ( minutes == 3 ) { 528 if ( minutes == 3 ) {
529 mess += mCustomText; 529 mess += mCustomText;
530 minutes = mCustomMinutes ; 530 minutes = mCustomMinutes ;
531 mRunningTimerText = mCustomText.stripWhiteSpace (); 531 mRunningTimerText = mCustomText.stripWhiteSpace ();
532 int in = mRunningTimerText.find( " " ); 532 int in = mRunningTimerText.find( " " );
533 mRunningTimerText = mRunningTimerText.left ( in ); 533 mRunningTimerText = mRunningTimerText.left ( in );
534 disp = mCustomText; 534 disp = mCustomText;
535 } 535 }
536 else { 536 else {
537 if ( minutes == 2 ) { 537 if ( minutes == 2 ) {
538 // ask time 538 // ask time
539 QDialog dia ( 0, ("Customize Timer" ), true ); 539 QDialog dia ( 0, ("Customize Timer" ), true );
540 QLabel lab (("Message Text:"), &dia ); 540 QLabel lab (("Message Text:"), &dia );
541 dia.setCaption(("KO/Pi Timer" )); 541 dia.setCaption(("KO/Pi Timer" ));
542 QVBoxLayout lay( &dia ); 542 QVBoxLayout lay( &dia );
543 lay.setMargin(5); 543 lay.setMargin(5);
544 lay.setSpacing(5); 544 lay.setSpacing(5);
545 lay.addWidget( &lab); 545 lay.addWidget( &lab);
546 QLineEdit lEdit( mCustomText, &dia ); 546 QLineEdit lEdit( mCustomText, &dia );
547 lay.addWidget( &lEdit); 547 lay.addWidget( &lEdit);
548 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 548 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
549 lay.addWidget( &lab2); 549 lay.addWidget( &lab2);
550 QHBox hbox1 ( &dia ); 550 QHBox hbox1 ( &dia );
551 lay.addWidget( &hbox1); 551 lay.addWidget( &hbox1);
552 QLabel lab3 (("Hours"), &hbox1 ); 552 QLabel lab3 (("Hours"), &hbox1 );
553 QLabel lab4 (("Minutes"), &hbox1 ); 553 QLabel lab4 (("Minutes"), &hbox1 );
554 QHBox hbox ( &dia ); 554 QHBox hbox ( &dia );
555 QSpinBox spinh( 0, 24, 1,& hbox ); 555 QSpinBox spinh( 0, 24, 1,& hbox );
556 QFont fo = dia.font(); 556 QFont fo = dia.font();
557 fo.setPointSize( 36 ); 557 fo.setPointSize( 36 );
558 QSpinBox spinm( 0, 59, 1,&hbox ); 558 QSpinBox spinm( 0, 59, 1,&hbox );
559 spinm.setFont( fo ); 559 spinm.setFont( fo );
560 spinh.setFont( fo ); 560 spinh.setFont( fo );
561 spinh.setButtonSymbols( QSpinBox::PlusMinus ); 561 spinh.setButtonSymbols( QSpinBox::PlusMinus );
562 spinm.setButtonSymbols( QSpinBox::PlusMinus ); 562 spinm.setButtonSymbols( QSpinBox::PlusMinus );
563 spinh.upButton ()->setFixedSize( QSize( 48, 30 )); 563 spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
564 spinh.downButton ()->setFixedSize( QSize( 48, 30 )); 564 spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
565 //spinh.editor ()->setFixedSize( QSize( 50, 100 )); 565 //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
566 spinh.setFixedSize( 100,62 ); 566 spinh.setFixedSize( 100,62 );
567 spinm.upButton ()->setFixedSize( QSize( 48, 30 )); 567 spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
568 spinm.downButton ()->setFixedSize( QSize( 48, 30 )); 568 spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
569 spinm.downButton ()->setGeometry( 50,50,50,50); 569 spinm.downButton ()->setGeometry( 50,50,50,50);
570 // spinm.setSuffix( " m" ); 570 // spinm.setSuffix( " m" );
571 //spinh.setSuffix( " h" ); 571 //spinh.setSuffix( " h" );
572 spinm.setWrapping ( true ); 572 spinm.setWrapping ( true );
573 //spinm.editor ()->setFixedSize( QSize( 50, 100 )); 573 //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
574 spinm.setLineStep( 1 ); 574 spinm.setLineStep( 1 );
575 spinm.setFixedSize( 110,62 ); 575 spinm.setFixedSize( 110,62 );
576 lay.addWidget( &hbox); 576 lay.addWidget( &hbox);
577 QLabel lab5 ("Timer fires at:", &dia ); 577 QLabel lab5 ("Timer fires at:", &dia );
578 lab5.setAlignment( AlignCenter ); 578 lab5.setAlignment( AlignCenter );
579 lay.addWidget( &lab5); 579 lay.addWidget( &lab5);
580 KODateLabel dl ( &dia ); 580 KODateLabel dl ( &dia );
581 dl.setAlignment( AlignCenter ); 581 dl.setAlignment( AlignCenter );
582 dl.setFont( fo ); 582 dl.setFont( fo );
583 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); 583 connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
584 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); 584 connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
585 lay.addWidget( &dl); 585 lay.addWidget( &dl);
586 spinh.setValue( mCustomMinutes/60 ); 586 spinh.setValue( mCustomMinutes/60 );
587 spinm.setValue( mCustomMinutes%60 ); 587 spinm.setValue( mCustomMinutes%60 );
588 QPushButton ok ( "Start timer", &dia); 588 QPushButton ok ( "Start timer", &dia);
589 ok.setDefault( true ); 589 ok.setDefault( true );
590 ok.setFont( fo ); 590 ok.setFont( fo );
591 spinh.setFocus(); 591 spinh.setFocus();
592 lay.addWidget( &ok); 592 lay.addWidget( &ok);
593 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 593 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
594 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 594 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
595 595
596 if ( !dia.exec() ) 596 if ( !dia.exec() )
597 return; 597 return;
598 mCustomText = lEdit.text(); 598 mCustomText = lEdit.text();
599 mCustomMinutes = spinh.value()*60+spinm.value(); 599 mCustomMinutes = spinh.value()*60+spinm.value();
600 if ( mCustomMinutes == 0 ) 600 if ( mCustomMinutes == 0 )
601 mCustomMinutes = 1; 601 mCustomMinutes = 1;
602 if ( mCustomMinutes > 1440 ) 602 if ( mCustomMinutes > 1440 )
603 mCustomMinutes = 1440; 603 mCustomMinutes = 1440;
604 mess += mCustomText; 604 mess += mCustomText;
605 disp = mCustomText; 605 disp = mCustomText;
606 minutes = mCustomMinutes; 606 minutes = mCustomMinutes;
607 mRunningTimerText = mCustomText.stripWhiteSpace (); 607 mRunningTimerText = mCustomText.stripWhiteSpace ();
608 int in = mRunningTimerText.find( " " ); 608 int in = mRunningTimerText.find( " " );
609 mRunningTimerText = mRunningTimerText.left ( in ); 609 mRunningTimerText = mRunningTimerText.left ( in );
610 } 610 }
611 else { 611 else {
612 mess += mTimerPopUp->text( minutes ); 612 mess += mTimerPopUp->text( minutes );
613 disp = mTimerPopUp->text( minutes ); 613 disp = mTimerPopUp->text( minutes );
614 mRunningTimerText = mTimerPopUp->text( minutes ); 614 mRunningTimerText = mTimerPopUp->text( minutes );
615 minutes -= 10; 615 minutes -= 10;
616 } 616 }
617 } 617 }
618 //minutes = 1; 618 //minutes = 1;
619 619
620 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 620 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
621 timerMesssage = mess; 621 timerMesssage = mess;
622 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 622 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
623 mTimerStartLabel->setText( disp + "\n\nTimer started!" ); 623 mTimerStartLabel->setText( disp + "\n\nTimer started!" );
624 int w = mTimerStartLabel->sizeHint().width()+20; 624 int w = mTimerStartLabel->sizeHint().width()+20;
625 int h = mTimerStartLabel->sizeHint().height()+40 ; 625 int h = mTimerStartLabel->sizeHint().height()+40 ;
626 int dw = QApplication::desktop()->width(); 626 int dw = QApplication::desktop()->width();
627 int dh = QApplication::desktop()->height(); 627 int dh = QApplication::desktop()->height();
628 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 628 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
629 mTimerStartLabel->show(); 629 mTimerStartLabel->show();
630 QTimer::singleShot( 3000, mTimerStartLabel, SLOT ( hide() ) ); 630 QTimer::singleShot( 5000, mTimerStartLabel, SLOT ( hide() ) );
631 mTimerTime = 1; 631 mTimerTime = 1;
632} 632}
633 633
634void SimpleAlarmDaemonImpl::writeFile() 634void SimpleAlarmDaemonImpl::writeFile()
635{ 635{
636 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 636 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
637 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 637 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
638} 638}
639void SimpleAlarmDaemonImpl::showWN() 639void SimpleAlarmDaemonImpl::showWN()
640{ 640{
641 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 641 QCopEnvelope e("QPE/Application/kopi", "-showWN");
642} 642}
643void SimpleAlarmDaemonImpl::newTodo() 643void SimpleAlarmDaemonImpl::newTodo()
644{ 644{
645 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 645 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
646} 646}
647 647
648void SimpleAlarmDaemonImpl::newEvent() 648void SimpleAlarmDaemonImpl::newEvent()
649{ 649{
650 QCopEnvelope e("QPE/Application/kopi", "-newEvent"); 650 QCopEnvelope e("QPE/Application/kopi", "-newEvent");
651 651
652} 652}
653void SimpleAlarmDaemonImpl::newMail() 653void SimpleAlarmDaemonImpl::newMail()
654{ 654{
655 QCopEnvelope e("QPE/Application/ompi", "newMail()"); 655 QCopEnvelope e("QPE/Application/ompi", "newMail()");
656} 656}
657void SimpleAlarmDaemonImpl::showAdd() 657void SimpleAlarmDaemonImpl::showAdd()
658{ 658{
659 QCopEnvelope e("QPE/Application/kapi", "raise()"); 659 QCopEnvelope e("QPE/Application/kapi", "raise()");
660} 660}
661void SimpleAlarmDaemonImpl::ringSync() 661void SimpleAlarmDaemonImpl::ringSync()
662{ 662{
663 QCopEnvelope e("QPE/Application/kopi", "-ringSync"); 663 QCopEnvelope e("QPE/Application/kopi", "-ringSync");
664 664
665} 665}
666void SimpleAlarmDaemonImpl::newCountdown() 666void SimpleAlarmDaemonImpl::newCountdown()
667{ 667{
668 //recieve("cal_alarm", 10 ); 668 //recieve("cal_alarm", 10 );
669} 669}
670void SimpleAlarmDaemonImpl::simulate() 670void SimpleAlarmDaemonImpl::simulate()
671{ 671{
672 QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); 672 QTimer::singleShot( 2000, this, SLOT ( writeFile() ) );
673 QString filename = getenv("QPEDIR") ; 673 QString filename = getenv("QPEDIR") ;
674 filename += "/pics/kdepim/korganizer/koalarm.wav"; 674 filename += "/pics/kdepim/korganizer/koalarm.wav";
675 startAlarm("Alarm simulation", filename ); 675 startAlarm("Alarm simulation", filename );
676} 676}
677void SimpleAlarmDaemonImpl::showKO() 677void SimpleAlarmDaemonImpl::showKO()
678{ 678{
679 QCopEnvelope e("QPE/Application/kopi", "-showKO"); 679 QCopEnvelope e("QPE/Application/kopi", "-showKO");
680 // testing only 680 // testing only
681 //QCopEnvelope e("QPE/Application/kopi", "nextView()"); 681 //QCopEnvelope e("QPE/Application/kopi", "nextView()");
682 682
683} 683}
684void SimpleAlarmDaemonImpl::showTodo() 684void SimpleAlarmDaemonImpl::showTodo()
685{ 685{
686 QCopEnvelope e("QPE/Application/kopi", "-showTodo"); 686 QCopEnvelope e("QPE/Application/kopi", "-showTodo");
687 687
688} 688}
689void SimpleAlarmDaemonImpl::writeJournal() 689void SimpleAlarmDaemonImpl::writeJournal()
690{ 690{
691 QCopEnvelope e("QPE/Application/kopi", "-showJournal"); 691 QCopEnvelope e("QPE/Application/kopi", "-showJournal");
692 692
693} 693}
694 694
695void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) 695void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * )
696{ 696{
697 697
698 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); 698 mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() )));
699 699
700} 700}
701 701