summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp23
-rw-r--r--kalarmd/simplealarmdaemonimpl.h1
2 files changed, 23 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 8ea8a73..04b8b21 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -135,39 +135,48 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
135 mCustomMinutes = 7; 135 mCustomMinutes = 7;
136 mTimerPopupConf = 1; 136 mTimerPopupConf = 1;
137 fillTimerPopUp(); 137 fillTimerPopUp();
138 mPausePlay = 0; 138 mPausePlay = 0;
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 );
152 mTimerStartLabel->setCaption( "Timer started!");
153 fon = mTimerPopUp->font();
154 fon.setBold( true );
155 points = (fon.pointSize()*2);
156 fon.setPointSize( points );
157 mTimerStartLabel->setFont( fon );
151} 158}
152 159
153SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() 160SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
154{ 161{
155 //delete mPopUp; 162 //delete mPopUp;
156 delete mAlarmDialog; 163 delete mAlarmDialog;
164 delete mTimerStartLabel;
157} 165}
166
158void SimpleAlarmDaemonImpl::saveSlot( int load ) 167void SimpleAlarmDaemonImpl::saveSlot( int load )
159{ 168{
160 QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; 169 QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
161 //qDebug("save %d ", load ); 170 //qDebug("save %d ", load );
162 QFile file( fileName ); 171 QFile file( fileName );
163 if ( load ) { 172 if ( load ) {
164 if( !QFile::exists( fileName) ) 173 if( !QFile::exists( fileName) )
165 return; 174 return;
166 if (!file.open( IO_ReadOnly ) ) { 175 if (!file.open( IO_ReadOnly ) ) {
167 return ; 176 return ;
168 } 177 }
169 QString line; 178 QString line;
170 bool ok; 179 bool ok;
171 int val; 180 int val;
172 int len; 181 int len;
173 while ( file.readLine( line, 1024 ) > 0 ) { 182 while ( file.readLine( line, 1024 ) > 0 ) {
@@ -389,34 +398,34 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
389 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); 398 mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
390 mTimerPopUp->insertItem( t.toString() + " (countdown)",1); 399 mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
391 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); 400 mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
392 } else { 401 } else {
393 402
394 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; 403 QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
395 QFile file( fileName ); 404 QFile file( fileName );
396 if( !QFile::exists( fileName) ) { 405 if( !QFile::exists( fileName) ) {
397 // write defaults 406 // write defaults
398 if (!file.open( IO_WriteOnly ) ) { 407 if (!file.open( IO_WriteOnly ) ) {
399 return; 408 return;
400 } 409 }
401 QString configString ; 410 QString configString ;
402 configString += "#config file for kopi alarm timer\n"; 411 configString += "#config file for kopi alarm timer\n";
403 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; 412 configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
404 configString += "24 hours; 1440\n"; 413 configString += "24 hours; 1440\n";
414 configString += "9 hours; 540\n";
405 configString += "8 hours; 480\n"; 415 configString += "8 hours; 480\n";
406 configString += "5 hours; 300\n";
407 configString += "1 hour; 60\n"; 416 configString += "1 hour; 60\n";
408 configString += "30 min; 30\n"; 417 configString += "30 min; 30\n";
409 configString += "15 min; 15\n"; 418 configString += "15 min; 15\n";
410 configString += "SEPARATOR\n"; 419 configString += "SEPARATOR\n";
411 configString += "Pizza; 22\n"; 420 configString += "Pizza; 22\n";
412 configString += "Nap; 45\n"; 421 configString += "Nap; 45\n";
413 configString += "Tea; 5\n"; 422 configString += "Tea; 5\n";
414 QTextStream ts( &file ); 423 QTextStream ts( &file );
415 ts << configString ; 424 ts << configString ;
416 file.close(); 425 file.close();
417 } 426 }
418 427
419 if (!file.open( IO_ReadOnly ) ) { 428 if (!file.open( IO_ReadOnly ) ) {
420 return ; 429 return ;
421 } 430 }
422 QString line; 431 QString line;
@@ -500,39 +509,41 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
500 lay.setSpacing(5); 509 lay.setSpacing(5);
501 dia.resize(dia.sizeHint() ); 510 dia.resize(dia.sizeHint() );
502 511
503 if ( !dia.exec() ) 512 if ( !dia.exec() )
504 return; 513 return;
505 514
506 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() ); 515 AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
507 mTimerTime = 0; 516 mTimerTime = 0;
508 return; 517 return;
509 } 518 }
510 if ( mTimerTime ) 519 if ( mTimerTime )
511 return; 520 return;
512 if ( minutes == 1 ) { 521 if ( minutes == 1 ) {
513 return; 522 return;
514 } 523 }
515 QString mess = "timer_alarm"; 524 QString mess = "timer_alarm";
525 QString disp;
516 mess += ("Timer Alarm!\n"); 526 mess += ("Timer Alarm!\n");
517 if ( minutes == 3 ) { 527 if ( minutes == 3 ) {
518 mess += mCustomText; 528 mess += mCustomText;
519 minutes = mCustomMinutes ; 529 minutes = mCustomMinutes ;
520 mRunningTimerText = mCustomText.stripWhiteSpace (); 530 mRunningTimerText = mCustomText.stripWhiteSpace ();
521 int in = mRunningTimerText.find( " " ); 531 int in = mRunningTimerText.find( " " );
522 mRunningTimerText = mRunningTimerText.left ( in ); 532 mRunningTimerText = mRunningTimerText.left ( in );
533 disp = mCustomText;
523 } 534 }
524 else { 535 else {
525 if ( minutes == 2 ) { 536 if ( minutes == 2 ) {
526 // ask time 537 // ask time
527 QDialog dia ( 0, ("Customize Timer" ), true ); 538 QDialog dia ( 0, ("Customize Timer" ), true );
528 QLabel lab (("Message Text:"), &dia ); 539 QLabel lab (("Message Text:"), &dia );
529 dia.setCaption(("KO/Pi Timer" )); 540 dia.setCaption(("KO/Pi Timer" ));
530 QVBoxLayout lay( &dia ); 541 QVBoxLayout lay( &dia );
531 lay.setMargin(5); 542 lay.setMargin(5);
532 lay.setSpacing(5); 543 lay.setSpacing(5);
533 lay.addWidget( &lab); 544 lay.addWidget( &lab);
534 QLineEdit lEdit( mCustomText, &dia ); 545 QLineEdit lEdit( mCustomText, &dia );
535 lay.addWidget( &lEdit); 546 lay.addWidget( &lEdit);
536 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); 547 QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
537 lay.addWidget( &lab2); 548 lay.addWidget( &lab2);
538 QHBox hbox1 ( &dia ); 549 QHBox hbox1 ( &dia );
@@ -577,48 +588,58 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
577 ok.setDefault( true ); 588 ok.setDefault( true );
578 ok.setFont( fo ); 589 ok.setFont( fo );
579 spinh.setFocus(); 590 spinh.setFocus();
580 lay.addWidget( &ok); 591 lay.addWidget( &ok);
581 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); 592 connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
582 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); 593 dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
583 594
584 if ( !dia.exec() ) 595 if ( !dia.exec() )
585 return; 596 return;
586 mCustomText = lEdit.text(); 597 mCustomText = lEdit.text();
587 mCustomMinutes = spinh.value()*60+spinm.value(); 598 mCustomMinutes = spinh.value()*60+spinm.value();
588 if ( mCustomMinutes == 0 ) 599 if ( mCustomMinutes == 0 )
589 mCustomMinutes = 1; 600 mCustomMinutes = 1;
590 if ( mCustomMinutes > 1440 ) 601 if ( mCustomMinutes > 1440 )
591 mCustomMinutes = 1440; 602 mCustomMinutes = 1440;
592 mess += mCustomText; 603 mess += mCustomText;
604 disp = mCustomText;
593 minutes = mCustomMinutes; 605 minutes = mCustomMinutes;
594 mRunningTimerText = mCustomText.stripWhiteSpace (); 606 mRunningTimerText = mCustomText.stripWhiteSpace ();
595 int in = mRunningTimerText.find( " " ); 607 int in = mRunningTimerText.find( " " );
596 mRunningTimerText = mRunningTimerText.left ( in ); 608 mRunningTimerText = mRunningTimerText.left ( in );
597 } 609 }
598 else { 610 else {
599 mess += mTimerPopUp->text( minutes ); 611 mess += mTimerPopUp->text( minutes );
612 disp = mTimerPopUp->text( minutes );
600 mRunningTimerText = mTimerPopUp->text( minutes ); 613 mRunningTimerText = mTimerPopUp->text( minutes );
601 minutes -= 10; 614 minutes -= 10;
602 } 615 }
603 } 616 }
604 //minutes = 1; 617 //minutes = 1;
605 618
606 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 619 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
607 timerMesssage = mess; 620 timerMesssage = mess;
608 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8()); 621 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
622 mTimerStartLabel->setText( disp );
623 int w = 200;
624 int h = mTimerStartLabel->sizeHint().height() ;
625 int dw = QApplication::desktop()->width();
626 int dh = QApplication::desktop()->height();
627 mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
628 mTimerStartLabel->show();
629 QTimer::singleShot( 3000, mTimerStartLabel, SLOT ( hide() ) );
609 mTimerTime = 1; 630 mTimerTime = 1;
610} 631}
611 632
612void SimpleAlarmDaemonImpl::writeFile() 633void SimpleAlarmDaemonImpl::writeFile()
613{ 634{
614 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 635 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
615 //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 636 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
616} 637}
617void SimpleAlarmDaemonImpl::showWN() 638void SimpleAlarmDaemonImpl::showWN()
618{ 639{
619 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 640 QCopEnvelope e("QPE/Application/kopi", "-showWN");
620} 641}
621void SimpleAlarmDaemonImpl::newTodo() 642void SimpleAlarmDaemonImpl::newTodo()
622{ 643{
623 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 644 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
624} 645}
diff --git a/kalarmd/simplealarmdaemonimpl.h b/kalarmd/simplealarmdaemonimpl.h
index cbdba47..9b7de94 100644
--- a/kalarmd/simplealarmdaemonimpl.h
+++ b/kalarmd/simplealarmdaemonimpl.h
@@ -55,32 +55,33 @@ class SimpleAlarmDaemonImpl : public QLabel
55 void writeFile(); 55 void writeFile();
56 void writeJournal(); 56 void writeJournal();
57 void slotPlayBeep( int ); 57 void slotPlayBeep( int );
58 void showTimer( ); 58 void showTimer( );
59 void confPause( int ); 59 void confPause( int );
60 void confTimer( int ); 60 void confTimer( int );
61 void saveSlot( int ); 61 void saveSlot( int );
62 void confSuspend( int ); 62 void confSuspend( int );
63 void confSound( int num ); 63 void confSound( int num );
64 void startAlarm(QString mess, QString fn ); 64 void startAlarm(QString mess, QString fn );
65 65
66 protected: 66 protected:
67 void mousePressEvent( QMouseEvent * ); 67 void mousePressEvent( QMouseEvent * );
68 68
69 private: 69 private:
70 AlarmDialog *mAlarmDialog; 70 AlarmDialog *mAlarmDialog;
71 QLabel * mTimerStartLabel;
71 int mPlayBeeps; 72 int mPlayBeeps;
72 int mPausePlay; 73 int mPausePlay;
73 int mSuspend; 74 int mSuspend;
74 QString mAlarmMessage; 75 QString mAlarmMessage;
75 int mTimerTime; 76 int mTimerTime;
76 int getFileNameLen( QString ); 77 int getFileNameLen( QString );
77 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp; 78 QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp;
78 QDateTime mRunningTimer; 79 QDateTime mRunningTimer;
79 void fillTimerPopUp(); 80 void fillTimerPopUp();
80 QString timerMesssage; 81 QString timerMesssage;
81 QString mCustomText; 82 QString mCustomText;
82 QString mRunningTimerText; 83 QString mRunningTimerText;
83 int mCustomMinutes; 84 int mCustomMinutes;
84 int mTimerPopupConf; 85 int mTimerPopupConf;
85 bool wavAlarm; 86 bool wavAlarm;
86}; 87};