summaryrefslogtreecommitdiffabout
path: root/kalarmd/alarmdialog.cpp
authorzautrix <zautrix>2005-09-18 23:40:38 (UTC)
committer zautrix <zautrix>2005-09-18 23:40:38 (UTC)
commit2d346e4052fd726e657daee4ac3f2bcc7103f5fb (patch) (unidiff)
tree9952b888e0790bc032ba4e0c3c4165ec283a4139 /kalarmd/alarmdialog.cpp
parent06ebec95579816144ee65981835e6e3482e20a28 (diff)
downloadkdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.zip
kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.gz
kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.bz2
wn
Diffstat (limited to 'kalarmd/alarmdialog.cpp') (more/less context) (ignore 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
@@ -158,183 +158,187 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
158void AlarmDialog::reject () 158void AlarmDialog::reject ()
159{ 159{
160 QTimer::singleShot ( 3000, this, SLOT (suspend()) ); 160 QTimer::singleShot ( 3000, this, SLOT (suspend()) );
161 slotSuspend(); 161 slotSuspend();
162} 162}
163AlarmDialog::~AlarmDialog() 163AlarmDialog::~AlarmDialog()
164{ 164{
165} 165}
166void AlarmDialog::silent () 166void AlarmDialog::silent ()
167{ 167{
168 mSilent = true; 168 mSilent = true;
169} 169}
170void AlarmDialog::accept() 170void AlarmDialog::accept()
171{ 171{
172 slotOk(); 172 slotOk();
173} 173}
174 174
175void AlarmDialog::suspend() 175void AlarmDialog::suspend()
176{ 176{
177#ifdef DESKTOP_VERSION 177#ifdef DESKTOP_VERSION
178 178
179#else 179#else
180 Sound::soundAlarm (); 180 Sound::soundAlarm ();
181#endif 181#endif
182} 182}
183void AlarmDialog::slotOk() 183void AlarmDialog::slotOk()
184{ 184{
185 mStopAlarm = true; 185 mStopAlarm = true;
186 mMissedAlarms->setText("(No missed Alarms)"); 186 mMissedAlarms->setText("(No missed Alarms)");
187 mMessage->setText(""); 187 mMessage->setText("");
188 mMissedAlarmsCombo->clear(); 188 mMissedAlarmsCombo->clear();
189#ifndef _WIN32_ 189#ifndef _WIN32_
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
198void AlarmDialog::slotSuspend() 198void 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
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
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 );
340} 344}