-rw-r--r-- | kalarmd/alarmdialog.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index bdeee4a..53ff488 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -23,24 +23,25 @@ | |||
23 | 23 | ||
24 | // $Id$ | 24 | // $Id$ |
25 | 25 | ||
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qsound.h> | 33 | #include <qsound.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qregexp.h> | ||
35 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
36 | #define protected public | 37 | #define protected public |
37 | #include <qspinbox.h> | 38 | #include <qspinbox.h> |
38 | #undef protected | 39 | #undef protected |
39 | #else | 40 | #else |
40 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
41 | #endif | 42 | #endif |
42 | #include <stdlib.h> | 43 | #include <stdlib.h> |
43 | #ifndef _WIN32_ | 44 | #ifndef _WIN32_ |
44 | #include <unistd.h> | 45 | #include <unistd.h> |
45 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
46 | #endif | 47 | #endif |
@@ -49,25 +50,25 @@ | |||
49 | 50 | ||
50 | #ifndef DESKTOP_VERSION | 51 | #ifndef DESKTOP_VERSION |
51 | #include <qtopia/alarmserver.h> | 52 | #include <qtopia/alarmserver.h> |
52 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
53 | #include <qtopia/sound.h> | 54 | #include <qtopia/sound.h> |
54 | 55 | ||
55 | #endif | 56 | #endif |
56 | 57 | ||
57 | #include "alarmdialog.h" | 58 | #include "alarmdialog.h" |
58 | 59 | ||
59 | 60 | ||
60 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
61 | : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) | 62 | : QDialog (parent, name, true, Qt::WStyle_Customize |Qt::WStyle_StaysOnTop | Qt::WStyle_DialogBorder) |
62 | { | 63 | { |
63 | setCaption( "KO/Pi Alarm!" ); | 64 | setCaption( "KO/Pi Alarm!" ); |
64 | QVBoxLayout* layout = new QVBoxLayout( this); | 65 | QVBoxLayout* layout = new QVBoxLayout( this); |
65 | QLabel* l = new QLabel("The following event triggered alarm:",this); | 66 | QLabel* l = new QLabel("The following event triggered alarm:",this); |
66 | layout->addWidget ( l ); | 67 | layout->addWidget ( l ); |
67 | l->setAlignment( AlignCenter); | 68 | l->setAlignment( AlignCenter); |
68 | mMessage = new QLabel ( " ", this ); | 69 | mMessage = new QLabel ( " ", this ); |
69 | int fs = 18; | 70 | int fs = 18; |
70 | int fs2 = 12; | 71 | int fs2 = 12; |
71 | int baseSize = 6; | 72 | int baseSize = 6; |
72 | if ( QApplication::desktop()->width() < 480 ) { | 73 | if ( QApplication::desktop()->width() < 480 ) { |
73 | fs2 = 10; | 74 | fs2 = 10; |
@@ -223,25 +224,27 @@ bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, boo | |||
223 | mSuspendCounter = suspendtimes; | 224 | mSuspendCounter = suspendtimes; |
224 | mPauseCount = pause; | 225 | mPauseCount = pause; |
225 | mFileName = fn; | 226 | mFileName = fn; |
226 | mPlayWav = playwav; | 227 | mPlayWav = playwav; |
227 | if ( !QFile::exists( fn ) ) | 228 | if ( !QFile::exists( fn ) ) |
228 | mFileName = ""; | 229 | mFileName = ""; |
229 | alarmCounter = 0 ; | 230 | alarmCounter = 0 ; |
230 | maxAlarmReplay = replay ; | 231 | maxAlarmReplay = replay ; |
231 | mStopAlarm = false; | 232 | mStopAlarm = false; |
232 | mSilent = false; | 233 | mSilent = false; |
233 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { | 234 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { |
234 | mMissedAlarmsCombo->show(); | 235 | mMissedAlarmsCombo->show(); |
235 | mMissedAlarmsCombo->insertItem( mMessage->text().stripWhiteSpace() ); | 236 | QString newItem = mMessage->text().stripWhiteSpace(); |
237 | newItem.replace( QRegExp("\n"), QString(" ") ); | ||
238 | mMissedAlarmsCombo->insertItem( newItem ); | ||
236 | mMissedAlarms->setText( "Missed alarms:"); | 239 | mMissedAlarms->setText( "Missed alarms:"); |
237 | } else | 240 | } else |
238 | mMissedAlarmsCombo->hide(); | 241 | mMissedAlarmsCombo->hide(); |
239 | mMessage->setText(mess); | 242 | mMessage->setText(mess); |
240 | int w =sizeHint().width() ; | 243 | int w =sizeHint().width() ; |
241 | int h = sizeHint().height() ; | 244 | int h = sizeHint().height() ; |
242 | int dw = QApplication::desktop()->width(); | 245 | int dw = QApplication::desktop()->width(); |
243 | int dh = QApplication::desktop()->height(); | 246 | int dh = QApplication::desktop()->height(); |
244 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 247 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
245 | show(); | 248 | show(); |
246 | raise(); | 249 | raise(); |
247 | //qApp->processEvents(); | 250 | //qApp->processEvents(); |
@@ -256,31 +259,31 @@ bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, boo | |||
256 | #endif | 259 | #endif |
257 | playSoundTimer->start( 1000, true ); | 260 | playSoundTimer->start( 1000, true ); |
258 | return true; | 261 | return true; |
259 | 262 | ||
260 | } | 263 | } |
261 | 264 | ||
262 | 265 | ||
263 | void AlarmDialog::playSound () | 266 | void AlarmDialog::playSound () |
264 | { | 267 | { |
265 | 268 | ||
266 | if (mStopAlarm ) | 269 | if (mStopAlarm ) |
267 | return; | 270 | return; |
268 | if (mSilent ) | 271 | if ( mSilent ) |
269 | return; | 272 | return; |
270 | showNormal(); | 273 | showNormal(); |
271 | setActiveWindow(); | 274 | setActiveWindow(); |
275 | raise(); | ||
272 | mSuspendSpin->setFocus(); | 276 | mSuspendSpin->setFocus(); |
273 | raise(); | 277 | |
274 | repaint(); | ||
275 | 278 | ||
276 | qApp->processEvents(); | 279 | qApp->processEvents(); |
277 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 280 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
278 | ++alarmCounter; | 281 | ++alarmCounter; |
279 | #ifdef DESKTOP_VERSION | 282 | #ifdef DESKTOP_VERSION |
280 | mPlayWav = true; | 283 | mPlayWav = true; |
281 | #endif | 284 | #endif |
282 | if ( !mPlayWav || mFileName.length() < 2 ) { | 285 | if ( !mPlayWav || mFileName.length() < 2 ) { |
283 | 286 | ||
284 | #ifdef DESKTOP_VERSION | 287 | #ifdef DESKTOP_VERSION |
285 | qDebug("Sound play not possible - file not found"); | 288 | qDebug("Sound play not possible - file not found"); |
286 | #else | 289 | #else |