-rw-r--r-- | kalarmd/alarmdialog.cpp | 36 | ||||
-rw-r--r-- | kalarmd/alarmdialog.h | 2 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 9 |
3 files changed, 29 insertions, 18 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index 65073f6..d72a8c2 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -1,328 +1,334 @@ | |||
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 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #define protected public | 37 | #define protected public |
38 | #include <qspinbox.h> | 38 | #include <qspinbox.h> |
39 | #undef protected | 39 | #undef protected |
40 | #else | 40 | #else |
41 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
42 | #endif | 42 | #endif |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #ifndef _WIN32_ | 44 | #ifndef _WIN32_ |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
47 | #endif | 47 | #endif |
48 | #include <stdio.h> | 48 | #include <stdio.h> |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> |
50 | 50 | ||
51 | #ifndef DESKTOP_VERSION | 51 | #ifndef DESKTOP_VERSION |
52 | #include <qtopia/alarmserver.h> | 52 | #include <qtopia/alarmserver.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qtopia/sound.h> | 54 | #include <qtopia/sound.h> |
55 | 55 | ||
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #include "alarmdialog.h" | 58 | #include "alarmdialog.h" |
59 | 59 | ||
60 | 60 | ||
61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
62 | : QDialog (parent, name, true, Qt::WStyle_Customize |Qt::WStyle_StaysOnTop | Qt::WStyle_DialogBorder) | 62 | : QDialog (parent, name, true, Qt::WStyle_Customize |Qt::WStyle_StaysOnTop | Qt::WStyle_DialogBorder) |
63 | { | 63 | { |
64 | setCaption( "KO/Pi Alarm!" ); | 64 | setCaption( "KO/Pi Alarm!" ); |
65 | QVBoxLayout* layout = new QVBoxLayout( this); | 65 | QVBoxLayout* layout = new QVBoxLayout( this); |
66 | QLabel* l = new QLabel("The following event triggered alarm:",this); | 66 | QLabel* l = new QLabel("The following event triggered alarm:",this); |
67 | layout->addWidget ( l ); | 67 | layout->addWidget ( l ); |
68 | l->setAlignment( AlignCenter); | 68 | l->setAlignment( AlignCenter); |
69 | mMessage = new QLabel ( " ", this ); | 69 | mMessage = new QLabel ( " ", this ); |
70 | int fs = 18; | 70 | int fs = 18; |
71 | int fs2 = 12; | 71 | int fs2 = 12; |
72 | int baseSize = 6; | 72 | int baseSize = 6; |
73 | if ( QApplication::desktop()->width() < 480 ) { | 73 | if ( QApplication::desktop()->width() < 480 ) { |
74 | fs2 = 10; | 74 | fs2 = 10; |
75 | fs = 12; | 75 | fs = 12; |
76 | baseSize = 4; | 76 | baseSize = 4; |
77 | } | 77 | } |
78 | layout->setSpacing( 3 ); | 78 | layout->setSpacing( 3 ); |
79 | layout->setMargin( 3 ); | 79 | layout->setMargin( 3 ); |
80 | QFont fo = QApplication::font(); | 80 | QFont fo = QApplication::font(); |
81 | fo.setBold( true ); | 81 | fo.setBold( true ); |
82 | fo.setPointSize( fs2 ); | 82 | fo.setPointSize( fs2 ); |
83 | l->setFont( fo ); | 83 | l->setFont( fo ); |
84 | fo.setPointSize( fs ); | 84 | fo.setPointSize( fs ); |
85 | mMessage->setFont(fo ); | 85 | mMessage->setFont(fo ); |
86 | mMessage->setAlignment( AlignCenter); | 86 | mMessage->setAlignment( AlignCenter); |
87 | layout->addWidget ( mMessage ); | 87 | layout->addWidget ( mMessage ); |
88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); | 88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); |
89 | mMissedAlarms->setAlignment( AlignCenter); | 89 | mMissedAlarms->setAlignment( AlignCenter); |
90 | 90 | ||
91 | playSoundTimer = new QTimer( this ); | 91 | playSoundTimer = new QTimer( this ); |
92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); | 92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); |
93 | 93 | ||
94 | playSoundTimer->stop(); | 94 | playSoundTimer->stop(); |
95 | 95 | ||
96 | layout->addWidget ( mMissedAlarms ); | 96 | layout->addWidget ( mMissedAlarms ); |
97 | mMissedAlarmsCombo = new QComboBox ( this ); | 97 | mMissedAlarmsCombo = new QComboBox ( this ); |
98 | layout->addWidget ( mMissedAlarmsCombo ); | 98 | layout->addWidget ( mMissedAlarmsCombo ); |
99 | 99 | ||
100 | QLabel* labb = new QLabel("Suspend duration (minutes):",this); | 100 | QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this); |
101 | labb->setAlignment(AlignCenter); | 101 | labb->setAlignment(AlignCenter); |
102 | layout->addWidget ( labb ); | 102 | //layout->addWidget ( labb ); |
103 | fo = font(); | 103 | fo = font(); |
104 | int pointSize = 36; | 104 | int pointSize = 36; |
105 | if ( QApplication::desktop()->width() <= 320 ) | 105 | if ( QApplication::desktop()->width() <= 320 ) |
106 | pointSize = 18; | 106 | pointSize = 18; |
107 | fo.setPointSize( pointSize ); | 107 | fo.setPointSize( pointSize ); |
108 | mSuspendSpin = new QSpinBox(1,1440,1,this); | 108 | mSuspendSpin = new QSpinBox(1,1440,1,this); |
109 | mSuspendSpin->setFont( fo ); | 109 | mSuspendSpin->setFont( fo ); |
110 | mSuspendSpin->setValue(7); // default suspend duration | 110 | mSuspendSpin->setValue(7); // default suspend duration |
111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
112 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 112 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
113 | 113 | ||
114 | #if QT_VERSION < 0x030000 | 114 | #if QT_VERSION < 0x030000 |
115 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 115 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
116 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 116 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
117 | #endif | 117 | #endif |
118 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); | 118 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); |
119 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 119 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
120 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | 120 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); |
121 | layoutSpin->addStretch (); | 121 | layoutSpin->addStretch (); |
122 | layoutSpin->addWidget ( labb ); | ||
122 | layoutSpin->addWidget ( mSuspendSpin ); | 123 | layoutSpin->addWidget ( mSuspendSpin ); |
123 | layoutSpin->addStretch (); | 124 | layoutSpin->addStretch (); |
124 | 125 | ||
125 | QVBox * bbox = new QVBox ( this ); | 126 | QVBox * bbox = new QVBox ( this ); |
126 | layout->addWidget ( bbox ); | 127 | layout->addWidget ( bbox ); |
127 | bbox->layout()->setSpacing( 2 ); | 128 | bbox->layout()->setSpacing( 2 ); |
128 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | 129 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); |
129 | labb->setAlignment(AlignCenter); | 130 | labb->setAlignment(AlignCenter); |
130 | mSuspendButton = new QPushButton( "Suspend", bbox); | 131 | mSuspendButton = new QPushButton( "Suspend", bbox); |
131 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 132 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
132 | QPushButton* okbut = new QPushButton( "Ok", bbox); | 133 | okbut = new QPushButton( "Ok", bbox); |
133 | mSuspendButton->setFont( fo ); | 134 | mSuspendButton->setFont( fo ); |
134 | silen->setFont( fo ); | 135 | silen->setFont( fo ); |
135 | okbut->setFont( fo ); | 136 | okbut->setFont( fo ); |
136 | okbut->setDefault( true ); | 137 | okbut->setDefault( true ); |
137 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); | 138 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); |
138 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); | 139 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); |
139 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); | 140 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); |
140 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); | 141 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); |
141 | #ifndef _WIN32_ | 142 | #ifndef _WIN32_ |
142 | if ( QFile::exists ( "/dev/sharp_led" ) ) | 143 | if ( QFile::exists ( "/dev/sharp_led" ) ) |
143 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 144 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
144 | else | 145 | else |
145 | #endif | 146 | #endif |
146 | fd_led = 0; | 147 | fd_led = 0; |
147 | statusLED.which = SHARP_LED_SALARM; | 148 | statusLED.which = SHARP_LED_SALARM; |
148 | mSilent = false; | 149 | mSilent = false; |
149 | mSuspendCounter = 0; | 150 | mSuspendCounter = 0; |
150 | setServerNotification( true ); | 151 | setServerNotification( true ); |
151 | } | 152 | } |
152 | void AlarmDialog::reject () | 153 | void AlarmDialog::reject () |
153 | { | 154 | { |
154 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); | 155 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); |
155 | slotSuspend(); | 156 | slotSuspend(); |
156 | } | 157 | } |
157 | AlarmDialog::~AlarmDialog() | 158 | AlarmDialog::~AlarmDialog() |
158 | { | 159 | { |
159 | } | 160 | } |
160 | void AlarmDialog::silent () | 161 | void AlarmDialog::silent () |
161 | { | 162 | { |
162 | mSilent = true; | 163 | mSilent = true; |
163 | } | 164 | } |
164 | void AlarmDialog::accept() | 165 | void AlarmDialog::accept() |
165 | { | 166 | { |
166 | slotOk(); | 167 | slotOk(); |
167 | } | 168 | } |
168 | 169 | ||
169 | void AlarmDialog::suspend() | 170 | void AlarmDialog::suspend() |
170 | { | 171 | { |
171 | #ifdef DESKTOP_VERSION | 172 | #ifdef DESKTOP_VERSION |
172 | 173 | ||
173 | #else | 174 | #else |
174 | Sound::soundAlarm (); | 175 | Sound::soundAlarm (); |
175 | #endif | 176 | #endif |
176 | } | 177 | } |
177 | void AlarmDialog::slotOk() | 178 | void AlarmDialog::slotOk() |
178 | { | 179 | { |
179 | mStopAlarm = true; | 180 | mStopAlarm = true; |
180 | mMissedAlarms->setText("(No missed Alarms)"); | 181 | mMissedAlarms->setText("(No missed Alarms)"); |
181 | mMessage->setText(""); | 182 | mMessage->setText(""); |
182 | mMissedAlarmsCombo->clear(); | 183 | mMissedAlarmsCombo->clear(); |
183 | #ifndef _WIN32_ | 184 | #ifndef _WIN32_ |
184 | if ( fd_led > 0 ) { | 185 | if ( fd_led > 0 ) { |
185 | statusLED.status = LED_SALARM_OFF ; | 186 | statusLED.status = LED_SALARM_OFF ; |
186 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 187 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
187 | } | 188 | } |
188 | #endif | 189 | #endif |
189 | QDialog::accept(); | 190 | QDialog::accept(); |
190 | } | 191 | } |
191 | 192 | ||
192 | void AlarmDialog::slotSuspend() | 193 | void AlarmDialog::slotSuspend() |
193 | { | 194 | { |
194 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); | 195 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); |
195 | mStopAlarm = true; | 196 | mStopAlarm = true; |
196 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); | 197 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); |
197 | QString mess = "suspend_alarm" +mFileName+"+++" ; | 198 | QString mess = "suspend_alarm" +mFileName+"+++" ; |
198 | if ( mMessage->text().left( 10 ) !="Suspended:" ) | 199 | if ( mMessage->text().left( 10 ) !="Suspended:" ) |
199 | mess += "Suspended:\n"; | 200 | mess += "Suspended:\n"; |
200 | mess +=mMessage->text(); | 201 | mess +=mMessage->text(); |
201 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
202 | if ( mServerNotification ) | 203 | if ( mServerNotification ) |
203 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); | 204 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); |
204 | #endif | 205 | #endif |
205 | emit addAlarm( nextA , mess ); | 206 | emit addAlarm( nextA , mess ); |
206 | slotOk(); | 207 | slotOk(); |
207 | } | 208 | } |
208 | 209 | ||
209 | void AlarmDialog::setServerNotification( bool b ) | 210 | void AlarmDialog::setServerNotification( bool b ) |
210 | { | 211 | { |
211 | mServerNotification = b; | 212 | mServerNotification = b; |
212 | } | 213 | } |
213 | int AlarmDialog::getSuspendTime( ) | 214 | int AlarmDialog::getSuspendTime( ) |
214 | { | 215 | { |
215 | return mSuspendSpin->value(); | 216 | return mSuspendSpin->value(); |
216 | 217 | ||
217 | } | 218 | } |
218 | void AlarmDialog::setSuspendTime( int val ) | 219 | void AlarmDialog::setSuspendTime( int val ) |
219 | { | 220 | { |
220 | mSuspendSpin->setValue( val ); | 221 | mSuspendSpin->setValue( val ); |
221 | } | 222 | } |
222 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) | 223 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) |
223 | { | 224 | { |
224 | if ( mess.left( 9) != "Suspended" ) | 225 | if ( mess.left( 9) != "Suspended" ) |
225 | mSuspendCounter = suspendtimes; | 226 | mSuspendCounter = suspendtimes; |
226 | mPauseCount = pause; | 227 | mPauseCount = pause; |
227 | mFileName = fn; | 228 | mFileName = fn; |
228 | mPlayWav = playwav; | 229 | mPlayWav = playwav; |
229 | if ( !QFile::exists( fn ) ) | 230 | if ( !QFile::exists( fn ) ) |
230 | mFileName = ""; | 231 | mFileName = ""; |
231 | alarmCounter = 0 ; | 232 | alarmCounter = 0 ; |
232 | maxAlarmReplay = replay ; | 233 | maxAlarmReplay = replay ; |
233 | mStopAlarm = false; | 234 | mStopAlarm = false; |
234 | mSilent = false; | 235 | mSilent = false; |
235 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { | 236 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { |
236 | mMissedAlarmsCombo->show(); | 237 | mMissedAlarmsCombo->show(); |
237 | QString newItem = mMessage->text().stripWhiteSpace(); | 238 | QString newItem = mMessage->text().stripWhiteSpace(); |
238 | newItem.replace( QRegExp("\n"), QString(" ") ); | 239 | newItem.replace( QRegExp("\n"), QString(" ") ); |
239 | mMissedAlarmsCombo->insertItem( newItem ); | 240 | mMissedAlarmsCombo->insertItem( newItem ); |
240 | mMissedAlarms->setText( "Missed alarms:"); | 241 | mMissedAlarms->setText( "Missed alarms:"); |
241 | } else | 242 | } else |
242 | mMissedAlarmsCombo->hide(); | 243 | mMissedAlarmsCombo->hide(); |
243 | mMessage->setText(mess); | 244 | mMessage->setText(mess); |
244 | int w =sizeHint().width() ; | 245 | int w = minimumSizeHint().width() ; |
245 | int h = sizeHint().height() ; | 246 | int h = minimumSizeHint().height() ; |
246 | int dw = QApplication::desktop()->width(); | 247 | int dw = QApplication::desktop()->width(); |
247 | int dh = QApplication::desktop()->height(); | 248 | int dh = QApplication::desktop()->height(); |
248 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 249 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
249 | show(); | 250 | hide(); |
250 | raise(); | ||
251 | //qApp->processEvents(); | ||
252 | //repaint(); | ||
253 | qApp->processEvents(); | ||
254 | 251 | ||
255 | #ifndef _WIN32_ | 252 | #ifndef _WIN32_ |
256 | if ( fd_led > 0 ) { | 253 | if ( fd_led > 0 ) { |
257 | statusLED.status = LED_SALARM_ON ; | 254 | statusLED.status = LED_SALARM_ON ; |
258 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 255 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
259 | } | 256 | } |
260 | #endif | 257 | #endif |
261 | playSoundTimer->start( 1000, true ); | 258 | okbut->setDefault( true ); |
259 | QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); | ||
260 | // playSoundTimer->start( 1000, true ); | ||
262 | return true; | 261 | return true; |
263 | 262 | ||
264 | } | 263 | } |
265 | 264 | ||
266 | void AlarmDialog::spinBoxChanged( int ) | 265 | void AlarmDialog::forceRepaint() |
267 | { | 266 | { |
267 | |||
268 | showNormal(); | ||
269 | setActiveWindow(); | ||
270 | raise(); | ||
271 | playSoundTimer->start( 1000, true ); | ||
272 | |||
273 | } | ||
274 | void AlarmDialog::spinBoxChanged( int v ) | ||
275 | { | ||
276 | okbut->setDefault( false ); | ||
268 | mSilent = true; | 277 | mSilent = true; |
269 | } | 278 | } |
270 | 279 | ||
271 | void AlarmDialog::playSound () | 280 | void AlarmDialog::playSound () |
272 | { | 281 | { |
273 | 282 | ||
274 | if (mStopAlarm ) | 283 | if (mStopAlarm ) |
275 | return; | 284 | return; |
276 | if ( mSilent ) | 285 | if ( mSilent ) |
277 | return; | 286 | return; |
278 | showNormal(); | 287 | showNormal(); |
279 | setActiveWindow(); | 288 | setActiveWindow(); |
280 | raise(); | 289 | raise(); |
281 | mSuspendSpin->setFocus(); | 290 | mSuspendSpin->setFocus(); |
282 | |||
283 | |||
284 | qApp->processEvents(); | ||
285 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 291 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
286 | ++alarmCounter; | 292 | ++alarmCounter; |
287 | #ifdef DESKTOP_VERSION | 293 | #ifdef DESKTOP_VERSION |
288 | mPlayWav = true; | 294 | mPlayWav = true; |
289 | #endif | 295 | #endif |
290 | if ( !mPlayWav || mFileName.length() < 2 ) { | 296 | if ( !mPlayWav || mFileName.length() < 2 ) { |
291 | 297 | ||
292 | #ifdef DESKTOP_VERSION | 298 | #ifdef DESKTOP_VERSION |
293 | qDebug("Sound play not possible - file not found"); | 299 | qDebug("Sound play not possible - file not found"); |
294 | #else | 300 | #else |
295 | Sound::soundAlarm (); | 301 | Sound::soundAlarm (); |
296 | #endif | 302 | #endif |
297 | } else | 303 | } else |
298 | 304 | ||
299 | { | 305 | { |
300 | #ifdef DESKTOP_VERSION | 306 | #ifdef DESKTOP_VERSION |
301 | #ifdef _WIN32_ | 307 | #ifdef _WIN32_ |
302 | QSound::play ( mFileName ); | 308 | QSound::play ( mFileName ); |
303 | #else | 309 | #else |
304 | 310 | ||
305 | QString command = "playwave -r 22050 " + mFileName; | 311 | QString command = "playwave -r 22050 " + mFileName; |
306 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); | 312 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); |
307 | int ret = system ( command.latin1() ); | 313 | int ret = system ( command.latin1() ); |
308 | if ( ret != 0 ) { | 314 | if ( ret != 0 ) { |
309 | qDebug("Sound play command failed: %s ",command.latin1() ); | 315 | qDebug("Sound play command failed: %s ",command.latin1() ); |
310 | } | 316 | } |
311 | 317 | ||
312 | #endif | 318 | #endif |
313 | 319 | ||
314 | #else | 320 | #else |
315 | QSound::play ( mFileName ); | 321 | QSound::play ( mFileName ); |
316 | #endif | 322 | #endif |
317 | qDebug("BEEP!"); | 323 | qDebug("BEEP!"); |
318 | } | 324 | } |
319 | } else { | 325 | } else { |
320 | if ( ! mSilent && mSuspendCounter > 0 ) { | 326 | if ( ! mSilent && mSuspendCounter > 0 ) { |
321 | --mSuspendCounter; | 327 | --mSuspendCounter; |
322 | reject (); | 328 | reject (); |
323 | hide(); | 329 | hide(); |
324 | return; | 330 | return; |
325 | } | 331 | } |
326 | } | 332 | } |
327 | playSoundTimer->start( mPauseCount * 1000, true ); | 333 | playSoundTimer->start( mPauseCount * 1000, true ); |
328 | } | 334 | } |
diff --git a/kalarmd/alarmdialog.h b/kalarmd/alarmdialog.h index 1e4636c..52e681a 100644 --- a/kalarmd/alarmdialog.h +++ b/kalarmd/alarmdialog.h | |||
@@ -1,85 +1,87 @@ | |||
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 | #ifndef ALARMDIALOG_H | 23 | #ifndef ALARMDIALOG_H |
24 | #define ALARMDIALOG_H | 24 | #define ALARMDIALOG_H |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | 33 | ||
34 | #include "sharp_char.h" | 34 | #include "sharp_char.h" |
35 | 35 | ||
36 | 36 | ||
37 | class QSpinBox; | 37 | class QSpinBox; |
38 | class QLabel; | 38 | class QLabel; |
39 | class QString; | 39 | class QString; |
40 | 40 | ||
41 | class AlarmDialog : public QDialog { | 41 | class AlarmDialog : public QDialog { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | AlarmDialog( QWidget *parent = 0, const char *name = 0 ); | 44 | AlarmDialog( QWidget *parent = 0, const char *name = 0 ); |
45 | virtual ~AlarmDialog(); | 45 | virtual ~AlarmDialog(); |
46 | 46 | ||
47 | bool eventNotification(QString m, int replay , QString m2 , bool, int, int ); | 47 | bool eventNotification(QString m, int replay , QString m2 , bool, int, int ); |
48 | int getSuspendTime( ); | 48 | int getSuspendTime( ); |
49 | void setSuspendTime( int ); | 49 | void setSuspendTime( int ); |
50 | void setServerNotification( bool b ); | 50 | void setServerNotification( bool b ); |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | void forceRepaint(); | ||
53 | void spinBoxChanged( int ); | 54 | void spinBoxChanged( int ); |
54 | void slotOk(); | 55 | void slotOk(); |
55 | void slotSuspend(); | 56 | void slotSuspend(); |
56 | void reject () ; | 57 | void reject () ; |
57 | void silent () ; | 58 | void silent () ; |
58 | void accept(); | 59 | void accept(); |
59 | void suspend(); | 60 | void suspend(); |
60 | void playSound (); | 61 | void playSound (); |
61 | signals: | 62 | signals: |
62 | // void suspendSignal(int duration); | 63 | // void suspendSignal(int duration); |
63 | void addAlarm(const QDateTime &, const QString & ); | 64 | void addAlarm(const QDateTime &, const QString & ); |
64 | 65 | ||
65 | private: | 66 | private: |
67 | QPushButton* okbut; | ||
66 | int alarmCounter; | 68 | int alarmCounter; |
67 | int mPauseCount; | 69 | int mPauseCount; |
68 | int mSuspendCounter; | 70 | int mSuspendCounter; |
69 | int maxAlarmReplay; | 71 | int maxAlarmReplay; |
70 | QTimer* playSoundTimer; | 72 | QTimer* playSoundTimer; |
71 | bool mStopAlarm; | 73 | bool mStopAlarm; |
72 | bool mSilent; | 74 | bool mSilent; |
73 | bool mPlayWav; | 75 | bool mPlayWav; |
74 | bool mServerNotification; | 76 | bool mServerNotification; |
75 | QLabel* mMessage; | 77 | QLabel* mMessage; |
76 | QLabel* mMissedAlarms; | 78 | QLabel* mMissedAlarms; |
77 | QSpinBox *mSuspendSpin; | 79 | QSpinBox *mSuspendSpin; |
78 | QComboBox *mMissedAlarmsCombo; | 80 | QComboBox *mMissedAlarmsCombo; |
79 | QPushButton* mSuspendButton; | 81 | QPushButton* mSuspendButton; |
80 | QString mFileName; | 82 | QString mFileName; |
81 | int fd_led; | 83 | int fd_led; |
82 | sharp_led_status statusLED; | 84 | sharp_led_status statusLED; |
83 | }; | 85 | }; |
84 | 86 | ||
85 | #endif | 87 | #endif |
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index 294ce7d..2a463b3 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -116,571 +116,574 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | |||
116 | mPopUp->insertSeparator(); | 116 | mPopUp->insertSeparator(); |
117 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | 117 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); |
118 | 118 | ||
119 | mPopUp->resize( mPopUp->sizeHint() ); | 119 | mPopUp->resize( mPopUp->sizeHint() ); |
120 | mPlayBeeps = 60; | 120 | mPlayBeeps = 60; |
121 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 121 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
122 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | 122 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); |
123 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | 123 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); |
124 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | 124 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); |
125 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | 125 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); |
126 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | 126 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); |
127 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | 127 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); |
128 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | 128 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); |
129 | mTimerTime = 0; | 129 | mTimerTime = 0; |
130 | mCustomText = "Custom Text"; | 130 | mCustomText = "Custom Text"; |
131 | mCustomMinutes = 7; | 131 | mCustomMinutes = 7; |
132 | mTimerPopupConf = 1; | 132 | mTimerPopupConf = 1; |
133 | fillTimerPopUp(); | 133 | fillTimerPopUp(); |
134 | mPausePlay = 0; | 134 | mPausePlay = 0; |
135 | confPause( 1 ); | 135 | confPause( 1 ); |
136 | mSuspend = 0; | 136 | mSuspend = 0; |
137 | confSuspend( 0 ); | 137 | confSuspend( 0 ); |
138 | if ( QApplication::desktop()->width() < 480 ) { | 138 | if ( QApplication::desktop()->width() < 480 ) { |
139 | wavAlarm = false; | 139 | wavAlarm = false; |
140 | mSoundPopUp->setItemChecked ( 0, true ); | 140 | mSoundPopUp->setItemChecked ( 0, true ); |
141 | } | 141 | } |
142 | else { | 142 | else { |
143 | wavAlarm = true; | 143 | wavAlarm = true; |
144 | mSoundPopUp->setItemChecked ( 1, true ); | 144 | mSoundPopUp->setItemChecked ( 1, true ); |
145 | } | 145 | } |
146 | saveSlot( 1 ); | 146 | saveSlot( 1 ); |
147 | } | 147 | } |
148 | 148 | ||
149 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 149 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
150 | { | 150 | { |
151 | //delete mPopUp; | 151 | //delete mPopUp; |
152 | delete mAlarmDialog; | 152 | delete mAlarmDialog; |
153 | } | 153 | } |
154 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 154 | void SimpleAlarmDaemonImpl::saveSlot( int load ) |
155 | { | 155 | { |
156 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | 156 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; |
157 | //qDebug("save %d ", load ); | 157 | //qDebug("save %d ", load ); |
158 | QFile file( fileName ); | 158 | QFile file( fileName ); |
159 | if ( load ) { | 159 | if ( load ) { |
160 | if( !QFile::exists( fileName) ) | 160 | if( !QFile::exists( fileName) ) |
161 | return; | 161 | return; |
162 | if (!file.open( IO_ReadOnly ) ) { | 162 | if (!file.open( IO_ReadOnly ) ) { |
163 | return ; | 163 | return ; |
164 | } | 164 | } |
165 | QString line; | 165 | QString line; |
166 | bool ok; | 166 | bool ok; |
167 | int val; | 167 | int val; |
168 | int len; | 168 | int len; |
169 | while ( file.readLine( line, 1024 ) > 0 ) { | 169 | while ( file.readLine( line, 1024 ) > 0 ) { |
170 | //qDebug("read %s ", line.latin1()); | 170 | //qDebug("read %s ", line.latin1()); |
171 | len = line.length(); | 171 | len = line.length(); |
172 | if ( line.left(4 ) == "PPAU" ) { | 172 | if ( line.left(4 ) == "PPAU" ) { |
173 | val = line.mid( 4,len-5).toInt( &ok ); | 173 | val = line.mid( 4,len-5).toInt( &ok ); |
174 | if ( ok ) { | 174 | if ( ok ) { |
175 | confPause( val ); | 175 | confPause( val ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | if ( line.left(4 ) == "SUCO" ) { | 178 | if ( line.left(4 ) == "SUCO" ) { |
179 | val = line.mid( 4,len-5).toInt( &ok ); | 179 | val = line.mid( 4,len-5).toInt( &ok ); |
180 | if ( ok ) | 180 | if ( ok ) |
181 | confSuspend ( val ); | 181 | confSuspend ( val ); |
182 | } | 182 | } |
183 | if ( line.left(4 ) == "WAAL" ) { | 183 | if ( line.left(4 ) == "WAAL" ) { |
184 | val = line.mid( 4,len-5).toInt( &ok ); | 184 | val = line.mid( 4,len-5).toInt( &ok ); |
185 | if ( ok ) | 185 | if ( ok ) |
186 | confSound( val ); | 186 | confSound( val ); |
187 | 187 | ||
188 | } | 188 | } |
189 | if ( line.left(4 ) == "PLBE" ) { | 189 | if ( line.left(4 ) == "PLBE" ) { |
190 | val = line.mid( 4,len-5).toInt( &ok ); | 190 | val = line.mid( 4,len-5).toInt( &ok ); |
191 | if ( ok ) | 191 | if ( ok ) |
192 | slotPlayBeep( val ); | 192 | slotPlayBeep( val ); |
193 | 193 | ||
194 | } | 194 | } |
195 | if ( line.left(4 ) == "CUTE" ) { | 195 | if ( line.left(4 ) == "CUTE" ) { |
196 | mCustomText = line.mid( 5,len-6); | 196 | mCustomText = line.mid( 5,len-6); |
197 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | 197 | // qDebug("text ***%s*** ",mCustomText.latin1() ); |
198 | 198 | ||
199 | } | 199 | } |
200 | if ( line.left(4 ) == "CUMI" ) { | 200 | if ( line.left(4 ) == "CUMI" ) { |
201 | val = line.mid( 4,len-5).toInt( &ok ); | 201 | val = line.mid( 4,len-5).toInt( &ok ); |
202 | if ( ok ) | 202 | if ( ok ) |
203 | mCustomMinutes = val; | 203 | mCustomMinutes = val; |
204 | 204 | ||
205 | } | 205 | } |
206 | if ( line.left(4 ) == "SUTI" ) { | 206 | if ( line.left(4 ) == "SUTI" ) { |
207 | val = line.mid( 4,len-5).toInt( &ok ); | 207 | val = line.mid( 4,len-5).toInt( &ok ); |
208 | if ( ok ) | 208 | if ( ok ) |
209 | mAlarmDialog->setSuspendTime( val );; | 209 | mAlarmDialog->setSuspendTime( val );; |
210 | 210 | ||
211 | } | 211 | } |
212 | } | 212 | } |
213 | file.close(); | 213 | file.close(); |
214 | } else { | 214 | } else { |
215 | if (!file.open( IO_WriteOnly ) ) { | 215 | if (!file.open( IO_WriteOnly ) ) { |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | QString configString ; | 218 | QString configString ; |
219 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | 219 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; |
220 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | 220 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; |
221 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 221 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
222 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 222 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
223 | configString += "CUTE " + mCustomText + "\n"; | 223 | configString += "CUTE " + mCustomText + "\n"; |
224 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 224 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
225 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 225 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
226 | QTextStream ts( &file ); | 226 | QTextStream ts( &file ); |
227 | ts << configString ; | 227 | ts << configString ; |
228 | file.close(); | 228 | file.close(); |
229 | } | 229 | } |
230 | 230 | ||
231 | } | 231 | } |
232 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 232 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
233 | { | 233 | { |
234 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 234 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
235 | mSuspend = num; | 235 | mSuspend = num; |
236 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 236 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
237 | } | 237 | } |
238 | void SimpleAlarmDaemonImpl::confPause( int num ) | 238 | void SimpleAlarmDaemonImpl::confPause( int num ) |
239 | { | 239 | { |
240 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 240 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
241 | mPausePlay = num; | 241 | mPausePlay = num; |
242 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 242 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
243 | } | 243 | } |
244 | void SimpleAlarmDaemonImpl::confSound( int num ) | 244 | void SimpleAlarmDaemonImpl::confSound( int num ) |
245 | { | 245 | { |
246 | if ( num == 0 ) { | 246 | if ( num == 0 ) { |
247 | wavAlarm = false; | 247 | wavAlarm = false; |
248 | mSoundPopUp->setItemChecked ( 0, true ); | 248 | mSoundPopUp->setItemChecked ( 0, true ); |
249 | mSoundPopUp->setItemChecked ( 1, false ); | 249 | mSoundPopUp->setItemChecked ( 1, false ); |
250 | } else { | 250 | } else { |
251 | wavAlarm = true; | 251 | wavAlarm = true; |
252 | mSoundPopUp->setItemChecked ( 0, false ); | 252 | mSoundPopUp->setItemChecked ( 0, false ); |
253 | mSoundPopUp->setItemChecked ( 1, true ); | 253 | mSoundPopUp->setItemChecked ( 1, true ); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 256 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
257 | { | 257 | { |
258 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 258 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
259 | mPlayBeeps = num; | 259 | mPlayBeeps = num; |
260 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 260 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 263 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
264 | { | 264 | { |
265 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 265 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
266 | QString mess = msg; | 266 | QString mess = msg; |
267 | mAlarmMessage = mess.mid( 9 ); | 267 | mAlarmMessage = mess.mid( 9 ); |
268 | QString filename = getenv("QPEDIR") ; | 268 | QString filename = getenv("QPEDIR") ; |
269 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 269 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
270 | QString tempfilename; | 270 | QString tempfilename; |
271 | if ( mess.left( 13 ) == "suspend_alarm") { | 271 | if ( mess.left( 13 ) == "suspend_alarm") { |
272 | bool error = false; | 272 | bool error = false; |
273 | int len = mess.mid( 13 ).find("+++"); | 273 | int len = mess.mid( 13 ).find("+++"); |
274 | if ( len < 2 ) | 274 | if ( len < 2 ) |
275 | error = true; | 275 | error = true; |
276 | else { | 276 | else { |
277 | tempfilename = mess.mid( 13, len ); | 277 | tempfilename = mess.mid( 13, len ); |
278 | if ( !QFile::exists( tempfilename ) ) | 278 | if ( !QFile::exists( tempfilename ) ) |
279 | error = true; | 279 | error = true; |
280 | } | 280 | } |
281 | if ( ! error ) { | 281 | if ( ! error ) { |
282 | filename = tempfilename; | 282 | filename = tempfilename; |
283 | } | 283 | } |
284 | mAlarmMessage = mess.mid( 13+len+3 ); | 284 | mAlarmMessage = mess.mid( 13+len+3 ); |
285 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 285 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
286 | startAlarm( mAlarmMessage, filename); | 286 | startAlarm( mAlarmMessage, filename); |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | if ( mess.left( 11 ) == "timer_alarm") { | 289 | if ( mess.left( 11 ) == "timer_alarm") { |
290 | mTimerTime = 0; | 290 | mTimerTime = 0; |
291 | startAlarm( mess.mid( 11 ), filename ); | 291 | startAlarm( mess.mid( 11 ), filename ); |
292 | return; | 292 | return; |
293 | } | 293 | } |
294 | if ( mess.left( 10 ) == "proc_alarm") { | 294 | if ( mess.left( 10 ) == "proc_alarm") { |
295 | bool error = false; | 295 | bool error = false; |
296 | int len = mess.mid( 10 ).find("+++"); | 296 | int len = mess.mid( 10 ).find("+++"); |
297 | if ( len < 2 ) | 297 | if ( len < 2 ) |
298 | error = true; | 298 | error = true; |
299 | else { | 299 | else { |
300 | tempfilename = mess.mid( 10, len ); | 300 | tempfilename = mess.mid( 10, len ); |
301 | if ( !QFile::exists( tempfilename ) ) | 301 | if ( !QFile::exists( tempfilename ) ) |
302 | error = true; | 302 | error = true; |
303 | } | 303 | } |
304 | if ( error ) { | 304 | if ( error ) { |
305 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 305 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
306 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 306 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
307 | } else { | 307 | } else { |
308 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 308 | { |
309 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | ||
310 | } | ||
309 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 311 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
310 | if ( vfork () == 0 ) { | 312 | if ( vfork () == 0 ) { |
311 | execl ( tempfilename.latin1(), 0 ); | 313 | execl ( tempfilename.latin1(), 0 ); |
312 | return; | 314 | return; |
313 | } | 315 | } |
314 | return; | 316 | return; |
315 | } | 317 | } |
316 | 318 | ||
317 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 319 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
318 | } | 320 | } |
319 | if ( mess.left( 11 ) == "audio_alarm") { | 321 | if ( mess.left( 11 ) == "audio_alarm") { |
320 | bool error = false; | 322 | bool error = false; |
321 | int len = mess.mid( 11 ).find("+++"); | 323 | int len = mess.mid( 11 ).find("+++"); |
322 | if ( len < 2 ) | 324 | if ( len < 2 ) |
323 | error = true; | 325 | error = true; |
324 | else { | 326 | else { |
325 | tempfilename = mess.mid( 11, len ); | 327 | tempfilename = mess.mid( 11, len ); |
326 | if ( !QFile::exists( tempfilename ) ) | 328 | if ( !QFile::exists( tempfilename ) ) |
327 | error = true; | 329 | error = true; |
328 | } | 330 | } |
329 | if ( ! error ) { | 331 | if ( ! error ) { |
330 | filename = tempfilename; | 332 | filename = tempfilename; |
331 | } | 333 | } |
332 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 334 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
333 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 335 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
334 | } | 336 | } |
335 | if ( mess.left( 9 ) == "cal_alarm") { | 337 | if ( mess.left( 9 ) == "cal_alarm") { |
336 | mAlarmMessage = mess.mid( 9 ) ; | 338 | mAlarmMessage = mess.mid( 9 ) ; |
337 | } | 339 | } |
338 | 340 | ||
339 | writeFile(); | 341 | writeFile(); |
340 | startAlarm( mAlarmMessage, filename ); | 342 | startAlarm( mAlarmMessage, filename ); |
341 | 343 | ||
342 | } | 344 | } |
343 | 345 | ||
344 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 346 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
345 | { | 347 | { |
346 | return 0; | 348 | return 0; |
347 | } | 349 | } |
348 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 350 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
349 | { | 351 | { |
350 | //mAlarmDialog->show(); | 352 | //mAlarmDialog->show(); |
351 | //mAlarmDialog->raise(); | 353 | //mAlarmDialog->raise(); |
352 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 354 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
353 | } | 355 | } |
354 | 356 | ||
355 | 357 | ||
356 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 358 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
357 | { | 359 | { |
358 | 360 | ||
359 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 361 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
360 | if ( mTimerPopupConf == mTimerTime ) { | 362 | if ( mTimerPopupConf == mTimerTime ) { |
361 | if ( mTimerTime ) { | 363 | if ( mTimerTime ) { |
362 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 364 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
363 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 365 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
364 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 366 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
365 | } | 367 | } |
366 | else { | 368 | else { |
367 | QString text = mCustomText.stripWhiteSpace (); | 369 | QString text = mCustomText.stripWhiteSpace (); |
368 | int in = text.find( " " ); | 370 | int in = text.find( " " ); |
369 | text = text.left ( in ); | 371 | text = text.left ( in ); |
370 | mTimerPopUp->changeItem ( 3, text ); | 372 | mTimerPopUp->changeItem ( 3, text ); |
371 | } | 373 | } |
372 | return; | 374 | return; |
373 | } | 375 | } |
374 | mTimerPopupConf = mTimerTime; | 376 | mTimerPopupConf = mTimerTime; |
375 | mTimerPopUp->clear(); | 377 | mTimerPopUp->clear(); |
376 | if ( mTimerTime ) { | 378 | if ( mTimerTime ) { |
377 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 379 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
378 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 380 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
379 | 381 | ||
380 | 382 | ||
381 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); | 383 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); |
382 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); | 384 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); |
383 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); | 385 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); |
384 | } else { | 386 | } else { |
385 | 387 | ||
386 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 388 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
387 | QFile file( fileName ); | 389 | QFile file( fileName ); |
388 | if( !QFile::exists( fileName) ) { | 390 | if( !QFile::exists( fileName) ) { |
389 | // write defaults | 391 | // write defaults |
390 | if (!file.open( IO_WriteOnly ) ) { | 392 | if (!file.open( IO_WriteOnly ) ) { |
391 | return; | 393 | return; |
392 | } | 394 | } |
393 | QString configString ; | 395 | QString configString ; |
394 | configString += "#config file for kopi alarm timer\n"; | 396 | configString += "#config file for kopi alarm timer\n"; |
395 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 397 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
396 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; | 398 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; |
397 | configString += "24 h; 1440\n"; | 399 | configString += "24 h; 1440\n"; |
398 | configString += " 8 h; 480\n"; | 400 | configString += " 8 h; 480\n"; |
399 | configString += " 5 h; 300\n"; | 401 | configString += " 5 h; 300\n"; |
400 | configString += " 1 h; 60\n"; | 402 | configString += " 1 h; 60\n"; |
401 | configString += "30 min; 30\n"; | 403 | configString += "30 min; 30\n"; |
402 | configString += "15 min; 15\n"; | 404 | configString += "15 min; 15\n"; |
403 | configString += "SEPARATOR\n"; | 405 | configString += "SEPARATOR\n"; |
404 | configString += "Pizza; 22\n"; | 406 | configString += "Pizza; 22\n"; |
405 | configString += "Nap; 45\n"; | 407 | configString += "Nap; 45\n"; |
406 | configString += "Tea; 5\n"; | 408 | configString += "Tea; 5\n"; |
407 | QTextStream ts( &file ); | 409 | QTextStream ts( &file ); |
408 | ts << configString ; | 410 | ts << configString ; |
409 | file.close(); | 411 | file.close(); |
410 | } | 412 | } |
411 | 413 | ||
412 | if (!file.open( IO_ReadOnly ) ) { | 414 | if (!file.open( IO_ReadOnly ) ) { |
413 | return ; | 415 | return ; |
414 | } | 416 | } |
415 | QString line; | 417 | QString line; |
416 | bool ok; | 418 | bool ok; |
417 | while ( file.readLine( line, 1024 ) > 0 ) { | 419 | while ( file.readLine( line, 1024 ) > 0 ) { |
418 | //qDebug("read %s ", line.latin1()); | 420 | //qDebug("read %s ", line.latin1()); |
419 | if ( line.left(1 ) != "#" ) { | 421 | if ( line.left(1 ) != "#" ) { |
420 | // no comment | 422 | // no comment |
421 | if ( line.left(9 ) == "SEPARATOR" ) { | 423 | if ( line.left(9 ) == "SEPARATOR" ) { |
422 | mTimerPopUp->insertSeparator(); | 424 | mTimerPopUp->insertSeparator(); |
423 | } else { | 425 | } else { |
424 | QStringList li = QStringList::split(";",line); | 426 | QStringList li = QStringList::split(";",line); |
425 | ok = false; | 427 | ok = false; |
426 | if ( li.count() == 2 ) { | 428 | if ( li.count() == 2 ) { |
427 | int val = li[1].toInt( &ok ); | 429 | int val = li[1].toInt( &ok ); |
428 | if ( ok && val > 2 ) { | 430 | if ( ok && val > 2 ) { |
429 | mTimerPopUp->insertItem( li[0], val); | 431 | mTimerPopUp->insertItem( li[0], val); |
430 | } | 432 | } |
431 | } | 433 | } |
432 | } | 434 | } |
433 | } | 435 | } |
434 | } | 436 | } |
435 | file.close(); | 437 | file.close(); |
436 | #if 0 | 438 | #if 0 |
437 | mTimerPopUp->insertItem( "24 h", 1440 ); | 439 | mTimerPopUp->insertItem( "24 h", 1440 ); |
438 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 440 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
439 | mTimerPopUp->insertItem( " 8 h", 480 ); | 441 | mTimerPopUp->insertItem( " 8 h", 480 ); |
440 | mTimerPopUp->insertItem( " 5 h", 300 ); | 442 | mTimerPopUp->insertItem( " 5 h", 300 ); |
441 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 443 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
442 | mTimerPopUp->insertItem( " 1 h", 60 ); | 444 | mTimerPopUp->insertItem( " 1 h", 60 ); |
443 | mTimerPopUp->insertItem( "30 min", 30 ); | 445 | mTimerPopUp->insertItem( "30 min", 30 ); |
444 | mTimerPopUp->insertItem( "15 min", 15 ); | 446 | mTimerPopUp->insertItem( "15 min", 15 ); |
445 | mTimerPopUp->insertItem( "10 min", 10 ); | 447 | mTimerPopUp->insertItem( "10 min", 10 ); |
446 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 448 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
447 | mTimerPopUp->insertSeparator(); | 449 | mTimerPopUp->insertSeparator(); |
448 | mTimerPopUp->insertItem( "Pizza", 22 ); | 450 | mTimerPopUp->insertItem( "Pizza", 22 ); |
449 | mTimerPopUp->insertItem( "Nap", 45 ); | 451 | mTimerPopUp->insertItem( "Nap", 45 ); |
450 | mTimerPopUp->insertItem( "Tea", 5 ); | 452 | mTimerPopUp->insertItem( "Tea", 5 ); |
451 | #endif | 453 | #endif |
452 | QString text = mCustomText.stripWhiteSpace (); | 454 | QString text = mCustomText.stripWhiteSpace (); |
453 | int in = text.find( " " ); | 455 | int in = text.find( " " ); |
454 | text = text.left ( in ); | 456 | text = text.left ( in ); |
455 | mTimerPopUp->insertItem( text, 3 ); | 457 | mTimerPopUp->insertItem( text, 3 ); |
456 | mTimerPopUp->insertSeparator(); | 458 | mTimerPopUp->insertSeparator(); |
457 | mTimerPopUp->insertItem( "Customize", 2 ); | 459 | mTimerPopUp->insertItem( "Customize", 2 ); |
458 | } | 460 | } |
459 | 461 | ||
460 | } | 462 | } |
461 | 463 | ||
462 | void SimpleAlarmDaemonImpl::showTimer() | 464 | void SimpleAlarmDaemonImpl::showTimer() |
463 | { | 465 | { |
464 | fillTimerPopUp(); | 466 | fillTimerPopUp(); |
465 | } | 467 | } |
466 | 468 | ||
467 | void SimpleAlarmDaemonImpl::confTimer( int time ) | 469 | void SimpleAlarmDaemonImpl::confTimer( int time ) |
468 | { | 470 | { |
469 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 471 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
470 | int minutes = time; | 472 | int minutes = time; |
471 | if ( minutes == 0 ) { | 473 | if ( minutes == 0 ) { |
472 | if ( ! mTimerTime ) | 474 | if ( ! mTimerTime ) |
473 | return; | 475 | return; |
474 | 476 | ||
475 | QDialog dia ( 0, ("Stop Timer" ), true ); | 477 | QDialog dia ( 0, ("Stop Timer" ), true ); |
476 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); | 478 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); |
477 | lab.setAlignment( AlignCenter ); | 479 | lab.setAlignment( AlignCenter ); |
478 | dia.setCaption(("KO/Pi Timer Stop" )); | 480 | dia.setCaption(("KO/Pi Timer Stop" )); |
479 | QVBoxLayout lay( &dia ); | 481 | QVBoxLayout lay( &dia ); |
480 | lay.addWidget( &lab); | 482 | lay.addWidget( &lab); |
481 | QPushButton ok ( "Stop timer!", &dia); | 483 | QPushButton ok ( "Stop timer!", &dia); |
482 | QFont fo = dia.font(); | 484 | QFont fo = dia.font(); |
483 | fo.setPointSize( 36 ); | 485 | fo.setPointSize( 36 ); |
484 | ok.setFont( fo ); | 486 | ok.setFont( fo ); |
485 | lay.addWidget( &ok); | 487 | lay.addWidget( &ok); |
486 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 488 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
487 | QPushButton con ( "Continue timer!", &dia); | 489 | QPushButton con ( "Continue timer!", &dia); |
488 | fo.setPointSize( 36 ); | 490 | fo.setPointSize( 36 ); |
489 | con.setFont( fo ); | 491 | con.setFont( fo ); |
490 | lay.addWidget( &con); | 492 | lay.addWidget( &con); |
491 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 493 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
492 | lay.setMargin(5); | 494 | lay.setMargin(5); |
493 | lay.setSpacing(5); | 495 | lay.setSpacing(5); |
494 | dia.resize(dia.sizeHint() ); | 496 | dia.resize(dia.sizeHint() ); |
495 | 497 | ||
496 | if ( !dia.exec() ) | 498 | if ( !dia.exec() ) |
497 | return; | 499 | return; |
498 | 500 | ||
499 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 501 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); |
500 | mTimerTime = 0; | 502 | mTimerTime = 0; |
501 | return; | 503 | return; |
502 | } | 504 | } |
503 | if ( mTimerTime ) | 505 | if ( mTimerTime ) |
504 | return; | 506 | return; |
505 | if ( minutes == 1 ) { | 507 | if ( minutes == 1 ) { |
506 | return; | 508 | return; |
507 | } | 509 | } |
508 | QString mess = "timer_alarm"; | 510 | QString mess = "timer_alarm"; |
509 | mess += ("Timer Alarm!\n"); | 511 | mess += ("Timer Alarm!\n"); |
510 | if ( minutes == 22 ) { | 512 | if ( minutes == 22 ) { |
511 | mess += ( "Pizza is ready"); | 513 | mess += ( "Pizza is ready"); |
512 | mRunningTimerText = "Pizza"; | 514 | mRunningTimerText = "Pizza"; |
513 | } | 515 | } |
514 | else if ( minutes == 45 ) { | 516 | else if ( minutes == 45 ) { |
515 | mess += ( "Please wake up!"); | 517 | mess += ( "Please wake up!"); |
516 | mRunningTimerText = "Nap"; | 518 | mRunningTimerText = "Nap"; |
517 | } | 519 | } |
518 | else if ( minutes == 5 ) { | 520 | else if ( minutes == 5 ) { |
519 | mess += ( "Tea is ready"); | 521 | mess += ( "Tea is ready"); |
520 | mRunningTimerText = "Tea"; | 522 | mRunningTimerText = "Tea"; |
521 | } | 523 | } |
522 | else if ( minutes == 3 ) { | 524 | else if ( minutes == 3 ) { |
523 | mess += mCustomText; | 525 | mess += mCustomText; |
524 | minutes = mCustomMinutes ; | 526 | minutes = mCustomMinutes ; |
525 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 527 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
526 | int in = mRunningTimerText.find( " " ); | 528 | int in = mRunningTimerText.find( " " ); |
527 | mRunningTimerText = mRunningTimerText.left ( in ); | 529 | mRunningTimerText = mRunningTimerText.left ( in ); |
528 | } | 530 | } |
529 | else { | 531 | else { |
530 | if ( minutes == 2 ) { | 532 | if ( minutes == 2 ) { |
531 | // ask time | 533 | // ask time |
532 | QDialog dia ( 0, ("Customize Timer" ), true ); | 534 | QDialog dia ( 0, ("Customize Timer" ), true ); |
533 | QLabel lab (("Message Text:"), &dia ); | 535 | QLabel lab (("Message Text:"), &dia ); |
534 | dia.setCaption(("KO/Pi Timer" )); | 536 | dia.setCaption(("KO/Pi Timer" )); |
535 | QVBoxLayout lay( &dia ); | 537 | QVBoxLayout lay( &dia ); |
536 | lay.setMargin(5); | 538 | lay.setMargin(5); |
537 | lay.setSpacing(5); | 539 | lay.setSpacing(5); |
538 | lay.addWidget( &lab); | 540 | lay.addWidget( &lab); |
539 | QLineEdit lEdit( mCustomText, &dia ); | 541 | QLineEdit lEdit( mCustomText, &dia ); |
540 | lay.addWidget( &lEdit); | 542 | lay.addWidget( &lEdit); |
541 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 543 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
542 | lay.addWidget( &lab2); | 544 | lay.addWidget( &lab2); |
543 | QHBox hbox1 ( &dia ); | 545 | QHBox hbox1 ( &dia ); |
544 | lay.addWidget( &hbox1); | 546 | lay.addWidget( &hbox1); |
545 | QLabel lab3 (("Hours"), &hbox1 ); | 547 | QLabel lab3 (("Hours"), &hbox1 ); |
546 | QLabel lab4 (("Minutes"), &hbox1 ); | 548 | QLabel lab4 (("Minutes"), &hbox1 ); |
547 | QHBox hbox ( &dia ); | 549 | QHBox hbox ( &dia ); |
548 | QSpinBox spinh( 0, 24, 1,& hbox ); | 550 | QSpinBox spinh( 0, 24, 1,& hbox ); |
549 | QFont fo = dia.font(); | 551 | QFont fo = dia.font(); |
550 | fo.setPointSize( 36 ); | 552 | fo.setPointSize( 36 ); |
551 | QSpinBox spinm( 0, 59, 1,&hbox ); | 553 | QSpinBox spinm( 0, 59, 1,&hbox ); |
552 | spinm.setFont( fo ); | 554 | spinm.setFont( fo ); |
553 | spinh.setFont( fo ); | 555 | spinh.setFont( fo ); |
554 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 556 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
555 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 557 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
556 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 558 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
557 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 559 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
558 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 560 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
559 | spinh.setFixedSize( 100,62 ); | 561 | spinh.setFixedSize( 100,62 ); |
560 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 562 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
561 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 563 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
562 | spinm.downButton ()->setGeometry( 50,50,50,50); | 564 | spinm.downButton ()->setGeometry( 50,50,50,50); |
563 | // spinm.setSuffix( " m" ); | 565 | // spinm.setSuffix( " m" ); |
564 | //spinh.setSuffix( " h" ); | 566 | //spinh.setSuffix( " h" ); |
565 | spinm.setWrapping ( true ); | 567 | spinm.setWrapping ( true ); |
566 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 568 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
567 | spinm.setLineStep( 1 ); | 569 | spinm.setLineStep( 1 ); |
568 | spinm.setFixedSize( 110,62 ); | 570 | spinm.setFixedSize( 110,62 ); |
569 | lay.addWidget( &hbox); | 571 | lay.addWidget( &hbox); |
570 | QLabel lab5 ("Timer fires at:", &dia ); | 572 | QLabel lab5 ("Timer fires at:", &dia ); |
571 | lab5.setAlignment( AlignCenter ); | 573 | lab5.setAlignment( AlignCenter ); |
572 | lay.addWidget( &lab5); | 574 | lay.addWidget( &lab5); |
573 | KODateLabel dl ( &dia ); | 575 | KODateLabel dl ( &dia ); |
574 | dl.setAlignment( AlignCenter ); | 576 | dl.setAlignment( AlignCenter ); |
575 | dl.setFont( fo ); | 577 | dl.setFont( fo ); |
576 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); | 578 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); |
577 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); | 579 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); |
578 | lay.addWidget( &dl); | 580 | lay.addWidget( &dl); |
579 | spinh.setValue( mCustomMinutes/60 ); | 581 | spinh.setValue( mCustomMinutes/60 ); |
580 | spinm.setValue( mCustomMinutes%60 ); | 582 | spinm.setValue( mCustomMinutes%60 ); |
581 | QPushButton ok ( "Start timer", &dia); | 583 | QPushButton ok ( "Start timer", &dia); |
582 | ok.setDefault( true ); | 584 | ok.setDefault( true ); |
583 | ok.setFont( fo ); | 585 | ok.setFont( fo ); |
584 | spinh.setFocus(); | 586 | spinh.setFocus(); |
585 | lay.addWidget( &ok); | 587 | lay.addWidget( &ok); |
586 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 588 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
587 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 589 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
588 | 590 | ||
589 | if ( !dia.exec() ) | 591 | if ( !dia.exec() ) |
590 | return; | 592 | return; |
591 | mCustomText = lEdit.text(); | 593 | mCustomText = lEdit.text(); |
592 | mCustomMinutes = spinh.value()*60+spinm.value(); | 594 | mCustomMinutes = spinh.value()*60+spinm.value(); |
593 | if ( mCustomMinutes == 0 ) | 595 | if ( mCustomMinutes == 0 ) |
594 | mCustomMinutes = 1; | 596 | mCustomMinutes = 1; |
595 | if ( mCustomMinutes > 1440 ) | 597 | if ( mCustomMinutes > 1440 ) |
596 | mCustomMinutes = 1440; | 598 | mCustomMinutes = 1440; |
597 | mess += mCustomText; | 599 | mess += mCustomText; |
598 | minutes = mCustomMinutes; | 600 | minutes = mCustomMinutes; |
599 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 601 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
600 | int in = mRunningTimerText.find( " " ); | 602 | int in = mRunningTimerText.find( " " ); |
601 | mRunningTimerText = mRunningTimerText.left ( in ); | 603 | mRunningTimerText = mRunningTimerText.left ( in ); |
602 | } | 604 | } |
603 | else { | 605 | else { |
604 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | 606 | mess+= QString::number ( minutes ) + ( " minutes are past!"); |
605 | int min = minutes; | 607 | int min = minutes; |
606 | if ( min % 60 == 0 ) | 608 | if ( min % 60 == 0 ) |
607 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); | 609 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); |
608 | else | 610 | else |
609 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); | 611 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); |
610 | } | 612 | } |
611 | } | 613 | } |
612 | //minutes = 1; | 614 | //minutes = 1; |
613 | 615 | ||
614 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 616 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
615 | timerMesssage = mess; | 617 | timerMesssage = mess; |
616 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); | 618 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); |
617 | mTimerTime = 1; | 619 | mTimerTime = 1; |
618 | } | 620 | } |
619 | 621 | ||
620 | void SimpleAlarmDaemonImpl::writeFile() | 622 | void SimpleAlarmDaemonImpl::writeFile() |
621 | { | 623 | { |
622 | QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 624 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
625 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | ||
623 | } | 626 | } |
624 | void SimpleAlarmDaemonImpl::showWN() | 627 | void SimpleAlarmDaemonImpl::showWN() |
625 | { | 628 | { |
626 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 629 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
627 | } | 630 | } |
628 | void SimpleAlarmDaemonImpl::newTodo() | 631 | void SimpleAlarmDaemonImpl::newTodo() |
629 | { | 632 | { |
630 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 633 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
631 | } | 634 | } |
632 | 635 | ||
633 | void SimpleAlarmDaemonImpl::newEvent() | 636 | void SimpleAlarmDaemonImpl::newEvent() |
634 | { | 637 | { |
635 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 638 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
636 | 639 | ||
637 | } | 640 | } |
638 | void SimpleAlarmDaemonImpl::newMail() | 641 | void SimpleAlarmDaemonImpl::newMail() |
639 | { | 642 | { |
640 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 643 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
641 | } | 644 | } |
642 | void SimpleAlarmDaemonImpl::showAdd() | 645 | void SimpleAlarmDaemonImpl::showAdd() |
643 | { | 646 | { |
644 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 647 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
645 | } | 648 | } |
646 | void SimpleAlarmDaemonImpl::ringSync() | 649 | void SimpleAlarmDaemonImpl::ringSync() |
647 | { | 650 | { |
648 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 651 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
649 | 652 | ||
650 | } | 653 | } |
651 | void SimpleAlarmDaemonImpl::newCountdown() | 654 | void SimpleAlarmDaemonImpl::newCountdown() |
652 | { | 655 | { |
653 | //recieve("cal_alarm", 10 ); | 656 | //recieve("cal_alarm", 10 ); |
654 | } | 657 | } |
655 | void SimpleAlarmDaemonImpl::simulate() | 658 | void SimpleAlarmDaemonImpl::simulate() |
656 | { | 659 | { |
657 | writeFile(); | 660 | writeFile(); |
658 | QString filename = getenv("QPEDIR") ; | 661 | QString filename = getenv("QPEDIR") ; |
659 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 662 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
660 | startAlarm("Alarm simulation", filename ); | 663 | startAlarm("Alarm simulation", filename ); |
661 | } | 664 | } |
662 | void SimpleAlarmDaemonImpl::showKO() | 665 | void SimpleAlarmDaemonImpl::showKO() |
663 | { | 666 | { |
664 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 667 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
665 | // testing only | 668 | // testing only |
666 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | 669 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); |
667 | 670 | ||
668 | } | 671 | } |
669 | void SimpleAlarmDaemonImpl::showTodo() | 672 | void SimpleAlarmDaemonImpl::showTodo() |
670 | { | 673 | { |
671 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 674 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
672 | 675 | ||
673 | } | 676 | } |
674 | void SimpleAlarmDaemonImpl::writeJournal() | 677 | void SimpleAlarmDaemonImpl::writeJournal() |
675 | { | 678 | { |
676 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 679 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
677 | 680 | ||
678 | } | 681 | } |
679 | 682 | ||
680 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 683 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
681 | { | 684 | { |
682 | 685 | ||
683 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 686 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
684 | 687 | ||
685 | } | 688 | } |
686 | 689 | ||