author | zautrix <zautrix> | 2005-04-01 21:26:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 21:26:34 (UTC) |
commit | efb66afca923f23a94b19da1fa12555956e70844 (patch) (unidiff) | |
tree | 0259b37dc87cc74308b3600f79675dc785216d11 | |
parent | 12fc62df25e15f6b20d8026ceb09118ca3ed7205 (diff) | |
download | kdepimpi-efb66afca923f23a94b19da1fa12555956e70844.zip kdepimpi-efb66afca923f23a94b19da1fa12555956e70844.tar.gz kdepimpi-efb66afca923f23a94b19da1fa12555956e70844.tar.bz2 |
alarm fixes
-rw-r--r-- | kalarmd/alarmdialog.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index 7b888ab..bdeee4a 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -1,316 +1,320 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KDE alarm daemon. | 2 | This file is part of the KDE alarm daemon. |
3 | Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
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 | #ifndef DESKTOP_VERSION | 35 | #ifndef DESKTOP_VERSION |
36 | #define protected public | 36 | #define protected public |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #undef protected | 38 | #undef protected |
39 | #else | 39 | #else |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #endif | 41 | #endif |
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #ifndef _WIN32_ | 43 | #ifndef _WIN32_ |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
46 | #endif | 46 | #endif |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <fcntl.h> | 48 | #include <fcntl.h> |
49 | 49 | ||
50 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
51 | #include <qtopia/alarmserver.h> | 51 | #include <qtopia/alarmserver.h> |
52 | #include <qpe/resource.h> | 52 | #include <qpe/resource.h> |
53 | #include <qtopia/sound.h> | 53 | #include <qtopia/sound.h> |
54 | 54 | ||
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #include "alarmdialog.h" | 57 | #include "alarmdialog.h" |
58 | 58 | ||
59 | 59 | ||
60 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 60 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
61 | : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) | 61 | : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) |
62 | { | 62 | { |
63 | setCaption( "KO/Pi Alarm!" ); | 63 | setCaption( "KO/Pi Alarm!" ); |
64 | QVBoxLayout* layout = new QVBoxLayout( this); | 64 | QVBoxLayout* layout = new QVBoxLayout( this); |
65 | QLabel* l = new QLabel("The following event triggered alarm:",this); | 65 | QLabel* l = new QLabel("The following event triggered alarm:",this); |
66 | layout->addWidget ( l ); | 66 | layout->addWidget ( l ); |
67 | l->setAlignment( AlignCenter); | 67 | l->setAlignment( AlignCenter); |
68 | mMessage = new QLabel ( " ", this ); | 68 | mMessage = new QLabel ( " ", this ); |
69 | int fs = 18; | 69 | int fs = 18; |
70 | int fs2 = 12; | 70 | int fs2 = 12; |
71 | int baseSize = 6; | ||
71 | if ( QApplication::desktop()->width() < 480 ) { | 72 | if ( QApplication::desktop()->width() < 480 ) { |
72 | setMaximumSize(220, 260); | ||
73 | fs2 = 10; | 73 | fs2 = 10; |
74 | } | 74 | fs = 12; |
75 | else { | 75 | baseSize = 4; |
76 | setMaximumSize(440, 440); | ||
77 | } | 76 | } |
78 | layout->setSpacing( 3 ); | 77 | layout->setSpacing( 3 ); |
79 | layout->setMargin( 3 ); | 78 | layout->setMargin( 3 ); |
80 | QFont fo = QApplication::font(); | 79 | QFont fo = QApplication::font(); |
81 | fo.setBold( true ); | 80 | fo.setBold( true ); |
82 | fo.setPointSize( fs2 ); | 81 | fo.setPointSize( fs2 ); |
83 | l->setFont( fo ); | 82 | l->setFont( fo ); |
84 | fo.setPointSize( fs ); | 83 | fo.setPointSize( fs ); |
85 | mMessage->setFont(fo ); | 84 | mMessage->setFont(fo ); |
86 | mMessage->setAlignment( AlignCenter); | 85 | mMessage->setAlignment( AlignCenter); |
87 | layout->addWidget ( mMessage ); | 86 | layout->addWidget ( mMessage ); |
88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); | 87 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); |
89 | mMissedAlarms->setAlignment( AlignCenter); | 88 | mMissedAlarms->setAlignment( AlignCenter); |
90 | 89 | ||
91 | playSoundTimer = new QTimer( this ); | 90 | playSoundTimer = new QTimer( this ); |
92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); | 91 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); |
93 | 92 | ||
94 | playSoundTimer->stop(); | 93 | playSoundTimer->stop(); |
95 | 94 | ||
96 | layout->addWidget ( mMissedAlarms ); | 95 | layout->addWidget ( mMissedAlarms ); |
97 | mMissedAlarmsCombo = new QComboBox ( this ); | 96 | mMissedAlarmsCombo = new QComboBox ( this ); |
98 | layout->addWidget ( mMissedAlarmsCombo ); | 97 | layout->addWidget ( mMissedAlarmsCombo ); |
99 | 98 | ||
100 | QLabel* labb = new QLabel("Suspend duration (minutes):",this); | 99 | QLabel* labb = new QLabel("Suspend duration (minutes):",this); |
101 | labb->setAlignment(AlignCenter); | 100 | labb->setAlignment(AlignCenter); |
102 | layout->addWidget ( labb ); | 101 | layout->addWidget ( labb ); |
103 | fo = font(); | 102 | fo = font(); |
104 | int pointSize = 36; | 103 | int pointSize = 36; |
105 | if ( QApplication::desktop()->width() <= 320 ) | 104 | if ( QApplication::desktop()->width() <= 320 ) |
106 | pointSize = 24; | 105 | pointSize = 18; |
107 | fo.setPointSize( pointSize ); | 106 | fo.setPointSize( pointSize ); |
108 | mSuspendSpin = new QSpinBox(1,1440,1,this); | 107 | mSuspendSpin = new QSpinBox(1,1440,1,this); |
109 | mSuspendSpin->setFont( fo ); | 108 | mSuspendSpin->setFont( fo ); |
110 | mSuspendSpin->setValue(7); // default suspend duration | 109 | mSuspendSpin->setValue(7); // default suspend duration |
111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 110 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
112 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
112 | |||
113 | #if QT_VERSION < 0x030000 | 113 | #if QT_VERSION < 0x030000 |
114 | mSuspendSpin->upButton ()->setFixedSize( QSize( 48, 30 )); | 114 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
115 | mSuspendSpin->downButton ()->setFixedSize( QSize( 48, 30 )); | 115 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
116 | #endif | 116 | #endif |
117 | mSuspendSpin->setFixedSize( 100,62 ); | 117 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); |
118 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 118 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
119 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | 119 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); |
120 | layoutSpin->addStretch (); | 120 | layoutSpin->addStretch (); |
121 | layoutSpin->addWidget ( mSuspendSpin ); | 121 | layoutSpin->addWidget ( mSuspendSpin ); |
122 | layoutSpin->addStretch (); | 122 | layoutSpin->addStretch (); |
123 | 123 | ||
124 | QVBox * bbox = new QVBox ( this ); | 124 | QVBox * bbox = new QVBox ( this ); |
125 | layout->addWidget ( bbox ); | 125 | layout->addWidget ( bbox ); |
126 | bbox->layout()->setSpacing( 2 ); | 126 | bbox->layout()->setSpacing( 2 ); |
127 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | 127 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); |
128 | labb->setAlignment(AlignCenter); | 128 | labb->setAlignment(AlignCenter); |
129 | mSuspendButton = new QPushButton( "Suspend", bbox); | 129 | mSuspendButton = new QPushButton( "Suspend", bbox); |
130 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 130 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
131 | QPushButton* okbut = new QPushButton( "Ok", bbox); | 131 | QPushButton* okbut = new QPushButton( "Ok", bbox); |
132 | mSuspendButton->setFont( fo ); | 132 | mSuspendButton->setFont( fo ); |
133 | silen->setFont( fo ); | 133 | silen->setFont( fo ); |
134 | okbut->setFont( fo ); | 134 | okbut->setFont( fo ); |
135 | okbut->setDefault( true ); | 135 | okbut->setDefault( true ); |
136 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); | 136 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); |
137 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); | 137 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); |
138 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); | 138 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); |
139 | #ifndef _WIN32_ | 139 | #ifndef _WIN32_ |
140 | if ( QFile::exists ( "/dev/sharp_led" ) ) | 140 | if ( QFile::exists ( "/dev/sharp_led" ) ) |
141 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 141 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
142 | else | 142 | else |
143 | #endif | 143 | #endif |
144 | fd_led = 0; | 144 | fd_led = 0; |
145 | statusLED.which = SHARP_LED_SALARM; | 145 | statusLED.which = SHARP_LED_SALARM; |
146 | mSilent = false; | 146 | mSilent = false; |
147 | mSuspendCounter = 0; | 147 | mSuspendCounter = 0; |
148 | setServerNotification( true ); | 148 | setServerNotification( true ); |
149 | } | 149 | } |
150 | void AlarmDialog::reject () | 150 | void AlarmDialog::reject () |
151 | { | 151 | { |
152 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); | 152 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); |
153 | slotSuspend(); | 153 | slotSuspend(); |
154 | } | 154 | } |
155 | AlarmDialog::~AlarmDialog() | 155 | AlarmDialog::~AlarmDialog() |
156 | { | 156 | { |
157 | } | 157 | } |
158 | void AlarmDialog::silent () | 158 | void AlarmDialog::silent () |
159 | { | 159 | { |
160 | mSilent = true; | 160 | mSilent = true; |
161 | } | 161 | } |
162 | void AlarmDialog::accept() | 162 | void AlarmDialog::accept() |
163 | { | 163 | { |
164 | slotOk(); | 164 | slotOk(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void AlarmDialog::suspend() | 167 | void AlarmDialog::suspend() |
168 | { | 168 | { |
169 | #ifdef DESKTOP_VERSION | 169 | #ifdef DESKTOP_VERSION |
170 | 170 | ||
171 | #else | 171 | #else |
172 | Sound::soundAlarm (); | 172 | Sound::soundAlarm (); |
173 | #endif | 173 | #endif |
174 | } | 174 | } |
175 | void AlarmDialog::slotOk() | 175 | void AlarmDialog::slotOk() |
176 | { | 176 | { |
177 | mStopAlarm = true; | 177 | mStopAlarm = true; |
178 | mMissedAlarms->setText("(No missed Alarms)"); | 178 | mMissedAlarms->setText("(No missed Alarms)"); |
179 | mMessage->setText(""); | 179 | mMessage->setText(""); |
180 | mMissedAlarmsCombo->clear(); | 180 | mMissedAlarmsCombo->clear(); |
181 | #ifndef _WIN32_ | 181 | #ifndef _WIN32_ |
182 | if ( fd_led > 0 ) { | 182 | if ( fd_led > 0 ) { |
183 | statusLED.status = LED_SALARM_OFF ; | 183 | statusLED.status = LED_SALARM_OFF ; |
184 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 184 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
185 | } | 185 | } |
186 | #endif | 186 | #endif |
187 | QDialog::accept(); | 187 | QDialog::accept(); |
188 | } | 188 | } |
189 | 189 | ||
190 | void AlarmDialog::slotSuspend() | 190 | void AlarmDialog::slotSuspend() |
191 | { | 191 | { |
192 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); | 192 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); |
193 | mStopAlarm = true; | 193 | mStopAlarm = true; |
194 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); | 194 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); |
195 | QString mess = "suspend_alarm" +mFileName+"+++" ; | 195 | QString mess = "suspend_alarm" +mFileName+"+++" ; |
196 | if ( mMessage->text().left( 10 ) !="Suspended:" ) | 196 | if ( mMessage->text().left( 10 ) !="Suspended:" ) |
197 | mess += "Suspended:\n"; | 197 | mess += "Suspended:\n"; |
198 | mess +=mMessage->text(); | 198 | mess +=mMessage->text(); |
199 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
200 | if ( mServerNotification ) | 200 | if ( mServerNotification ) |
201 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); | 201 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); |
202 | #endif | 202 | #endif |
203 | emit addAlarm( nextA , mess ); | 203 | emit addAlarm( nextA , mess ); |
204 | slotOk(); | 204 | slotOk(); |
205 | } | 205 | } |
206 | 206 | ||
207 | void AlarmDialog::setServerNotification( bool b ) | 207 | void AlarmDialog::setServerNotification( bool b ) |
208 | { | 208 | { |
209 | mServerNotification = b; | 209 | mServerNotification = b; |
210 | } | 210 | } |
211 | int AlarmDialog::getSuspendTime( ) | 211 | int AlarmDialog::getSuspendTime( ) |
212 | { | 212 | { |
213 | return mSuspendSpin->value(); | 213 | return mSuspendSpin->value(); |
214 | 214 | ||
215 | } | 215 | } |
216 | void AlarmDialog::setSuspendTime( int val ) | 216 | void AlarmDialog::setSuspendTime( int val ) |
217 | { | 217 | { |
218 | mSuspendSpin->setValue( val ); | 218 | mSuspendSpin->setValue( val ); |
219 | } | 219 | } |
220 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) | 220 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) |
221 | { | 221 | { |
222 | if ( mess.left( 9) != "Suspended" ) | 222 | if ( mess.left( 9) != "Suspended" ) |
223 | mSuspendCounter = suspendtimes; | 223 | mSuspendCounter = suspendtimes; |
224 | mPauseCount = pause; | 224 | mPauseCount = pause; |
225 | mFileName = fn; | 225 | mFileName = fn; |
226 | mPlayWav = playwav; | 226 | mPlayWav = playwav; |
227 | if ( !QFile::exists( fn ) ) | 227 | if ( !QFile::exists( fn ) ) |
228 | mFileName = ""; | 228 | mFileName = ""; |
229 | alarmCounter = 0 ; | 229 | alarmCounter = 0 ; |
230 | maxAlarmReplay = replay ; | 230 | maxAlarmReplay = replay ; |
231 | mStopAlarm = false; | 231 | mStopAlarm = false; |
232 | mSilent = false; | 232 | mSilent = false; |
233 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { | 233 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { |
234 | mMissedAlarmsCombo->show(); | 234 | mMissedAlarmsCombo->show(); |
235 | mMissedAlarmsCombo->insertItem( mMessage->text().stripWhiteSpace() ); | 235 | mMissedAlarmsCombo->insertItem( mMessage->text().stripWhiteSpace() ); |
236 | mMissedAlarms->setText( "Missed alarms:"); | 236 | mMissedAlarms->setText( "Missed alarms:"); |
237 | } else | 237 | } else |
238 | mMissedAlarmsCombo->hide(); | 238 | mMissedAlarmsCombo->hide(); |
239 | mMessage->setText(mess); | 239 | mMessage->setText(mess); |
240 | int w =sizeHint().width() ; | 240 | int w =sizeHint().width() ; |
241 | int h = sizeHint().height() ; | 241 | int h = sizeHint().height() ; |
242 | int dw = QApplication::desktop()->width(); | 242 | int dw = QApplication::desktop()->width(); |
243 | int dh = QApplication::desktop()->height(); | 243 | int dh = QApplication::desktop()->height(); |
244 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 244 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
245 | show(); | 245 | show(); |
246 | raise(); | 246 | raise(); |
247 | qApp->processEvents(); | 247 | //qApp->processEvents(); |
248 | repaint(); | 248 | //repaint(); |
249 | qApp->processEvents(); | 249 | qApp->processEvents(); |
250 | 250 | ||
251 | #ifndef _WIN32_ | 251 | #ifndef _WIN32_ |
252 | if ( fd_led > 0 ) { | 252 | if ( fd_led > 0 ) { |
253 | statusLED.status = LED_SALARM_ON ; | 253 | statusLED.status = LED_SALARM_ON ; |
254 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 254 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
255 | } | 255 | } |
256 | #endif | 256 | #endif |
257 | playSoundTimer->start( 1000, true ); | 257 | playSoundTimer->start( 1000, true ); |
258 | return true; | 258 | return true; |
259 | 259 | ||
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | void AlarmDialog::playSound () | 263 | void AlarmDialog::playSound () |
264 | { | 264 | { |
265 | |||
265 | if (mStopAlarm ) | 266 | if (mStopAlarm ) |
266 | return; | 267 | return; |
268 | if (mSilent ) | ||
269 | return; | ||
267 | showNormal(); | 270 | showNormal(); |
268 | setActiveWindow(); | 271 | setActiveWindow(); |
269 | mSuspendSpin->setFocus(); | 272 | mSuspendSpin->setFocus(); |
270 | raise(); | 273 | raise(); |
274 | repaint(); | ||
271 | 275 | ||
272 | qApp->processEvents(); | 276 | qApp->processEvents(); |
273 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 277 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
274 | ++alarmCounter; | 278 | ++alarmCounter; |
275 | #ifdef DESKTOP_VERSION | 279 | #ifdef DESKTOP_VERSION |
276 | mPlayWav = true; | 280 | mPlayWav = true; |
277 | #endif | 281 | #endif |
278 | if ( !mPlayWav || mFileName.length() < 2 ) { | 282 | if ( !mPlayWav || mFileName.length() < 2 ) { |
279 | 283 | ||
280 | #ifdef DESKTOP_VERSION | 284 | #ifdef DESKTOP_VERSION |
281 | qDebug("Sound play not possible - file not found"); | 285 | qDebug("Sound play not possible - file not found"); |
282 | #else | 286 | #else |
283 | Sound::soundAlarm (); | 287 | Sound::soundAlarm (); |
284 | #endif | 288 | #endif |
285 | } else | 289 | } else |
286 | 290 | ||
287 | { | 291 | { |
288 | #ifdef DESKTOP_VERSION | 292 | #ifdef DESKTOP_VERSION |
289 | #ifdef _WIN32_ | 293 | #ifdef _WIN32_ |
290 | QSound::play ( mFileName ); | 294 | QSound::play ( mFileName ); |
291 | #else | 295 | #else |
292 | 296 | ||
293 | QString command = "playwave -r 22050 " + mFileName; | 297 | QString command = "playwave -r 22050 " + mFileName; |
294 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); | 298 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); |
295 | int ret = system ( command.latin1() ); | 299 | int ret = system ( command.latin1() ); |
296 | if ( ret != 0 ) { | 300 | if ( ret != 0 ) { |
297 | qDebug("Sound play command failed: %s ",command.latin1() ); | 301 | qDebug("Sound play command failed: %s ",command.latin1() ); |
298 | } | 302 | } |
299 | 303 | ||
300 | #endif | 304 | #endif |
301 | 305 | ||
302 | #else | 306 | #else |
303 | QSound::play ( mFileName ); | 307 | QSound::play ( mFileName ); |
304 | #endif | 308 | #endif |
305 | //qDebug("BEEP!"); | 309 | qDebug("BEEP!"); |
306 | } | 310 | } |
307 | } else { | 311 | } else { |
308 | if ( ! mSilent && mSuspendCounter > 0 ) { | 312 | if ( ! mSilent && mSuspendCounter > 0 ) { |
309 | --mSuspendCounter; | 313 | --mSuspendCounter; |
310 | reject (); | 314 | reject (); |
311 | hide(); | 315 | hide(); |
312 | return; | 316 | return; |
313 | } | 317 | } |
314 | } | 318 | } |
315 | playSoundTimer->start( mPauseCount * 1000, true ); | 319 | playSoundTimer->start( mPauseCount * 1000, true ); |
316 | } | 320 | } |