summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-08 23:40:38 (UTC)
committer zautrix <zautrix>2005-04-08 23:40:38 (UTC)
commita74c23d91e80343cd1ccfd1fe712958fad1d5891 (patch) (unidiff)
tree2dc90dffe822e1425ace17cdbf9e420fa0be6ac7
parentc4bab697d650c249cdff45b753b9e6df2a817877 (diff)
downloadkdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.zip
kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.tar.gz
kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.tar.bz2
ad fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp36
-rw-r--r--kalarmd/alarmdialog.h2
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp9
3 files changed, 29 insertions, 18 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index 65073f6..d72a8c2 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -88,57 +88,58 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
88 mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); 88 mMissedAlarms= new QLabel ( "(No missed Alarms)", this );
89 mMissedAlarms->setAlignment( AlignCenter); 89 mMissedAlarms->setAlignment( AlignCenter);
90 90
91 playSoundTimer = new QTimer( this ); 91 playSoundTimer = new QTimer( this );
92 connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); 92 connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) );
93 93
94 playSoundTimer->stop(); 94 playSoundTimer->stop();
95 95
96 layout->addWidget ( mMissedAlarms ); 96 layout->addWidget ( mMissedAlarms );
97 mMissedAlarmsCombo = new QComboBox ( this ); 97 mMissedAlarmsCombo = new QComboBox ( this );
98 layout->addWidget ( mMissedAlarmsCombo ); 98 layout->addWidget ( mMissedAlarmsCombo );
99 99
100 QLabel* labb = new QLabel("Suspend duration (minutes):",this); 100 QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this);
101 labb->setAlignment(AlignCenter); 101 labb->setAlignment(AlignCenter);
102 layout->addWidget ( labb ); 102 //layout->addWidget ( labb );
103 fo = font(); 103 fo = font();
104 int pointSize = 36; 104 int pointSize = 36;
105 if ( QApplication::desktop()->width() <= 320 ) 105 if ( QApplication::desktop()->width() <= 320 )
106 pointSize = 18; 106 pointSize = 18;
107 fo.setPointSize( pointSize ); 107 fo.setPointSize( pointSize );
108 mSuspendSpin = new QSpinBox(1,1440,1,this); 108 mSuspendSpin = new QSpinBox(1,1440,1,this);
109 mSuspendSpin->setFont( fo ); 109 mSuspendSpin->setFont( fo );
110 mSuspendSpin->setValue(7); // default suspend duration 110 mSuspendSpin->setValue(7); // default suspend duration
111 mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); 111 mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus );
112 mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); 112 mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus );
113 113
114#if QT_VERSION < 0x030000 114#if QT_VERSION < 0x030000
115 mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); 115 mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize ));
116 mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); 116 mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize ));
117#endif 117#endif
118 mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); 118 mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 );
119 mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); 119 mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus );
120 QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); 120 QHBoxLayout* layoutSpin = new QHBoxLayout( layout );
121 layoutSpin->addStretch (); 121 layoutSpin->addStretch ();
122 layoutSpin->addWidget ( labb );
122 layoutSpin->addWidget ( mSuspendSpin ); 123 layoutSpin->addWidget ( mSuspendSpin );
123 layoutSpin->addStretch (); 124 layoutSpin->addStretch ();
124 125
125 QVBox * bbox = new QVBox ( this ); 126 QVBox * bbox = new QVBox ( this );
126 layout->addWidget ( bbox ); 127 layout->addWidget ( bbox );
127 bbox->layout()->setSpacing( 2 ); 128 bbox->layout()->setSpacing( 2 );
128 labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); 129 labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox);
129 labb->setAlignment(AlignCenter); 130 labb->setAlignment(AlignCenter);
130 mSuspendButton = new QPushButton( "Suspend", bbox); 131 mSuspendButton = new QPushButton( "Suspend", bbox);
131 QPushButton* silen = new QPushButton( " Stop sound ", bbox); 132 QPushButton* silen = new QPushButton( " Stop sound ", bbox);
132 QPushButton* okbut = new QPushButton( "Ok", bbox); 133 okbut = new QPushButton( "Ok", bbox);
133 mSuspendButton->setFont( fo ); 134 mSuspendButton->setFont( fo );
134 silen->setFont( fo ); 135 silen->setFont( fo );
135 okbut->setFont( fo ); 136 okbut->setFont( fo );
136 okbut->setDefault( true ); 137 okbut->setDefault( true );
137 connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); 138 connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) );
138 connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); 139 connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) );
139 connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); 140 connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) );
140 connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); 141 connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) );
141#ifndef _WIN32_ 142#ifndef _WIN32_
142 if ( QFile::exists ( "/dev/sharp_led" ) ) 143 if ( QFile::exists ( "/dev/sharp_led" ) )
143 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 144 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
144 else 145 else
@@ -232,65 +233,70 @@ bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, boo
232 maxAlarmReplay = replay ; 233 maxAlarmReplay = replay ;
233 mStopAlarm = false; 234 mStopAlarm = false;
234 mSilent = false; 235 mSilent = false;
235 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { 236 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) {
236 mMissedAlarmsCombo->show(); 237 mMissedAlarmsCombo->show();
237 QString newItem = mMessage->text().stripWhiteSpace(); 238 QString newItem = mMessage->text().stripWhiteSpace();
238 newItem.replace( QRegExp("\n"), QString(" ") ); 239 newItem.replace( QRegExp("\n"), QString(" ") );
239 mMissedAlarmsCombo->insertItem( newItem ); 240 mMissedAlarmsCombo->insertItem( newItem );
240 mMissedAlarms->setText( "Missed alarms:"); 241 mMissedAlarms->setText( "Missed alarms:");
241 } else 242 } else
242 mMissedAlarmsCombo->hide(); 243 mMissedAlarmsCombo->hide();
243 mMessage->setText(mess); 244 mMessage->setText(mess);
244 int w =sizeHint().width() ; 245 int w = minimumSizeHint().width() ;
245 int h = sizeHint().height() ; 246 int h = minimumSizeHint().height() ;
246 int dw = QApplication::desktop()->width(); 247 int dw = QApplication::desktop()->width();
247 int dh = QApplication::desktop()->height(); 248 int dh = QApplication::desktop()->height();
248 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 249 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
249 show(); 250 hide();
250 raise();
251 //qApp->processEvents();
252 //repaint();
253 qApp->processEvents();
254 251
255#ifndef _WIN32_ 252#ifndef _WIN32_
256 if ( fd_led > 0 ) { 253 if ( fd_led > 0 ) {
257 statusLED.status = LED_SALARM_ON ; 254 statusLED.status = LED_SALARM_ON ;
258 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 255 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
259 } 256 }
260#endif 257#endif
261 playSoundTimer->start( 1000, true ); 258 okbut->setDefault( true );
259 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) );
260 // playSoundTimer->start( 1000, true );
262 return true; 261 return true;
263 262
264} 263}
265 264
266void AlarmDialog::spinBoxChanged( int ) 265void AlarmDialog::forceRepaint()
267{ 266{
267
268 showNormal();
269 setActiveWindow();
270 raise();
271 playSoundTimer->start( 1000, true );
272
273}
274void AlarmDialog::spinBoxChanged( int v )
275{
276 okbut->setDefault( false );
268 mSilent = true; 277 mSilent = true;
269} 278}
270 279
271void AlarmDialog::playSound () 280void AlarmDialog::playSound ()
272{ 281{
273 282
274 if (mStopAlarm ) 283 if (mStopAlarm )
275 return; 284 return;
276 if ( mSilent ) 285 if ( mSilent )
277 return; 286 return;
278 showNormal(); 287 showNormal();
279 setActiveWindow(); 288 setActiveWindow();
280 raise(); 289 raise();
281 mSuspendSpin->setFocus(); 290 mSuspendSpin->setFocus();
282
283
284 qApp->processEvents();
285 if ( alarmCounter < maxAlarmReplay && ! mSilent) { 291 if ( alarmCounter < maxAlarmReplay && ! mSilent) {
286 ++alarmCounter; 292 ++alarmCounter;
287#ifdef DESKTOP_VERSION 293#ifdef DESKTOP_VERSION
288 mPlayWav = true; 294 mPlayWav = true;
289#endif 295#endif
290 if ( !mPlayWav || mFileName.length() < 2 ) { 296 if ( !mPlayWav || mFileName.length() < 2 ) {
291 297
292#ifdef DESKTOP_VERSION 298#ifdef DESKTOP_VERSION
293 qDebug("Sound play not possible - file not found"); 299 qDebug("Sound play not possible - file not found");
294#else 300#else
295 Sound::soundAlarm (); 301 Sound::soundAlarm ();
296#endif 302#endif
diff --git a/kalarmd/alarmdialog.h b/kalarmd/alarmdialog.h
index 1e4636c..52e681a 100644
--- a/kalarmd/alarmdialog.h
+++ b/kalarmd/alarmdialog.h
@@ -41,37 +41,39 @@ class QString;
41class AlarmDialog : public QDialog { 41class AlarmDialog : public QDialog {
42 Q_OBJECT 42 Q_OBJECT
43 public: 43 public:
44 AlarmDialog( QWidget *parent = 0, const char *name = 0 ); 44 AlarmDialog( QWidget *parent = 0, const char *name = 0 );
45 virtual ~AlarmDialog(); 45 virtual ~AlarmDialog();
46 46
47 bool eventNotification(QString m, int replay , QString m2 , bool, int, int ); 47 bool eventNotification(QString m, int replay , QString m2 , bool, int, int );
48 int getSuspendTime( ); 48 int getSuspendTime( );
49 void setSuspendTime( int ); 49 void setSuspendTime( int );
50 void setServerNotification( bool b ); 50 void setServerNotification( bool b );
51 51
52 public slots: 52 public slots:
53 void forceRepaint();
53 void spinBoxChanged( int ); 54 void spinBoxChanged( int );
54 void slotOk(); 55 void slotOk();
55 void slotSuspend(); 56 void slotSuspend();
56 void reject () ; 57 void reject () ;
57 void silent () ; 58 void silent () ;
58 void accept(); 59 void accept();
59 void suspend(); 60 void suspend();
60 void playSound (); 61 void playSound ();
61 signals: 62 signals:
62 // void suspendSignal(int duration); 63 // void suspendSignal(int duration);
63 void addAlarm(const QDateTime &, const QString & ); 64 void addAlarm(const QDateTime &, const QString & );
64 65
65 private: 66 private:
67 QPushButton* okbut;
66 int alarmCounter; 68 int alarmCounter;
67 int mPauseCount; 69 int mPauseCount;
68 int mSuspendCounter; 70 int mSuspendCounter;
69 int maxAlarmReplay; 71 int maxAlarmReplay;
70 QTimer* playSoundTimer; 72 QTimer* playSoundTimer;
71 bool mStopAlarm; 73 bool mStopAlarm;
72 bool mSilent; 74 bool mSilent;
73 bool mPlayWav; 75 bool mPlayWav;
74 bool mServerNotification; 76 bool mServerNotification;
75 QLabel* mMessage; 77 QLabel* mMessage;
76 QLabel* mMissedAlarms; 78 QLabel* mMissedAlarms;
77 QSpinBox *mSuspendSpin; 79 QSpinBox *mSuspendSpin;
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 294ce7d..2a463b3 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -296,25 +296,27 @@ void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& )
296 int len = mess.mid( 10 ).find("+++"); 296 int len = mess.mid( 10 ).find("+++");
297 if ( len < 2 ) 297 if ( len < 2 )
298 error = true; 298 error = true;
299 else { 299 else {
300 tempfilename = mess.mid( 10, len ); 300 tempfilename = mess.mid( 10, len );
301 if ( !QFile::exists( tempfilename ) ) 301 if ( !QFile::exists( tempfilename ) )
302 error = true; 302 error = true;
303 } 303 }
304 if ( error ) { 304 if ( error ) {
305 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 305 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
306 mAlarmMessage += mess.mid( 10+len+3+9 ); 306 mAlarmMessage += mess.mid( 10+len+3+9 );
307 } else { 307 } else {
308 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 308 {
309 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
310 }
309 //qDebug("-----system command %s ",tempfilename.latin1() ); 311 //qDebug("-----system command %s ",tempfilename.latin1() );
310 if ( vfork () == 0 ) { 312 if ( vfork () == 0 ) {
311 execl ( tempfilename.latin1(), 0 ); 313 execl ( tempfilename.latin1(), 0 );
312 return; 314 return;
313 } 315 }
314 return; 316 return;
315 } 317 }
316 318
317 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 319 //qDebug("+++++++system command %s ",tempfilename.latin1() );
318 } 320 }
319 if ( mess.left( 11 ) == "audio_alarm") { 321 if ( mess.left( 11 ) == "audio_alarm") {
320 bool error = false; 322 bool error = false;
@@ -609,26 +611,27 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
609 mRunningTimerText = QString::number ( minutes ) + ( " minutes"); 611 mRunningTimerText = QString::number ( minutes ) + ( " minutes");
610 } 612 }
611 } 613 }
612 //minutes = 1; 614 //minutes = 1;
613 615
614 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); 616 mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
615 timerMesssage = mess; 617 timerMesssage = mess;
616 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); 618 AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1());
617 mTimerTime = 1; 619 mTimerTime = 1;
618} 620}
619 621
620void SimpleAlarmDaemonImpl::writeFile() 622void SimpleAlarmDaemonImpl::writeFile()
621{ 623{
622 QCopEnvelope e("QPE/Application/kopi", "-writeFile"); 624 QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
625 //QCopEnvelope e("QPE/Application/kopi", "-writeFile");
623} 626}
624void SimpleAlarmDaemonImpl::showWN() 627void SimpleAlarmDaemonImpl::showWN()
625{ 628{
626 QCopEnvelope e("QPE/Application/kopi", "-showWN"); 629 QCopEnvelope e("QPE/Application/kopi", "-showWN");
627} 630}
628void SimpleAlarmDaemonImpl::newTodo() 631void SimpleAlarmDaemonImpl::newTodo()
629{ 632{
630 QCopEnvelope e("QPE/Application/kopi", "-newTodo"); 633 QCopEnvelope e("QPE/Application/kopi", "-newTodo");
631} 634}
632 635
633void SimpleAlarmDaemonImpl::newEvent() 636void SimpleAlarmDaemonImpl::newEvent()
634{ 637{