summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp47
-rw-r--r--noncore/tools/clock/clock.h2
2 files changed, 28 insertions, 21 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 9898332..0eb2b83 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -172,211 +172,222 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
172 connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( changeClock( bool ) ) ); 172 connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( changeClock( bool ) ) );
173 173
174 174
175 Config config( "qpe" ); 175 Config config( "qpe" );
176 config.setGroup( "Time" ); 176 config.setGroup( "Time" );
177 ampm = config.readBoolEntry( "AMPM", TRUE ); 177 ampm = config.readBoolEntry( "AMPM", TRUE );
178 178
179 QString tmp = config.readEntry( "clockAlarmHour", "" ); 179 QString tmp = config.readEntry( "clockAlarmHour", "" );
180 bool ok; 180 bool ok;
181 hour = tmp.toInt( &ok, 10 ); 181 hour = tmp.toInt( &ok, 10 );
182 tmp = config.readEntry( "clockAlarmMinute", "" ); 182 tmp = config.readEntry( "clockAlarmMinute", "" );
183 minute = tmp.toInt( &ok, 10 ); 183 minute = tmp.toInt( &ok, 10 );
184 184
185 if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) 185 if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" )
186 { 186 {
187 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 187 alarmOffBtn->setText( tr( "Alarm Is On" ) );
188 alarmBool = TRUE; 188 alarmBool = TRUE;
189 snoozeBtn->show(); 189 snoozeBtn->show();
190 } 190 }
191 else 191 else
192 { 192 {
193 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 193 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
194 alarmBool = FALSE; 194 alarmBool = FALSE;
195 snoozeBtn->hide(); 195 snoozeBtn->hide();
196 } 196 }
197 197
198 QTimer::singleShot( 0, this, SLOT( updateClock() ) ); 198 QTimer::singleShot( 0, this, SLOT( updateClock() ) );
199 199
200 Config cfg( "Clock" ); 200 Config cfg( "Clock" );
201 cfg.setGroup( "Mode" ); 201 cfg.setGroup( "Mode" );
202 int mode = cfg.readBoolEntry( "clockMode");setSwatchMode( mode); 202 int mode = cfg.readBoolEntry( "clockMode");setSwatchMode( mode);
203 modeSelect( mode); 203 modeSelect( mode);
204} 204}
205 205
206Clock::~Clock() 206Clock::~Clock()
207{ 207{
208 toggleScreenSaver( true ); 208 toggleScreenSaver( true );
209} 209}
210 210
211void Clock::updateClock() 211void Clock::updateClock()
212{ 212{
213 if ( clockRB->isChecked() ) 213 if ( clockRB->isChecked() )
214 { 214 {
215 QTime tm = QDateTime::currentDateTime().time(); 215 QTime tm = QDateTime::currentDateTime().time();
216 QString s; 216 QString s;
217 if ( ampm ) 217 if ( ampm )
218 { 218 {
219 int hour = tm.hour(); 219 int hour = tm.hour();
220 if ( hour == 0 ) 220 if ( hour == 0 )
221 hour = 12; 221 hour = 12;
222 if ( hour > 12 ) 222 if ( hour > 12 )
223 hour -= 12; 223 hour -= 12;
224 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); 224 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() );
225 ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" ); 225 ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" );
226 ampmLabel->show(); 226 ampmLabel->show();
227 } 227 }
228 else 228 else
229 { 229 {
230 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); 230 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
231 ampmLabel->hide(); 231 ampmLabel->hide();
232 } 232 }
233 lcd->display( s ); 233 lcd->display( s );
234 lcd->repaint( FALSE ); 234 lcd->repaint( FALSE );
235 aclock->display( QTime::currentTime() ); 235 aclock->display( QTime::currentTime() );
236 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 236 date->setText( TimeString::longDateString( QDate::currentDate() ) );
237 } 237 }
238 else 238 else
239 { 239 {
240 QTime swatch_time; 240 QTime swatch_time;
241 QString lcdtext; 241 QString lcdtext;
242 int totalms = swatch_totalms; 242 int totalms = swatch_totalms;
243 if ( swatch_running ) 243 if ( swatch_running )
244 totalms += swatch_start.elapsed(); 244 totalms += swatch_start.elapsed();
245 swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms ); 245 swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms );
246 QString d = swatch_running ? QString( " " ) 246 QString d = swatch_running ? QString( " " )
247 : QString::number( totalms % 1000 + 1000 ); 247 : QString::number( totalms % 1000 + 1000 );
248 lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec ); 248 lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec );
249 lcd->display( lcdtext ); 249 lcd->display( lcdtext );
250 lcd->repaint( FALSE ); 250 lcd->repaint( FALSE );
251 aclock->display( swatch_time ); 251 aclock->display( swatch_time );
252 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 252 date->setText( TimeString::longDateString( QDate::currentDate() ) );
253 } 253 }
254} 254}
255 255
256void Clock::changeClock( bool a ) 256void Clock::changeClock( bool a )
257{ 257{
258 ampm = a; 258 ampm = a;
259 updateClock(); 259 updateClock();
260} 260}
261 261
262void Clock::clearClock( void ) 262void Clock::clearClock( void )
263{ 263{
264 lcd->display( QTime( 0, 0, 0 ).toString() ); 264 lcd->display( QTime( 0, 0, 0 ).toString() );
265 aclock->display( QTime( 0, 0, 0 ) ); 265 aclock->display( QTime( 0, 0, 0 ) );
266} 266}
267 267
268void Clock::startSWatch()
269{
270 swatch_start.start();
271 set->setText( tr( "Stop" ) );
272 t->start( 1000 );
273 swatch_running = TRUE;
274 // disable screensaver while stop watch is running
275 toggleScreenSaver( FALSE );
276}
277
278void Clock::stopSWatch()
279{
280 swatch_totalms += swatch_start.elapsed();
281 set->setText( tr( "Start" ) );
282 t->stop();
283 swatch_running = FALSE;
284 toggleScreenSaver( TRUE );
285 updateClock();
286}
287
288
268void Clock::slotSet() 289void Clock::slotSet()
269{ 290{
270 if ( t->isActive() ) 291 if ( t->isActive() )
271 { 292 {
272 swatch_totalms += swatch_start.elapsed(); 293 startSWatch();
273 set->setText( tr( "Start" ) );
274 t->stop();
275 swatch_running = FALSE;
276 toggleScreenSaver( TRUE );
277 updateClock();
278 } 294 }
279 else 295 else
280 { 296 {
281 swatch_start.start(); 297 stopSWatch();
282 set->setText( tr( "Stop" ) );
283 t->start( 1000 );
284 swatch_running = TRUE;
285 // disable screensaver while stop watch is running
286 toggleScreenSaver( FALSE );
287 } 298 }
288} 299}
289 300
290void Clock::slotReset() 301void Clock::slotReset()
291{ 302{
292 t->stop(); 303 t->stop();
293 swatch_start.start(); 304 swatch_start.start();
294 swatch_totalms = 0; 305 swatch_totalms = 0;
295 306
296 if ( swatch_running ) 307 if ( swatch_running )
297 t->start( 1000 ); 308 t->start( 1000 );
298 309
299 updateClock(); 310 updateClock();
300} 311}
301 312
302void Clock::modeSelect( int m ) 313void Clock::modeSelect( int m )
303{ 314{
304 qDebug("Clock::modeSelect( %d) ", m); 315 qDebug("Clock::modeSelect( %d) ", m);
305 if ( m ) 316 if ( m )
306 { 317 {
307 lcd->setNumDigits( 8 + 1 + sw_prec ); 318 lcd->setNumDigits( 8 + 1 + sw_prec );
308 lcd->setMinimumWidth( lcd->sizeHint().width() ); 319 lcd->setMinimumWidth( lcd->sizeHint().width() );
309 set->setEnabled( TRUE ); 320 set->setEnabled( TRUE );
310 reset->setEnabled( TRUE ); 321 reset->setEnabled( TRUE );
311 ampmLabel->hide(); 322 ampmLabel->hide();
312 323
313 if ( !swatch_running ) 324 if ( !swatch_running )
314 t->stop(); 325 t->stop();
315 } 326 }
316 else 327 else
317 { 328 {
318 lcd->setNumDigits( 5 ); 329 lcd->setNumDigits( 5 );
319 lcd->setMinimumWidth( lcd->sizeHint().width() ); 330 lcd->setMinimumWidth( lcd->sizeHint().width() );
320 set->setEnabled( FALSE ); 331 set->setEnabled( FALSE );
321 reset->setEnabled( FALSE ); 332 reset->setEnabled( FALSE );
322 t->start( 1000 ); 333 t->start( 1000 );
323 } 334 }
324 335
325 Config config( "Clock" ); 336 Config config( "Clock" );
326 config.setGroup( "Mode" ); 337 config.setGroup( "Mode" );
327 config.writeEntry( "clockMode", m ); 338 config.writeEntry( "clockMode", m );
328 updateClock(); 339 updateClock();
329} 340}
330 341
331//this sets the alarm time 342//this sets the alarm time
332void Clock::slotSetAlarm() 343void Clock::slotSetAlarm()
333{ 344{
334 if ( !snoozeBtn->isHidden() ) 345 if ( !snoozeBtn->isHidden() )
335 slotToggleAlarm(); 346 slotToggleAlarm();
336 Set_Alarm *setAlarmDlg; 347 Set_Alarm *setAlarmDlg;
337 setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); 348 setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE );
338 int result = setAlarmDlg->exec(); 349 int result = setAlarmDlg->exec();
339 if ( result == 1 ) { 350 if ( result == 1 ) {
340 Config config( "qpe" ); 351 Config config( "qpe" );
341 config.setGroup( "Time" ); 352 config.setGroup( "Time" );
342 QString tmp; 353 QString tmp;
343 hour = setAlarmDlg->Hour_Slider->value(); 354 hour = setAlarmDlg->Hour_Slider->value();
344 minute = setAlarmDlg->Minute_Slider->value(); 355 minute = setAlarmDlg->Minute_Slider->value();
345 snoozeTime = setAlarmDlg->SnoozeSlider->value(); 356 snoozeTime = setAlarmDlg->SnoozeSlider->value();
346 if ( ampm ) { 357 if ( ampm ) {
347 if ( hour == 12 ) 358 if ( hour == 12 )
348 hour = 0; 359 hour = 0;
349 360
350 if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) 361 if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 )
351 hour += 12; 362 hour += 12;
352 } 363 }
353 config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); 364 config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 );
354 config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); 365 config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 );
355 config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); 366 config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 );
356 config.write(); 367 config.write();
357 } 368 }
358} 369}
359 370
360void Clock::slotSnooze() 371void Clock::slotSnooze()
361{ 372{
362 bSound = FALSE; 373 bSound = FALSE;
363 int warn = 0; 374 int warn = 0;
364 QTime t = QTime::currentTime(); 375 QTime t = QTime::currentTime();
365 QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); 376 QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) );
366 when = whenl; 377 when = whenl;
367 AlarmServer::addAlarm( when, 378 AlarmServer::addAlarm( when,
368 "QPE/Application/clock", 379 "QPE/Application/clock",
369 "alarm(QDateTime,int)", warn ); 380 "alarm(QDateTime,int)", warn );
370 381
371} 382}
372 383
373//toggles alarm on/off 384//toggles alarm on/off
374void Clock::slotToggleAlarm() 385void Clock::slotToggleAlarm()
375{ 386{
376 Config config( "qpe" ); 387 Config config( "qpe" );
377 config.setGroup( "Time" ); 388 config.setGroup( "Time" );
378 if ( alarmBool ) 389 if ( alarmBool )
379 { 390 {
380 config.writeEntry( "clockAlarmSet", "FALSE" ); 391 config.writeEntry( "clockAlarmSet", "FALSE" );
381 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 392 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
382 snoozeBtn->hide(); 393 snoozeBtn->hide();
@@ -508,128 +519,122 @@ void AnalogClock::drawContents( QPainter *p )
508 fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); 519 fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( ));
509 520
510 QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); 521 QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 );
511 QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); 522 QPoint l1 ( center. x ( ), fr. y ( ) + 2 );
512 QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); 523 QPoint l2 ( center. x ( ), fr. y ( ) + 8 );
513 524
514 525
515 526
516 if ( clear ) 527 if ( clear )
517 { 528 {
518 erase ( r ); 529 erase ( r );
519 p-> setPen ( NoPen ); 530 p-> setPen ( NoPen );
520 p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); 531 p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base ));
521 p-> drawEllipse ( fr ); 532 p-> drawEllipse ( fr );
522 p-> setBrush ( NoBrush ); 533 p-> setBrush ( NoBrush );
523 534
524 // draw ticks 535 // draw ticks
525 p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); 536 p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) );
526 for ( int i = 0; i < 12; i++ ) 537 for ( int i = 0; i < 12; i++ )
527 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); 538 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
528 } 539 }
529 else 540 else
530 { 541 {
531 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); 542 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime );
532 } 543 }
533 544
534 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); 545 drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime );
535 546
536 prevTime = currTime; 547 prevTime = currTime;
537} 548}
538 549
539void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) 550void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 )
540{ 551{
541 QPoint center = r. center ( ); 552 QPoint center = r. center ( );
542 553
543 QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); 554 QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 );
544 QPoint h2( center. x ( ), center. y ( ) ); 555 QPoint h2( center. x ( ), center. y ( ) );
545 556
546 QPoint m1( center. x ( ), r.y() + r.height() / 8 ); 557 QPoint m1( center. x ( ), r.y() + r.height() / 8 );
547 QPoint m2( center. x ( ), center. y ( ) ); 558 QPoint m2( center. x ( ), center. y ( ) );
548 559
549 QPoint s1( center. x ( ), r. y ( ) + 8 ); 560 QPoint s1( center. x ( ), r. y ( ) + 8 );
550 QPoint s2( center. x ( ), center. y ( ) ); 561 QPoint s2( center. x ( ), center. y ( ) );
551 562
552 563
553 if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { 564 if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) {
554 // draw hour pointer 565 // draw hour pointer
555 h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); 566 h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 );
556 h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); 567 h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 );
557 p-> setPen ( QPen ( c, 3 )); 568 p-> setPen ( QPen ( c, 3 ));
558 p-> drawLine ( h1, h2 ); 569 p-> drawLine ( h1, h2 );
559 } 570 }
560 571
561 if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { 572 if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) {
562 // draw minute pointer 573 // draw minute pointer
563 m1 = rotate( center, m1, t.minute() * 6 ); 574 m1 = rotate( center, m1, t.minute() * 6 );
564 m2 = rotate( center, m2, t.minute() * 6 ); 575 m2 = rotate( center, m2, t.minute() * 6 );
565 p-> setPen ( QPen ( c, 2 )); 576 p-> setPen ( QPen ( c, 2 ));
566 p-> drawLine ( m1, m2 ); 577 p-> drawLine ( m1, m2 );
567 } 578 }
568 579
569 if ( !t2 || ( t. second ( ) != t2-> second ( ))) { 580 if ( !t2 || ( t. second ( ) != t2-> second ( ))) {
570 // draw second pointer 581 // draw second pointer
571 s1 = rotate( center, s1, t.second() * 6 ); 582 s1 = rotate( center, s1, t.second() * 6 );
572 s2 = rotate( center, s2, t.second() * 6 ); 583 s2 = rotate( center, s2, t.second() * 6 );
573 p-> setPen ( QPen ( c, 1 )); 584 p-> setPen ( QPen ( c, 1 ));
574 p-> drawLine ( s1, s2 ); 585 p-> drawLine ( s1, s2 );
575 } 586 }
576} 587}
577 588
578void AnalogClock::display( const QTime& t ) 589void AnalogClock::display( const QTime& t )
579{ 590{
580 currTime = t; 591 currTime = t;
581 clear = false; 592 clear = false;
582 repaint( false ); 593 repaint( false );
583 clear = true; 594 clear = true;
584} 595}
585 596
586QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) 597QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
587{ 598{
588 double angle = deg2rad * ( - a + 180 ); 599 double angle = deg2rad * ( - a + 180 );
589 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - 600 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
590 ( p.y() - c.y() ) * sin( angle ); 601 ( p.y() - c.y() ) * sin( angle );
591 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + 602 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
592 ( p.x() - c.x() ) * sin( angle ); 603 ( p.x() - c.x() ) * sin( angle );
593 return QPoint( nx, ny ); 604 return QPoint( nx, ny );
594} 605}
595 606
596void Clock::slotAdjustTime() 607void Clock::slotAdjustTime()
597{ 608{
598 QCopEnvelope e( "QPE/System", "execute(QString)" ); 609 QCopEnvelope e( "QPE/System", "execute(QString)" );
599 e << QString( "systemtime" ); 610 e << QString( "systemtime" );
600} 611}
601 612
602void Clock::slotStartTimer() 613void Clock::slotStartTimer()
603{ 614{
604 Config cfg( "Clock" );
605 cfg.setGroup( "Mode" );
606 int mode = cfg.readBoolEntry( "clockMode");
607 if ( clockRB->isChecked() ) 615 if ( clockRB->isChecked() )
608 setSwatchMode( 1); 616 setSwatchMode( 1);
609 slotSet(); 617 startSWatch();
610} 618}
611 619
612void Clock::slotStopTimer() 620void Clock::slotStopTimer()
613{ 621{
614 Config cfg( "Clock" );
615 cfg.setGroup( "Mode" );
616 int mode = cfg.readBoolEntry( "clockMode");
617 if ( clockRB->isChecked() ) 622 if ( clockRB->isChecked() )
618 setSwatchMode( 1); 623 setSwatchMode( 1);
619slotSet(); 624 stopSWatch();
620} 625}
621 626
622void Clock::slotResetTimer() 627void Clock::slotResetTimer()
623{ 628{
624 if ( clockRB->isChecked() ) 629 if ( clockRB->isChecked() )
625 setSwatchMode( 1); 630 setSwatchMode( 1);
626slotReset(); 631slotReset();
627} 632}
628 633
629void Clock::setSwatchMode(int mode) 634void Clock::setSwatchMode(int mode)
630{ 635{
631 qDebug("Clock::setSwatchMode( %d)"), mode; 636 qDebug("Clock::setSwatchMode( %d)", mode);
632 swatchRB->setChecked( mode); 637 swatchRB->setChecked( mode);
633 clearClock( ); 638 clearClock( );
634 modeSelect( mode ); 639 modeSelect( mode );
635} 640}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index 9b00e28..1e5aa2c 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -7,100 +7,102 @@
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#ifndef CLOCK_H 20#ifndef CLOCK_H
21#define CLOCK_H 21#define CLOCK_H
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qvbox.h> 24#include <qvbox.h>
25 25
26class QLCDNumber; 26class QLCDNumber;
27class QLabel; 27class QLabel;
28class QTimer; 28class QTimer;
29class QRadioButton; 29class QRadioButton;
30class QPushButton; 30class QPushButton;
31class QDateTime; 31class QDateTime;
32 32
33class AnalogClock : public QFrame 33class AnalogClock : public QFrame
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36 36
37public: 37public:
38 AnalogClock( QWidget * parent = 0, const char * name = 0 ) 38 AnalogClock( QWidget * parent = 0, const char * name = 0 )
39 : QFrame( parent, name ), clear(true) {} 39 : QFrame( parent, name ), clear(true) {}
40 40
41 QSizePolicy sizePolicy() const; 41 QSizePolicy sizePolicy() const;
42 42
43 void display( const QTime& time ); 43 void display( const QTime& time );
44 44
45protected: 45protected:
46 void drawContents( QPainter *p ); 46 void drawContents( QPainter *p );
47 47
48private: 48private:
49 49
50 QTime currTime; 50 QTime currTime;
51 QTime prevTime; 51 QTime prevTime;
52 bool clear; 52 bool clear;
53 53
54 QPoint rotate( QPoint center, QPoint p, int angle ); 54 QPoint rotate( QPoint center, QPoint p, int angle );
55 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); 55 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
56 56
57}; 57};
58 58
59class Clock : public QVBox 59class Clock : public QVBox
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 62
63public: 63public:
64 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); 64 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 );
65 ~Clock(); 65 ~Clock();
66 QDateTime when; 66 QDateTime when;
67 bool bSound; 67 bool bSound;
68 int hour, minute, snoozeTime; 68 int hour, minute, snoozeTime;
69private slots: 69private slots:
70 void slotSet(); 70 void slotSet();
71 void slotReset(); 71 void slotReset();
72 void modeSelect(int); 72 void modeSelect(int);
73 void updateClock(); 73 void updateClock();
74 void changeClock( bool ); 74 void changeClock( bool );
75 void slotSetAlarm(); 75 void slotSetAlarm();
76 void slotSnooze(); 76 void slotSnooze();
77 void slotToggleAlarm(); 77 void slotToggleAlarm();
78 void alarmOn(); 78 void alarmOn();
79 void alarmOff(); 79 void alarmOff();
80 void appMessage(const QCString& msg, const QByteArray& data); 80 void appMessage(const QCString& msg, const QByteArray& data);
81 void timerEvent( QTimerEvent *e ); 81 void timerEvent( QTimerEvent *e );
82 void slotAdjustTime(); 82 void slotAdjustTime();
83 83
84 void slotStartTimer(); 84 void slotStartTimer();
85 void slotStopTimer(); 85 void slotStopTimer();
86 void slotResetTimer(); 86 void slotResetTimer();
87 void setSwatchMode( int ); 87 void setSwatchMode( int );
88private: 88private:
89 bool alarmBool; 89 bool alarmBool;
90 QTimer *t; 90 QTimer *t;
91 QLCDNumber *lcd; 91 QLCDNumber *lcd;
92 QLabel *date; 92 QLabel *date;
93 QLabel *ampmLabel; 93 QLabel *ampmLabel;
94 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; 94 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn;
95 QRadioButton *clockRB, *swatchRB; 95 QRadioButton *clockRB, *swatchRB;
96 AnalogClock *aclock; 96 AnalogClock *aclock;
97 QTime swatch_start; 97 QTime swatch_start;
98 int swatch_totalms; 98 int swatch_totalms;
99 bool swatch_running; 99 bool swatch_running;
100 bool ampm; 100 bool ampm;
101 void clearClock(); 101 void clearClock();
102 void clearTimer(); 102 void clearTimer();
103 void startSWatch();
104 void stopSWatch();
103}; 105};
104 106
105#endif 107#endif
106 108