summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp3
-rw-r--r--noncore/tools/clock/setAlarm.cpp7
2 files changed, 8 insertions, 2 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 9b9e644..a47793b 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -1,499 +1,502 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002 20// changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002
21 21
22#include "clock.h" 22#include "clock.h"
23#include "setAlarm.h" 23#include "setAlarm.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/timestring.h> 28#include <qpe/timestring.h>
29#include <qpe/alarmserver.h> 29#include <qpe/alarmserver.h>
30#include <qpe/sound.h> 30#include <qpe/sound.h>
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#include <qsound.h> 32#include <qsound.h>
33#include <qtimer.h> 33#include <qtimer.h>
34 34
35#include <opie/oclickablelabel.h> 35#include <opie/oclickablelabel.h>
36 36
37#include <qlcdnumber.h> 37#include <qlcdnumber.h>
38#include <qslider.h> 38#include <qslider.h>
39#include <qlabel.h> 39#include <qlabel.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qtimer.h> 41#include <qtimer.h>
42#include <qpushbutton.h> 42#include <qpushbutton.h>
43#include <qradiobutton.h> 43#include <qradiobutton.h>
44#include <qbuttongroup.h> 44#include <qbuttongroup.h>
45#include <qpainter.h> 45#include <qpainter.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qdatetime.h> 47#include <qdatetime.h>
48 48
49#include <math.h> 49#include <math.h>
50 50
51const double deg2rad = 0.017453292519943295769; // pi/180 51const double deg2rad = 0.017453292519943295769; // pi/180
52const int sw_prec = 2; 52const int sw_prec = 2;
53 53
54static void toggleScreenSaver( bool on ) 54static void toggleScreenSaver( bool on )
55{ 55{
56 QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); 56 QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" );
57 e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend ); 57 e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend );
58} 58}
59 59
60Clock::Clock( QWidget * parent, const char * name, WFlags f ) 60Clock::Clock( QWidget * parent, const char * name, WFlags f )
61 : QVBox( parent, name , f ) 61 : QVBox( parent, name , f )
62{ 62{
63 setSpacing( 4 ); 63 setSpacing( 4 );
64 setMargin( 1 ); 64 setMargin( 1 );
65 65
66 Config config( "qpe" ); 66 Config config( "qpe" );
67 config.setGroup("Time"); 67 config.setGroup("Time");
68 ampm = config.readBoolEntry( "AMPM", TRUE ); 68 ampm = config.readBoolEntry( "AMPM", TRUE );
69 69
70 70
71 snoozeBtn = new QPushButton ( this); 71 snoozeBtn = new QPushButton ( this);
72 snoozeBtn->setText( tr( "Snooze" ) ); 72 snoozeBtn->setText( tr( "Snooze" ) );
73 73
74 aclock = new AnalogClock( this ); 74 aclock = new AnalogClock( this );
75 aclock->display( QTime::currentTime() ); 75 aclock->display( QTime::currentTime() );
76 aclock->setLineWidth( 2 ); 76 aclock->setLineWidth( 2 );
77 77
78 QHBox *hb = new QHBox( this ); 78 QHBox *hb = new QHBox( this );
79 hb->setMargin( 0 ); 79 hb->setMargin( 0 );
80 QWidget *space = new QWidget( hb ); 80 QWidget *space = new QWidget( hb );
81 lcd = new QLCDNumber( hb ); 81 lcd = new QLCDNumber( hb );
82 lcd->setSegmentStyle( QLCDNumber::Flat ); 82 lcd->setSegmentStyle( QLCDNumber::Flat );
83 lcd->setFrameStyle( QFrame::NoFrame ); 83 lcd->setFrameStyle( QFrame::NoFrame );
84 lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); 84 lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
85 lcd->setFixedHeight( 23 ); 85 lcd->setFixedHeight( 23 );
86 86
87 ampmLabel = new QLabel( tr("PM"), hb ); 87 ampmLabel = new QLabel( tr("PM"), hb );
88 ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); 88 ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) );
89 ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); 89 ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) );
90 ampmLabel->setAlignment( AlignLeft | AlignBottom ); 90 ampmLabel->setAlignment( AlignLeft | AlignBottom );
91 space = new QWidget( hb ); 91 space = new QWidget( hb );
92 92
93 date = new QLabel( this ); 93 date = new QLabel( this );
94 date->setAlignment( AlignHCenter | AlignVCenter ); 94 date->setAlignment( AlignHCenter | AlignVCenter );
95 date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); 95 date->setFont( QFont( "Helvetica", 14, QFont::Bold ) );
96 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 96 date->setText( TimeString::longDateString( QDate::currentDate() ) );
97 97
98 QWidget *controls = new QWidget( this ); 98 QWidget *controls = new QWidget( this );
99 QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 ); 99 QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 );
100 100
101 QButtonGroup *grp = new QButtonGroup( controls ); 101 QButtonGroup *grp = new QButtonGroup( controls );
102 grp->setRadioButtonExclusive( true ); 102 grp->setRadioButtonExclusive( true );
103 grp->hide(); 103 grp->hide();
104 104
105 clockRB = new QRadioButton ( tr( "Clock" ), controls ); 105 clockRB = new QRadioButton ( tr( "Clock" ), controls );
106 gl->addWidget( clockRB, 0, 0 ); 106 gl->addWidget( clockRB, 0, 0 );
107 grp->insert( clockRB ); 107 grp->insert( clockRB );
108 108
109 swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); 109 swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls );
110 gl->addWidget( swatchRB, 1, 0 ); 110 gl->addWidget( swatchRB, 1, 0 );
111 grp->insert( swatchRB ); 111 grp->insert( swatchRB );
112 112
113 connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) ); 113 connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) );
114 grp->setButton( 0 ); 114 grp->setButton( 0 );
115 115
116 set = new QPushButton ( controls ); 116 set = new QPushButton ( controls );
117 set->setMaximumSize(50,30); 117 set->setMaximumSize(50,30);
118 gl->addWidget( set, 0, 1 ); 118 gl->addWidget( set, 0, 1 );
119 set->setText( tr( "Start" ) ); 119 set->setText( tr( "Start" ) );
120 set->setEnabled( FALSE ); 120 set->setEnabled( FALSE );
121 grp->insert( set ); 121 grp->insert( set );
122 122
123 reset = new QPushButton ( controls ); 123 reset = new QPushButton ( controls );
124 gl->addWidget( reset, 1, 1 ); 124 gl->addWidget( reset, 1, 1 );
125 reset->setText( tr( "Reset" ) ); 125 reset->setText( tr( "Reset" ) );
126 reset->setEnabled( FALSE ); 126 reset->setEnabled( FALSE );
127 grp->insert( reset ); 127 grp->insert( reset );
128 128
129 alarmOffBtn = new QPushButton ( controls ); 129 alarmOffBtn = new QPushButton ( controls );
130// alarmOffBtn->setMaximumSize(60,30); 130// alarmOffBtn->setMaximumSize(60,30);
131 gl->addWidget( alarmOffBtn, 0, 2 ); 131 gl->addWidget( alarmOffBtn, 0, 2 );
132 132
133 alarmBtn = new QPushButton ( controls ); 133 alarmBtn = new QPushButton ( controls );
134 // alarmBtn->setMaximumSize(60,30); 134 // alarmBtn->setMaximumSize(60,30);
135 gl->addWidget( alarmBtn, 1, 2 ); 135 gl->addWidget( alarmBtn, 1, 2 );
136 alarmBtn->setText( tr( "Set Alarm" ) ); 136 alarmBtn->setText( tr( "Set Alarm" ) );
137 137
138 OClickableLabel *click = new OClickableLabel(controls, "label" ); 138 OClickableLabel *click = new OClickableLabel(controls, "label" );
139 click->setText(tr("Set date and time." ) ); 139 click->setText(tr("Set date and time." ) );
140 gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter); 140 gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter);
141 connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) ); 141 connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) );
142 142
143 connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); 143 connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) );
144 connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); 144 connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) );
145 145
146 connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); 146 connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) );
147 connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); 147 connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) );
148 connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); 148 connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) );
149 149
150 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 150 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
151 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 151 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
152 152
153 t = new QTimer( this ); 153 t = new QTimer( this );
154 connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); 154 connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) );
155 t->start( 1000 ); 155 t->start( 1000 );
156 156
157 connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); 157 connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) );
158 158
159 swatch_running = FALSE; 159 swatch_running = FALSE;
160 swatch_totalms = 0; 160 swatch_totalms = 0;
161 161
162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
163 163
164 QString tmp = config.readEntry("clockAlarmHour", ""); 164 QString tmp = config.readEntry("clockAlarmHour", "");
165 bool ok; 165 bool ok;
166 hour = tmp.toInt(&ok,10); 166 hour = tmp.toInt(&ok,10);
167 tmp = config.readEntry("clockAlarmMinute",""); 167 tmp = config.readEntry("clockAlarmMinute","");
168 minute = tmp.toInt(&ok,10); 168 minute = tmp.toInt(&ok,10);
169 169
170 if( config.readEntry("clockAlarmSet","FALSE") == "TRUE") { 170 if( config.readEntry("clockAlarmSet","FALSE") == "TRUE") {
171 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 171 alarmOffBtn->setText( tr( "Alarm Is On" ) );
172 alarmBool=TRUE; 172 alarmBool=TRUE;
173 snoozeBtn->show(); 173 snoozeBtn->show();
174 } else { 174 } else {
175 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 175 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
176 alarmBool=FALSE; 176 alarmBool=FALSE;
177 snoozeBtn->hide(); 177 snoozeBtn->hide();
178 } 178 }
179 179
180 QTimer::singleShot( 0, this, SLOT(updateClock()) ); 180 QTimer::singleShot( 0, this, SLOT(updateClock()) );
181 modeSelect(0); 181 modeSelect(0);
182} 182}
183 183
184Clock::~Clock() 184Clock::~Clock()
185{ 185{
186 toggleScreenSaver( true ); 186 toggleScreenSaver( true );
187} 187}
188 188
189void Clock::updateClock() 189void Clock::updateClock()
190{ 190{
191 if ( clockRB->isChecked() ) { 191 if ( clockRB->isChecked() ) {
192 QTime tm = QDateTime::currentDateTime().time(); 192 QTime tm = QDateTime::currentDateTime().time();
193 QString s; 193 QString s;
194 if ( ampm ) { 194 if ( ampm ) {
195 int hour = tm.hour(); 195 int hour = tm.hour();
196 if (hour == 0) 196 if (hour == 0)
197 hour = 12; 197 hour = 12;
198 if (hour > 12) 198 if (hour > 12)
199 hour -= 12; 199 hour -= 12;
200 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); 200 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() );
201 ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" ); 201 ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" );
202 ampmLabel->show(); 202 ampmLabel->show();
203 } else { 203 } else {
204 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); 204 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
205 ampmLabel->hide(); 205 ampmLabel->hide();
206 } 206 }
207 lcd->display( s ); 207 lcd->display( s );
208 lcd->repaint( FALSE ); 208 lcd->repaint( FALSE );
209 aclock->display( QTime::currentTime() ); 209 aclock->display( QTime::currentTime() );
210 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 210 date->setText( TimeString::longDateString( QDate::currentDate() ) );
211 } else { 211 } else {
212 QTime swatch_time; 212 QTime swatch_time;
213 QString lcdtext; 213 QString lcdtext;
214 int totalms = swatch_totalms; 214 int totalms = swatch_totalms;
215 if ( swatch_running ) 215 if ( swatch_running )
216 totalms += swatch_start.elapsed(); 216 totalms += swatch_start.elapsed();
217 swatch_time = QTime(0,0,0).addMSecs(totalms); 217 swatch_time = QTime(0,0,0).addMSecs(totalms);
218 QString d = swatch_running ? QString(" ") 218 QString d = swatch_running ? QString(" ")
219 : QString::number(totalms%1000+1000); 219 : QString::number(totalms%1000+1000);
220 lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); 220 lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec);
221 lcd->display( lcdtext ); 221 lcd->display( lcdtext );
222 lcd->repaint( FALSE ); 222 lcd->repaint( FALSE );
223 aclock->display( swatch_time ); 223 aclock->display( swatch_time );
224 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 224 date->setText( TimeString::longDateString( QDate::currentDate() ) );
225 } 225 }
226} 226}
227 227
228void Clock::changeClock( bool a ) 228void Clock::changeClock( bool a )
229{ 229{
230 ampm = a; 230 ampm = a;
231 updateClock(); 231 updateClock();
232} 232}
233 233
234void Clock::clearClock( void ) 234void Clock::clearClock( void )
235{ 235{
236 lcd->display( QTime( 0,0,0 ).toString() ); 236 lcd->display( QTime( 0,0,0 ).toString() );
237 aclock->display( QTime( 0,0,0 ) ); 237 aclock->display( QTime( 0,0,0 ) );
238} 238}
239 239
240void Clock::slotSet() 240void Clock::slotSet()
241{ 241{
242 if ( t->isActive() ) { 242 if ( t->isActive() ) {
243 swatch_totalms += swatch_start.elapsed(); 243 swatch_totalms += swatch_start.elapsed();
244 set->setText( tr( "Start" ) ); 244 set->setText( tr( "Start" ) );
245 t->stop(); 245 t->stop();
246 swatch_running = FALSE; 246 swatch_running = FALSE;
247 toggleScreenSaver( TRUE ); 247 toggleScreenSaver( TRUE );
248 updateClock(); 248 updateClock();
249 } else { 249 } else {
250 swatch_start.start(); 250 swatch_start.start();
251 set->setText( tr( "Stop" ) ); 251 set->setText( tr( "Stop" ) );
252 t->start( 1000 ); 252 t->start( 1000 );
253 swatch_running = TRUE; 253 swatch_running = TRUE;
254 // disable screensaver while stop watch is running 254 // disable screensaver while stop watch is running
255 toggleScreenSaver( FALSE ); 255 toggleScreenSaver( FALSE );
256 } 256 }
257} 257}
258 258
259void Clock::slotReset() 259void Clock::slotReset()
260{ 260{
261 t->stop(); 261 t->stop();
262 swatch_start.start(); 262 swatch_start.start();
263 swatch_totalms = 0; 263 swatch_totalms = 0;
264 264
265 if (swatch_running ) 265 if (swatch_running )
266 t->start(1000); 266 t->start(1000);
267 267
268 updateClock(); 268 updateClock();
269} 269}
270 270
271void Clock::modeSelect( int m ) 271void Clock::modeSelect( int m )
272{ 272{
273 if ( m ) { 273 if ( m ) {
274 lcd->setNumDigits( 8+1+sw_prec ); 274 lcd->setNumDigits( 8+1+sw_prec );
275 lcd->setMinimumWidth( lcd->sizeHint().width() ); 275 lcd->setMinimumWidth( lcd->sizeHint().width() );
276 set->setEnabled( TRUE ); 276 set->setEnabled( TRUE );
277 reset->setEnabled( TRUE ); 277 reset->setEnabled( TRUE );
278 ampmLabel->hide(); 278 ampmLabel->hide();
279 279
280 if ( !swatch_running ) 280 if ( !swatch_running )
281 t->stop(); 281 t->stop();
282 } else { 282 } else {
283 lcd->setNumDigits( 5 ); 283 lcd->setNumDigits( 5 );
284 lcd->setMinimumWidth( lcd->sizeHint().width() ); 284 lcd->setMinimumWidth( lcd->sizeHint().width() );
285 set->setEnabled( FALSE ); 285 set->setEnabled( FALSE );
286 reset->setEnabled( FALSE ); 286 reset->setEnabled( FALSE );
287 t->start(1000); 287 t->start(1000);
288 } 288 }
289 updateClock(); 289 updateClock();
290} 290}
291 291
292//this sets the alarm time 292//this sets the alarm time
293void Clock::slotSetAlarm() 293void Clock::slotSetAlarm()
294{ 294{
295 if( !snoozeBtn->isHidden()) 295 if( !snoozeBtn->isHidden())
296 slotToggleAlarm(); 296 slotToggleAlarm();
297 Set_Alarm *setAlarmDlg; 297 Set_Alarm *setAlarmDlg;
298 setAlarmDlg = new Set_Alarm(this,"SetAlarm", TRUE); 298 setAlarmDlg = new Set_Alarm(this,"SetAlarm", TRUE);
299 int result = setAlarmDlg->exec(); 299 int result = setAlarmDlg->exec();
300 if(result == 1) { 300 if(result == 1) {
301 Config config( "qpe" ); 301 Config config( "qpe" );
302 config.setGroup("Time"); 302 config.setGroup("Time");
303 QString tmp; 303 QString tmp;
304 hour = setAlarmDlg->Hour_Slider->value(); 304 hour = setAlarmDlg->Hour_Slider->value();
305 minute = setAlarmDlg->Minute_Slider->value(); 305 minute = setAlarmDlg->Minute_Slider->value();
306 snoozeTime=setAlarmDlg->SnoozeSlider->value(); 306 snoozeTime=setAlarmDlg->SnoozeSlider->value();
307 if(ampm) { 307 if(ampm) {
308 if ( hour == 12 )
309 hour = 0;
310
308 if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) 311 if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 )
309 hour+=12; 312 hour+=12;
310 } 313 }
311 config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10); 314 config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10);
312 config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10); 315 config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10);
313 config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10); 316 config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10);
314 config.write(); 317 config.write();
315 } 318 }
316} 319}
317 320
318void Clock::slotSnooze() 321void Clock::slotSnooze()
319{ 322{
320 bSound=FALSE; 323 bSound=FALSE;
321 int warn = 0; 324 int warn = 0;
322 QTime t = QTime::currentTime(); 325 QTime t = QTime::currentTime();
323 QDateTime whenl( when.date(), t.addSecs( snoozeTime*60)); 326 QDateTime whenl( when.date(), t.addSecs( snoozeTime*60));
324 when=whenl; 327 when=whenl;
325 AlarmServer::addAlarm( when, 328 AlarmServer::addAlarm( when,
326 "QPE/Application/clock", 329 "QPE/Application/clock",
327 "alarm(QDateTime,int)", warn ); 330 "alarm(QDateTime,int)", warn );
328 331
329} 332}
330 333
331//toggles alarm on/off 334//toggles alarm on/off
332void Clock::slotToggleAlarm() 335void Clock::slotToggleAlarm()
333{ 336{
334 Config config( "qpe" ); 337 Config config( "qpe" );
335 config.setGroup("Time"); 338 config.setGroup("Time");
336 if(alarmBool) { 339 if(alarmBool) {
337 config.writeEntry("clockAlarmSet","FALSE"); 340 config.writeEntry("clockAlarmSet","FALSE");
338 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 341 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
339 snoozeBtn->hide(); 342 snoozeBtn->hide();
340 alarmBool=FALSE; 343 alarmBool=FALSE;
341 alarmOff(); 344 alarmOff();
342 } else { 345 } else {
343 config.writeEntry("clockAlarmSet","TRUE"); 346 config.writeEntry("clockAlarmSet","TRUE");
344 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 347 alarmOffBtn->setText( tr( "Alarm Is On" ) );
345 snoozeBtn->show(); 348 snoozeBtn->show();
346 alarmBool=TRUE; 349 alarmBool=TRUE;
347 alarmOn(); 350 alarmOn();
348 } 351 }
349 config.write(); 352 config.write();
350} 353}
351 354
352void Clock::alarmOn() 355void Clock::alarmOn()
353{ 356{
354 QDate d = QDate::currentDate(); 357 QDate d = QDate::currentDate();
355 QTime tm((int)hour,(int)minute,0); 358 QTime tm((int)hour,(int)minute,0);
356 qDebug("Time set "+tm.toString()); 359 qDebug("Time set "+tm.toString());
357 QTime t = QTime::currentTime(); 360 QTime t = QTime::currentTime();
358 if( t > tm) 361 if( t > tm)
359 d = d.addDays(1); 362 d = d.addDays(1);
360 int warn = 0; 363 int warn = 0;
361 QDateTime whenl(d,tm); 364 QDateTime whenl(d,tm);
362 when=whenl; 365 when=whenl;
363 AlarmServer::addAlarm( when, 366 AlarmServer::addAlarm( when,
364 "QPE/Application/clock", 367 "QPE/Application/clock",
365 "alarm(QDateTime,int)", warn ); 368 "alarm(QDateTime,int)", warn );
366 setCaption("Alarm set: "+ whenl.toString()); 369 setCaption("Alarm set: "+ whenl.toString());
367} 370}
368 371
369void Clock::alarmOff() 372void Clock::alarmOff()
370{ 373{
371 int warn = 0; 374 int warn = 0;
372 bSound=FALSE; 375 bSound=FALSE;
373 AlarmServer::deleteAlarm( when, 376 AlarmServer::deleteAlarm( when,
374 "QPE/Application/clock", 377 "QPE/Application/clock",
375 "alarm(QDateTime,int)", warn ); 378 "alarm(QDateTime,int)", warn );
376 qDebug("Alarm Off "+ when.toString()); 379 qDebug("Alarm Off "+ when.toString());
377 setCaption("Clock"); 380 setCaption("Clock");
378} 381}
379 382
380void Clock::appMessage(const QCString& msg, const QByteArray& data) 383void Clock::appMessage(const QCString& msg, const QByteArray& data)
381{ 384{
382 int stopTimer = 0; 385 int stopTimer = 0;
383 int timerStay = 5000; 386 int timerStay = 5000;
384 bSound=TRUE; 387 bSound=TRUE;
385 qDebug("Message received in clock"); 388 qDebug("Message received in clock");
386 if ( msg == "alarm(QDateTime,int)" ) { 389 if ( msg == "alarm(QDateTime,int)" ) {
387 Sound::soundAlarm(); 390 Sound::soundAlarm();
388 stopTimer = startTimer( timerStay); 391 stopTimer = startTimer( timerStay);
389 } 392 }
390 show(); 393 show();
391 raise(); 394 raise();
392 QPEApplication::setKeepRunning(); 395 QPEApplication::setKeepRunning();
393 setActiveWindow(); 396 setActiveWindow();
394} 397}
395 398
396void Clock::timerEvent( QTimerEvent *e ) 399void Clock::timerEvent( QTimerEvent *e )
397{ 400{
398 static int stop = 0; 401 static int stop = 0;
399 if ( stop < 120 && bSound) { 402 if ( stop < 120 && bSound) {
400 Sound::soundAlarm(); 403 Sound::soundAlarm();
401 stop++; 404 stop++;
402 } else { 405 } else {
403 stop = 0; 406 stop = 0;
404 killTimer( e->timerId() ); 407 killTimer( e->timerId() );
405 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 408 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
406 alarmBool=FALSE; 409 alarmBool=FALSE;
407 snoozeBtn->hide(); 410 snoozeBtn->hide();
408 setCaption("Clock: Alarm was missed."); 411 setCaption("Clock: Alarm was missed.");
409 } 412 }
410} 413}
411 414
412 415
413QSizePolicy AnalogClock::sizePolicy() const 416QSizePolicy AnalogClock::sizePolicy() const
414{ 417{
415 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); 418 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
416} 419}
417 420
418void AnalogClock::drawContents( QPainter *p ) 421void AnalogClock::drawContents( QPainter *p )
419{ 422{
420 QRect r = contentsRect(); 423 QRect r = contentsRect();
421 QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 424 QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 );
422 425
423 QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); 426 QPoint l1( r.x() + r.width() / 2, r.y() + 2 );
424 QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); 427 QPoint l2( r.x() + r.width() / 2, r.y() + 8 );
425 428
426 QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); 429 QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 );
427 QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 430 QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
428 431
429 QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 ); 432 QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 );
430 QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 433 QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
431 434
432 QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); 435 QPoint s1( r.x() + r.width() / 2, r.y() + 8 );
433 QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 436 QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
434 437
435 QColor color( clear ? backgroundColor() : black ); 438 QColor color( clear ? backgroundColor() : black );
436 QTime time = clear ? prevTime : currTime; 439 QTime time = clear ? prevTime : currTime;
437 440
438 if ( clear && prevTime.secsTo(currTime) > 1 ) { 441 if ( clear && prevTime.secsTo(currTime) > 1 ) {
439 p->eraseRect( rect() ); 442 p->eraseRect( rect() );
440 return; 443 return;
441 } 444 }
442 445
443 if ( !clear ) { 446 if ( !clear ) {
444 // draw ticks 447 // draw ticks
445 p->setPen( QPen( color, 1 ) ); 448 p->setPen( QPen( color, 1 ) );
446 for ( int i = 0; i < 12; i++ ) 449 for ( int i = 0; i < 12; i++ )
447 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); 450 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
448 } 451 }
449 452
450 if ( !clear || prevTime.minute() != currTime.minute() || 453 if ( !clear || prevTime.minute() != currTime.minute() ||
451 prevTime.hour() != currTime.hour() ) { 454 prevTime.hour() != currTime.hour() ) {
452 // draw hour pointer 455 // draw hour pointer
453 h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); 456 h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
454 h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); 457 h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
455 p->setPen( QPen( color, 3 ) ); 458 p->setPen( QPen( color, 3 ) );
456 p->drawLine( h1, h2 ); 459 p->drawLine( h1, h2 );
457 } 460 }
458 461
459 if ( !clear || prevTime.minute() != currTime.minute() ) { 462 if ( !clear || prevTime.minute() != currTime.minute() ) {
460 // draw minute pointer 463 // draw minute pointer
461 m1 = rotate( center, m1, time.minute() * 6 ); 464 m1 = rotate( center, m1, time.minute() * 6 );
462 m2 = rotate( center, m2, time.minute() * 6 ); 465 m2 = rotate( center, m2, time.minute() * 6 );
463 p->setPen( QPen( color, 2 ) ); 466 p->setPen( QPen( color, 2 ) );
464 p->drawLine( m1, m2 ); 467 p->drawLine( m1, m2 );
465 } 468 }
466 469
467 // draw second pointer 470 // draw second pointer
468 s1 = rotate( center, s1, time.second() * 6 ); 471 s1 = rotate( center, s1, time.second() * 6 );
469 s2 = rotate( center, s2, time.second() * 6 ); 472 s2 = rotate( center, s2, time.second() * 6 );
470 p->setPen( QPen( color, 1 ) ); 473 p->setPen( QPen( color, 1 ) );
471 p->drawLine( s1, s2 ); 474 p->drawLine( s1, s2 );
472 475
473 if ( !clear ) 476 if ( !clear )
474 prevTime = currTime; 477 prevTime = currTime;
475} 478}
476 479
477void AnalogClock::display( const QTime& t ) 480void AnalogClock::display( const QTime& t )
478{ 481{
479 currTime = t; 482 currTime = t;
480 clear = true; 483 clear = true;
481 repaint( false ); 484 repaint( false );
482 clear = false; 485 clear = false;
483 repaint( false ); 486 repaint( false );
484} 487}
485 488
486QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) 489QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
487{ 490{
488 double angle = deg2rad * ( - a + 180 ); 491 double angle = deg2rad * ( - a + 180 );
489 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - 492 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
490 ( p.y() - c.y() ) * sin( angle ); 493 ( p.y() - c.y() ) * sin( angle );
491 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + 494 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
492 ( p.x() - c.x() ) * sin( angle ); 495 ( p.x() - c.x() ) * sin( angle );
493 return QPoint( nx, ny ); 496 return QPoint( nx, ny );
494} 497}
495 498
496void Clock::slotAdjustTime() { 499void Clock::slotAdjustTime() {
497 QCopEnvelope e("QPE/System", "execute(QString)"); 500 QCopEnvelope e("QPE/System", "execute(QString)");
498 e << QString("systemtime"); 501 e << QString("systemtime");
499} 502}
diff --git a/noncore/tools/clock/setAlarm.cpp b/noncore/tools/clock/setAlarm.cpp
index 6b95e6a..bd964e0 100644
--- a/noncore/tools/clock/setAlarm.cpp
+++ b/noncore/tools/clock/setAlarm.cpp
@@ -1,184 +1,187 @@
1 /*************************************************************************** 1 /***************************************************************************
2// setAlarm.cpp - description 2// setAlarm.cpp - description
3// ------------------- 3// -------------------
4// Created: Wed Mar 13 19:47:24 2002 4// Created: Wed Mar 13 19:47:24 2002
5// copyright : (C) 2002 by ljp 5// copyright : (C) 2002 by ljp
6// email : ljp@llornkcor.com 6// email : ljp@llornkcor.com
7// 7//
8*************************************************************************** 8***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15#include "setAlarm.h" 15#include "setAlarm.h"
16 16
17#include <qpe/config.h> 17#include <qpe/config.h>
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qstring.h> 20#include <qstring.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qlcdnumber.h> 22#include <qlcdnumber.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qradiobutton.h> 24#include <qradiobutton.h>
25#include <qslider.h> 25#include <qslider.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvariant.h> 27#include <qvariant.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#include <qbuttongroup.h> 30#include <qbuttongroup.h>
31 31
32Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl ) 32Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl )
33 : QDialog( parent, name, modal, fl ) 33 : QDialog( parent, name, modal, fl )
34{ 34{
35 if ( !name ) 35 if ( !name )
36 setName( "Set_Alarm" ); 36 setName( "Set_Alarm" );
37 resize( 240, 101 ); 37 resize( 240, 101 );
38 setMaximumSize( QSize( 240, 320 ) ); 38 setMaximumSize( QSize( 240, 320 ) );
39 setCaption( tr( "Set Alarm" ) ); 39 setCaption( tr( "Set Alarm" ) );
40 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 40 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
41 41
42 Set_AlarmLayout = new QGridLayout( this ); 42 Set_AlarmLayout = new QGridLayout( this );
43 Set_AlarmLayout->setSpacing( 6 ); 43 Set_AlarmLayout->setSpacing( 6 );
44 Set_AlarmLayout->setMargin( 11 ); 44 Set_AlarmLayout->setMargin( 11 );
45 45
46 TextLabel1 = new QLabel( this, "TextLabel1" ); 46 TextLabel1 = new QLabel( this, "TextLabel1" );
47 TextLabel1->setText( tr( "Hour" ) ); 47 TextLabel1->setText( tr( "Hour" ) );
48 48
49 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 ); 49 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 );
50 50
51 TextLabel2 = new QLabel( this, "TextLabel2" ); 51 TextLabel2 = new QLabel( this, "TextLabel2" );
52 TextLabel2->setText( tr( "Minute" ) ); 52 TextLabel2->setText( tr( "Minute" ) );
53 53
54 Set_AlarmLayout->addMultiCellWidget( TextLabel2, 0, 0, 1, 2 ); 54 Set_AlarmLayout->addMultiCellWidget( TextLabel2, 0, 0, 1, 2 );
55 55
56 Hour_Slider = new QSlider( this, "Hour_Slider" ); 56 Hour_Slider = new QSlider( this, "Hour_Slider" );
57 Hour_Slider->setPageStep( 1); 57 Hour_Slider->setPageStep( 1);
58 Hour_Slider->setOrientation( QSlider::Horizontal ); 58 Hour_Slider->setOrientation( QSlider::Horizontal );
59 connect(Hour_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeHour(int))); 59 connect(Hour_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeHour(int)));
60 60
61 Set_AlarmLayout->addWidget( Hour_Slider, 2, 0 ); 61 Set_AlarmLayout->addWidget( Hour_Slider, 2, 0 );
62 62
63 Hour_LCDNumber = new QLCDNumber( this, "Hour_LCDNumber" ); 63 Hour_LCDNumber = new QLCDNumber( this, "Hour_LCDNumber" );
64 Hour_LCDNumber->setFrameShape( QLCDNumber::Box ); 64 Hour_LCDNumber->setFrameShape( QLCDNumber::Box );
65 Hour_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 65 Hour_LCDNumber->setFrameShadow( QLCDNumber::Plain );
66 Hour_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 66 Hour_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
67 67
68 Set_AlarmLayout->addWidget( Hour_LCDNumber, 1, 0 ); 68 Set_AlarmLayout->addWidget( Hour_LCDNumber, 1, 0 );
69 69
70 Minute_Slider = new QSlider( this, "Minute_Slider" ); 70 Minute_Slider = new QSlider( this, "Minute_Slider" );
71 Minute_Slider->setMaxValue( 59); 71 Minute_Slider->setMaxValue( 59);
72 Minute_Slider->setPageStep( 1); 72 Minute_Slider->setPageStep( 1);
73 Minute_Slider->setOrientation( QSlider::Horizontal ); 73 Minute_Slider->setOrientation( QSlider::Horizontal );
74 connect(Minute_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeMinute(int))); 74 connect(Minute_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeMinute(int)));
75 75
76 Set_AlarmLayout->addMultiCellWidget( Minute_Slider, 2, 2, 1, 2 ); 76 Set_AlarmLayout->addMultiCellWidget( Minute_Slider, 2, 2, 1, 2 );
77 77
78 Minute_LCDNumber = new QLCDNumber( this, "Minute_LCDNumber" ); 78 Minute_LCDNumber = new QLCDNumber( this, "Minute_LCDNumber" );
79 Minute_LCDNumber->setFrameShape( QLCDNumber::Box ); 79 Minute_LCDNumber->setFrameShape( QLCDNumber::Box );
80 Minute_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 80 Minute_LCDNumber->setFrameShadow( QLCDNumber::Plain );
81 Minute_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 81 Minute_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
82 82
83 Set_AlarmLayout->addMultiCellWidget( Minute_LCDNumber, 1, 1, 1, 2 ); 83 Set_AlarmLayout->addMultiCellWidget( Minute_LCDNumber, 1, 1, 1, 2 );
84 84
85 Am_RadioButton = new QRadioButton( this, "Am_RadioButton" ); 85 Am_RadioButton = new QRadioButton( this, "Am_RadioButton" );
86 Am_RadioButton->setText( tr( "AM" ) ); 86 Am_RadioButton->setText( tr( "AM" ) );
87 Am_RadioButton->setChecked(TRUE); 87 Am_RadioButton->setChecked(TRUE);
88 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool))); 88 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool)));
89 89
90 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 ); 90 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 );
91 91
92 92
93 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" ); 93 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" );
94 Pm_RadioButton->setText( tr( "PM" ) ); 94 Pm_RadioButton->setText( tr( "PM" ) );
95 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool))); 95 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool)));
96 96
97 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 ); 97 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 );
98 98
99 TextLabel3 = new QLabel( this, "TextLabel3" ); 99 TextLabel3 = new QLabel( this, "TextLabel3" );
100 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) ); 100 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) );
101 101
102 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 ); 102 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 );
103 103
104 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" ); 104 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" );
105 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box ); 105 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box );
106 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 106 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain );
107 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 107 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
108 108
109 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 ); 109 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 );
110 110
111 SnoozeSlider = new QSlider( this, "SnoozeSlider" ); 111 SnoozeSlider = new QSlider( this, "SnoozeSlider" );
112 SnoozeSlider->setMaxValue( 60 ); 112 SnoozeSlider->setMaxValue( 60 );
113 SnoozeSlider->setOrientation( QSlider::Horizontal ); 113 SnoozeSlider->setOrientation( QSlider::Horizontal );
114 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int))); 114 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int)));
115 115
116 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 3, 3, 3, 4 ); 116 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 3, 3, 3, 4 );
117 117
118 Config config( "qpe" ); 118 Config config( "qpe" );
119 config.setGroup("Time"); 119 config.setGroup("Time");
120 120
121 bool ok; 121 bool ok;
122 bool ampm = config.readBoolEntry( "AMPM", TRUE ); 122 bool ampm = config.readBoolEntry( "AMPM", TRUE );
123 QString alarmHour=config.readEntry("clockAlarmHour","8"); 123 QString alarmHour=config.readEntry("clockAlarmHour","8");
124 int i_alarmHour = alarmHour.toInt(&ok,10); 124 int i_alarmHour = alarmHour.toInt(&ok,10);
125 QString alarmMinute=config.readEntry("clockAlarmMinute","0"); 125 QString alarmMinute=config.readEntry("clockAlarmMinute","0");
126 QString snoozeTime=config.readEntry("clockAlarmSnooze","0"); 126 QString snoozeTime=config.readEntry("clockAlarmSnooze","0");
127 if(ampm) { 127 if(ampm) {
128 Hour_Slider->setMaxValue( 12); 128 Hour_Slider->setMaxValue( 12);
129 Hour_Slider->setMinValue( 1); 129 Hour_Slider->setMinValue( 1);
130 130
131 if( i_alarmHour > 12) { 131 if( i_alarmHour > 12) {
132 i_alarmHour = i_alarmHour - 12; 132 i_alarmHour = i_alarmHour - 12;
133 Pm_RadioButton->setChecked(TRUE); 133 Pm_RadioButton->setChecked(TRUE);
134 } 134 }
135 Hour_Slider->setValue( i_alarmHour); 135 else if ( i_alarmHour == 0 ) {
136 i_alarmHour = 12;
137 }
138 Hour_Slider->setValue( i_alarmHour );
136 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 139 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
137 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 140 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
138 } else { 141 } else {
139 Hour_Slider->setMaxValue( 23); 142 Hour_Slider->setMaxValue( 23);
140 Hour_Slider->setMinValue( 1); 143 Hour_Slider->setMinValue( 0);
141 Hour_Slider->setValue( i_alarmHour); 144 Hour_Slider->setValue( i_alarmHour);
142 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 145 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
143 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 146 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
144 Am_RadioButton->hide(); 147 Am_RadioButton->hide();
145 Pm_RadioButton->hide(); 148 Pm_RadioButton->hide();
146 } 149 }
147 // signals and slots connections 150 // signals and slots connections
148} 151}
149 152
150Set_Alarm::~Set_Alarm() 153Set_Alarm::~Set_Alarm()
151{ 154{
152 155
153} 156}
154 157
155void Set_Alarm::slotChangeHour(int hour) 158void Set_Alarm::slotChangeHour(int hour)
156{ 159{
157 Hour_LCDNumber->display(hour); 160 Hour_LCDNumber->display(hour);
158} 161}
159 162
160void Set_Alarm::slotChangeMinute(int minute) 163void Set_Alarm::slotChangeMinute(int minute)
161{ 164{
162 Minute_LCDNumber->display(minute); 165 Minute_LCDNumber->display(minute);
163} 166}
164 167
165void Set_Alarm::slotChangeSnooze(int minute) 168void Set_Alarm::slotChangeSnooze(int minute)
166{ 169{
167 Snooze_LCDNumber->display(minute); 170 Snooze_LCDNumber->display(minute);
168} 171}
169 172
170void Set_Alarm::amButtonToggled(bool b) 173void Set_Alarm::amButtonToggled(bool b)
171{ 174{
172 if ( b) 175 if ( b)
173 Pm_RadioButton->setChecked(FALSE); 176 Pm_RadioButton->setChecked(FALSE);
174} 177}
175 178
176void Set_Alarm::pmButtonToggled(bool b) 179void Set_Alarm::pmButtonToggled(bool b)
177{ 180{
178 if (b) 181 if (b)
179 Am_RadioButton->setChecked(FALSE); 182 Am_RadioButton->setChecked(FALSE);
180} 183}
181 184
182void Set_Alarm::cleanUp() 185void Set_Alarm::cleanUp()
183{ 186{
184} 187}