From 93aeaa0de75ba89bd565c845e79e470a80816b0a Mon Sep 17 00:00:00 2001 From: zecke Date: Sat, 03 Apr 2004 18:20:07 +0000 Subject: Initial revision --- diff --git a/noncore/tools/clock/alarmdlgbase.ui b/noncore/tools/clock/alarmdlgbase.ui new file mode 100644 index 0000000..63759f3 --- a/dev/null +++ b/noncore/tools/clock/alarmdlgbase.ui @@ -0,0 +1,154 @@ + +AlarmDlgBase + + QDialog + + name + AlarmDlgBase + + + geometry + + 0 + 0 + 124 + 92 + + + + caption + Form1 + + + layoutMargin + + + + margin + 6 + + + spacing + 6 + + + QLayoutWidget + + name + Layout1 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + pixmap + + + scaledContents + true + + + + + name + Spacer1 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLabel + + name + alarmDlgLabel + + + text + TextLabel1 + + + + + + QLayoutWidget + + name + Layout2 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel2 + + + text + Snooze + + + + QSpinBox + + name + snoozeTime + + + suffix + mins + + + maxValue + 60 + + + lineStep + 5 + + + + + + QPushButton + + name + cmdOk + + + text + Close + + + + + diff --git a/noncore/tools/clock/analogclock.cpp b/noncore/tools/clock/analogclock.cpp new file mode 100644 index 0000000..bf358e2 --- a/dev/null +++ b/noncore/tools/clock/analogclock.cpp @@ -0,0 +1,203 @@ +/********************************************************************** +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** +** This file is part of the Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "analogclock.h" + +#include +#include +#include + +#include + +const double deg2rad = 0.017453292519943295769; // pi/180 + +AnalogClock::AnalogClock( QWidget *parent, const char *name ) + : QFrame( parent, name ), clear(false) +{ + setMinimumSize(50,50); +} + +QSizePolicy AnalogClock::sizePolicy() const +{ + return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); +} + +void AnalogClock::drawContents( QPainter *p ) +{ +#if !defined(NO_DEBUG) + static bool first = true; + if ( first ) { + QTOPIA_PROFILE("first paint event"); + first = false; + } +#endif + + QRect r = contentsRect(); + + if ( r.width() < r.height() ) { + r.setY( (r.height() - r.width())/2 ); + r.setHeight( r.width() ); + } + + QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); + + const int w_tick = r.width()/300+1; + const int w_sec = r.width()/400+1; + const int w_hour = r.width()/80+1; + + QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); + QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); + + QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); + QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); + + QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 9 ); + QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); + + QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); + QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); + + QColor color( clear ? backgroundColor() : black ); + QTime time = clear ? prevTime : currTime; + + if ( clear && prevTime.secsTo(currTime) > 1 ) { + p->eraseRect( rect() ); + return; + } + + if ( !clear ) { + // draw ticks + p->setPen( QPen( color, w_tick ) ); + for ( int i = 0; i < 12; i++ ) + p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); + } + + if ( !clear || prevTime.minute() != currTime.minute() || + prevTime.hour() != currTime.hour() ) { + // draw hour pointer + h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); + h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); + p->setPen( color ); + p->setBrush( color ); + drawHand( p, h1, h2 ); + } + + if ( !clear || prevTime.minute() != currTime.minute() ) { + // draw minute pointer + m1 = rotate( center, m1, time.minute() * 6 ); + m2 = rotate( center, m2, time.minute() * 6 ); + p->setPen( color ); + p->setBrush( color ); + drawHand( p, m1, m2 ); + } + + // draw second pointer + s1 = rotate( center, s1, time.second() * 6 ); + s2 = rotate( center, s2, time.second() * 6 ); + p->setPen( QPen( color, w_sec ) ); + p->drawLine( s1, s2 ); + + // cap + p->setBrush(color); + p->drawEllipse( center.x()-w_hour/2, center.y()-w_hour/2, w_hour, w_hour ); + + if ( !clear ) + prevTime = currTime; +} + +// Dijkstra's bisection algorithm to find the square root as an integer. + +static uint int_sqrt(uint n) +{ + if ( n >= UINT_MAX>>2 ) // n must be in the range 0...UINT_MAX/2-1 + return 2*int_sqrt( n/4 ); + uint h, p= 0, q= 1, r= n; + while ( q <= n ) + q <<= 2; + while ( q != 1 ) { + q >>= 2; + h= p + q; + p >>= 1; + if ( r >= h ) { + p += q; + r -= h; + } + } + return p; +} + +void AnalogClock::drawHand( QPainter *p, QPoint p1, QPoint p2 ) +{ + int hw = 7; + if ( contentsRect().height() < 100 ) + hw = 5; + + int dx = p2.x() - p1.x(); + int dy = p2.y() - p1.y(); + int w = dx*dx+dy*dy; + int ix,iy; + w = int_sqrt(w*256); + iy = w ? (hw * dy * 16)/ w : dy ? 0 : hw; + ix = w ? (hw * dx * 16)/ w : dx ? 0 : hw; + + // rounding dependent on sign + int nix, niy; + if ( ix < 0 ) { + nix = ix/2; + ix = (ix-1)/2; + } else { + nix = (ix+1)/2; + ix = ix/2; + } + if ( iy < 0 ) { + niy = iy/2; + iy = (iy-1)/2; + } else { + niy = (iy+1)/2; + iy = iy/2; + } + + QPointArray pa(4); + pa[0] = p1; + pa[1] = QPoint( p2.x()+iy, p2.y()-nix ); + pa[2] = QPoint( p2.x()-niy, p2.y()+ix ); + pa[3] = p1; + + p->drawPolygon( pa ); +} + +void AnalogClock::display( const QTime& t ) +{ + currTime = t; + clear = true; + repaint( false ); + clear = false; + repaint( false ); +} + +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( int(nx), int(ny) ); +} diff --git a/noncore/tools/clock/analogclock.h b/noncore/tools/clock/analogclock.h new file mode 100644 index 0000000..3aa035e --- a/dev/null +++ b/noncore/tools/clock/analogclock.h @@ -0,0 +1,49 @@ +/********************************************************************** +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** +** This file is part of the Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef ANALOGCLOCK_H +#define ANALOGCLOCK_H + +#include +#include + +class AnalogClock : public QFrame +{ + Q_OBJECT +public: + AnalogClock( QWidget *parent=0, const char *name=0 ); + + QSizePolicy sizePolicy() const; + + void display( const QTime& time ); + +protected: + void drawContents( QPainter *p ); + void drawHand( QPainter *p, QPoint, QPoint ); + +private: + QPoint rotate( QPoint center, QPoint p, int angle ); + + QTime currTime; + QTime prevTime; + bool clear; +}; + +#endif + diff --git a/noncore/tools/clock/clockbase.ui b/noncore/tools/clock/clockbase.ui new file mode 100644 index 0000000..91d0da0 --- a/dev/null +++ b/noncore/tools/clock/clockbase.ui @@ -0,0 +1,921 @@ + +ClockBase + + QWidget + + name + ClockBase + + + geometry + + 0 + 0 + 220 + 337 + + + + caption + Clock + + + layoutMargin + + + + margin + 6 + + + spacing + 6 + + + QTabWidget + + name + tabs + + + layoutMargin + + + layoutSpacing + + + QWidget + + name + tab + + + title + Clock + + + + margin + 4 + + + spacing + 4 + + + AnalogClock + + name + analogClock + + + + QLayoutWidget + + name + Layout3 + + + + margin + 0 + + + spacing + 6 + + + QFrame + + name + Frame3 + + + sizePolicy + + 7 + 5 + + + + frameShape + NoFrame + + + frameShadow + Plain + + + lineWidth + 0 + + + + QLCDNumber + + name + clockLcd + + + sizePolicy + + 1 + 1 + + + + minimumSize + + 0 + 23 + + + + frameShape + NoFrame + + + frameShadow + Plain + + + segmentStyle + Flat + + + + QLabel + + name + clockAmPm + + + font + + 14 + 1 + + + + text + ... + + + alignment + AlignBottom|AlignLeft + + + vAlign + + + + QFrame + + name + Frame4 + + + sizePolicy + + 7 + 5 + + + + frameShape + NoFrame + + + frameShadow + Plain + + + + + + QLabel + + name + date + + + font + + 16 + 1 + + + + text + ... + + + textFormat + RichText + + + alignment + AlignCenter + + + hAlign + + + + + + QWidget + + name + tab + + + title + Stopwatch + + + + margin + 6 + + + spacing + 4 + + + QFrame + + name + swFrame + + + sizePolicy + + 5 + 7 + + + + frameShape + NoFrame + + + frameShadow + Raised + + + + QLayoutWidget + + name + Layout7 + + + layoutSpacing + + + + margin + 0 + + + spacing + 0 + + + QLCDNumber + + name + lapLcd + + + sizePolicy + + 7 + 1 + + + + maximumSize + + 32767 + 20 + + + + frameShape + NoFrame + + + numDigits + 11 + + + segmentStyle + Flat + + + + QLCDNumber + + name + lapNumLcd + + + sizePolicy + + 7 + 1 + + + + frameShape + NoFrame + + + numDigits + 2 + + + segmentStyle + Flat + + + + QFrame + + name + lapFrame + + + minimumSize + + 15 + 0 + + + + frameShape + NoFrame + + + frameShadow + Raised + + + + QLabel + + name + TextLabel4 + + + text + Split + + + alignment + AlignTop|AlignRight + + + hAlign + + + vAlign + + + + QLCDNumber + + name + splitLcd + + + sizePolicy + + 7 + 1 + + + + maximumSize + + 32767 + 20 + + + + frameShape + NoFrame + + + numDigits + 11 + + + segmentStyle + Flat + + + + QLabel + + name + TextLabel3_2 + + + text + Lap + + + alignment + AlignTop|AlignRight + + + hAlign + + + vAlign + + + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + stopStart + + + font + + 14 + 1 + + + + text + Start + + + whatsThis + Starts and stops the stopwatch. + + + + QPushButton + + name + reset + + + font + + 14 + 1 + + + + text + Lap/Split + + + whatsThis + Resets the stopwatch. + + + + + + + + QWidget + + name + tab + + + title + Alarm + + + + margin + 6 + + + spacing + 4 + + + QGroupBox + + name + dailyGroup + + + title + Daily Alarm + + + layoutMargin + + + + margin + 6 + + + spacing + 6 + + + QCheckBox + + name + dailyEnabled + + + text + Enabled + + + whatsThis + Check to enable the daily alarm + + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + QSpinBox + + name + dailyHour + + + minimumSize + + 40 + 0 + + + + wrapping + true + + + maxValue + 23 + + + whatsThis + Set the hour the alarm will sound. + + + + QLabel + + name + TextLabel2 + + + sizePolicy + + 4 + 1 + + + + minimumSize + + 5 + 0 + + + + text + : + + + + QSpinBox + + name + dailyMinute + + + minimumSize + + 40 + 0 + + + + wrapping + true + + + maxValue + 59 + + + lineStep + 5 + + + whatsThis + Set the minute the alarm will sound. + + + + QComboBox + + + text + AM + + + + + text + PM + + + + name + dailyAmPm + + + minimumSize + + 50 + 0 + + + + + QFrame + + name + Frame5 + + + sizePolicy + + 7 + 5 + + + + frameShape + NoFrame + + + frameShadow + Plain + + + + + + QLabel + + name + TextLabel1 + + + text + Days: + + + + QFrame + + name + daysFrame + + + frameShape + NoFrame + + + frameShadow + Raised + + + + + + QGroupBox + + name + cdGroup + + + title + Countdown Alarm + + + layoutMargin + + + + margin + 6 + + + spacing + 6 + + + QLabel + + name + TextLabel3 + + + sizePolicy + + 4 + 1 + + + + text + : + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QSpinBox + + name + cdHour + + + minimumSize + + 40 + 0 + + + + maxValue + 999 + + + lineStep + 1 + + + + QSpinBox + + name + cdMinute + + + minimumSize + + 40 + 0 + + + + wrapping + true + + + maxValue + 55 + + + lineStep + 5 + + + + QPushButton + + name + cdStartStop + + + text + Start + + + + + + QLCDNumber + + name + cdLcd + + + frameShape + NoFrame + + + frameShadow + Plain + + + segmentStyle + Flat + + + + + + + name + Spacer1 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + + + AnalogClock +
analogclock.h
+ + 50 + 50 + + 0 + + 3 + 3 + + image0 +
+
+ + + image0 + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + +
diff --git a/noncore/tools/clock/specification.html b/noncore/tools/clock/specification.html new file mode 100644 index 0000000..5913277 --- a/dev/null +++ b/noncore/tools/clock/specification.html @@ -0,0 +1,145 @@ + + +Clock Specification + + + + +

Clock Specification

+ + + + + + + +The clock shows the time, a stopwatch and allows a daily alarm to be set. + +

+The clock provides three functions: 1. Displays the current date and time. +2. Provides a stopwatch. 3. Allows a daily alarm to be set and enabled/disabled. +

+ +

+Status: BT +

+ + +

Use Cases

+
+ +
    +
  • Viewing Date and Time +

    While the PDA is in its cradle, the office worker uses it as a + desktop clock. +

  • Jogger +

    A jogger runs around a 400m track 6 times. He starts the stopwatch as + he starts, and presses a button each time he rounds the track. He can + observe the precise time taken for each lap. +

  • Setting Daily Alarm +

    The traveller sets an alarm to wake him up at 5:30 each morning. +

    (not yet implemented: The traveller never wants to be woken on Saturday, + Sunday, or Wednesday; the traveller can easily press a "Snooze" button + to get a little more rest, but the alarm will sound again; he never + misses getting woken) +

+ + +

Features

+
+ + +
    +
  • Clock: Display an analog clock, digital clock and the date in one view. +
  • Stopwatch: Display an analog and digital stopwatch timer. + The digital timer has a resolution of 1/100 second. +
      +
    • Start/Stop: The [Select] hardware button must Start/Stop the stopwatch. +
    +
  • Daily Alarm: Allows a daily alarm to be enabled/disabled and set. +
      +
    • Audible Alarm: When the alarm is activated an audible alarm must be + sounded. +
    • Visual Alarm: When the alarm is activated a dialog box must be shown + with the alarm details. +
    +
+ + +

Prerequisites

+
+ + +
    +
  • Alarm Server: requires a working alarm server for daily alarm function. +
  • Audible Alarm: requires speaker/buzzer. +
+ + + diff --git a/noncore/tools/clock/tests.html b/noncore/tools/clock/tests.html new file mode 100644 index 0000000..4df5ead --- a/dev/null +++ b/noncore/tools/clock/tests.html @@ -0,0 +1,203 @@ + + + + Qtopia test + + + + +

Qtopia/Clock

+

Test cases

+
+
+

 Basic Clock

+ + + + + + + + + + + + + + + + + + + + + + + +
Test Purpose
+
Verify that the basic clock +functionality works as expected.
+
Test +Description
+
+
    +
  1. Start the clock.
  2. +
  3. Confirm that the Clock tab is displayed.
  4. +
  5. Check that the time displayed on the analog clock matches +the device system time.
  6. +
  7. Check that the time displayed on the digital clock matches +the device system time.
  8. +
  9. Check that the date displayed matches the device system +date.
  10. +
+
Expected +TestResult
+
All the verification steps as +described in the Test Description must be met.
+
Testnorm/Criteria
+
Exact Match
+
Test +Suitability
+
Manual test
+
+
+
+

 Stopwatch

+ + + + + + + + + + + + + + + + + + + + + + + +
Test Purpose
+
Verify that the clock app can be +used as a stopwatch.
+
Test +Description
+
+
    +
  1. Click on the Stopwatch tab.
  2. +
  3. Confirm that the stopwatch reads 00:00:00.00 and that the +analog hands indicate 00:00.
  4. +
  5. Press the Start button and confirm that the analog and +digital timers count up (resolution 1 sec).
  6. +
  7. Press the Stop button and confirm that the timers have +stopped. The digital timer should show 1/100 sec resolution.
  8. +
  9. Press the Reset button and confirm that the stopwatch reads +00:00:00.00 and that the analog hands indicate 00:00.
  10. +
  11. Press the Start button and wait 3 seconds. 
  12. +
  13. Press the Lap/Split button and wait 3 seconds again.
  14. +
  15. Press Stop.
  16. +
  17. Verify that the lap counter reads 3.
  18. +
  19. Use the decrement button in front of the lap counter to +select lap 1.
  20. +
  21. Verify that the Split value reads a value of approx 3 +seconds and the Lap value is the same.
  22. +
  23. Use the increment button in front of the lap counter to +select lap 2.
  24. +
  25. Verify that the Split value reads a value of approx 6 +seconds (2 laps total) and the Lap value again is approx 3 seconds.
  26. +
  27. Use the increment button to select lap 3.
  28. +
  29. Verify that the Split value reads a value of approx 9 +seconds (3 laps total) and the Lap value is approx 3 seconds.
  30. +
  31. Verify that no other laps can be selected using the +incr/decr buttons that 1, 2 or 3.
  32. +
  33. Tap the Reset button.
  34. +
  35. Verify that all values are reset to 0, the lap counter is +reset to 1 and the incr/decr buttons are disabled.
    +
  36. +
+
Expected +TestResult
+
All the verification steps as +described in the Test Description must be met.
+
Testnorm/Criteria
+
Exact Match, but the actual +values for the Lap and Split readouts depend on the timing of the +tester.
+
Test +Suitability
+
Manual test
+
+
+
+

 Daily alarm

+ + + + + + + + + + + + + + + + + + + + + + + +
Test Purpose
+
Verify that a daily alarm can be +set.
+
Test +Description
+
+
    +
  1. Click on the Alarms tab.
  2. +
  3. Set the alarm time 1-5 minutes in the future and check the +Enabled box.
  4. +
  5. Confirm that when the alarm time is reached the alarm +sounds and a message box is displayed with the alarm details.
  6. +
  7. Set the alarm time 1-5 minutes in the future and uncheck +the Enabled box.
  8. +
  9. Confirm that when the alarm time is reached no alarm is +sounded.
  10. +
  11. Set the alarm time 1-5 minutes in the future, check +Enabled, and close the clock application.
  12. +
  13. Confirm that when the alarm time is reached the alarm +sounds and a message box is displayed with the alarm details.
  14. +
+
Expected +TestResult
+
All the verification steps as +described in the Test Description must be met.
+
Testnorm/Criteria
+
Exact Match
+
Test +Suitability
+
Manual test
+
+
+
+ + -- cgit v0.9.0.2