-rw-r--r-- | kalarmd/alarmdialog.cpp | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index c939ae0..7ead3b9 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -38,24 +38,25 @@ | |||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #ifndef _WIN32_ | 39 | #ifndef _WIN32_ |
40 | #include <unistd.h> | 40 | #include <unistd.h> |
41 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
42 | #endif | 42 | #endif |
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <fcntl.h> | 44 | #include <fcntl.h> |
45 | 45 | ||
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qtopia/alarmserver.h> | 47 | #include <qtopia/alarmserver.h> |
48 | #include <qpe/resource.h> | 48 | #include <qpe/resource.h> |
49 | #include <qtopia/sound.h> | 49 | #include <qtopia/sound.h> |
50 | |||
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | #include "alarmdialog.h" | 53 | #include "alarmdialog.h" |
53 | 54 | ||
54 | 55 | ||
55 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 56 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
56 | : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) | 57 | : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) |
57 | { | 58 | { |
58 | setCaption( "KO/Pi Alarm!" ); | 59 | setCaption( "KO/Pi Alarm!" ); |
59 | QVBoxLayout* layout = new QVBoxLayout( this); | 60 | QVBoxLayout* layout = new QVBoxLayout( this); |
60 | QLabel* l = new QLabel("The following event triggered alarm:",this); | 61 | QLabel* l = new QLabel("The following event triggered alarm:",this); |
61 | layout->addWidget ( l ); | 62 | layout->addWidget ( l ); |
@@ -82,46 +83,54 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | |||
82 | layout->addWidget ( mMessage ); | 83 | layout->addWidget ( mMessage ); |
83 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); | 84 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); |
84 | mMissedAlarms->setAlignment( AlignCenter); | 85 | mMissedAlarms->setAlignment( AlignCenter); |
85 | 86 | ||
86 | playSoundTimer = new QTimer( this ); | 87 | playSoundTimer = new QTimer( this ); |
87 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); | 88 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); |
88 | 89 | ||
89 | playSoundTimer->stop(); | 90 | playSoundTimer->stop(); |
90 | 91 | ||
91 | layout->addWidget ( mMissedAlarms ); | 92 | layout->addWidget ( mMissedAlarms ); |
92 | mMissedAlarmsCombo = new QComboBox ( this ); | 93 | mMissedAlarmsCombo = new QComboBox ( this ); |
93 | layout->addWidget ( mMissedAlarmsCombo ); | 94 | layout->addWidget ( mMissedAlarmsCombo ); |
94 | QVBox *suspendBox = new QVBox( this ); | 95 | |
95 | suspendBox->setSpacing(3); | 96 | QLabel* labb = new QLabel("Suspend duration (minutes):",this); |
96 | layout->addWidget ( suspendBox ); | ||
97 | QLabel* labb = new QLabel("Suspend duration (minutes):",suspendBox); | ||
98 | labb->setAlignment(AlignCenter); | 97 | labb->setAlignment(AlignCenter); |
98 | layout->addWidget ( labb ); | ||
99 | fo = font(); | 99 | fo = font(); |
100 | fo.setPointSize( 36 ); | 100 | int pointSize = 36; |
101 | mSuspendSpin = new QSpinBox(1,1440,1,suspendBox); | 101 | if ( QApplication::desktop()->width() <= 320 ) |
102 | pointSize = 24; | ||
103 | fo.setPointSize( pointSize ); | ||
104 | mSuspendSpin = new QSpinBox(1,1440,1,this); | ||
102 | mSuspendSpin->setFont( fo ); | 105 | mSuspendSpin->setFont( fo ); |
103 | mSuspendSpin->setValue(7); // default suspend duration | 106 | mSuspendSpin->setValue(7); // default suspend duration |
104 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 107 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
105 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 108 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
106 | #if QT_VERSION < 0x030000 | 109 | #if QT_VERSION < 0x030000 |
107 | mSuspendSpin->upButton ()->setFixedSize( QSize( 48, 30 )); | 110 | mSuspendSpin->upButton ()->setFixedSize( QSize( 48, 30 )); |
108 | mSuspendSpin->downButton ()->setFixedSize( QSize( 48, 30 )); | 111 | mSuspendSpin->downButton ()->setFixedSize( QSize( 48, 30 )); |
109 | #endif | 112 | #endif |
110 | mSuspendSpin->setFixedSize( 100,62 ); | 113 | mSuspendSpin->setFixedSize( 100,62 ); |
111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 114 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
115 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | ||
116 | layoutSpin->addStretch (); | ||
117 | layoutSpin->addWidget ( mSuspendSpin ); | ||
118 | layoutSpin->addStretch (); | ||
112 | 119 | ||
113 | QVBox * bbox = new QVBox ( this ); | 120 | QVBox * bbox = new QVBox ( this ); |
114 | layout->addWidget ( bbox ); | 121 | layout->addWidget ( bbox ); |
115 | bbox->layout()->setSpacing( 2 ); | 122 | bbox->layout()->setSpacing( 2 ); |
123 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | ||
124 | labb->setAlignment(AlignCenter); | ||
116 | mSuspendButton = new QPushButton( "Suspend", bbox); | 125 | mSuspendButton = new QPushButton( "Suspend", bbox); |
117 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 126 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
118 | QPushButton* okbut = new QPushButton( "Ok", bbox); | 127 | QPushButton* okbut = new QPushButton( "Ok", bbox); |
119 | mSuspendButton->setFont( fo ); | 128 | mSuspendButton->setFont( fo ); |
120 | silen->setFont( fo ); | 129 | silen->setFont( fo ); |
121 | okbut->setFont( fo ); | 130 | okbut->setFont( fo ); |
122 | okbut->setDefault( true ); | 131 | okbut->setDefault( true ); |
123 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); | 132 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); |
124 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); | 133 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); |
125 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); | 134 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); |
126 | #ifndef _WIN32_ | 135 | #ifndef _WIN32_ |
127 | if ( QFile::exists ( "/dev/sharp_led" ) ) | 136 | if ( QFile::exists ( "/dev/sharp_led" ) ) |
@@ -250,31 +259,54 @@ bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, boo | |||
250 | void AlarmDialog::playSound () | 259 | void AlarmDialog::playSound () |
251 | { | 260 | { |
252 | if (mStopAlarm ) | 261 | if (mStopAlarm ) |
253 | return; | 262 | return; |
254 | showNormal(); | 263 | showNormal(); |
255 | setActiveWindow(); | 264 | setActiveWindow(); |
256 | mSuspendSpin->setFocus(); | 265 | mSuspendSpin->setFocus(); |
257 | raise(); | 266 | raise(); |
258 | 267 | ||
259 | qApp->processEvents(); | 268 | qApp->processEvents(); |
260 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 269 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
261 | ++alarmCounter; | 270 | ++alarmCounter; |
271 | #ifdef DESKTOP_VERSION | ||
272 | mPlayWav = true; | ||
273 | #endif | ||
262 | if ( !mPlayWav || mFileName.length() < 2 ) { | 274 | if ( !mPlayWav || mFileName.length() < 2 ) { |
263 | 275 | ||
264 | #ifndef DESKTOP_VERSION | 276 | #ifdef DESKTOP_VERSION |
277 | qDebug("Sound play not possible - file not found"); | ||
278 | #else | ||
265 | Sound::soundAlarm (); | 279 | Sound::soundAlarm (); |
266 | #endif | 280 | #endif |
267 | } else { | 281 | } else |
282 | |||
283 | { | ||
284 | #ifdef DESKTOP_VERSION | ||
285 | #ifdef _WIN32_ | ||
286 | QSound::play ( mFileName ); | ||
287 | #else | ||
288 | |||
289 | QString command = "playwave -r 22050 " + mFileName; | ||
290 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); | ||
291 | int ret = system ( command.latin1() ); | ||
292 | if ( ret != 0 ) { | ||
293 | qDebug("Sound play command failed: %s ",command.latin1() ); | ||
294 | } | ||
295 | |||
296 | #endif | ||
297 | |||
298 | #else | ||
268 | QSound::play ( mFileName ); | 299 | QSound::play ( mFileName ); |
300 | #endif | ||
269 | //qDebug("BEEP!"); | 301 | //qDebug("BEEP!"); |
270 | } | 302 | } |
271 | } else { | 303 | } else { |
272 | if ( ! mSilent && mSuspendCounter > 0 ) { | 304 | if ( ! mSilent && mSuspendCounter > 0 ) { |
273 | --mSuspendCounter; | 305 | --mSuspendCounter; |
274 | reject (); | 306 | reject (); |
275 | hide(); | 307 | hide(); |
276 | return; | 308 | return; |
277 | } | 309 | } |
278 | } | 310 | } |
279 | playSoundTimer->start( mPauseCount * 1000, true ); | 311 | playSoundTimer->start( mPauseCount * 1000, true ); |
280 | } | 312 | } |