-rw-r--r-- | noncore/tools/clock/clock.cpp | 47 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 2 |
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 @@ -244,67 +244,78 @@ void Clock::updateClock() totalms += swatch_start.elapsed(); swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms ); QString d = swatch_running ? QString( " " ) : QString::number( totalms % 1000 + 1000 ); lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec ); lcd->display( lcdtext ); lcd->repaint( FALSE ); aclock->display( swatch_time ); date->setText( TimeString::longDateString( QDate::currentDate() ) ); } } void Clock::changeClock( bool a ) { ampm = a; updateClock(); } void Clock::clearClock( void ) { lcd->display( QTime( 0, 0, 0 ).toString() ); aclock->display( QTime( 0, 0, 0 ) ); } +void Clock::startSWatch() +{ + swatch_start.start(); + set->setText( tr( "Stop" ) ); + t->start( 1000 ); + swatch_running = TRUE; + // disable screensaver while stop watch is running + toggleScreenSaver( FALSE ); +} + +void Clock::stopSWatch() +{ + swatch_totalms += swatch_start.elapsed(); + set->setText( tr( "Start" ) ); + t->stop(); + swatch_running = FALSE; + toggleScreenSaver( TRUE ); + updateClock(); +} + + void Clock::slotSet() { if ( t->isActive() ) { - swatch_totalms += swatch_start.elapsed(); - set->setText( tr( "Start" ) ); - t->stop(); - swatch_running = FALSE; - toggleScreenSaver( TRUE ); - updateClock(); + startSWatch(); } else { - swatch_start.start(); - set->setText( tr( "Stop" ) ); - t->start( 1000 ); - swatch_running = TRUE; - // disable screensaver while stop watch is running - toggleScreenSaver( FALSE ); + stopSWatch(); } } void Clock::slotReset() { t->stop(); swatch_start.start(); swatch_totalms = 0; if ( swatch_running ) t->start( 1000 ); updateClock(); } void Clock::modeSelect( int m ) { qDebug("Clock::modeSelect( %d) ", m); if ( m ) { lcd->setNumDigits( 8 + 1 + sw_prec ); lcd->setMinimumWidth( lcd->sizeHint().width() ); set->setEnabled( TRUE ); reset->setEnabled( TRUE ); @@ -580,56 +591,50 @@ void AnalogClock::display( const QTime& t ) currTime = t; clear = false; repaint( false ); clear = true; } QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) { double angle = deg2rad * ( - a + 180 ); double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - ( p.y() - c.y() ) * sin( angle ); double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + ( p.x() - c.x() ) * sin( angle ); return QPoint( nx, ny ); } void Clock::slotAdjustTime() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( "systemtime" ); } void Clock::slotStartTimer() { - Config cfg( "Clock" ); - cfg.setGroup( "Mode" ); - int mode = cfg.readBoolEntry( "clockMode"); if ( clockRB->isChecked() ) setSwatchMode( 1); - slotSet(); + startSWatch(); } void Clock::slotStopTimer() { - Config cfg( "Clock" ); - cfg.setGroup( "Mode" ); - int mode = cfg.readBoolEntry( "clockMode"); if ( clockRB->isChecked() ) setSwatchMode( 1); -slotSet(); + stopSWatch(); } void Clock::slotResetTimer() { if ( clockRB->isChecked() ) setSwatchMode( 1); slotReset(); } void Clock::setSwatchMode(int mode) { - qDebug("Clock::setSwatchMode( %d)"), mode; + qDebug("Clock::setSwatchMode( %d)", mode); swatchRB->setChecked( mode); clearClock( ); modeSelect( mode ); } 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 @@ -79,28 +79,30 @@ private slots: void alarmOff(); void appMessage(const QCString& msg, const QByteArray& data); void timerEvent( QTimerEvent *e ); void slotAdjustTime(); void slotStartTimer(); void slotStopTimer(); void slotResetTimer(); void setSwatchMode( int ); private: bool alarmBool; QTimer *t; QLCDNumber *lcd; QLabel *date; QLabel *ampmLabel; QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; QRadioButton *clockRB, *swatchRB; AnalogClock *aclock; QTime swatch_start; int swatch_totalms; bool swatch_running; bool ampm; void clearClock(); void clearTimer(); + void startSWatch(); + void stopSWatch(); }; #endif |