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
@@ -256,43 +256,54 @@ void Clock::updateClock()
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
@@ -592,44 +603,38 @@ QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
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
@@ -91,16 +91,18 @@ private:
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