author | zautrix <zautrix> | 2005-09-18 23:40:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-18 23:40:38 (UTC) |
commit | 2d346e4052fd726e657daee4ac3f2bcc7103f5fb (patch) (unidiff) | |
tree | 9952b888e0790bc032ba4e0c3c4165ec283a4139 /kalarmd/alarmdialog.cpp | |
parent | 06ebec95579816144ee65981835e6e3482e20a28 (diff) | |
download | kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.zip kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.gz kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.bz2 |
wn
-rw-r--r-- | kalarmd/alarmdialog.cpp | 12 |
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 | |||
@@ -190,150 +190,154 @@ void AlarmDialog::slotOk() | |||
190 | if ( fd_led > 0 ) { | 190 | if ( fd_led > 0 ) { |
191 | statusLED.status = LED_SALARM_OFF ; | 191 | statusLED.status = LED_SALARM_OFF ; |
192 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 192 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
193 | } | 193 | } |
194 | #endif | 194 | #endif |
195 | QDialog::accept(); | 195 | QDialog::accept(); |
196 | } | 196 | } |
197 | 197 | ||
198 | void AlarmDialog::slotSuspend() | 198 | void AlarmDialog::slotSuspend() |
199 | { | 199 | { |
200 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); | 200 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); |
201 | mStopAlarm = true; | 201 | mStopAlarm = true; |
202 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); | 202 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); |
203 | QString mess = "suspend_alarm" +mFileName+"+++" ; | 203 | QString mess = "suspend_alarm" +mFileName+"+++" ; |
204 | if ( mMessage->text().left( 10 ) !="Suspended:" ) | 204 | if ( mMessage->text().left( 10 ) !="Suspended:" ) |
205 | mess += "Suspended:\n"; | 205 | mess += "Suspended:\n"; |
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 | ||
215 | void AlarmDialog::setServerNotification( bool b ) | 215 | void AlarmDialog::setServerNotification( bool b ) |
216 | { | 216 | { |
217 | mServerNotification = b; | 217 | mServerNotification = b; |
218 | } | 218 | } |
219 | int AlarmDialog::getSuspendTime( ) | 219 | int AlarmDialog::getSuspendTime( ) |
220 | { | 220 | { |
221 | return mSuspendSpin->value(); | 221 | return mSuspendSpin->value(); |
222 | 222 | ||
223 | } | 223 | } |
224 | void AlarmDialog::setSuspendTime( int val ) | 224 | void AlarmDialog::setSuspendTime( int val ) |
225 | { | 225 | { |
226 | mSuspendSpin->setValue( val ); | 226 | mSuspendSpin->setValue( val ); |
227 | } | 227 | } |
228 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) | 228 | bool 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 | ||
270 | void AlarmDialog::forceRepaint() | 276 | void 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 | } |
280 | void AlarmDialog::spinBoxChanged( int v ) | 284 | void AlarmDialog::spinBoxChanged( int v ) |
281 | { | 285 | { |
282 | okbut->setDefault( false ); | 286 | okbut->setDefault( false ); |
283 | mSilent = true; | 287 | mSilent = true; |
284 | } | 288 | } |
285 | 289 | ||
286 | void AlarmDialog::playSound () | 290 | void 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 | ||
324 | #endif | 328 | #endif |
325 | 329 | ||
326 | #else | 330 | #else |
327 | QSound::play ( mFileName ); | 331 | QSound::play ( mFileName ); |
328 | #endif | 332 | #endif |
329 | qDebug("BEEP!"); | 333 | qDebug("BEEP!"); |
330 | } | 334 | } |
331 | } else { | 335 | } else { |
332 | if ( ! mSilent && mSuspendCounter > 0 ) { | 336 | if ( ! mSilent && mSuspendCounter > 0 ) { |
333 | --mSuspendCounter; | 337 | --mSuspendCounter; |
334 | reject (); | 338 | reject (); |
335 | hide(); | 339 | hide(); |
336 | return; | 340 | return; |
337 | } | 341 | } |
338 | } | 342 | } |
339 | playSoundTimer->start( mPauseCount * 1000, true ); | 343 | playSoundTimer->start( mPauseCount * 1000, true ); |