summaryrefslogtreecommitdiffabout
path: root/kalarmd/alarmdialog.cpp
Unidiff
Diffstat (limited to 'kalarmd/alarmdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index ddb125a..18ce9da 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -206,118 +206,122 @@ void AlarmDialog::slotSuspend()
206 mess +=mMessage->text(); 206 mess +=mMessage->text();
207#ifndef DESKTOP_VERSION 207#ifndef DESKTOP_VERSION
208 if ( mServerNotification ) 208 if ( mServerNotification )
209 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); 209 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1());
210#endif 210#endif
211 emit addAlarm( nextA , mess ); 211 emit addAlarm( nextA , mess );
212 slotOk(); 212 slotOk();
213} 213}
214 214
215void AlarmDialog::setServerNotification( bool b ) 215void AlarmDialog::setServerNotification( bool b )
216{ 216{
217 mServerNotification = b; 217 mServerNotification = b;
218} 218}
219int AlarmDialog::getSuspendTime( ) 219int AlarmDialog::getSuspendTime( )
220{ 220{
221 return mSuspendSpin->value(); 221 return mSuspendSpin->value();
222 222
223} 223}
224void AlarmDialog::setSuspendTime( int val ) 224void AlarmDialog::setSuspendTime( int val )
225{ 225{
226 mSuspendSpin->setValue( val ); 226 mSuspendSpin->setValue( val );
227} 227}
228bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) 228bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes)
229{ 229{
230 if ( mess.left( 9) != "Suspended" ) 230 if ( mess.left( 9) != "Suspended" )
231 mSuspendCounter = suspendtimes; 231 mSuspendCounter = suspendtimes;
232 mPauseCount = pause; 232 mPauseCount = pause;
233 mFileName = fn; 233 mFileName = fn;
234 mPlayWav = playwav; 234 mPlayWav = playwav;
235 if ( !QFile::exists( fn ) ) 235 if ( !QFile::exists( fn ) )
236 mFileName = ""; 236 mFileName = "";
237 alarmCounter = 0 ; 237 alarmCounter = 0 ;
238 maxAlarmReplay = replay ; 238 maxAlarmReplay = replay ;
239 mStopAlarm = false; 239 mStopAlarm = false;
240 mSilent = false; 240 mSilent = false;
241 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { 241 if ( !mMessage->text().stripWhiteSpace().isEmpty() ) {
242 mMissedAlarmsCombo->show(); 242 mMissedAlarmsCombo->show();
243 QString newItem = mMessage->text().stripWhiteSpace(); 243 QString newItem = mMessage->text().stripWhiteSpace();
244 newItem.replace( QRegExp("\n"), QString(" ") ); 244 newItem.replace( QRegExp("\n"), QString(" ") );
245 mMissedAlarmsCombo->insertItem( newItem ); 245 mMissedAlarmsCombo->insertItem( newItem );
246 mMissedAlarms->setText( "Missed alarms:"); 246 mMissedAlarms->setText( "Missed alarms:");
247 } else 247 } else
248 mMissedAlarmsCombo->hide(); 248 mMissedAlarmsCombo->hide();
249 mMessage->setText(mess); 249 mMessage->setText(mess);
250 int w = minimumSizeHint().width() ; 250 int w = minimumSizeHint().width() ;
251 int h = minimumSizeHint().height() ; 251 int h = minimumSizeHint().height() ;
252 int dw = QApplication::desktop()->width(); 252 int dw = QApplication::desktop()->width();
253 int dh = QApplication::desktop()->height(); 253 int dh = QApplication::desktop()->height();
254 if ( w < 220 ) w = 220;
255 if ( h < 220 ) h = 220;
254 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 256 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
255 hide(); 257 showNormal();
258 setActiveWindow();
259 raise();
260 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
261 //hide();
256 262
257#ifndef _WIN32_ 263#ifndef _WIN32_
258 if ( fd_led > 0 ) { 264 if ( fd_led > 0 ) {
259 statusLED.status = LED_SALARM_ON ; 265 statusLED.status = LED_SALARM_ON ;
260 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 266 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
261 } 267 }
262#endif 268#endif
263 okbut->setDefault( true ); 269 okbut->setDefault( true );
264 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); 270 QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) );
265 // playSoundTimer->start( 1000, true ); 271 // playSoundTimer->start( 1000, true );
266 return true; 272 return true;
267 273
268} 274}
269 275
270void AlarmDialog::forceRepaint() 276void AlarmDialog::forceRepaint()
271{ 277{
272
273 showNormal();
274 setActiveWindow(); 278 setActiveWindow();
275 raise(); 279 repaint();
276 mSuspendSpin->setFocus(); 280 mSuspendSpin->setFocus();
277 playSoundTimer->start( 1000, true ); 281 playSoundTimer->start( 1000, true );
278 282
279} 283}
280void AlarmDialog::spinBoxChanged( int v ) 284void AlarmDialog::spinBoxChanged( int v )
281{ 285{
282 okbut->setDefault( false ); 286 okbut->setDefault( false );
283 mSilent = true; 287 mSilent = true;
284} 288}
285 289
286void AlarmDialog::playSound () 290void AlarmDialog::playSound ()
287{ 291{
288 292
289 if (mStopAlarm ) 293 if (mStopAlarm )
290 return; 294 return;
291 if ( mSilent ) 295 if ( mSilent )
292 return; 296 return;
293 //showNormal(); 297 //showNormal();
294 setActiveWindow(); 298 setActiveWindow();
295 //raise(); 299 //raise();
296 mSuspendSpin->setFocus(); 300 mSuspendSpin->setFocus();
297 if ( alarmCounter < maxAlarmReplay && ! mSilent) { 301 if ( alarmCounter < maxAlarmReplay && ! mSilent) {
298 ++alarmCounter; 302 ++alarmCounter;
299#ifdef DESKTOP_VERSION 303#ifdef DESKTOP_VERSION
300 mPlayWav = true; 304 mPlayWav = true;
301#endif 305#endif
302 if ( !mPlayWav || mFileName.length() < 2 ) { 306 if ( !mPlayWav || mFileName.length() < 2 ) {
303 307
304#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
305 qDebug("Sound play not possible - file not found"); 309 qDebug("Sound play not possible - file not found");
306#else 310#else
307 Sound::soundAlarm (); 311 Sound::soundAlarm ();
308#endif 312#endif
309 } else 313 } else
310 314
311 { 315 {
312#ifdef DESKTOP_VERSION 316#ifdef DESKTOP_VERSION
313#ifdef _WIN32_ 317#ifdef _WIN32_
314 QSound::play ( mFileName ); 318 QSound::play ( mFileName );
315#else 319#else
316 320
317 QString command = "playwave -r 22050 " + mFileName; 321 QString command = "playwave -r 22050 " + mFileName;
318 qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); 322 qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() );
319 int ret = system ( command.latin1() ); 323 int ret = system ( command.latin1() );
320 if ( ret != 0 ) { 324 if ( ret != 0 ) {
321 qDebug("Sound play command failed: %s ",command.latin1() ); 325 qDebug("Sound play command failed: %s ",command.latin1() );
322 } 326 }
323 327