-rw-r--r-- | noncore/tools/clock/clock.cpp | 94 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 3 |
2 files changed, 57 insertions, 40 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 5b901c1..d69c56f 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -260,272 +260,288 @@ void Clock::slotSet() | |||
260 | } | 260 | } |
261 | else { | 261 | else { |
262 | swatch_start.start(); | 262 | swatch_start.start(); |
263 | set | 263 | set |
264 | ->setText( tr( "Stop" ) ); | 264 | ->setText( tr( "Stop" ) ); |
265 | t->start( 1000 ); | 265 | t->start( 1000 ); |
266 | swatch_running = TRUE; | 266 | swatch_running = TRUE; |
267 | // disable screensaver while stop watch is running | 267 | // disable screensaver while stop watch is running |
268 | toggleScreenSaver( FALSE ); | 268 | toggleScreenSaver( FALSE ); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void Clock::slotReset() | 272 | void Clock::slotReset() |
273 | { | 273 | { |
274 | t->stop(); | 274 | t->stop(); |
275 | swatch_start.start(); | 275 | swatch_start.start(); |
276 | swatch_totalms = 0; | 276 | swatch_totalms = 0; |
277 | 277 | ||
278 | if ( swatch_running ) | 278 | if ( swatch_running ) |
279 | t->start( 1000 ); | 279 | t->start( 1000 ); |
280 | 280 | ||
281 | updateClock(); | 281 | updateClock(); |
282 | } | 282 | } |
283 | 283 | ||
284 | void Clock::modeSelect( int m ) | 284 | void Clock::modeSelect( int m ) |
285 | { | 285 | { |
286 | if ( m ) { | 286 | if ( m ) { |
287 | lcd->setNumDigits( 8 + 1 + sw_prec ); | 287 | lcd->setNumDigits( 8 + 1 + sw_prec ); |
288 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 288 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
289 | set | 289 | set |
290 | ->setEnabled( TRUE ); | 290 | ->setEnabled( TRUE ); |
291 | reset->setEnabled( TRUE ); | 291 | reset->setEnabled( TRUE ); |
292 | ampmLabel->hide(); | 292 | ampmLabel->hide(); |
293 | 293 | ||
294 | if ( !swatch_running ) | 294 | if ( !swatch_running ) |
295 | t->stop(); | 295 | t->stop(); |
296 | } | 296 | } |
297 | else { | 297 | else { |
298 | lcd->setNumDigits( 5 ); | 298 | lcd->setNumDigits( 5 ); |
299 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 299 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
300 | set | 300 | set |
301 | ->setEnabled( FALSE ); | 301 | ->setEnabled( FALSE ); |
302 | reset->setEnabled( FALSE ); | 302 | reset->setEnabled( FALSE ); |
303 | t->start( 1000 ); | 303 | t->start( 1000 ); |
304 | } | 304 | } |
305 | updateClock(); | 305 | updateClock(); |
306 | } | 306 | } |
307 | 307 | ||
308 | //this sets the alarm time | 308 | //this sets the alarm time |
309 | void Clock::slotSetAlarm() | 309 | void Clock::slotSetAlarm() |
310 | { | 310 | { |
311 | if ( !snoozeBtn->isHidden() ) | 311 | if ( !snoozeBtn->isHidden() ) |
312 | slotToggleAlarm(); | 312 | slotToggleAlarm(); |
313 | Set_Alarm *setAlarmDlg; | 313 | Set_Alarm *setAlarmDlg; |
314 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); | 314 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); |
315 | int result = setAlarmDlg->exec(); | 315 | int result = setAlarmDlg->exec(); |
316 | if ( result == 1 ) { | 316 | if ( result == 1 ) { |
317 | Config config( "qpe" ); | 317 | Config config( "qpe" ); |
318 | config.setGroup( "Time" ); | 318 | config.setGroup( "Time" ); |
319 | QString tmp; | 319 | QString tmp; |
320 | hour = setAlarmDlg->Hour_Slider->value(); | 320 | hour = setAlarmDlg->Hour_Slider->value(); |
321 | minute = setAlarmDlg->Minute_Slider->value(); | 321 | minute = setAlarmDlg->Minute_Slider->value(); |
322 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); | 322 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); |
323 | if ( ampm ) { | 323 | if ( ampm ) { |
324 | if ( hour == 12 ) | 324 | if ( hour == 12 ) |
325 | hour = 0; | 325 | hour = 0; |
326 | 326 | ||
327 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) | 327 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) |
328 | hour += 12; | 328 | hour += 12; |
329 | } | 329 | } |
330 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); | 330 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); |
331 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); | 331 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); |
332 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); | 332 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); |
333 | config.write(); | 333 | config.write(); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | void Clock::slotSnooze() | 337 | void Clock::slotSnooze() |
338 | { | 338 | { |
339 | bSound = FALSE; | 339 | bSound = FALSE; |
340 | int warn = 0; | 340 | int warn = 0; |
341 | QTime t = QTime::currentTime(); | 341 | QTime t = QTime::currentTime(); |
342 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); | 342 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); |
343 | when = whenl; | 343 | when = whenl; |
344 | AlarmServer::addAlarm( when, | 344 | AlarmServer::addAlarm( when, |
345 | "QPE/Application/clock", | 345 | "QPE/Application/clock", |
346 | "alarm(QDateTime,int)", warn ); | 346 | "alarm(QDateTime,int)", warn ); |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | //toggles alarm on/off | 350 | //toggles alarm on/off |
351 | void Clock::slotToggleAlarm() | 351 | void Clock::slotToggleAlarm() |
352 | { | 352 | { |
353 | Config config( "qpe" ); | 353 | Config config( "qpe" ); |
354 | config.setGroup( "Time" ); | 354 | config.setGroup( "Time" ); |
355 | if ( alarmBool ) { | 355 | if ( alarmBool ) { |
356 | config.writeEntry( "clockAlarmSet", "FALSE" ); | 356 | config.writeEntry( "clockAlarmSet", "FALSE" ); |
357 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 357 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
358 | snoozeBtn->hide(); | 358 | snoozeBtn->hide(); |
359 | alarmBool = FALSE; | 359 | alarmBool = FALSE; |
360 | alarmOff(); | 360 | alarmOff(); |
361 | } | 361 | } |
362 | else { | 362 | else { |
363 | config.writeEntry( "clockAlarmSet", "TRUE" ); | 363 | config.writeEntry( "clockAlarmSet", "TRUE" ); |
364 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 364 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
365 | snoozeBtn->show(); | 365 | snoozeBtn->show(); |
366 | alarmBool = TRUE; | 366 | alarmBool = TRUE; |
367 | alarmOn(); | 367 | alarmOn(); |
368 | } | 368 | } |
369 | config.write(); | 369 | config.write(); |
370 | } | 370 | } |
371 | 371 | ||
372 | void Clock::alarmOn() | 372 | void Clock::alarmOn() |
373 | { | 373 | { |
374 | QDate d = QDate::currentDate(); | 374 | QDate d = QDate::currentDate(); |
375 | QTime tm( ( int ) hour, ( int ) minute, 0 ); | 375 | QTime tm( ( int ) hour, ( int ) minute, 0 ); |
376 | qDebug( "Time set " + tm.toString() ); | 376 | qDebug( "Time set " + tm.toString() ); |
377 | QTime t = QTime::currentTime(); | 377 | QTime t = QTime::currentTime(); |
378 | if ( t > tm ) | 378 | if ( t > tm ) |
379 | d = d.addDays( 1 ); | 379 | d = d.addDays( 1 ); |
380 | int warn = 0; | 380 | int warn = 0; |
381 | QDateTime whenl( d, tm ); | 381 | QDateTime whenl( d, tm ); |
382 | when = whenl; | 382 | when = whenl; |
383 | AlarmServer::addAlarm( when, | 383 | AlarmServer::addAlarm( when, |
384 | "QPE/Application/clock", | 384 | "QPE/Application/clock", |
385 | "alarm(QDateTime,int)", warn ); | 385 | "alarm(QDateTime,int)", warn ); |
386 | setCaption( "Alarm set: " + whenl.toString() ); | 386 | setCaption( "Alarm set: " + whenl.toString() ); |
387 | } | 387 | } |
388 | 388 | ||
389 | void Clock::alarmOff() | 389 | void Clock::alarmOff() |
390 | { | 390 | { |
391 | int warn = 0; | 391 | int warn = 0; |
392 | bSound = FALSE; | 392 | bSound = FALSE; |
393 | AlarmServer::deleteAlarm( when, | 393 | AlarmServer::deleteAlarm( when, |
394 | "QPE/Application/clock", | 394 | "QPE/Application/clock", |
395 | "alarm(QDateTime,int)", warn ); | 395 | "alarm(QDateTime,int)", warn ); |
396 | qDebug( "Alarm Off " + when.toString() ); | 396 | qDebug( "Alarm Off " + when.toString() ); |
397 | setCaption( "Clock" ); | 397 | setCaption( "Clock" ); |
398 | } | 398 | } |
399 | 399 | ||
400 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | 400 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) |
401 | { | 401 | { |
402 | int stopTimer = 0; | 402 | int stopTimer = 0; |
403 | int timerStay = 5000; | 403 | int timerStay = 5000; |
404 | bSound = TRUE; | 404 | bSound = TRUE; |
405 | qDebug( "Message received in clock" ); | 405 | qDebug( "Message received in clock" ); |
406 | if ( msg == "alarm(QDateTime,int)" ) { | 406 | if ( msg == "alarm(QDateTime,int)" ) { |
407 | Config config( "qpe" ); | 407 | Config config( "qpe" ); |
408 | config.setGroup( "Time" ); | 408 | config.setGroup( "Time" ); |
409 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) { | 409 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) { |
410 | 410 | ||
411 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | 411 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); |
412 | e << config.readEntry( "mp3File", "" ); | 412 | e << config.readEntry( "mp3File", "" ); |
413 | } | 413 | } |
414 | else { | 414 | else { |
415 | 415 | ||
416 | Sound::soundAlarm(); | 416 | Sound::soundAlarm(); |
417 | stopTimer = startTimer( timerStay ); | 417 | stopTimer = startTimer( timerStay ); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | show(); | 420 | show(); |
421 | raise(); | 421 | raise(); |
422 | QPEApplication::setKeepRunning(); | 422 | QPEApplication::setKeepRunning(); |
423 | setActiveWindow(); | 423 | setActiveWindow(); |
424 | } | 424 | } |
425 | 425 | ||
426 | void Clock::timerEvent( QTimerEvent *e ) | 426 | void Clock::timerEvent( QTimerEvent *e ) |
427 | { | 427 | { |
428 | static int stop = 0; | 428 | static int stop = 0; |
429 | if ( stop < 120 && bSound ) { | 429 | if ( stop < 120 && bSound ) { |
430 | Sound::soundAlarm(); | 430 | Sound::soundAlarm(); |
431 | stop++; | 431 | stop++; |
432 | } | 432 | } |
433 | else { | 433 | else { |
434 | stop = 0; | 434 | stop = 0; |
435 | killTimer( e->timerId() ); | 435 | killTimer( e->timerId() ); |
436 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 436 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
437 | alarmBool = FALSE; | 437 | alarmBool = FALSE; |
438 | snoozeBtn->hide(); | 438 | snoozeBtn->hide(); |
439 | setCaption( tr( "Clock: Alarm was missed." ) ); | 439 | setCaption( tr( "Clock: Alarm was missed." ) ); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | 443 | ||
444 | QSizePolicy AnalogClock::sizePolicy() const | 444 | QSizePolicy AnalogClock::sizePolicy() const |
445 | { | 445 | { |
446 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | 446 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
447 | } | 447 | } |
448 | 448 | ||
449 | void AnalogClock::drawContents( QPainter *p ) | 449 | void AnalogClock::drawContents( QPainter *p ) |
450 | { | 450 | { |
451 | QRect r = contentsRect(); | 451 | QRect r = contentsRect(); |
452 | QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | 452 | QRect fr; |
453 | |||
454 | QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); | ||
455 | QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); | ||
456 | |||
457 | QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); | ||
458 | QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
459 | 453 | ||
460 | QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 ); | 454 | if ( r. width ( ) > r. height ( )) |
461 | QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | 455 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); |
456 | else | ||
457 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); | ||
458 | |||
459 | QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); | ||
460 | QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); | ||
461 | QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); | ||
462 | 462 | ||
463 | QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); | ||
464 | QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
465 | 463 | ||
466 | QColor color( clear ? backgroundColor() : black ); | ||
467 | QTime time = clear ? prevTime : currTime; | ||
468 | 464 | ||
469 | if ( clear ) { | 465 | if ( clear ) { |
470 | erase( rect() ); | 466 | erase ( r ); |
471 | return ; | 467 | p-> setPen ( NoPen ); |
472 | } | 468 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); |
469 | p-> drawEllipse ( fr ); | ||
470 | p-> setBrush ( NoBrush ); | ||
473 | 471 | ||
474 | if ( !clear ) { | ||
475 | // draw ticks | 472 | // draw ticks |
476 | p->setPen( QPen( color, 1 ) ); | 473 | p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); |
477 | for ( int i = 0; i < 12; i++ ) | 474 | for ( int i = 0; i < 12; i++ ) |
478 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); | 475 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); |
479 | } | 476 | } |
477 | else { | ||
478 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); | ||
479 | } | ||
480 | |||
481 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); | ||
482 | |||
483 | prevTime = currTime; | ||
484 | } | ||
485 | |||
486 | void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) | ||
487 | { | ||
488 | QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
480 | 489 | ||
481 | if ( !clear || prevTime.minute() != currTime.minute() || | 490 | QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); |
482 | prevTime.hour() != currTime.hour() ) { | 491 | QPoint h2( center. x ( ), center. y ( ) ); |
492 | |||
493 | QPoint m1( center. x ( ), r.y() + r.height() / 8 ); | ||
494 | QPoint m2( center. x ( ), center. y ( ) ); | ||
495 | |||
496 | QPoint s1( center. x ( ), r. y ( ) + 8 ); | ||
497 | QPoint s2( center. x ( ), center. y ( ) ); | ||
498 | |||
499 | |||
500 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { | ||
483 | // draw hour pointer | 501 | // draw hour pointer |
484 | h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); | 502 | h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); |
485 | h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); | 503 | h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); |
486 | p->setPen( QPen( color, 3 ) ); | 504 | p-> setPen ( QPen ( c, 3 )); |
487 | p->drawLine( h1, h2 ); | 505 | p-> drawLine ( h1, h2 ); |
488 | } | 506 | } |
489 | 507 | ||
490 | if ( !clear || prevTime.minute() != currTime.minute() ) { | 508 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { |
491 | // draw minute pointer | 509 | // draw minute pointer |
492 | m1 = rotate( center, m1, time.minute() * 6 ); | 510 | m1 = rotate( center, m1, t.minute() * 6 ); |
493 | m2 = rotate( center, m2, time.minute() * 6 ); | 511 | m2 = rotate( center, m2, t.minute() * 6 ); |
494 | p->setPen( QPen( color, 2 ) ); | 512 | p-> setPen ( QPen ( c, 2 )); |
495 | p->drawLine( m1, m2 ); | 513 | p-> drawLine ( m1, m2 ); |
496 | } | 514 | } |
497 | 515 | ||
498 | // draw second pointer | 516 | if ( !t2 || ( t. second ( ) != t2-> second ( ))) { |
499 | s1 = rotate( center, s1, time.second() * 6 ); | 517 | // draw second pointer |
500 | s2 = rotate( center, s2, time.second() * 6 ); | 518 | s1 = rotate( center, s1, t.second() * 6 ); |
501 | p->setPen( QPen( color, 1 ) ); | 519 | s2 = rotate( center, s2, t.second() * 6 ); |
502 | p->drawLine( s1, s2 ); | 520 | p-> setPen ( QPen ( c, 1 )); |
503 | 521 | p-> drawLine ( s1, s2 ); | |
504 | if ( !clear ) | 522 | } |
505 | prevTime = currTime; | ||
506 | } | 523 | } |
507 | 524 | ||
508 | void AnalogClock::display( const QTime& t ) | 525 | void AnalogClock::display( const QTime& t ) |
509 | { | 526 | { |
510 | currTime = t; | 527 | currTime = t; |
511 | clear = true; | ||
512 | repaint( false ); | ||
513 | clear = false; | 528 | clear = false; |
514 | repaint( false ); | 529 | repaint( false ); |
530 | clear = true; | ||
515 | } | 531 | } |
516 | 532 | ||
517 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) | 533 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) |
518 | { | 534 | { |
519 | double angle = deg2rad * ( - a + 180 ); | 535 | double angle = deg2rad * ( - a + 180 ); |
520 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - | 536 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - |
521 | ( p.y() - c.y() ) * sin( angle ); | 537 | ( p.y() - c.y() ) * sin( angle ); |
522 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + | 538 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + |
523 | ( p.x() - c.x() ) * sin( angle ); | 539 | ( p.x() - c.x() ) * sin( angle ); |
524 | return QPoint( nx, ny ); | 540 | return QPoint( nx, ny ); |
525 | } | 541 | } |
526 | 542 | ||
527 | void Clock::slotAdjustTime() | 543 | void Clock::slotAdjustTime() |
528 | { | 544 | { |
529 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 545 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
530 | e << QString( "systemtime" ); | 546 | e << QString( "systemtime" ); |
531 | } | 547 | } |
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h index be71b9d..092d84f 100644 --- a/noncore/tools/clock/clock.h +++ b/noncore/tools/clock/clock.h | |||
@@ -1,98 +1,99 @@ | |||
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 | #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 | ||
26 | class QLCDNumber; | 26 | class QLCDNumber; |
27 | class QLabel; | 27 | class QLabel; |
28 | class QTimer; | 28 | class QTimer; |
29 | class QRadioButton; | 29 | class QRadioButton; |
30 | class QPushButton; | 30 | class QPushButton; |
31 | class QDateTime; | 31 | class QDateTime; |
32 | 32 | ||
33 | class AnalogClock : public QFrame | 33 | class AnalogClock : public QFrame |
34 | { | 34 | { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | 36 | ||
37 | public: | 37 | public: |
38 | AnalogClock( QWidget * parent = 0, const char * name = 0 ) | 38 | AnalogClock( QWidget * parent = 0, const char * name = 0 ) |
39 | : QFrame( parent, name ), clear(false) {} | 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 | ||
45 | protected: | 45 | protected: |
46 | void drawContents( QPainter *p ); | 46 | void drawContents( QPainter *p ); |
47 | 47 | ||
48 | private: | 48 | private: |
49 | QPoint rotate( QPoint center, QPoint p, int angle ); | 49 | QPoint rotate( QPoint center, QPoint p, int angle ); |
50 | void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); | ||
50 | 51 | ||
51 | QTime currTime; | 52 | QTime currTime; |
52 | QTime prevTime; | 53 | QTime prevTime; |
53 | bool clear; | 54 | bool clear; |
54 | }; | 55 | }; |
55 | 56 | ||
56 | class Clock : public QVBox | 57 | class Clock : public QVBox |
57 | { | 58 | { |
58 | Q_OBJECT | 59 | Q_OBJECT |
59 | 60 | ||
60 | public: | 61 | public: |
61 | Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); | 62 | Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); |
62 | ~Clock(); | 63 | ~Clock(); |
63 | QDateTime when; | 64 | QDateTime when; |
64 | bool bSound; | 65 | bool bSound; |
65 | int hour, minute, snoozeTime; | 66 | int hour, minute, snoozeTime; |
66 | private slots: | 67 | private slots: |
67 | void slotSet(); | 68 | void slotSet(); |
68 | void slotReset(); | 69 | void slotReset(); |
69 | void modeSelect(int); | 70 | void modeSelect(int); |
70 | void updateClock(); | 71 | void updateClock(); |
71 | void changeClock( bool ); | 72 | void changeClock( bool ); |
72 | void slotSetAlarm(); | 73 | void slotSetAlarm(); |
73 | void slotSnooze(); | 74 | void slotSnooze(); |
74 | void slotToggleAlarm(); | 75 | void slotToggleAlarm(); |
75 | void alarmOn(); | 76 | void alarmOn(); |
76 | void alarmOff(); | 77 | void alarmOff(); |
77 | void appMessage(const QCString& msg, const QByteArray& data); | 78 | void appMessage(const QCString& msg, const QByteArray& data); |
78 | void timerEvent( QTimerEvent *e ); | 79 | void timerEvent( QTimerEvent *e ); |
79 | void slotAdjustTime(); | 80 | void slotAdjustTime(); |
80 | private: | 81 | private: |
81 | void clearClock(); | 82 | void clearClock(); |
82 | 83 | ||
83 | bool alarmBool; | 84 | bool alarmBool; |
84 | QTimer *t; | 85 | QTimer *t; |
85 | QLCDNumber *lcd; | 86 | QLCDNumber *lcd; |
86 | QLabel *date; | 87 | QLabel *date; |
87 | QLabel *ampmLabel; | 88 | QLabel *ampmLabel; |
88 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; | 89 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; |
89 | QRadioButton *clockRB, *swatchRB; | 90 | QRadioButton *clockRB, *swatchRB; |
90 | AnalogClock *aclock; | 91 | AnalogClock *aclock; |
91 | QTime swatch_start; | 92 | QTime swatch_start; |
92 | int swatch_totalms; | 93 | int swatch_totalms; |
93 | bool swatch_running; | 94 | bool swatch_running; |
94 | bool ampm; | 95 | bool ampm; |
95 | }; | 96 | }; |
96 | 97 | ||
97 | #endif | 98 | #endif |
98 | 99 | ||