author | llornkcor <llornkcor> | 2003-02-17 01:22:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-17 01:22:21 (UTC) |
commit | a5e3911518d00ae327d3fe29871c03354344f086 (patch) (unidiff) | |
tree | 15b4a17d942283a98bd7f482c380ef54220d2fa8 | |
parent | 0c50793d0ef839e90b9b2dea5001c3170971fc06 (diff) | |
download | opie-a5e3911518d00ae327d3fe29871c03354344f086.zip opie-a5e3911518d00ae327d3fe29871c03354344f086.tar.gz opie-a5e3911518d00ae327d3fe29871c03354344f086.tar.bz2 |
attempt to fix bug 586 - new thread and sleep 15 sec for cards to mount for mp3 alarm
-rw-r--r-- | noncore/tools/clock/clock.cpp | 841 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 2 | ||||
-rw-r--r-- | noncore/tools/clock/clock.pro | 32 |
3 files changed, 457 insertions, 418 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 2f81c3a..0937362 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -1,547 +1,586 @@ | |||
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 | // changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002 | 20 | // changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002 |
21 | 21 | ||
22 | #include "clock.h" | 22 | #include "clock.h" |
23 | #include "setAlarm.h" | 23 | #include "setAlarm.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/timestring.h> | 28 | #include <qpe/timestring.h> |
29 | #include <qpe/alarmserver.h> | 29 | #include <qpe/alarmserver.h> |
30 | #include <qpe/sound.h> | 30 | #include <qpe/sound.h> |
31 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
32 | #include <qsound.h> | 32 | #include <qsound.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | 34 | ||
35 | #include <opie/oclickablelabel.h> | 35 | #include <opie/oclickablelabel.h> |
36 | 36 | ||
37 | #include <qlcdnumber.h> | 37 | #include <qlcdnumber.h> |
38 | #include <qslider.h> | 38 | #include <qslider.h> |
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
44 | #include <qbuttongroup.h> | 44 | #include <qbuttongroup.h> |
45 | #include <qpainter.h> | 45 | #include <qpainter.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qdatetime.h> | 47 | #include <qdatetime.h> |
48 | 48 | ||
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <unistd.h> | ||
51 | #include <sys/types.h> | ||
52 | |||
53 | #include <pthread.h> | ||
54 | |||
50 | 55 | ||
51 | const double deg2rad = 0.017453292519943295769; // pi/180 | 56 | const double deg2rad = 0.017453292519943295769; // pi/180 |
52 | const int sw_prec = 2; | 57 | const int sw_prec = 2; |
53 | 58 | ||
59 | void startPlayer() | ||
60 | { | ||
61 | Config config( "qpe" ); | ||
62 | config.setGroup( "Time" ); | ||
63 | sleep(15); | ||
64 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | ||
65 | e << config.readEntry( "mp3File", "" ); | ||
66 | } | ||
67 | |||
68 | |||
54 | static void toggleScreenSaver( bool on ) | 69 | static void toggleScreenSaver( bool on ) |
55 | { | 70 | { |
56 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); | 71 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); |
57 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); | 72 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); |
58 | } | 73 | } |
59 | 74 | ||
60 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) | 75 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) |
61 | : QVBox( parent, name , f ) | 76 | : QVBox( parent, name , f ) |
62 | { | 77 | { |
63 | setSpacing( 4 ); | 78 | setSpacing( 4 ); |
64 | setMargin( 1 ); | 79 | setMargin( 1 ); |
65 | 80 | ||
66 | Config config( "qpe" ); | 81 | Config config( "qpe" ); |
67 | config.setGroup( "Time" ); | 82 | config.setGroup( "Time" ); |
68 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 83 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
69 | 84 | ||
70 | 85 | ||
71 | snoozeBtn = new QPushButton ( this ); | 86 | snoozeBtn = new QPushButton ( this ); |
72 | snoozeBtn->setText( tr( "Snooze" ) ); | 87 | snoozeBtn->setText( tr( "Snooze" ) ); |
73 | 88 | ||
74 | aclock = new AnalogClock( this ); | 89 | aclock = new AnalogClock( this ); |
75 | aclock->display( QTime::currentTime() ); | 90 | aclock->display( QTime::currentTime() ); |
76 | aclock->setLineWidth( 2 ); | 91 | aclock->setLineWidth( 2 ); |
77 | 92 | ||
78 | QHBox *hb = new QHBox( this ); | 93 | QHBox *hb = new QHBox( this ); |
79 | hb->setMargin( 0 ); | 94 | hb->setMargin( 0 ); |
80 | QWidget *space = new QWidget( hb ); | 95 | QWidget *space = new QWidget( hb ); |
81 | lcd = new QLCDNumber( hb ); | 96 | lcd = new QLCDNumber( hb ); |
82 | lcd->setSegmentStyle( QLCDNumber::Flat ); | 97 | lcd->setSegmentStyle( QLCDNumber::Flat ); |
83 | lcd->setFrameStyle( QFrame::NoFrame ); | 98 | lcd->setFrameStyle( QFrame::NoFrame ); |
84 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | 99 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); |
85 | lcd->setFixedHeight( 23 ); | 100 | lcd->setFixedHeight( 23 ); |
86 | 101 | ||
87 | ampmLabel = new QLabel( tr( "PM" ), hb ); | 102 | ampmLabel = new QLabel( tr( "PM" ), hb ); |
88 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | 103 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); |
89 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); | 104 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); |
90 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); | 105 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); |
91 | space = new QWidget( hb ); | 106 | space = new QWidget( hb ); |
92 | 107 | ||
93 | date = new QLabel( this ); | 108 | date = new QLabel( this ); |
94 | date->setAlignment( AlignHCenter | AlignVCenter ); | 109 | date->setAlignment( AlignHCenter | AlignVCenter ); |
95 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | 110 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); |
96 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 111 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); |
97 | 112 | ||
98 | QWidget *controls = new QWidget( this ); | 113 | QWidget *controls = new QWidget( this ); |
99 | QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 ); | 114 | QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 ); |
100 | 115 | ||
101 | QButtonGroup *grp = new QButtonGroup( controls ); | 116 | QButtonGroup *grp = new QButtonGroup( controls ); |
102 | grp->setRadioButtonExclusive( true ); | 117 | grp->setRadioButtonExclusive( true ); |
103 | grp->hide(); | 118 | grp->hide(); |
104 | 119 | ||
105 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); | 120 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); |
106 | gl->addWidget( clockRB, 0, 0 ); | 121 | gl->addWidget( clockRB, 0, 0 ); |
107 | grp->insert( clockRB ); | 122 | grp->insert( clockRB ); |
108 | 123 | ||
109 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); | 124 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); |
110 | gl->addWidget( swatchRB, 1, 0 ); | 125 | gl->addWidget( swatchRB, 1, 0 ); |
111 | grp->insert( swatchRB ); | 126 | grp->insert( swatchRB ); |
112 | 127 | ||
113 | connect( grp, SIGNAL( clicked( int ) ), this, SLOT( modeSelect( int ) ) ); | 128 | connect( grp, SIGNAL( clicked( int ) ), this, SLOT( modeSelect( int ) ) ); |
114 | grp->setButton( 0 ); | 129 | grp->setButton( 0 ); |
115 | 130 | ||
116 | set | 131 | set |
117 | = new QPushButton ( controls ); | 132 | = new QPushButton ( controls ); |
118 | set | 133 | set |
119 | ->setMaximumSize( 50, 30 ); | 134 | ->setMaximumSize( 50, 30 ); |
120 | gl->addWidget( set | 135 | gl->addWidget( set |
121 | , 0, 1 ); | 136 | , 0, 1 ); |
122 | set | 137 | set |
123 | ->setText( tr( "Start" ) ); | 138 | ->setText( tr( "Start" ) ); |
124 | set | 139 | set |
125 | ->setEnabled( FALSE ); | 140 | ->setEnabled( FALSE ); |
126 | grp->insert( set | 141 | grp->insert( set |
127 | ); | 142 | ); |
128 | 143 | ||
129 | reset = new QPushButton ( controls ); | 144 | reset = new QPushButton ( controls ); |
130 | gl->addWidget( reset, 1, 1 ); | 145 | gl->addWidget( reset, 1, 1 ); |
131 | reset->setText( tr( "Reset" ) ); | 146 | reset->setText( tr( "Reset" ) ); |
132 | reset->setEnabled( FALSE ); | 147 | reset->setEnabled( FALSE ); |
133 | grp->insert( reset ); | 148 | grp->insert( reset ); |
134 | 149 | ||
135 | alarmOffBtn = new QPushButton ( controls ); | 150 | alarmOffBtn = new QPushButton ( controls ); |
136 | // alarmOffBtn->setMaximumSize(60,30); | 151 | // alarmOffBtn->setMaximumSize(60,30); |
137 | gl->addWidget( alarmOffBtn, 0, 2 ); | 152 | gl->addWidget( alarmOffBtn, 0, 2 ); |
138 | 153 | ||
139 | alarmBtn = new QPushButton ( controls ); | 154 | alarmBtn = new QPushButton ( controls ); |
140 | // alarmBtn->setMaximumSize(60,30); | 155 | // alarmBtn->setMaximumSize(60,30); |
141 | gl->addWidget( alarmBtn, 1, 2 ); | 156 | gl->addWidget( alarmBtn, 1, 2 ); |
142 | alarmBtn->setText( tr( "Set Alarm" ) ); | 157 | alarmBtn->setText( tr( "Set Alarm" ) ); |
143 | 158 | ||
144 | OClickableLabel *click = new OClickableLabel( controls, "label" ); | 159 | OClickableLabel *click = new OClickableLabel( controls, "label" ); |
145 | click->setText( tr( "Set date and time." ) ); | 160 | click->setText( tr( "Set date and time." ) ); |
146 | gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter ); | 161 | gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter ); |
147 | connect( click, SIGNAL( clicked() ), this, SLOT( slotAdjustTime() ) ); | 162 | connect( click, SIGNAL( clicked() ), this, SLOT( slotAdjustTime() ) ); |
148 | 163 | ||
149 | connect( set | 164 | connect( set |
150 | , SIGNAL( pressed() ), SLOT( slotSet() ) ); | 165 | , SIGNAL( pressed() ), SLOT( slotSet() ) ); |
151 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); | 166 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); |
152 | 167 | ||
153 | connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); | 168 | connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); |
154 | connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); | 169 | connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); |
155 | connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); | 170 | connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); |
156 | 171 | ||
157 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), | 172 | connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), |
158 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 173 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
159 | 174 | ||
160 | t = new QTimer( this ); | 175 | t = new QTimer( this ); |
161 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); | 176 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); |
162 | t->start( 1000 ); | 177 | t->start( 1000 ); |
163 | 178 | ||
164 | connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); | 179 | connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); |
165 | 180 | ||
166 | swatch_running = FALSE; | 181 | swatch_running = FALSE; |
167 | swatch_totalms = 0; | 182 | swatch_totalms = 0; |
168 | 183 | ||
169 | connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( changeClock( bool ) ) ); | 184 | connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( changeClock( bool ) ) ); |
170 | 185 | ||
171 | QString tmp = config.readEntry( "clockAlarmHour", "" ); | 186 | QString tmp = config.readEntry( "clockAlarmHour", "" ); |
172 | bool ok; | 187 | bool ok; |
173 | hour = tmp.toInt( &ok, 10 ); | 188 | hour = tmp.toInt( &ok, 10 ); |
174 | tmp = config.readEntry( "clockAlarmMinute", "" ); | 189 | tmp = config.readEntry( "clockAlarmMinute", "" ); |
175 | minute = tmp.toInt( &ok, 10 ); | 190 | minute = tmp.toInt( &ok, 10 ); |
176 | 191 | ||
177 | if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) { | 192 | if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) { |
178 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 193 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
179 | alarmBool = TRUE; | 194 | alarmBool = TRUE; |
180 | snoozeBtn->show(); | 195 | snoozeBtn->show(); |
181 | } | 196 | } |
182 | else { | 197 | else { |
183 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 198 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
184 | alarmBool = FALSE; | 199 | alarmBool = FALSE; |
185 | snoozeBtn->hide(); | 200 | snoozeBtn->hide(); |
186 | } | 201 | } |
187 | 202 | ||
188 | QTimer::singleShot( 0, this, SLOT( updateClock() ) ); | 203 | QTimer::singleShot( 0, this, SLOT( updateClock() ) ); |
189 | modeSelect( 0 ); | 204 | modeSelect( 0 ); |
190 | } | 205 | } |
191 | 206 | ||
192 | Clock::~Clock() | 207 | Clock::~Clock() |
193 | { | 208 | { |
194 | toggleScreenSaver( true ); | 209 | toggleScreenSaver( true ); |
195 | } | 210 | } |
196 | 211 | ||
197 | void Clock::updateClock() | 212 | void Clock::updateClock() |
198 | { | 213 | { |
199 | if ( clockRB->isChecked() ) { | 214 | if ( clockRB->isChecked() ) { |
200 | QTime tm = QDateTime::currentDateTime().time(); | 215 | QTime tm = QDateTime::currentDateTime().time(); |
201 | QString s; | 216 | QString s; |
202 | if ( ampm ) { | 217 | if ( ampm ) { |
203 | int hour = tm.hour(); | 218 | int hour = tm.hour(); |
204 | if ( hour == 0 ) | 219 | if ( hour == 0 ) |
205 | hour = 12; | 220 | hour = 12; |
206 | if ( hour > 12 ) | 221 | if ( hour > 12 ) |
207 | hour -= 12; | 222 | hour -= 12; |
208 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); | 223 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); |
209 | ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" ); | 224 | ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" ); |
210 | ampmLabel->show(); | 225 | ampmLabel->show(); |
211 | } | 226 | } |
212 | else { | 227 | else { |
213 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); | 228 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); |
214 | ampmLabel->hide(); | 229 | ampmLabel->hide(); |
215 | } | 230 | } |
216 | lcd->display( s ); | 231 | lcd->display( s ); |
217 | lcd->repaint( FALSE ); | 232 | lcd->repaint( FALSE ); |
218 | aclock->display( QTime::currentTime() ); | 233 | aclock->display( QTime::currentTime() ); |
219 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 234 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); |
220 | } | 235 | } |
221 | else { | 236 | else { |
222 | QTime swatch_time; | 237 | QTime swatch_time; |
223 | QString lcdtext; | 238 | QString lcdtext; |
224 | int totalms = swatch_totalms; | 239 | int totalms = swatch_totalms; |
225 | if ( swatch_running ) | 240 | if ( swatch_running ) |
226 | totalms += swatch_start.elapsed(); | 241 | totalms += swatch_start.elapsed(); |
227 | swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms ); | 242 | swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms ); |
228 | QString d = swatch_running ? QString( " " ) | 243 | QString d = swatch_running ? QString( " " ) |
229 | : QString::number( totalms % 1000 + 1000 ); | 244 | : QString::number( totalms % 1000 + 1000 ); |
230 | lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec ); | 245 | lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec ); |
231 | lcd->display( lcdtext ); | 246 | lcd->display( lcdtext ); |
232 | lcd->repaint( FALSE ); | 247 | lcd->repaint( FALSE ); |
233 | aclock->display( swatch_time ); | 248 | aclock->display( swatch_time ); |
234 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 249 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); |
235 | } | 250 | } |
236 | } | 251 | } |
237 | 252 | ||
238 | void Clock::changeClock( bool a ) | 253 | void Clock::changeClock( bool a ) |
239 | { | 254 | { |
240 | ampm = a; | 255 | ampm = a; |
241 | updateClock(); | 256 | updateClock(); |
242 | } | 257 | } |
243 | 258 | ||
244 | void Clock::clearClock( void ) | 259 | void Clock::clearClock( void ) |
245 | { | 260 | { |
246 | lcd->display( QTime( 0, 0, 0 ).toString() ); | 261 | lcd->display( QTime( 0, 0, 0 ).toString() ); |
247 | aclock->display( QTime( 0, 0, 0 ) ); | 262 | aclock->display( QTime( 0, 0, 0 ) ); |
248 | } | 263 | } |
249 | 264 | ||
250 | void Clock::slotSet() | 265 | void Clock::slotSet() |
251 | { | 266 | { |
252 | if ( t->isActive() ) { | 267 | if ( t->isActive() ) { |
253 | swatch_totalms += swatch_start.elapsed(); | 268 | swatch_totalms += swatch_start.elapsed(); |
254 | set | 269 | set |
255 | ->setText( tr( "Start" ) ); | 270 | ->setText( tr( "Start" ) ); |
256 | t->stop(); | 271 | t->stop(); |
257 | swatch_running = FALSE; | 272 | swatch_running = FALSE; |
258 | toggleScreenSaver( TRUE ); | 273 | toggleScreenSaver( TRUE ); |
259 | updateClock(); | 274 | updateClock(); |
260 | } | 275 | } |
261 | else { | 276 | else { |
262 | swatch_start.start(); | 277 | swatch_start.start(); |
263 | set | 278 | set |
264 | ->setText( tr( "Stop" ) ); | 279 | ->setText( tr( "Stop" ) ); |
265 | t->start( 1000 ); | 280 | t->start( 1000 ); |
266 | swatch_running = TRUE; | 281 | swatch_running = TRUE; |
267 | // disable screensaver while stop watch is running | 282 | // disable screensaver while stop watch is running |
268 | toggleScreenSaver( FALSE ); | 283 | toggleScreenSaver( FALSE ); |
269 | } | 284 | } |
270 | } | 285 | } |
271 | 286 | ||
272 | void Clock::slotReset() | 287 | void Clock::slotReset() |
273 | { | 288 | { |
274 | t->stop(); | 289 | t->stop(); |
275 | swatch_start.start(); | 290 | swatch_start.start(); |
276 | swatch_totalms = 0; | 291 | swatch_totalms = 0; |
277 | 292 | ||
278 | if ( swatch_running ) | 293 | if ( swatch_running ) |
279 | t->start( 1000 ); | 294 | t->start( 1000 ); |
280 | 295 | ||
281 | updateClock(); | 296 | updateClock(); |
282 | } | 297 | } |
283 | 298 | ||
284 | void Clock::modeSelect( int m ) | 299 | void Clock::modeSelect( int m ) |
285 | { | 300 | { |
286 | if ( m ) { | 301 | if ( m ) { |
287 | lcd->setNumDigits( 8 + 1 + sw_prec ); | 302 | lcd->setNumDigits( 8 + 1 + sw_prec ); |
288 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 303 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
289 | set | 304 | set |
290 | ->setEnabled( TRUE ); | 305 | ->setEnabled( TRUE ); |
291 | reset->setEnabled( TRUE ); | 306 | reset->setEnabled( TRUE ); |
292 | ampmLabel->hide(); | 307 | ampmLabel->hide(); |
293 | 308 | ||
294 | if ( !swatch_running ) | 309 | if ( !swatch_running ) |
295 | t->stop(); | 310 | t->stop(); |
296 | } | 311 | } |
297 | else { | 312 | else { |
298 | lcd->setNumDigits( 5 ); | 313 | lcd->setNumDigits( 5 ); |
299 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 314 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
300 | set | 315 | set |
301 | ->setEnabled( FALSE ); | 316 | ->setEnabled( FALSE ); |
302 | reset->setEnabled( FALSE ); | 317 | reset->setEnabled( FALSE ); |
303 | t->start( 1000 ); | 318 | t->start( 1000 ); |
304 | } | 319 | } |
305 | updateClock(); | 320 | updateClock(); |
306 | } | 321 | } |
307 | 322 | ||
308 | //this sets the alarm time | 323 | //this sets the alarm time |
309 | void Clock::slotSetAlarm() | 324 | void Clock::slotSetAlarm() |
310 | { | 325 | { |
311 | if ( !snoozeBtn->isHidden() ) | 326 | if ( !snoozeBtn->isHidden() ) |
312 | slotToggleAlarm(); | 327 | slotToggleAlarm(); |
313 | Set_Alarm *setAlarmDlg; | 328 | Set_Alarm *setAlarmDlg; |
314 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); | 329 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); |
315 | int result = setAlarmDlg->exec(); | 330 | int result = setAlarmDlg->exec(); |
316 | if ( result == 1 ) { | 331 | if ( result == 1 ) { |
317 | Config config( "qpe" ); | 332 | Config config( "qpe" ); |
318 | config.setGroup( "Time" ); | 333 | config.setGroup( "Time" ); |
319 | QString tmp; | 334 | QString tmp; |
320 | hour = setAlarmDlg->Hour_Slider->value(); | 335 | hour = setAlarmDlg->Hour_Slider->value(); |
321 | minute = setAlarmDlg->Minute_Slider->value(); | 336 | minute = setAlarmDlg->Minute_Slider->value(); |
322 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); | 337 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); |
323 | if ( ampm ) { | 338 | if ( ampm ) { |
324 | if ( hour == 12 ) | 339 | if ( hour == 12 ) |
325 | hour = 0; | 340 | hour = 0; |
326 | 341 | ||
327 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) | 342 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) |
328 | hour += 12; | 343 | hour += 12; |
329 | } | 344 | } |
330 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); | 345 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); |
331 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); | 346 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); |
332 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); | 347 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); |
333 | config.write(); | 348 | config.write(); |
334 | } | 349 | } |
335 | } | 350 | } |
336 | 351 | ||
337 | void Clock::slotSnooze() | 352 | void Clock::slotSnooze() |
338 | { | 353 | { |
339 | bSound = FALSE; | 354 | bSound = FALSE; |
340 | int warn = 0; | 355 | int warn = 0; |
341 | QTime t = QTime::currentTime(); | 356 | QTime t = QTime::currentTime(); |
342 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); | 357 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); |
343 | when = whenl; | 358 | when = whenl; |
344 | AlarmServer::addAlarm( when, | 359 | AlarmServer::addAlarm( when, |
345 | "QPE/Application/clock", | 360 | "QPE/Application/clock", |
346 | "alarm(QDateTime,int)", warn ); | 361 | "alarm(QDateTime,int)", warn ); |
347 | 362 | ||
348 | } | 363 | } |
349 | 364 | ||
350 | //toggles alarm on/off | 365 | //toggles alarm on/off |
351 | void Clock::slotToggleAlarm() | 366 | void Clock::slotToggleAlarm() |
352 | { | 367 | { |
353 | Config config( "qpe" ); | 368 | Config config( "qpe" ); |
354 | config.setGroup( "Time" ); | 369 | config.setGroup( "Time" ); |
355 | if ( alarmBool ) { | 370 | if ( alarmBool ) { |
356 | config.writeEntry( "clockAlarmSet", "FALSE" ); | 371 | config.writeEntry( "clockAlarmSet", "FALSE" ); |
357 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 372 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
358 | snoozeBtn->hide(); | 373 | snoozeBtn->hide(); |
359 | alarmBool = FALSE; | 374 | alarmBool = FALSE; |
360 | alarmOff(); | 375 | alarmOff(); |
361 | } | 376 | } |
362 | else { | 377 | else { |
363 | config.writeEntry( "clockAlarmSet", "TRUE" ); | 378 | config.writeEntry( "clockAlarmSet", "TRUE" ); |
364 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 379 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
365 | snoozeBtn->show(); | 380 | snoozeBtn->show(); |
366 | alarmBool = TRUE; | 381 | alarmBool = TRUE; |
367 | alarmOn(); | 382 | alarmOn(); |
368 | } | 383 | } |
369 | config.write(); | 384 | config.write(); |
370 | } | 385 | } |
371 | 386 | ||
372 | void Clock::alarmOn() | 387 | void Clock::alarmOn() |
373 | { | 388 | { |
374 | QDate d = QDate::currentDate(); | 389 | QDate d = QDate::currentDate(); |
375 | QTime tm( ( int ) hour, ( int ) minute, 0 ); | 390 | QTime tm( ( int ) hour, ( int ) minute, 0 ); |
376 | qDebug( "Time set " + tm.toString() ); | 391 | qDebug( "Time set " + tm.toString() ); |
377 | QTime t = QTime::currentTime(); | 392 | QTime t = QTime::currentTime(); |
378 | if ( t > tm ) | 393 | if ( t > tm ) |
379 | d = d.addDays( 1 ); | 394 | d = d.addDays( 1 ); |
380 | int warn = 0; | 395 | int warn = 0; |
381 | QDateTime whenl( d, tm ); | 396 | QDateTime whenl( d, tm ); |
382 | when = whenl; | 397 | when = whenl; |
383 | AlarmServer::addAlarm( when, | 398 | AlarmServer::addAlarm( when, |
384 | "QPE/Application/clock", | 399 | "QPE/Application/clock", |
385 | "alarm(QDateTime,int)", warn ); | 400 | "alarm(QDateTime,int)", warn ); |
386 | setCaption( "Alarm set: " + whenl.toString() ); | 401 | setCaption( "Alarm set: " + whenl.toString() ); |
387 | } | 402 | } |
388 | 403 | ||
389 | void Clock::alarmOff() | 404 | void Clock::alarmOff() |
390 | { | 405 | { |
391 | int warn = 0; | 406 | int warn = 0; |
392 | bSound = FALSE; | 407 | bSound = FALSE; |
393 | AlarmServer::deleteAlarm( when, | 408 | AlarmServer::deleteAlarm( when, |
394 | "QPE/Application/clock", | 409 | "QPE/Application/clock", |
395 | "alarm(QDateTime,int)", warn ); | 410 | "alarm(QDateTime,int)", warn ); |
396 | qDebug( "Alarm Off " + when.toString() ); | 411 | qDebug( "Alarm Off " + when.toString() ); |
397 | setCaption( "Clock" ); | 412 | setCaption( "Clock" ); |
413 | } | ||
414 | |||
415 | void Clock::clearTimer() | ||
416 | { | ||
417 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | ||
418 | alarmBool = FALSE; | ||
419 | snoozeBtn->hide(); | ||
420 | setCaption( "Clock" ); | ||
398 | } | 421 | } |
399 | 422 | ||
400 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | 423 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) |
401 | { | 424 | { |
402 | int stopTimer = 0; | 425 | int stopTimer = 0; |
403 | int timerStay = 5000; | 426 | int timerStay = 5000; |
404 | bSound = TRUE; | 427 | bSound = TRUE; |
405 | qDebug( "Message received in clock" ); | 428 | qDebug( "Message received in clock" ); |
406 | if ( msg == "alarm(QDateTime,int)" ) { | 429 | if ( msg == "alarm(QDateTime,int)" ) { |
407 | Config config( "qpe" ); | 430 | Config config( "qpe" ); |
408 | config.setGroup( "Time" ); | 431 | config.setGroup( "Time" ); |
409 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) { | 432 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) |
410 | 433 | { | |
411 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | 434 | clearTimer(); |
412 | e << config.readEntry( "mp3File", "" ); | 435 | // pid_t pid; |
413 | } | 436 | // switch(pid = fork()) |
414 | else { | 437 | // { |
415 | 438 | // case -1: | |
416 | Sound::soundAlarm(); | 439 | // {//failed |
417 | stopTimer = startTimer( timerStay ); | 440 | // } |
418 | } | 441 | // break; |
419 | } | 442 | // case 0: |
420 | show(); | 443 | // {//child |
421 | raise(); | 444 | // QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); |
422 | QPEApplication::setKeepRunning(); | 445 | // e << config.readEntry( "mp3File", "" ); |
423 | setActiveWindow(); | 446 | pthread_t thread; |
447 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); | ||
448 | // startPlayer(); | ||
449 | // } | ||
450 | // break; | ||
451 | // }; | ||
452 | |||
453 | } | ||
454 | else | ||
455 | { | ||
456 | |||
457 | Sound::soundAlarm(); | ||
458 | stopTimer = startTimer( timerStay ); | ||
459 | } | ||
460 | } | ||
461 | show(); | ||
462 | raise(); | ||
463 | QPEApplication::setKeepRunning(); | ||
464 | setActiveWindow(); | ||
424 | } | 465 | } |
425 | 466 | ||
426 | void Clock::timerEvent( QTimerEvent *e ) | 467 | void Clock::timerEvent( QTimerEvent *e ) |
427 | { | 468 | { |
428 | static int stop = 0; | 469 | static int stop = 0; |
429 | if ( stop < 120 && bSound ) { | 470 | if ( stop < 120 && bSound ) { |
430 | Sound::soundAlarm(); | 471 | Sound::soundAlarm(); |
431 | stop++; | 472 | stop++; |
432 | } | 473 | } |
433 | else { | 474 | else { |
434 | stop = 0; | 475 | stop = 0; |
435 | killTimer( e->timerId() ); | 476 | killTimer( e->timerId() ); |
436 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 477 | clearTimer(); |
437 | alarmBool = FALSE; | 478 | setCaption( tr( "Clock: Alarm was missed." ) ); |
438 | snoozeBtn->hide(); | 479 | } |
439 | setCaption( tr( "Clock: Alarm was missed." ) ); | ||
440 | } | ||
441 | } | 480 | } |
442 | 481 | ||
443 | 482 | ||
444 | QSizePolicy AnalogClock::sizePolicy() const | 483 | QSizePolicy AnalogClock::sizePolicy() const |
445 | { | 484 | { |
446 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | 485 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
447 | } | 486 | } |
448 | 487 | ||
449 | void AnalogClock::drawContents( QPainter *p ) | 488 | void AnalogClock::drawContents( QPainter *p ) |
450 | { | 489 | { |
451 | QRect r = contentsRect(); | 490 | QRect r = contentsRect(); |
452 | QRect fr; | 491 | QRect fr; |
453 | 492 | ||
454 | if ( r. width ( ) > r. height ( )) | 493 | if ( r. width ( ) > r. height ( )) |
455 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); | 494 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); |
456 | else | 495 | else |
457 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); | 496 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); |
458 | 497 | ||
459 | QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); | 498 | QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); |
460 | QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); | 499 | QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); |
461 | QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); | 500 | QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); |
462 | 501 | ||
463 | 502 | ||
464 | 503 | ||
465 | if ( clear ) { | 504 | if ( clear ) { |
466 | erase ( r ); | 505 | erase ( r ); |
467 | p-> setPen ( NoPen ); | 506 | p-> setPen ( NoPen ); |
468 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); | 507 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); |
469 | p-> drawEllipse ( fr ); | 508 | p-> drawEllipse ( fr ); |
470 | p-> setBrush ( NoBrush ); | 509 | p-> setBrush ( NoBrush ); |
471 | 510 | ||
472 | // draw ticks | 511 | // draw ticks |
473 | p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); | 512 | p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); |
474 | for ( int i = 0; i < 12; i++ ) | 513 | for ( int i = 0; i < 12; i++ ) |
475 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); | 514 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); |
476 | } | 515 | } |
477 | else { | 516 | else { |
478 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); | 517 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); |
479 | } | 518 | } |
480 | 519 | ||
481 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); | 520 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); |
482 | 521 | ||
483 | prevTime = currTime; | 522 | prevTime = currTime; |
484 | } | 523 | } |
485 | 524 | ||
486 | void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) | 525 | void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) |
487 | { | 526 | { |
488 | QPoint center = r. center ( ); | 527 | QPoint center = r. center ( ); |
489 | 528 | ||
490 | QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); | 529 | QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); |
491 | QPoint h2( center. x ( ), center. y ( ) ); | 530 | QPoint h2( center. x ( ), center. y ( ) ); |
492 | 531 | ||
493 | QPoint m1( center. x ( ), r.y() + r.height() / 8 ); | 532 | QPoint m1( center. x ( ), r.y() + r.height() / 8 ); |
494 | QPoint m2( center. x ( ), center. y ( ) ); | 533 | QPoint m2( center. x ( ), center. y ( ) ); |
495 | 534 | ||
496 | QPoint s1( center. x ( ), r. y ( ) + 8 ); | 535 | QPoint s1( center. x ( ), r. y ( ) + 8 ); |
497 | QPoint s2( center. x ( ), center. y ( ) ); | 536 | QPoint s2( center. x ( ), center. y ( ) ); |
498 | 537 | ||
499 | 538 | ||
500 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { | 539 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { |
501 | // draw hour pointer | 540 | // draw hour pointer |
502 | h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); | 541 | h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); |
503 | h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); | 542 | h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); |
504 | p-> setPen ( QPen ( c, 3 )); | 543 | p-> setPen ( QPen ( c, 3 )); |
505 | p-> drawLine ( h1, h2 ); | 544 | p-> drawLine ( h1, h2 ); |
506 | } | 545 | } |
507 | 546 | ||
508 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { | 547 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { |
509 | // draw minute pointer | 548 | // draw minute pointer |
510 | m1 = rotate( center, m1, t.minute() * 6 ); | 549 | m1 = rotate( center, m1, t.minute() * 6 ); |
511 | m2 = rotate( center, m2, t.minute() * 6 ); | 550 | m2 = rotate( center, m2, t.minute() * 6 ); |
512 | p-> setPen ( QPen ( c, 2 )); | 551 | p-> setPen ( QPen ( c, 2 )); |
513 | p-> drawLine ( m1, m2 ); | 552 | p-> drawLine ( m1, m2 ); |
514 | } | 553 | } |
515 | 554 | ||
516 | if ( !t2 || ( t. second ( ) != t2-> second ( ))) { | 555 | if ( !t2 || ( t. second ( ) != t2-> second ( ))) { |
517 | // draw second pointer | 556 | // draw second pointer |
518 | s1 = rotate( center, s1, t.second() * 6 ); | 557 | s1 = rotate( center, s1, t.second() * 6 ); |
519 | s2 = rotate( center, s2, t.second() * 6 ); | 558 | s2 = rotate( center, s2, t.second() * 6 ); |
520 | p-> setPen ( QPen ( c, 1 )); | 559 | p-> setPen ( QPen ( c, 1 )); |
521 | p-> drawLine ( s1, s2 ); | 560 | p-> drawLine ( s1, s2 ); |
522 | } | 561 | } |
523 | } | 562 | } |
524 | 563 | ||
525 | void AnalogClock::display( const QTime& t ) | 564 | void AnalogClock::display( const QTime& t ) |
526 | { | 565 | { |
527 | currTime = t; | 566 | currTime = t; |
528 | clear = false; | 567 | clear = false; |
529 | repaint( false ); | 568 | repaint( false ); |
530 | clear = true; | 569 | clear = true; |
531 | } | 570 | } |
532 | 571 | ||
533 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) | 572 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) |
534 | { | 573 | { |
535 | double angle = deg2rad * ( - a + 180 ); | 574 | double angle = deg2rad * ( - a + 180 ); |
536 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - | 575 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - |
537 | ( p.y() - c.y() ) * sin( angle ); | 576 | ( p.y() - c.y() ) * sin( angle ); |
538 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + | 577 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + |
539 | ( p.x() - c.x() ) * sin( angle ); | 578 | ( p.x() - c.x() ) * sin( angle ); |
540 | return QPoint( nx, ny ); | 579 | return QPoint( nx, ny ); |
541 | } | 580 | } |
542 | 581 | ||
543 | void Clock::slotAdjustTime() | 582 | void Clock::slotAdjustTime() |
544 | { | 583 | { |
545 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 584 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
546 | e << QString( "systemtime" ); | 585 | e << QString( "systemtime" ); |
547 | } | 586 | } |
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h index 092d84f..23cc143 100644 --- a/noncore/tools/clock/clock.h +++ b/noncore/tools/clock/clock.h | |||
@@ -1,99 +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(true) {} | 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 | void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); |
51 | 51 | ||
52 | QTime currTime; | 52 | QTime currTime; |
53 | QTime prevTime; | 53 | QTime prevTime; |
54 | bool clear; | 54 | bool clear; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | class Clock : public QVBox | 57 | class Clock : public QVBox |
58 | { | 58 | { |
59 | Q_OBJECT | 59 | Q_OBJECT |
60 | 60 | ||
61 | public: | 61 | public: |
62 | Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); | 62 | Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); |
63 | ~Clock(); | 63 | ~Clock(); |
64 | QDateTime when; | 64 | QDateTime when; |
65 | bool bSound; | 65 | bool bSound; |
66 | int hour, minute, snoozeTime; | 66 | int hour, minute, snoozeTime; |
67 | private slots: | 67 | private slots: |
68 | void slotSet(); | 68 | void slotSet(); |
69 | void slotReset(); | 69 | void slotReset(); |
70 | void modeSelect(int); | 70 | void modeSelect(int); |
71 | void updateClock(); | 71 | void updateClock(); |
72 | void changeClock( bool ); | 72 | void changeClock( bool ); |
73 | void slotSetAlarm(); | 73 | void slotSetAlarm(); |
74 | void slotSnooze(); | 74 | void slotSnooze(); |
75 | void slotToggleAlarm(); | 75 | void slotToggleAlarm(); |
76 | void alarmOn(); | 76 | void alarmOn(); |
77 | void alarmOff(); | 77 | void alarmOff(); |
78 | void appMessage(const QCString& msg, const QByteArray& data); | 78 | void appMessage(const QCString& msg, const QByteArray& data); |
79 | void timerEvent( QTimerEvent *e ); | 79 | void timerEvent( QTimerEvent *e ); |
80 | void slotAdjustTime(); | 80 | void slotAdjustTime(); |
81 | private: | 81 | private: |
82 | void clearClock(); | 82 | void clearClock(); |
83 | 83 | void clearTimer(); | |
84 | bool alarmBool; | 84 | bool alarmBool; |
85 | QTimer *t; | 85 | QTimer *t; |
86 | QLCDNumber *lcd; | 86 | QLCDNumber *lcd; |
87 | QLabel *date; | 87 | QLabel *date; |
88 | QLabel *ampmLabel; | 88 | QLabel *ampmLabel; |
89 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; | 89 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; |
90 | QRadioButton *clockRB, *swatchRB; | 90 | QRadioButton *clockRB, *swatchRB; |
91 | AnalogClock *aclock; | 91 | AnalogClock *aclock; |
92 | QTime swatch_start; | 92 | QTime swatch_start; |
93 | int swatch_totalms; | 93 | int swatch_totalms; |
94 | bool swatch_running; | 94 | bool swatch_running; |
95 | bool ampm; | 95 | bool ampm; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | #endif | 98 | #endif |
99 | 99 | ||
diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro index 29dd52b..8b92118 100644 --- a/noncore/tools/clock/clock.pro +++ b/noncore/tools/clock/clock.pro | |||
@@ -1,32 +1,32 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = clock.h setAlarm.h | 4 | HEADERS = clock.h setAlarm.h |
5 | SOURCES = clock.cpp setAlarm.cpp \ | 5 | SOURCES = clock.cpp setAlarm.cpp \ |
6 | main.cpp | 6 | main.cpp |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopie | 9 | LIBS += -lqpe -lopie -lpthread |
10 | INTERFACES = | 10 | INTERFACES = |
11 | TARGET = clock | 11 | TARGET = clock |
12 | 12 | ||
13 | TRANSLATIONS = ../../../i18n/de/clock.ts \ | 13 | TRANSLATIONS = ../../../i18n/de/clock.ts \ |
14 | ../../../i18n/xx/clock.ts \ | 14 | ../../../i18n/xx/clock.ts \ |
15 | ../../../i18n/en/clock.ts \ | 15 | ../../../i18n/en/clock.ts \ |
16 | ../../../i18n/es/clock.ts \ | 16 | ../../../i18n/es/clock.ts \ |
17 | ../../../i18n/fr/clock.ts \ | 17 | ../../../i18n/fr/clock.ts \ |
18 | ../../../i18n/hu/clock.ts \ | 18 | ../../../i18n/hu/clock.ts \ |
19 | ../../../i18n/ja/clock.ts \ | 19 | ../../../i18n/ja/clock.ts \ |
20 | ../../../i18n/ko/clock.ts \ | 20 | ../../../i18n/ko/clock.ts \ |
21 | ../../../i18n/no/clock.ts \ | 21 | ../../../i18n/no/clock.ts \ |
22 | ../../../i18n/pl/clock.ts \ | 22 | ../../../i18n/pl/clock.ts \ |
23 | ../../../i18n/pt/clock.ts \ | 23 | ../../../i18n/pt/clock.ts \ |
24 | ../../../i18n/pt_BR/clock.ts \ | 24 | ../../../i18n/pt_BR/clock.ts \ |
25 | ../../../i18n/sl/clock.ts \ | 25 | ../../../i18n/sl/clock.ts \ |
26 | ../../../i18n/zh_CN/clock.ts \ | 26 | ../../../i18n/zh_CN/clock.ts \ |
27 | ../../../i18n/zh_TW/clock.ts \ | 27 | ../../../i18n/zh_TW/clock.ts \ |
28 | ../../../i18n/da/clock.ts | 28 | ../../../i18n/da/clock.ts |
29 | 29 | ||
30 | 30 | ||
31 | 31 | ||
32 | include ( $(OPIEDIR)/include.pro ) | 32 | include ( $(OPIEDIR)/include.pro ) |