summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp13
-rw-r--r--noncore/tools/clock/setAlarm.cpp35
-rw-r--r--noncore/tools/clock/setAlarm.h4
3 files changed, 46 insertions, 6 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index a47793b..69d8214 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -1,502 +1,511 @@
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 ) 308 if ( hour == 12 )
309 hour = 0; 309 hour = 0;
310 310
311 if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) 311 if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 )
312 hour+=12; 312 hour+=12;
313 } 313 }
314 config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10); 314 config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10);
315 config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10); 315 config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10);
316 config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10); 316 config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10);
317 config.write(); 317 config.write();
318 } 318 }
319} 319}
320 320
321void Clock::slotSnooze() 321void Clock::slotSnooze()
322{ 322{
323 bSound=FALSE; 323 bSound=FALSE;
324 int warn = 0; 324 int warn = 0;
325 QTime t = QTime::currentTime(); 325 QTime t = QTime::currentTime();
326 QDateTime whenl( when.date(), t.addSecs( snoozeTime*60)); 326 QDateTime whenl( when.date(), t.addSecs( snoozeTime*60));
327 when=whenl; 327 when=whenl;
328 AlarmServer::addAlarm( when, 328 AlarmServer::addAlarm( when,
329 "QPE/Application/clock", 329 "QPE/Application/clock",
330 "alarm(QDateTime,int)", warn ); 330 "alarm(QDateTime,int)", warn );
331 331
332} 332}
333 333
334//toggles alarm on/off 334//toggles alarm on/off
335void Clock::slotToggleAlarm() 335void Clock::slotToggleAlarm()
336{ 336{
337 Config config( "qpe" ); 337 Config config( "qpe" );
338 config.setGroup("Time"); 338 config.setGroup("Time");
339 if(alarmBool) { 339 if(alarmBool) {
340 config.writeEntry("clockAlarmSet","FALSE"); 340 config.writeEntry("clockAlarmSet","FALSE");
341 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 341 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
342 snoozeBtn->hide(); 342 snoozeBtn->hide();
343 alarmBool=FALSE; 343 alarmBool=FALSE;
344 alarmOff(); 344 alarmOff();
345 } else { 345 } else {
346 config.writeEntry("clockAlarmSet","TRUE"); 346 config.writeEntry("clockAlarmSet","TRUE");
347 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 347 alarmOffBtn->setText( tr( "Alarm Is On" ) );
348 snoozeBtn->show(); 348 snoozeBtn->show();
349 alarmBool=TRUE; 349 alarmBool=TRUE;
350 alarmOn(); 350 alarmOn();
351 } 351 }
352 config.write(); 352 config.write();
353} 353}
354 354
355void Clock::alarmOn() 355void Clock::alarmOn()
356{ 356{
357 QDate d = QDate::currentDate(); 357 QDate d = QDate::currentDate();
358 QTime tm((int)hour,(int)minute,0); 358 QTime tm((int)hour,(int)minute,0);
359 qDebug("Time set "+tm.toString()); 359 qDebug("Time set "+tm.toString());
360 QTime t = QTime::currentTime(); 360 QTime t = QTime::currentTime();
361 if( t > tm) 361 if( t > tm)
362 d = d.addDays(1); 362 d = d.addDays(1);
363 int warn = 0; 363 int warn = 0;
364 QDateTime whenl(d,tm); 364 QDateTime whenl(d,tm);
365 when=whenl; 365 when=whenl;
366 AlarmServer::addAlarm( when, 366 AlarmServer::addAlarm( when,
367 "QPE/Application/clock", 367 "QPE/Application/clock",
368 "alarm(QDateTime,int)", warn ); 368 "alarm(QDateTime,int)", warn );
369 setCaption("Alarm set: "+ whenl.toString()); 369 setCaption("Alarm set: "+ whenl.toString());
370} 370}
371 371
372void Clock::alarmOff() 372void Clock::alarmOff()
373{ 373{
374 int warn = 0; 374 int warn = 0;
375 bSound=FALSE; 375 bSound=FALSE;
376 AlarmServer::deleteAlarm( when, 376 AlarmServer::deleteAlarm( when,
377 "QPE/Application/clock", 377 "QPE/Application/clock",
378 "alarm(QDateTime,int)", warn ); 378 "alarm(QDateTime,int)", warn );
379 qDebug("Alarm Off "+ when.toString()); 379 qDebug("Alarm Off "+ when.toString());
380 setCaption("Clock"); 380 setCaption("Clock");
381} 381}
382 382
383void Clock::appMessage(const QCString& msg, const QByteArray& data) 383void Clock::appMessage(const QCString& msg, const QByteArray& data)
384{ 384{
385 int stopTimer = 0; 385 int stopTimer = 0;
386 int timerStay = 5000; 386 int timerStay = 5000;
387 bSound=TRUE; 387 bSound=TRUE;
388 qDebug("Message received in clock"); 388 qDebug("Message received in clock");
389 if ( msg == "alarm(QDateTime,int)" ) { 389 if ( msg == "alarm(QDateTime,int)" ) {
390 Config config( "qpe" );
391 config.setGroup("Time");
392 if(config.readBoolEntry("mp3Alarm",0)){
393
394 QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)");
395 e<<config.readEntry("mp3File","");
396 } else {
397
390 Sound::soundAlarm(); 398 Sound::soundAlarm();
391 stopTimer = startTimer( timerStay); 399 stopTimer = startTimer( timerStay);
400 }
392 } 401 }
393 show(); 402 show();
394 raise(); 403 raise();
395 QPEApplication::setKeepRunning(); 404 QPEApplication::setKeepRunning();
396 setActiveWindow(); 405 setActiveWindow();
397} 406}
398 407
399void Clock::timerEvent( QTimerEvent *e ) 408void Clock::timerEvent( QTimerEvent *e )
400{ 409{
401 static int stop = 0; 410 static int stop = 0;
402 if ( stop < 120 && bSound) { 411 if ( stop < 120 && bSound) {
403 Sound::soundAlarm(); 412 Sound::soundAlarm();
404 stop++; 413 stop++;
405 } else { 414 } else {
406 stop = 0; 415 stop = 0;
407 killTimer( e->timerId() ); 416 killTimer( e->timerId() );
408 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 417 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
409 alarmBool=FALSE; 418 alarmBool=FALSE;
410 snoozeBtn->hide(); 419 snoozeBtn->hide();
411 setCaption("Clock: Alarm was missed."); 420 setCaption("Clock: Alarm was missed.");
412 } 421 }
413} 422}
414 423
415 424
416QSizePolicy AnalogClock::sizePolicy() const 425QSizePolicy AnalogClock::sizePolicy() const
417{ 426{
418 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); 427 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
419} 428}
420 429
421void AnalogClock::drawContents( QPainter *p ) 430void AnalogClock::drawContents( QPainter *p )
422{ 431{
423 QRect r = contentsRect(); 432 QRect r = contentsRect();
424 QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 433 QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 );
425 434
426 QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); 435 QPoint l1( r.x() + r.width() / 2, r.y() + 2 );
427 QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); 436 QPoint l2( r.x() + r.width() / 2, r.y() + 8 );
428 437
429 QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); 438 QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 );
430 QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 439 QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
431 440
432 QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 ); 441 QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 );
433 QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 442 QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
434 443
435 QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); 444 QPoint s1( r.x() + r.width() / 2, r.y() + 8 );
436 QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); 445 QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
437 446
438 QColor color( clear ? backgroundColor() : black ); 447 QColor color( clear ? backgroundColor() : black );
439 QTime time = clear ? prevTime : currTime; 448 QTime time = clear ? prevTime : currTime;
440 449
441 if ( clear && prevTime.secsTo(currTime) > 1 ) { 450 if ( clear && prevTime.secsTo(currTime) > 1 ) {
442 p->eraseRect( rect() ); 451 p->eraseRect( rect() );
443 return; 452 return;
444 } 453 }
445 454
446 if ( !clear ) { 455 if ( !clear ) {
447 // draw ticks 456 // draw ticks
448 p->setPen( QPen( color, 1 ) ); 457 p->setPen( QPen( color, 1 ) );
449 for ( int i = 0; i < 12; i++ ) 458 for ( int i = 0; i < 12; i++ )
450 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); 459 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
451 } 460 }
452 461
453 if ( !clear || prevTime.minute() != currTime.minute() || 462 if ( !clear || prevTime.minute() != currTime.minute() ||
454 prevTime.hour() != currTime.hour() ) { 463 prevTime.hour() != currTime.hour() ) {
455 // draw hour pointer 464 // draw hour pointer
456 h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); 465 h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
457 h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); 466 h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
458 p->setPen( QPen( color, 3 ) ); 467 p->setPen( QPen( color, 3 ) );
459 p->drawLine( h1, h2 ); 468 p->drawLine( h1, h2 );
460 } 469 }
461 470
462 if ( !clear || prevTime.minute() != currTime.minute() ) { 471 if ( !clear || prevTime.minute() != currTime.minute() ) {
463 // draw minute pointer 472 // draw minute pointer
464 m1 = rotate( center, m1, time.minute() * 6 ); 473 m1 = rotate( center, m1, time.minute() * 6 );
465 m2 = rotate( center, m2, time.minute() * 6 ); 474 m2 = rotate( center, m2, time.minute() * 6 );
466 p->setPen( QPen( color, 2 ) ); 475 p->setPen( QPen( color, 2 ) );
467 p->drawLine( m1, m2 ); 476 p->drawLine( m1, m2 );
468 } 477 }
469 478
470 // draw second pointer 479 // draw second pointer
471 s1 = rotate( center, s1, time.second() * 6 ); 480 s1 = rotate( center, s1, time.second() * 6 );
472 s2 = rotate( center, s2, time.second() * 6 ); 481 s2 = rotate( center, s2, time.second() * 6 );
473 p->setPen( QPen( color, 1 ) ); 482 p->setPen( QPen( color, 1 ) );
474 p->drawLine( s1, s2 ); 483 p->drawLine( s1, s2 );
475 484
476 if ( !clear ) 485 if ( !clear )
477 prevTime = currTime; 486 prevTime = currTime;
478} 487}
479 488
480void AnalogClock::display( const QTime& t ) 489void AnalogClock::display( const QTime& t )
481{ 490{
482 currTime = t; 491 currTime = t;
483 clear = true; 492 clear = true;
484 repaint( false ); 493 repaint( false );
485 clear = false; 494 clear = false;
486 repaint( false ); 495 repaint( false );
487} 496}
488 497
489QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) 498QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
490{ 499{
491 double angle = deg2rad * ( - a + 180 ); 500 double angle = deg2rad * ( - a + 180 );
492 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - 501 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
493 ( p.y() - c.y() ) * sin( angle ); 502 ( p.y() - c.y() ) * sin( angle );
494 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + 503 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
495 ( p.x() - c.x() ) * sin( angle ); 504 ( p.x() - c.x() ) * sin( angle );
496 return QPoint( nx, ny ); 505 return QPoint( nx, ny );
497} 506}
498 507
499void Clock::slotAdjustTime() { 508void Clock::slotAdjustTime() {
500 QCopEnvelope e("QPE/System", "execute(QString)"); 509 QCopEnvelope e("QPE/System", "execute(QString)");
501 e << QString("systemtime"); 510 e << QString("systemtime");
502} 511}
diff --git a/noncore/tools/clock/setAlarm.cpp b/noncore/tools/clock/setAlarm.cpp
index 990ff81..38de396 100644
--- a/noncore/tools/clock/setAlarm.cpp
+++ b/noncore/tools/clock/setAlarm.cpp
@@ -1,188 +1,217 @@
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 <opie/ofileselector.h>
18#include <opie/ofiledialog.h>
18 19
20#include <qpe/config.h>
19#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
20#include <qstring.h> 22#include <qstring.h>
21#include <qlabel.h> 23#include <qlabel.h>
22#include <qlcdnumber.h> 24#include <qlcdnumber.h>
23#include <qpushbutton.h> 25#include <qpushbutton.h>
24#include <qradiobutton.h> 26#include <qradiobutton.h>
25#include <qslider.h> 27#include <qslider.h>
26#include <qlayout.h> 28#include <qlayout.h>
27#include <qvariant.h> 29#include <qvariant.h>
28#include <qtooltip.h> 30#include <qtooltip.h>
29#include <qwhatsthis.h> 31#include <qwhatsthis.h>
30#include <qbuttongroup.h> 32#include <qbuttongroup.h>
33#include <qcheckbox.h>
31 34
32Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl ) 35Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl )
33 : QDialog( parent, name, modal, fl ) 36 : QDialog( parent, name, modal, fl )
34{ 37{
35 if ( !name ) 38 if ( !name )
36 setName( "Set_Alarm" ); 39 setName( "Set_Alarm" );
37 resize( 240, 101 ); 40 resize( 240, 101 );
38 setMaximumSize( QSize( 240, 320 ) ); 41 setMaximumSize( QSize( 240, 320 ) );
39 move(0,48); 42 move(0,45);
40 setCaption( tr( "Set Alarm" ) ); 43 setCaption( tr( "Set Alarm" ) );
41 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 44 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
42 45
43 Set_AlarmLayout = new QGridLayout( this ); 46 Set_AlarmLayout = new QGridLayout( this );
44 Set_AlarmLayout->setSpacing( 6 ); 47 Set_AlarmLayout->setSpacing( 6 );
45 Set_AlarmLayout->setMargin( 11 ); 48 Set_AlarmLayout->setMargin( 11 );
46 49
47 TextLabel1 = new QLabel( this, "TextLabel1" ); 50 TextLabel1 = new QLabel( this, "TextLabel1" );
48 TextLabel1->setText( tr( "Hour" ) ); 51 TextLabel1->setText( tr( "Hour" ) );
49 52
50 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 ); 53 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 );
51 54
52 TextLabel2 = new QLabel( this, "TextLabel2" ); 55 TextLabel2 = new QLabel( this, "TextLabel2" );
53 TextLabel2->setText( tr( "Minute" ) ); 56 TextLabel2->setText( tr( "Minute" ) );
54 57
55 Set_AlarmLayout->addMultiCellWidget( TextLabel2, 0, 0, 1, 2 ); 58 Set_AlarmLayout->addMultiCellWidget( TextLabel2, 0, 0, 1, 2 );
56 59
57 Hour_Slider = new QSlider( this, "Hour_Slider" ); 60 Hour_Slider = new QSlider( this, "Hour_Slider" );
58 Hour_Slider->setPageStep( 1); 61 Hour_Slider->setPageStep( 1);
59 Hour_Slider->setOrientation( QSlider::Horizontal ); 62 Hour_Slider->setOrientation( QSlider::Horizontal );
60 connect(Hour_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeHour(int))); 63 connect(Hour_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeHour(int)));
61 64
62 Set_AlarmLayout->addWidget( Hour_Slider, 2, 0 ); 65 Set_AlarmLayout->addWidget( Hour_Slider, 2, 0 );
63 66
64 Hour_LCDNumber = new QLCDNumber( this, "Hour_LCDNumber" ); 67 Hour_LCDNumber = new QLCDNumber( this, "Hour_LCDNumber" );
65 Hour_LCDNumber->setFrameShape( QLCDNumber::Box ); 68 Hour_LCDNumber->setFrameShape( QLCDNumber::Box );
66 Hour_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 69 Hour_LCDNumber->setFrameShadow( QLCDNumber::Plain );
67 Hour_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 70 Hour_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
68 71
69 Set_AlarmLayout->addWidget( Hour_LCDNumber, 1, 0 ); 72 Set_AlarmLayout->addWidget( Hour_LCDNumber, 1, 0 );
70 73
71 Minute_Slider = new QSlider( this, "Minute_Slider" ); 74 Minute_Slider = new QSlider( this, "Minute_Slider" );
72 Minute_Slider->setMaxValue( 59); 75 Minute_Slider->setMaxValue( 59);
73 Minute_Slider->setPageStep( 1); 76 Minute_Slider->setPageStep( 1);
74 Minute_Slider->setOrientation( QSlider::Horizontal ); 77 Minute_Slider->setOrientation( QSlider::Horizontal );
75 connect(Minute_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeMinute(int))); 78 connect(Minute_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeMinute(int)));
76 79
77 Set_AlarmLayout->addMultiCellWidget( Minute_Slider, 2, 2, 1, 2 ); 80 Set_AlarmLayout->addMultiCellWidget( Minute_Slider, 2, 2, 1, 2 );
78 81
79 Minute_LCDNumber = new QLCDNumber( this, "Minute_LCDNumber" ); 82 Minute_LCDNumber = new QLCDNumber( this, "Minute_LCDNumber" );
80 Minute_LCDNumber->setFrameShape( QLCDNumber::Box ); 83 Minute_LCDNumber->setFrameShape( QLCDNumber::Box );
81 Minute_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 84 Minute_LCDNumber->setFrameShadow( QLCDNumber::Plain );
82 Minute_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 85 Minute_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
83 86
84 Set_AlarmLayout->addMultiCellWidget( Minute_LCDNumber, 1, 1, 1, 2 ); 87 Set_AlarmLayout->addMultiCellWidget( Minute_LCDNumber, 1, 1, 1, 2 );
85 88
86 Am_RadioButton = new QRadioButton( this, "Am_RadioButton" ); 89 Am_RadioButton = new QRadioButton( this, "Am_RadioButton" );
87 Am_RadioButton->setText( tr( "AM" ) ); 90 Am_RadioButton->setText( tr( "AM" ) );
88 Am_RadioButton->setChecked(TRUE); 91 Am_RadioButton->setChecked(TRUE);
89 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool))); 92 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool)));
90 93
91 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 ); 94 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 );
92 95
93 96
94 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" ); 97 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" );
95 Pm_RadioButton->setText( tr( "PM" ) ); 98 Pm_RadioButton->setText( tr( "PM" ) );
96 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool))); 99 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool)));
97 100
98 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 ); 101 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 );
99 102
103 useMp3Check = new QCheckBox ( tr( "mp3 alarm" ), this );
104 useMp3Check-> setFocusPolicy ( QWidget::NoFocus );
105 Set_AlarmLayout->addMultiCellWidget( useMp3Check, 2, 3, 3, 4 );
106
107
108
100 TextLabel3 = new QLabel( this, "TextLabel3" ); 109 TextLabel3 = new QLabel( this, "TextLabel3" );
101 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) ); 110 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) );
102 111
103 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 ); 112 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 );
104 113
105 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" ); 114 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" );
106 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box ); 115 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box );
107 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 116 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain );
108 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 117 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
109 118
110 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 ); 119 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 );
111 120
112 SnoozeSlider = new QSlider( this, "SnoozeSlider" ); 121 SnoozeSlider = new QSlider( this, "SnoozeSlider" );
113 SnoozeSlider->setMaxValue( 60 ); 122 SnoozeSlider->setMaxValue( 60 );
114 SnoozeSlider->setOrientation( QSlider::Horizontal ); 123 SnoozeSlider->setOrientation( QSlider::Horizontal );
115 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int))); 124 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int)));
116 125
117 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 3, 3, 3, 4 ); 126 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 4, 4, 1, 2 );
118 127
119 Config config( "qpe" ); 128 Config config( "qpe" );
120 config.setGroup("Time"); 129 config.setGroup("Time");
121 130
122 bool ok; 131 bool ok;
123 bool ampm = config.readBoolEntry( "AMPM", TRUE ); 132 bool ampm = config.readBoolEntry( "AMPM", TRUE );
124 QString alarmHour=config.readEntry("clockAlarmHour","8"); 133 QString alarmHour=config.readEntry("clockAlarmHour","8");
125 int i_alarmHour = alarmHour.toInt(&ok,10); 134 int i_alarmHour = alarmHour.toInt(&ok,10);
126 QString alarmMinute=config.readEntry("clockAlarmMinute","0"); 135 QString alarmMinute=config.readEntry("clockAlarmMinute","0");
127 QString snoozeTime=config.readEntry("clockAlarmSnooze","0"); 136 QString snoozeTime=config.readEntry("clockAlarmSnooze","0");
128 if(ampm) { 137 if(ampm) {
129 Hour_Slider->setMaxValue( 12); 138 Hour_Slider->setMaxValue( 12);
130 Hour_Slider->setMinValue( 1); 139 Hour_Slider->setMinValue( 1);
131 140
132 if( i_alarmHour > 12) { 141 if( i_alarmHour > 12) {
133 i_alarmHour = i_alarmHour - 12; 142 i_alarmHour = i_alarmHour - 12;
134 Pm_RadioButton->setChecked(TRUE); 143 Pm_RadioButton->setChecked(TRUE);
135 } 144 }
136 else if ( i_alarmHour == 0 ) { 145 else if ( i_alarmHour == 0 ) {
137 i_alarmHour = 12; 146 i_alarmHour = 12;
138 } 147 }
139 Hour_Slider->setValue( i_alarmHour ); 148 Hour_Slider->setValue( i_alarmHour );
140 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 149 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
141 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 150 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
142 } else { 151 } else {
143 Hour_Slider->setMaxValue( 23); 152 Hour_Slider->setMaxValue( 23);
144 Hour_Slider->setMinValue( 0); 153 Hour_Slider->setMinValue( 0);
145 Hour_Slider->setValue( i_alarmHour); 154 Hour_Slider->setValue( i_alarmHour);
146 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 155 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
147 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 156 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
148 Am_RadioButton->hide(); 157 Am_RadioButton->hide();
149 Pm_RadioButton->hide(); 158 Pm_RadioButton->hide();
150 } 159 }
160 if( config.readBoolEntry("mp3Alarm") )
161 useMp3Check->setChecked(true);
162
151 // signals and slots connections 163 // signals and slots connections
164 connect(useMp3Check,SIGNAL(toggled(bool)),this,SLOT(slotChangemp3CkeckBox(bool)));
152} 165}
153 166
154Set_Alarm::~Set_Alarm() 167Set_Alarm::~Set_Alarm()
155{ 168{
156 169
157} 170}
158 171
159void Set_Alarm::slotChangeHour(int hour) 172void Set_Alarm::slotChangeHour(int hour)
160{ 173{
161 Hour_LCDNumber->display(hour); 174 Hour_LCDNumber->display(hour);
162} 175}
163 176
164void Set_Alarm::slotChangeMinute(int minute) 177void Set_Alarm::slotChangeMinute(int minute)
165{ 178{
166 Minute_LCDNumber->display(minute); 179 Minute_LCDNumber->display(minute);
167} 180}
168 181
169void Set_Alarm::slotChangeSnooze(int minute) 182void Set_Alarm::slotChangeSnooze(int minute)
170{ 183{
171 Snooze_LCDNumber->display(minute); 184 Snooze_LCDNumber->display(minute);
172} 185}
173 186
174void Set_Alarm::amButtonToggled(bool b) 187void Set_Alarm::amButtonToggled(bool b)
175{ 188{
176 if ( b) 189 if ( b)
177 Pm_RadioButton->setChecked(FALSE); 190 Pm_RadioButton->setChecked(FALSE);
178} 191}
179 192
180void Set_Alarm::pmButtonToggled(bool b) 193void Set_Alarm::pmButtonToggled(bool b)
181{ 194{
182 if (b) 195 if (b)
183 Am_RadioButton->setChecked(FALSE); 196 Am_RadioButton->setChecked(FALSE);
184} 197}
185 198
186void Set_Alarm::cleanUp() 199void Set_Alarm::cleanUp()
187{ 200{
188} 201}
202
203void Set_Alarm::slotChangemp3CkeckBox(bool b) {
204 Config config( "qpe" );
205 config.setGroup("Time");
206 if(b) {
207 QString str = OFileDialog::getOpenFileName( 2,"/");//,"", "*", this );
208 if(!str.isEmpty() ) {
209 qDebug(str);
210 config.writeEntry("mp3Alarm",1);
211 config.writeEntry("mp3File",str);
212 }
213 } else {
214 config.writeEntry("mp3Alarm",0);
215 config.writeEntry("mp3File","");
216 }
217}
diff --git a/noncore/tools/clock/setAlarm.h b/noncore/tools/clock/setAlarm.h
index 7d63237..a21af05 100644
--- a/noncore/tools/clock/setAlarm.h
+++ b/noncore/tools/clock/setAlarm.h
@@ -1,57 +1,59 @@
1 /*************************************************************************** 1 /***************************************************************************
2// setAlarm.h - description 2// setAlarm.h - 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#ifndef SET_ALARM_H 15#ifndef SET_ALARM_H
16#define SET_ALARM_H 16#define SET_ALARM_H
17 17
18#include <qvariant.h> 18#include <qvariant.h>
19#include <qdialog.h> 19#include <qdialog.h>
20 20
21class QVBoxLayout; 21class QVBoxLayout;
22class QHBoxLayout; 22class QHBoxLayout;
23class QGridLayout; 23class QGridLayout;
24class QLCDNumber; 24class QLCDNumber;
25class QLabel; 25class QLabel;
26class QRadioButton; 26class QRadioButton;
27class QSlider; 27class QSlider;
28class QButtonGroup; 28class QButtonGroup;
29 29class QCheckBox;
30class Set_Alarm : public QDialog 30class Set_Alarm : public QDialog
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33 33
34public: 34public:
35 Set_Alarm( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 35 Set_Alarm( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
36 ~Set_Alarm(); 36 ~Set_Alarm();
37 37
38 QLabel *TextLabel1, *TextLabel2, *TextLabel3; 38 QLabel *TextLabel1, *TextLabel2, *TextLabel3;
39 QSlider *Hour_Slider, *Minute_Slider, *SnoozeSlider; 39 QSlider *Hour_Slider, *Minute_Slider, *SnoozeSlider;
40 QLCDNumber *Hour_LCDNumber, *Minute_LCDNumber, *Snooze_LCDNumber; 40 QLCDNumber *Hour_LCDNumber, *Minute_LCDNumber, *Snooze_LCDNumber;
41 41
42 QRadioButton* Am_RadioButton; 42 QRadioButton* Am_RadioButton;
43 43
44 QRadioButton* Pm_RadioButton; 44 QRadioButton* Pm_RadioButton;
45 QButtonGroup *ButtonGroup1; 45 QButtonGroup *ButtonGroup1;
46 QCheckBox *useMp3Check;
46protected slots: 47protected slots:
48 void slotChangemp3CkeckBox(bool);
47 void slotChangeHour(int); 49 void slotChangeHour(int);
48 void slotChangeMinute(int); 50 void slotChangeMinute(int);
49 void slotChangeSnooze(int); 51 void slotChangeSnooze(int);
50 void amButtonToggled(bool); 52 void amButtonToggled(bool);
51 void pmButtonToggled(bool); 53 void pmButtonToggled(bool);
52 void cleanUp(); 54 void cleanUp();
53protected: 55protected:
54 QGridLayout* Set_AlarmLayout; 56 QGridLayout* Set_AlarmLayout;
55}; 57};
56 58
57#endif // SET_ALARM_H 59#endif // SET_ALARM_H