-rw-r--r-- | noncore/tools/clock/clock.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 0eb2b83..74b7147 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -190,25 +190,26 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
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"); |
203 | setSwatchMode( mode); | ||
203 | modeSelect( mode); | 204 | modeSelect( mode); |
204 | } | 205 | } |
205 | 206 | ||
206 | Clock::~Clock() | 207 | Clock::~Clock() |
207 | { | 208 | { |
208 | toggleScreenSaver( true ); | 209 | toggleScreenSaver( true ); |
209 | } | 210 | } |
210 | 211 | ||
211 | void Clock::updateClock() | 212 | void Clock::updateClock() |
212 | { | 213 | { |
213 | if ( clockRB->isChecked() ) | 214 | if ( clockRB->isChecked() ) |
214 | { | 215 | { |
@@ -258,34 +259,40 @@ void Clock::changeClock( bool a ) | |||
258 | ampm = a; | 259 | ampm = a; |
259 | updateClock(); | 260 | updateClock(); |
260 | } | 261 | } |
261 | 262 | ||
262 | void Clock::clearClock( void ) | 263 | void Clock::clearClock( void ) |
263 | { | 264 | { |
264 | lcd->display( QTime( 0, 0, 0 ).toString() ); | 265 | lcd->display( QTime( 0, 0, 0 ).toString() ); |
265 | aclock->display( QTime( 0, 0, 0 ) ); | 266 | aclock->display( QTime( 0, 0, 0 ) ); |
266 | } | 267 | } |
267 | 268 | ||
268 | void Clock::startSWatch() | 269 | void Clock::startSWatch() |
269 | { | 270 | { |
271 | if(swatch_running) { | ||
272 | stopSWatch(); | ||
273 | return; | ||
274 | } | ||
275 | qDebug("startSWatch()"); | ||
270 | swatch_start.start(); | 276 | swatch_start.start(); |
271 | set->setText( tr( "Stop" ) ); | 277 | set->setText( tr( "Stop" ) ); |
272 | t->start( 1000 ); | 278 | t->start( 1000 ); |
273 | swatch_running = TRUE; | 279 | swatch_running = TRUE; |
274 | // disable screensaver while stop watch is running | 280 | // disable screensaver while stop watch is running |
275 | toggleScreenSaver( FALSE ); | 281 | toggleScreenSaver( FALSE ); |
276 | } | 282 | } |
277 | 283 | ||
278 | void Clock::stopSWatch() | 284 | void Clock::stopSWatch() |
279 | { | 285 | { |
286 | qDebug("stopSWatch()"); | ||
280 | swatch_totalms += swatch_start.elapsed(); | 287 | swatch_totalms += swatch_start.elapsed(); |
281 | set->setText( tr( "Start" ) ); | 288 | set->setText( tr( "Start" ) ); |
282 | t->stop(); | 289 | t->stop(); |
283 | swatch_running = FALSE; | 290 | swatch_running = FALSE; |
284 | toggleScreenSaver( TRUE ); | 291 | toggleScreenSaver( TRUE ); |
285 | updateClock(); | 292 | updateClock(); |
286 | } | 293 | } |
287 | 294 | ||
288 | 295 | ||
289 | void Clock::slotSet() | 296 | void Clock::slotSet() |
290 | { | 297 | { |
291 | if ( t->isActive() ) | 298 | if ( t->isActive() ) |
@@ -304,36 +311,43 @@ void Clock::slotReset() | |||
304 | swatch_start.start(); | 311 | swatch_start.start(); |
305 | swatch_totalms = 0; | 312 | swatch_totalms = 0; |
306 | 313 | ||
307 | if ( swatch_running ) | 314 | if ( swatch_running ) |
308 | t->start( 1000 ); | 315 | t->start( 1000 ); |
309 | 316 | ||
310 | updateClock(); | 317 | updateClock(); |
311 | } | 318 | } |
312 | 319 | ||
313 | void Clock::modeSelect( int m ) | 320 | void Clock::modeSelect( int m ) |
314 | { | 321 | { |
315 | qDebug("Clock::modeSelect( %d) ", m); | 322 | qDebug("Clock::modeSelect( %d) ", m); |
316 | if ( m ) | 323 | if ( m != 0 ) |
317 | { | 324 | { |
318 | lcd->setNumDigits( 8 + 1 + sw_prec ); | 325 | lcd->setNumDigits( 8 + 1 + sw_prec ); |
319 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 326 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
320 | set->setEnabled( TRUE ); | 327 | set->setEnabled( TRUE ); |
321 | reset->setEnabled( TRUE ); | 328 | reset->setEnabled( TRUE ); |
322 | ampmLabel->hide(); | 329 | ampmLabel->hide(); |
323 | 330 | ||
324 | if ( !swatch_running ) | 331 | // if(m == 2) { |
325 | t->stop(); | 332 | if ( !swatch_running ) { |
333 | t->start( 1000 ); | ||
326 | } | 334 | } |
327 | else | 335 | // else |
336 | // { | ||
337 | // stopSWatch(); | ||
338 | // } | ||
339 | // } | ||
340 | } | ||
341 | else //clock mode | ||
328 | { | 342 | { |
329 | lcd->setNumDigits( 5 ); | 343 | lcd->setNumDigits( 5 ); |
330 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 344 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
331 | set->setEnabled( FALSE ); | 345 | set->setEnabled( FALSE ); |
332 | reset->setEnabled( FALSE ); | 346 | reset->setEnabled( FALSE ); |
333 | t->start( 1000 ); | 347 | t->start( 1000 ); |
334 | } | 348 | } |
335 | 349 | ||
336 | Config config( "Clock" ); | 350 | Config config( "Clock" ); |
337 | config.setGroup( "Mode" ); | 351 | config.setGroup( "Mode" ); |
338 | config.writeEntry( "clockMode", m ); | 352 | config.writeEntry( "clockMode", m ); |
339 | updateClock(); | 353 | updateClock(); |