-rw-r--r-- | noncore/tools/clock/clock.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index d5d77bc..6f570c5 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -1,179 +1,179 @@ | |||
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 | 20 | ||
21 | #include "clock.h" | 21 | #include "clock.h" |
22 | #include "setAlarm.h" | 22 | #include "setAlarm.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/timestring.h> | 27 | #include <qpe/timestring.h> |
28 | #include <qpe/alarmserver.h> | 28 | #include <qpe/alarmserver.h> |
29 | #include <qpe/sound.h> | 29 | #include <qpe/sound.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qsound.h> | 31 | #include <qsound.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qlcdnumber.h> | 34 | #include <qlcdnumber.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qdatetime.h> | 44 | #include <qdatetime.h> |
45 | 45 | ||
46 | #include <math.h> | 46 | #include <math.h> |
47 | 47 | ||
48 | const double deg2rad = 0.017453292519943295769; // pi/180 | 48 | const double deg2rad = 0.017453292519943295769; // pi/180 |
49 | const int sw_prec = 2; | 49 | const int sw_prec = 2; |
50 | 50 | ||
51 | static void toggleScreenSaver( bool on ) | 51 | static void toggleScreenSaver( bool on ) |
52 | { | 52 | { |
53 | QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); | 53 | QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); |
54 | e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend ); | 54 | e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend ); |
55 | } | 55 | } |
56 | 56 | ||
57 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) | 57 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) |
58 | : QVBox( parent, name , f ) | 58 | : QVBox( parent, name , f ) |
59 | { | 59 | { |
60 | setSpacing( 4 ); | 60 | setSpacing( 4 ); |
61 | setMargin( 1 ); | 61 | setMargin( 1 ); |
62 | 62 | ||
63 | Config config( "qpe" ); | 63 | Config config( "qpe" ); |
64 | config.setGroup("Time"); | 64 | config.setGroup("Time"); |
65 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 65 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
66 | 66 | ||
67 | snoozeBtn = new QPushButton ( this); | 67 | snoozeBtn = new QPushButton ( this); |
68 | snoozeBtn->setText( tr( "Snooze" ) ); | 68 | snoozeBtn->setText( tr( "Snooze" ) ); |
69 | 69 | ||
70 | aclock = new AnalogClock( this ); | 70 | aclock = new AnalogClock( this ); |
71 | aclock->display( QTime::currentTime() ); | 71 | aclock->display( QTime::currentTime() ); |
72 | aclock->setLineWidth( 2 ); | 72 | aclock->setLineWidth( 2 ); |
73 | 73 | ||
74 | QHBox *hb = new QHBox( this ); | 74 | QHBox *hb = new QHBox( this ); |
75 | hb->setMargin( 0 ); | 75 | hb->setMargin( 0 ); |
76 | QWidget *space = new QWidget( hb ); | 76 | QWidget *space = new QWidget( hb ); |
77 | lcd = new QLCDNumber( hb ); | 77 | lcd = new QLCDNumber( hb ); |
78 | lcd->setSegmentStyle( QLCDNumber::Flat ); | 78 | lcd->setSegmentStyle( QLCDNumber::Flat ); |
79 | lcd->setFrameStyle( QFrame::NoFrame ); | 79 | lcd->setFrameStyle( QFrame::NoFrame ); |
80 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | 80 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); |
81 | lcd->setFixedHeight( 23 ); | 81 | lcd->setFixedHeight( 23 ); |
82 | 82 | ||
83 | ampmLabel = new QLabel( "PM", hb ); | 83 | ampmLabel = new QLabel( tr("PM"), hb ); |
84 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | 84 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); |
85 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); | 85 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); |
86 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); | 86 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); |
87 | space = new QWidget( hb ); | 87 | space = new QWidget( hb ); |
88 | 88 | ||
89 | date = new QLabel( this ); | 89 | date = new QLabel( this ); |
90 | date->setAlignment( AlignHCenter | AlignVCenter ); | 90 | date->setAlignment( AlignHCenter | AlignVCenter ); |
91 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | 91 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); |
92 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 92 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); |
93 | 93 | ||
94 | QWidget *controls = new QWidget( this ); | 94 | QWidget *controls = new QWidget( this ); |
95 | QGridLayout *gl = new QGridLayout( controls, 2, 2, 6, 4 ); | 95 | QGridLayout *gl = new QGridLayout( controls, 2, 2, 6, 4 ); |
96 | 96 | ||
97 | QButtonGroup *grp = new QButtonGroup( controls ); | 97 | QButtonGroup *grp = new QButtonGroup( controls ); |
98 | grp->setRadioButtonExclusive( true ); | 98 | grp->setRadioButtonExclusive( true ); |
99 | grp->hide(); | 99 | grp->hide(); |
100 | 100 | ||
101 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); | 101 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); |
102 | gl->addWidget( clockRB, 0, 0 ); | 102 | gl->addWidget( clockRB, 0, 0 ); |
103 | grp->insert( clockRB ); | 103 | grp->insert( clockRB ); |
104 | 104 | ||
105 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); | 105 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); |
106 | gl->addWidget( swatchRB, 1, 0 ); | 106 | gl->addWidget( swatchRB, 1, 0 ); |
107 | grp->insert( swatchRB ); | 107 | grp->insert( swatchRB ); |
108 | 108 | ||
109 | connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) ); | 109 | connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) ); |
110 | grp->setButton( 0 ); | 110 | grp->setButton( 0 ); |
111 | 111 | ||
112 | set = new QPushButton ( controls ); | 112 | set = new QPushButton ( controls ); |
113 | set->setMaximumSize(50,30); | 113 | set->setMaximumSize(50,30); |
114 | gl->addWidget( set, 0, 1 ); | 114 | gl->addWidget( set, 0, 1 ); |
115 | set->setText( tr( "Start" ) ); | 115 | set->setText( tr( "Start" ) ); |
116 | set->setEnabled( FALSE ); | 116 | set->setEnabled( FALSE ); |
117 | grp->insert( set ); | 117 | grp->insert( set ); |
118 | 118 | ||
119 | reset = new QPushButton ( controls ); | 119 | reset = new QPushButton ( controls ); |
120 | gl->addWidget( reset, 1, 1 ); | 120 | gl->addWidget( reset, 1, 1 ); |
121 | reset->setText( tr( "Reset" ) ); | 121 | reset->setText( tr( "Reset" ) ); |
122 | reset->setEnabled( FALSE ); | 122 | reset->setEnabled( FALSE ); |
123 | grp->insert( reset ); | 123 | grp->insert( reset ); |
124 | 124 | ||
125 | alarmOffBtn = new QPushButton ( controls ); | 125 | alarmOffBtn = new QPushButton ( controls ); |
126 | alarmOffBtn->setMaximumSize(60,30); | 126 | alarmOffBtn->setMaximumSize(60,30); |
127 | gl->addWidget( alarmOffBtn, 0, 2 ); | 127 | gl->addWidget( alarmOffBtn, 0, 2 ); |
128 | 128 | ||
129 | alarmBtn = new QPushButton ( controls ); | 129 | alarmBtn = new QPushButton ( controls ); |
130 | alarmBtn->setMaximumSize(60,30); | 130 | alarmBtn->setMaximumSize(60,30); |
131 | gl->addWidget( alarmBtn, 1, 2 ); | 131 | gl->addWidget( alarmBtn, 1, 2 ); |
132 | alarmBtn->setText( tr( "Set Alarm" ) ); | 132 | alarmBtn->setText( tr( "Set Alarm" ) ); |
133 | 133 | ||
134 | connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); | 134 | connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); |
135 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); | 135 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); |
136 | 136 | ||
137 | connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); | 137 | connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); |
138 | connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); | 138 | connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); |
139 | connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); | 139 | connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); |
140 | 140 | ||
141 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 141 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
142 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 142 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
143 | 143 | ||
144 | t = new QTimer( this ); | 144 | t = new QTimer( this ); |
145 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); | 145 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); |
146 | t->start( 1000 ); | 146 | t->start( 1000 ); |
147 | 147 | ||
148 | connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); | 148 | connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); |
149 | 149 | ||
150 | swatch_running = FALSE; | 150 | swatch_running = FALSE; |
151 | swatch_totalms = 0; | 151 | swatch_totalms = 0; |
152 | 152 | ||
153 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 153 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
154 | 154 | ||
155 | QString tmp = config.readEntry("clockAlarmHour", ""); | 155 | QString tmp = config.readEntry("clockAlarmHour", ""); |
156 | bool ok; | 156 | bool ok; |
157 | hour = tmp.toInt(&ok,10); | 157 | hour = tmp.toInt(&ok,10); |
158 | tmp = config.readEntry("clockAlarmMinute",""); | 158 | tmp = config.readEntry("clockAlarmMinute",""); |
159 | minute = tmp.toInt(&ok,10); | 159 | minute = tmp.toInt(&ok,10); |
160 | 160 | ||
161 | if( config.readEntry("clockAlarmSet","FALSE") == "TRUE") { | 161 | if( config.readEntry("clockAlarmSet","FALSE") == "TRUE") { |
162 | alarmOffBtn->setText( tr( "Alarm On" ) ); | 162 | alarmOffBtn->setText( tr( "Alarm On" ) ); |
163 | alarmBool=TRUE; | 163 | alarmBool=TRUE; |
164 | snoozeBtn->show(); | 164 | snoozeBtn->show(); |
165 | } else { | 165 | } else { |
166 | alarmOffBtn->setText( tr( "Alarm Off" ) ); | 166 | alarmOffBtn->setText( tr( "Alarm Off" ) ); |
167 | alarmBool=FALSE; | 167 | alarmBool=FALSE; |
168 | snoozeBtn->hide(); | 168 | snoozeBtn->hide(); |
169 | } | 169 | } |
170 | 170 | ||
171 | QTimer::singleShot( 0, this, SLOT(updateClock()) ); | 171 | QTimer::singleShot( 0, this, SLOT(updateClock()) ); |
172 | modeSelect(0); | 172 | modeSelect(0); |
173 | } | 173 | } |
174 | 174 | ||
175 | Clock::~Clock() | 175 | Clock::~Clock() |
176 | { | 176 | { |
177 | toggleScreenSaver( true ); | 177 | toggleScreenSaver( true ); |
178 | } | 178 | } |
179 | 179 | ||