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