summaryrefslogtreecommitdiffabout
path: root/kalarmd/alarmdialog.cpp
Unidiff
Diffstat (limited to 'kalarmd/alarmdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index d72a8c2..1cda534 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -143,192 +143,193 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
143 if ( QFile::exists ( "/dev/sharp_led" ) ) 143 if ( QFile::exists ( "/dev/sharp_led" ) )
144 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 144 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
145 else 145 else
146#endif 146#endif
147 fd_led = 0; 147 fd_led = 0;
148 statusLED.which = SHARP_LED_SALARM; 148 statusLED.which = SHARP_LED_SALARM;
149 mSilent = false; 149 mSilent = false;
150 mSuspendCounter = 0; 150 mSuspendCounter = 0;
151 setServerNotification( true ); 151 setServerNotification( true );
152} 152}
153void AlarmDialog::reject () 153void AlarmDialog::reject ()
154{ 154{
155 QTimer::singleShot ( 3000, this, SLOT (suspend()) ); 155 QTimer::singleShot ( 3000, this, SLOT (suspend()) );
156 slotSuspend(); 156 slotSuspend();
157} 157}
158AlarmDialog::~AlarmDialog() 158AlarmDialog::~AlarmDialog()
159{ 159{
160} 160}
161void AlarmDialog::silent () 161void AlarmDialog::silent ()
162{ 162{
163 mSilent = true; 163 mSilent = true;
164} 164}
165void AlarmDialog::accept() 165void AlarmDialog::accept()
166{ 166{
167 slotOk(); 167 slotOk();
168} 168}
169 169
170void AlarmDialog::suspend() 170void AlarmDialog::suspend()
171{ 171{
172#ifdef DESKTOP_VERSION 172#ifdef DESKTOP_VERSION
173 173
174#else 174#else
175 Sound::soundAlarm (); 175 Sound::soundAlarm ();
176#endif 176#endif
177} 177}
178void AlarmDialog::slotOk() 178void AlarmDialog::slotOk()
179{ 179{
180 mStopAlarm = true; 180 mStopAlarm = true;
181 mMissedAlarms->setText("(No missed Alarms)"); 181 mMissedAlarms->setText("(No missed Alarms)");
182 mMessage->setText(""); 182 mMessage->setText("");
183 mMissedAlarmsCombo->clear(); 183 mMissedAlarmsCombo->clear();
184#ifndef _WIN32_ 184#ifndef _WIN32_
185 if ( fd_led > 0 ) { 185 if ( fd_led > 0 ) {
186 statusLED.status = LED_SALARM_OFF ; 186 statusLED.status = LED_SALARM_OFF ;
187 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 187 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
188 } 188 }
189#endif 189#endif
190 QDialog::accept(); 190 QDialog::accept();
191} 191}
192 192
193void AlarmDialog::slotSuspend() 193void AlarmDialog::slotSuspend()
194{ 194{
195 //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); 195 //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value());
196 mStopAlarm = true; 196 mStopAlarm = true;
197 QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); 197 QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 );
198 QString mess = "suspend_alarm" +mFileName+"+++" ; 198 QString mess = "suspend_alarm" +mFileName+"+++" ;
199 if ( mMessage->text().left( 10 ) !="Suspended:" ) 199 if ( mMessage->text().left( 10 ) !="Suspended:" )
200 mess += "Suspended:\n"; 200 mess += "Suspended:\n";
201 mess +=mMessage->text(); 201 mess +=mMessage->text();
202#ifndef DESKTOP_VERSION 202#ifndef DESKTOP_VERSION
203 if ( mServerNotification ) 203 if ( mServerNotification )
204 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); 204 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1());
205#endif 205#endif
206 emit addAlarm( nextA , mess ); 206 emit addAlarm( nextA , mess );
207 slotOk(); 207 slotOk();
208} 208}
209 209
210void AlarmDialog::setServerNotification( bool b ) 210void AlarmDialog::setServerNotification( bool b )
211{ 211{
212 mServerNotification = b; 212 mServerNotification = b;
213} 213}
214int AlarmDialog::getSuspendTime( ) 214int AlarmDialog::getSuspendTime( )
215{ 215{
216 return mSuspendSpin->value(); 216 return mSuspendSpin->value();
217 217
218} 218}
219void AlarmDialog::setSuspendTime( int val ) 219void AlarmDialog::setSuspendTime( int val )
220{ 220{
221 mSuspendSpin->setValue( val ); 221 mSuspendSpin->setValue( val );
222} 222}
223bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) 223bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes)
224{ 224{
225 if ( mess.left( 9) != "Suspended" ) 225 if ( mess.left( 9) != "Suspended" )
226 mSuspendCounter = suspendtimes; 226 mSuspendCounter = suspendtimes;
227 mPauseCount = pause; 227 mPauseCount = pause;
228 mFileName = fn; 228 mFileName = fn;
229 mPlayWav = playwav; 229 mPlayWav = playwav;
230 if ( !QFile::exists( fn ) ) 230 if ( !QFile::exists( fn ) )
231 mFileName = ""; 231 mFileName = "";
232 alarmCounter = 0 ; 232 alarmCounter = 0 ;
233 maxAlarmReplay = replay ; 233 maxAlarmReplay = replay ;
234 mStopAlarm = false; 234 mStopAlarm = false;
235 mSilent = false; 235 mSilent = false;
236 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { 236 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) {
237 mMissedAlarmsCombo->show(); 237 mMissedAlarmsCombo->show();
238 QString newItem = mMessage->text().stripWhiteSpace(); 238 QString newItem = mMessage->text().stripWhiteSpace();
239 newItem.replace( QRegExp("\n"), QString(" ") ); 239 newItem.replace( QRegExp("\n"), QString(" ") );
240 mMissedAlarmsCombo->insertItem( newItem ); 240 mMissedAlarmsCombo->insertItem( newItem );
241 mMissedAlarms->setText( "Missed alarms:"); 241 mMissedAlarms->setText( "Missed alarms:");
242 } else 242 } else
243 mMissedAlarmsCombo->hide(); 243 mMissedAlarmsCombo->hide();
244 mMessage->setText(mess); 244 mMessage->setText(mess);
245 int w = minimumSizeHint().width() ; 245 int w = minimumSizeHint().width() ;
246 int h = minimumSizeHint().height() ; 246 int h = minimumSizeHint().height() ;
247 int dw = QApplication::desktop()->width(); 247 int dw = QApplication::desktop()->width();
248 int dh = QApplication::desktop()->height(); 248 int dh = QApplication::desktop()->height();
249 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 249 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
250 hide(); 250 hide();
251 251
252#ifndef _WIN32_ 252#ifndef _WIN32_
253 if ( fd_led > 0 ) { 253 if ( fd_led > 0 ) {
254 statusLED.status = LED_SALARM_ON ; 254 statusLED.status = LED_SALARM_ON ;
255 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 255 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
256 } 256 }
257#endif 257#endif
258 okbut->setDefault( true ); 258 okbut->setDefault( true );
259 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); 259 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) );
260 // playSoundTimer->start( 1000, true ); 260 // playSoundTimer->start( 1000, true );
261 return true; 261 return true;
262 262
263} 263}
264 264
265void AlarmDialog::forceRepaint() 265void AlarmDialog::forceRepaint()
266{ 266{
267 267
268 showNormal(); 268 showNormal();
269 setActiveWindow(); 269 setActiveWindow();
270 raise(); 270 raise();
271 mSuspendSpin->setFocus();
271 playSoundTimer->start( 1000, true ); 272 playSoundTimer->start( 1000, true );
272 273
273} 274}
274void AlarmDialog::spinBoxChanged( int v ) 275void AlarmDialog::spinBoxChanged( int v )
275{ 276{
276 okbut->setDefault( false ); 277 okbut->setDefault( false );
277 mSilent = true; 278 mSilent = true;
278} 279}
279 280
280void AlarmDialog::playSound () 281void AlarmDialog::playSound ()
281{ 282{
282 283
283 if (mStopAlarm ) 284 if (mStopAlarm )
284 return; 285 return;
285 if ( mSilent ) 286 if ( mSilent )
286 return; 287 return;
287 showNormal(); 288 //showNormal();
288 setActiveWindow(); 289 setActiveWindow();
289 raise(); 290 //raise();
290 mSuspendSpin->setFocus(); 291 mSuspendSpin->setFocus();
291 if ( alarmCounter < maxAlarmReplay && ! mSilent) { 292 if ( alarmCounter < maxAlarmReplay && ! mSilent) {
292 ++alarmCounter; 293 ++alarmCounter;
293#ifdef DESKTOP_VERSION 294#ifdef DESKTOP_VERSION
294 mPlayWav = true; 295 mPlayWav = true;
295#endif 296#endif
296 if ( !mPlayWav || mFileName.length() < 2 ) { 297 if ( !mPlayWav || mFileName.length() < 2 ) {
297 298
298#ifdef DESKTOP_VERSION 299#ifdef DESKTOP_VERSION
299 qDebug("Sound play not possible - file not found"); 300 qDebug("Sound play not possible - file not found");
300#else 301#else
301 Sound::soundAlarm (); 302 Sound::soundAlarm ();
302#endif 303#endif
303 } else 304 } else
304 305
305 { 306 {
306#ifdef DESKTOP_VERSION 307#ifdef DESKTOP_VERSION
307#ifdef _WIN32_ 308#ifdef _WIN32_
308 QSound::play ( mFileName ); 309 QSound::play ( mFileName );
309#else 310#else
310 311
311 QString command = "playwave -r 22050 " + mFileName; 312 QString command = "playwave -r 22050 " + mFileName;
312 qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); 313 qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() );
313 int ret = system ( command.latin1() ); 314 int ret = system ( command.latin1() );
314 if ( ret != 0 ) { 315 if ( ret != 0 ) {
315 qDebug("Sound play command failed: %s ",command.latin1() ); 316 qDebug("Sound play command failed: %s ",command.latin1() );
316 } 317 }
317 318
318#endif 319#endif
319 320
320#else 321#else
321 QSound::play ( mFileName ); 322 QSound::play ( mFileName );
322#endif 323#endif
323 qDebug("BEEP!"); 324 qDebug("BEEP!");
324 } 325 }
325 } else { 326 } else {
326 if ( ! mSilent && mSuspendCounter > 0 ) { 327 if ( ! mSilent && mSuspendCounter > 0 ) {
327 --mSuspendCounter; 328 --mSuspendCounter;
328 reject (); 329 reject ();
329 hide(); 330 hide();
330 return; 331 return;
331 } 332 }
332 } 333 }
333 playSoundTimer->start( mPauseCount * 1000, true ); 334 playSoundTimer->start( mPauseCount * 1000, true );
334} 335}