author | fbarros <fbarros> | 2002-08-29 17:49:16 (UTC) |
---|---|---|
committer | fbarros <fbarros> | 2002-08-29 17:49:16 (UTC) |
commit | 6707dd2b7abf2fac4aef4025cf8e554577d0891c (patch) (unidiff) | |
tree | 0991d5274dc372dc089368deac74abb96ad6e413 | |
parent | f30d948cc7fec19a00ebc131b5b1ace159212a81 (diff) | |
download | opie-6707dd2b7abf2fac4aef4025cf8e554577d0891c.zip opie-6707dd2b7abf2fac4aef4025cf8e554577d0891c.tar.gz opie-6707dd2b7abf2fac4aef4025cf8e554577d0891c.tar.bz2 |
just a tr()
-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 69d8214..e3621d9 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -164,348 +164,348 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
164 | QString tmp = config.readEntry("clockAlarmHour", ""); | 164 | QString tmp = config.readEntry("clockAlarmHour", ""); |
165 | bool ok; | 165 | bool ok; |
166 | hour = tmp.toInt(&ok,10); | 166 | hour = tmp.toInt(&ok,10); |
167 | tmp = config.readEntry("clockAlarmMinute",""); | 167 | tmp = config.readEntry("clockAlarmMinute",""); |
168 | minute = tmp.toInt(&ok,10); | 168 | minute = tmp.toInt(&ok,10); |
169 | 169 | ||
170 | if( config.readEntry("clockAlarmSet","FALSE") == "TRUE") { | 170 | if( config.readEntry("clockAlarmSet","FALSE") == "TRUE") { |
171 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 171 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
172 | alarmBool=TRUE; | 172 | alarmBool=TRUE; |
173 | snoozeBtn->show(); | 173 | snoozeBtn->show(); |
174 | } else { | 174 | } else { |
175 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 175 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
176 | alarmBool=FALSE; | 176 | alarmBool=FALSE; |
177 | snoozeBtn->hide(); | 177 | snoozeBtn->hide(); |
178 | } | 178 | } |
179 | 179 | ||
180 | QTimer::singleShot( 0, this, SLOT(updateClock()) ); | 180 | QTimer::singleShot( 0, this, SLOT(updateClock()) ); |
181 | modeSelect(0); | 181 | modeSelect(0); |
182 | } | 182 | } |
183 | 183 | ||
184 | Clock::~Clock() | 184 | Clock::~Clock() |
185 | { | 185 | { |
186 | toggleScreenSaver( true ); | 186 | toggleScreenSaver( true ); |
187 | } | 187 | } |
188 | 188 | ||
189 | void Clock::updateClock() | 189 | void Clock::updateClock() |
190 | { | 190 | { |
191 | if ( clockRB->isChecked() ) { | 191 | if ( clockRB->isChecked() ) { |
192 | QTime tm = QDateTime::currentDateTime().time(); | 192 | QTime tm = QDateTime::currentDateTime().time(); |
193 | QString s; | 193 | QString s; |
194 | if ( ampm ) { | 194 | if ( ampm ) { |
195 | int hour = tm.hour(); | 195 | int hour = tm.hour(); |
196 | if (hour == 0) | 196 | if (hour == 0) |
197 | hour = 12; | 197 | hour = 12; |
198 | if (hour > 12) | 198 | if (hour > 12) |
199 | hour -= 12; | 199 | hour -= 12; |
200 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); | 200 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); |
201 | ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" ); | 201 | ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" ); |
202 | ampmLabel->show(); | 202 | ampmLabel->show(); |
203 | } else { | 203 | } else { |
204 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); | 204 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); |
205 | ampmLabel->hide(); | 205 | ampmLabel->hide(); |
206 | } | 206 | } |
207 | lcd->display( s ); | 207 | lcd->display( s ); |
208 | lcd->repaint( FALSE ); | 208 | lcd->repaint( FALSE ); |
209 | aclock->display( QTime::currentTime() ); | 209 | aclock->display( QTime::currentTime() ); |
210 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 210 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); |
211 | } else { | 211 | } else { |
212 | QTime swatch_time; | 212 | QTime swatch_time; |
213 | QString lcdtext; | 213 | QString lcdtext; |
214 | int totalms = swatch_totalms; | 214 | int totalms = swatch_totalms; |
215 | if ( swatch_running ) | 215 | if ( swatch_running ) |
216 | totalms += swatch_start.elapsed(); | 216 | totalms += swatch_start.elapsed(); |
217 | swatch_time = QTime(0,0,0).addMSecs(totalms); | 217 | swatch_time = QTime(0,0,0).addMSecs(totalms); |
218 | QString d = swatch_running ? QString(" ") | 218 | QString d = swatch_running ? QString(" ") |
219 | : QString::number(totalms%1000+1000); | 219 | : QString::number(totalms%1000+1000); |
220 | lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); | 220 | lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); |
221 | lcd->display( lcdtext ); | 221 | lcd->display( lcdtext ); |
222 | lcd->repaint( FALSE ); | 222 | lcd->repaint( FALSE ); |
223 | aclock->display( swatch_time ); | 223 | aclock->display( swatch_time ); |
224 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 224 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | void Clock::changeClock( bool a ) | 228 | void Clock::changeClock( bool a ) |
229 | { | 229 | { |
230 | ampm = a; | 230 | ampm = a; |
231 | updateClock(); | 231 | updateClock(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void Clock::clearClock( void ) | 234 | void Clock::clearClock( void ) |
235 | { | 235 | { |
236 | lcd->display( QTime( 0,0,0 ).toString() ); | 236 | lcd->display( QTime( 0,0,0 ).toString() ); |
237 | aclock->display( QTime( 0,0,0 ) ); | 237 | aclock->display( QTime( 0,0,0 ) ); |
238 | } | 238 | } |
239 | 239 | ||
240 | void Clock::slotSet() | 240 | void Clock::slotSet() |
241 | { | 241 | { |
242 | if ( t->isActive() ) { | 242 | if ( t->isActive() ) { |
243 | swatch_totalms += swatch_start.elapsed(); | 243 | swatch_totalms += swatch_start.elapsed(); |
244 | set->setText( tr( "Start" ) ); | 244 | set->setText( tr( "Start" ) ); |
245 | t->stop(); | 245 | t->stop(); |
246 | swatch_running = FALSE; | 246 | swatch_running = FALSE; |
247 | toggleScreenSaver( TRUE ); | 247 | toggleScreenSaver( TRUE ); |
248 | updateClock(); | 248 | updateClock(); |
249 | } else { | 249 | } else { |
250 | swatch_start.start(); | 250 | swatch_start.start(); |
251 | set->setText( tr( "Stop" ) ); | 251 | set->setText( tr( "Stop" ) ); |
252 | t->start( 1000 ); | 252 | t->start( 1000 ); |
253 | swatch_running = TRUE; | 253 | swatch_running = TRUE; |
254 | // disable screensaver while stop watch is running | 254 | // disable screensaver while stop watch is running |
255 | toggleScreenSaver( FALSE ); | 255 | toggleScreenSaver( FALSE ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | void Clock::slotReset() | 259 | void Clock::slotReset() |
260 | { | 260 | { |
261 | t->stop(); | 261 | t->stop(); |
262 | swatch_start.start(); | 262 | swatch_start.start(); |
263 | swatch_totalms = 0; | 263 | swatch_totalms = 0; |
264 | 264 | ||
265 | if (swatch_running ) | 265 | if (swatch_running ) |
266 | t->start(1000); | 266 | t->start(1000); |
267 | 267 | ||
268 | updateClock(); | 268 | updateClock(); |
269 | } | 269 | } |
270 | 270 | ||
271 | void Clock::modeSelect( int m ) | 271 | void Clock::modeSelect( int m ) |
272 | { | 272 | { |
273 | if ( m ) { | 273 | if ( m ) { |
274 | lcd->setNumDigits( 8+1+sw_prec ); | 274 | lcd->setNumDigits( 8+1+sw_prec ); |
275 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 275 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
276 | set->setEnabled( TRUE ); | 276 | set->setEnabled( TRUE ); |
277 | reset->setEnabled( TRUE ); | 277 | reset->setEnabled( TRUE ); |
278 | ampmLabel->hide(); | 278 | ampmLabel->hide(); |
279 | 279 | ||
280 | if ( !swatch_running ) | 280 | if ( !swatch_running ) |
281 | t->stop(); | 281 | t->stop(); |
282 | } else { | 282 | } else { |
283 | lcd->setNumDigits( 5 ); | 283 | lcd->setNumDigits( 5 ); |
284 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 284 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
285 | set->setEnabled( FALSE ); | 285 | set->setEnabled( FALSE ); |
286 | reset->setEnabled( FALSE ); | 286 | reset->setEnabled( FALSE ); |
287 | t->start(1000); | 287 | t->start(1000); |
288 | } | 288 | } |
289 | updateClock(); | 289 | updateClock(); |
290 | } | 290 | } |
291 | 291 | ||
292 | //this sets the alarm time | 292 | //this sets the alarm time |
293 | void Clock::slotSetAlarm() | 293 | void Clock::slotSetAlarm() |
294 | { | 294 | { |
295 | if( !snoozeBtn->isHidden()) | 295 | if( !snoozeBtn->isHidden()) |
296 | slotToggleAlarm(); | 296 | slotToggleAlarm(); |
297 | Set_Alarm *setAlarmDlg; | 297 | Set_Alarm *setAlarmDlg; |
298 | setAlarmDlg = new Set_Alarm(this,"SetAlarm", TRUE); | 298 | setAlarmDlg = new Set_Alarm(this,"SetAlarm", TRUE); |
299 | int result = setAlarmDlg->exec(); | 299 | int result = setAlarmDlg->exec(); |
300 | if(result == 1) { | 300 | if(result == 1) { |
301 | Config config( "qpe" ); | 301 | Config config( "qpe" ); |
302 | config.setGroup("Time"); | 302 | config.setGroup("Time"); |
303 | QString tmp; | 303 | QString tmp; |
304 | hour = setAlarmDlg->Hour_Slider->value(); | 304 | hour = setAlarmDlg->Hour_Slider->value(); |
305 | minute = setAlarmDlg->Minute_Slider->value(); | 305 | minute = setAlarmDlg->Minute_Slider->value(); |
306 | snoozeTime=setAlarmDlg->SnoozeSlider->value(); | 306 | snoozeTime=setAlarmDlg->SnoozeSlider->value(); |
307 | if(ampm) { | 307 | if(ampm) { |
308 | if ( hour == 12 ) | 308 | if ( hour == 12 ) |
309 | hour = 0; | 309 | hour = 0; |
310 | 310 | ||
311 | if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) | 311 | if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) |
312 | hour+=12; | 312 | hour+=12; |
313 | } | 313 | } |
314 | config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10); | 314 | config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10); |
315 | config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10); | 315 | config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10); |
316 | config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10); | 316 | config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10); |
317 | config.write(); | 317 | config.write(); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | void Clock::slotSnooze() | 321 | void Clock::slotSnooze() |
322 | { | 322 | { |
323 | bSound=FALSE; | 323 | bSound=FALSE; |
324 | int warn = 0; | 324 | int warn = 0; |
325 | QTime t = QTime::currentTime(); | 325 | QTime t = QTime::currentTime(); |
326 | QDateTime whenl( when.date(), t.addSecs( snoozeTime*60)); | 326 | QDateTime whenl( when.date(), t.addSecs( snoozeTime*60)); |
327 | when=whenl; | 327 | when=whenl; |
328 | AlarmServer::addAlarm( when, | 328 | AlarmServer::addAlarm( when, |
329 | "QPE/Application/clock", | 329 | "QPE/Application/clock", |
330 | "alarm(QDateTime,int)", warn ); | 330 | "alarm(QDateTime,int)", warn ); |
331 | 331 | ||
332 | } | 332 | } |
333 | 333 | ||
334 | //toggles alarm on/off | 334 | //toggles alarm on/off |
335 | void Clock::slotToggleAlarm() | 335 | void Clock::slotToggleAlarm() |
336 | { | 336 | { |
337 | Config config( "qpe" ); | 337 | Config config( "qpe" ); |
338 | config.setGroup("Time"); | 338 | config.setGroup("Time"); |
339 | if(alarmBool) { | 339 | if(alarmBool) { |
340 | config.writeEntry("clockAlarmSet","FALSE"); | 340 | config.writeEntry("clockAlarmSet","FALSE"); |
341 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 341 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
342 | snoozeBtn->hide(); | 342 | snoozeBtn->hide(); |
343 | alarmBool=FALSE; | 343 | alarmBool=FALSE; |
344 | alarmOff(); | 344 | alarmOff(); |
345 | } else { | 345 | } else { |
346 | config.writeEntry("clockAlarmSet","TRUE"); | 346 | config.writeEntry("clockAlarmSet","TRUE"); |
347 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 347 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
348 | snoozeBtn->show(); | 348 | snoozeBtn->show(); |
349 | alarmBool=TRUE; | 349 | alarmBool=TRUE; |
350 | alarmOn(); | 350 | alarmOn(); |
351 | } | 351 | } |
352 | config.write(); | 352 | config.write(); |
353 | } | 353 | } |
354 | 354 | ||
355 | void Clock::alarmOn() | 355 | void Clock::alarmOn() |
356 | { | 356 | { |
357 | QDate d = QDate::currentDate(); | 357 | QDate d = QDate::currentDate(); |
358 | QTime tm((int)hour,(int)minute,0); | 358 | QTime tm((int)hour,(int)minute,0); |
359 | qDebug("Time set "+tm.toString()); | 359 | qDebug("Time set "+tm.toString()); |
360 | QTime t = QTime::currentTime(); | 360 | QTime t = QTime::currentTime(); |
361 | if( t > tm) | 361 | if( t > tm) |
362 | d = d.addDays(1); | 362 | d = d.addDays(1); |
363 | int warn = 0; | 363 | int warn = 0; |
364 | QDateTime whenl(d,tm); | 364 | QDateTime whenl(d,tm); |
365 | when=whenl; | 365 | when=whenl; |
366 | AlarmServer::addAlarm( when, | 366 | AlarmServer::addAlarm( when, |
367 | "QPE/Application/clock", | 367 | "QPE/Application/clock", |
368 | "alarm(QDateTime,int)", warn ); | 368 | "alarm(QDateTime,int)", warn ); |
369 | setCaption("Alarm set: "+ whenl.toString()); | 369 | setCaption("Alarm set: "+ whenl.toString()); |
370 | } | 370 | } |
371 | 371 | ||
372 | void Clock::alarmOff() | 372 | void Clock::alarmOff() |
373 | { | 373 | { |
374 | int warn = 0; | 374 | int warn = 0; |
375 | bSound=FALSE; | 375 | bSound=FALSE; |
376 | AlarmServer::deleteAlarm( when, | 376 | AlarmServer::deleteAlarm( when, |
377 | "QPE/Application/clock", | 377 | "QPE/Application/clock", |
378 | "alarm(QDateTime,int)", warn ); | 378 | "alarm(QDateTime,int)", warn ); |
379 | qDebug("Alarm Off "+ when.toString()); | 379 | qDebug("Alarm Off "+ when.toString()); |
380 | setCaption("Clock"); | 380 | setCaption("Clock"); |
381 | } | 381 | } |
382 | 382 | ||
383 | void Clock::appMessage(const QCString& msg, const QByteArray& data) | 383 | void Clock::appMessage(const QCString& msg, const QByteArray& data) |
384 | { | 384 | { |
385 | int stopTimer = 0; | 385 | int stopTimer = 0; |
386 | int timerStay = 5000; | 386 | int timerStay = 5000; |
387 | bSound=TRUE; | 387 | bSound=TRUE; |
388 | qDebug("Message received in clock"); | 388 | qDebug("Message received in clock"); |
389 | if ( msg == "alarm(QDateTime,int)" ) { | 389 | if ( msg == "alarm(QDateTime,int)" ) { |
390 | Config config( "qpe" ); | 390 | Config config( "qpe" ); |
391 | config.setGroup("Time"); | 391 | config.setGroup("Time"); |
392 | if(config.readBoolEntry("mp3Alarm",0)){ | 392 | if(config.readBoolEntry("mp3Alarm",0)){ |
393 | 393 | ||
394 | QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)"); | 394 | QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)"); |
395 | e<<config.readEntry("mp3File",""); | 395 | e<<config.readEntry("mp3File",""); |
396 | } else { | 396 | } else { |
397 | 397 | ||
398 | Sound::soundAlarm(); | 398 | Sound::soundAlarm(); |
399 | stopTimer = startTimer( timerStay); | 399 | stopTimer = startTimer( timerStay); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | show(); | 402 | show(); |
403 | raise(); | 403 | raise(); |
404 | QPEApplication::setKeepRunning(); | 404 | QPEApplication::setKeepRunning(); |
405 | setActiveWindow(); | 405 | setActiveWindow(); |
406 | } | 406 | } |
407 | 407 | ||
408 | void Clock::timerEvent( QTimerEvent *e ) | 408 | void Clock::timerEvent( QTimerEvent *e ) |
409 | { | 409 | { |
410 | static int stop = 0; | 410 | static int stop = 0; |
411 | if ( stop < 120 && bSound) { | 411 | if ( stop < 120 && bSound) { |
412 | Sound::soundAlarm(); | 412 | Sound::soundAlarm(); |
413 | stop++; | 413 | stop++; |
414 | } else { | 414 | } else { |
415 | stop = 0; | 415 | stop = 0; |
416 | killTimer( e->timerId() ); | 416 | killTimer( e->timerId() ); |
417 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 417 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
418 | alarmBool=FALSE; | 418 | alarmBool=FALSE; |
419 | snoozeBtn->hide(); | 419 | snoozeBtn->hide(); |
420 | setCaption("Clock: Alarm was missed."); | 420 | setCaption(tr("Clock: Alarm was missed.")); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | QSizePolicy AnalogClock::sizePolicy() const | 425 | QSizePolicy AnalogClock::sizePolicy() const |
426 | { | 426 | { |
427 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | 427 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
428 | } | 428 | } |
429 | 429 | ||
430 | void AnalogClock::drawContents( QPainter *p ) | 430 | void AnalogClock::drawContents( QPainter *p ) |
431 | { | 431 | { |
432 | QRect r = contentsRect(); | 432 | QRect r = contentsRect(); |
433 | QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | 433 | QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); |
434 | 434 | ||
435 | QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); | 435 | QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); |
436 | QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); | 436 | QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); |
437 | 437 | ||
438 | QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); | 438 | QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); |
439 | QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | 439 | QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); |
440 | 440 | ||
441 | QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 ); | 441 | QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 ); |
442 | QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | 442 | QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); |
443 | 443 | ||
444 | QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); | 444 | QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); |
445 | QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | 445 | QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); |
446 | 446 | ||
447 | QColor color( clear ? backgroundColor() : black ); | 447 | QColor color( clear ? backgroundColor() : black ); |
448 | QTime time = clear ? prevTime : currTime; | 448 | QTime time = clear ? prevTime : currTime; |
449 | 449 | ||
450 | if ( clear && prevTime.secsTo(currTime) > 1 ) { | 450 | if ( clear && prevTime.secsTo(currTime) > 1 ) { |
451 | p->eraseRect( rect() ); | 451 | p->eraseRect( rect() ); |
452 | return; | 452 | return; |
453 | } | 453 | } |
454 | 454 | ||
455 | if ( !clear ) { | 455 | if ( !clear ) { |
456 | // draw ticks | 456 | // draw ticks |
457 | p->setPen( QPen( color, 1 ) ); | 457 | p->setPen( QPen( color, 1 ) ); |
458 | for ( int i = 0; i < 12; i++ ) | 458 | for ( int i = 0; i < 12; i++ ) |
459 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); | 459 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); |
460 | } | 460 | } |
461 | 461 | ||
462 | if ( !clear || prevTime.minute() != currTime.minute() || | 462 | if ( !clear || prevTime.minute() != currTime.minute() || |
463 | prevTime.hour() != currTime.hour() ) { | 463 | prevTime.hour() != currTime.hour() ) { |
464 | // draw hour pointer | 464 | // draw hour pointer |
465 | h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); | 465 | h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); |
466 | h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); | 466 | h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); |
467 | p->setPen( QPen( color, 3 ) ); | 467 | p->setPen( QPen( color, 3 ) ); |
468 | p->drawLine( h1, h2 ); | 468 | p->drawLine( h1, h2 ); |
469 | } | 469 | } |
470 | 470 | ||
471 | if ( !clear || prevTime.minute() != currTime.minute() ) { | 471 | if ( !clear || prevTime.minute() != currTime.minute() ) { |
472 | // draw minute pointer | 472 | // draw minute pointer |
473 | m1 = rotate( center, m1, time.minute() * 6 ); | 473 | m1 = rotate( center, m1, time.minute() * 6 ); |
474 | m2 = rotate( center, m2, time.minute() * 6 ); | 474 | m2 = rotate( center, m2, time.minute() * 6 ); |
475 | p->setPen( QPen( color, 2 ) ); | 475 | p->setPen( QPen( color, 2 ) ); |
476 | p->drawLine( m1, m2 ); | 476 | p->drawLine( m1, m2 ); |
477 | } | 477 | } |
478 | 478 | ||
479 | // draw second pointer | 479 | // draw second pointer |
480 | s1 = rotate( center, s1, time.second() * 6 ); | 480 | s1 = rotate( center, s1, time.second() * 6 ); |
481 | s2 = rotate( center, s2, time.second() * 6 ); | 481 | s2 = rotate( center, s2, time.second() * 6 ); |
482 | p->setPen( QPen( color, 1 ) ); | 482 | p->setPen( QPen( color, 1 ) ); |
483 | p->drawLine( s1, s2 ); | 483 | p->drawLine( s1, s2 ); |
484 | 484 | ||
485 | if ( !clear ) | 485 | if ( !clear ) |
486 | prevTime = currTime; | 486 | prevTime = currTime; |
487 | } | 487 | } |
488 | 488 | ||
489 | void AnalogClock::display( const QTime& t ) | 489 | void AnalogClock::display( const QTime& t ) |
490 | { | 490 | { |
491 | currTime = t; | 491 | currTime = t; |
492 | clear = true; | 492 | clear = true; |
493 | repaint( false ); | 493 | repaint( false ); |
494 | clear = false; | 494 | clear = false; |
495 | repaint( false ); | 495 | repaint( false ); |
496 | } | 496 | } |
497 | 497 | ||
498 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) | 498 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) |
499 | { | 499 | { |
500 | double angle = deg2rad * ( - a + 180 ); | 500 | double angle = deg2rad * ( - a + 180 ); |
501 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - | 501 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - |
502 | ( p.y() - c.y() ) * sin( angle ); | 502 | ( p.y() - c.y() ) * sin( angle ); |
503 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + | 503 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + |
504 | ( p.x() - c.x() ) * sin( angle ); | 504 | ( p.x() - c.x() ) * sin( angle ); |
505 | return QPoint( nx, ny ); | 505 | return QPoint( nx, ny ); |
506 | } | 506 | } |
507 | 507 | ||
508 | void Clock::slotAdjustTime() { | 508 | void Clock::slotAdjustTime() { |
509 | QCopEnvelope e("QPE/System", "execute(QString)"); | 509 | QCopEnvelope e("QPE/System", "execute(QString)"); |
510 | e << QString("systemtime"); | 510 | e << QString("systemtime"); |
511 | } | 511 | } |