summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp66
1 files changed, 43 insertions, 23 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index e3621d9..5b901c1 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -113,12 +113,18 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
113 connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) ); 113 connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) );
114 grp->setButton( 0 ); 114 grp->setButton( 0 );
115 115
116 set = new QPushButton ( controls ); 116 set
117 set->setMaximumSize(50,30); 117 = new QPushButton ( controls );
118 gl->addWidget( set, 0, 1 ); 118 set
119 set->setText( tr( "Start" ) ); 119 ->setMaximumSize( 50, 30 );
120 set->setEnabled( FALSE ); 120 gl->addWidget( set
121 grp->insert( set ); 121 , 0, 1 );
122 set
123 ->setText( tr( "Start" ) );
124 set
125 ->setEnabled( FALSE );
126 grp->insert( set
127 );
122 128
123 reset = new QPushButton ( controls ); 129 reset = new QPushButton ( controls );
124 gl->addWidget( reset, 1, 1 ); 130 gl->addWidget( reset, 1, 1 );
@@ -140,7 +146,8 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
140 gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter); 146 gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter);
141 connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) ); 147 connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) );
142 148
143 connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); 149 connect( set
150 , SIGNAL( pressed() ), SLOT( slotSet() ) );
144 connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); 151 connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) );
145 152
146 connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); 153 connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) );
@@ -171,7 +178,8 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
171 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 178 alarmOffBtn->setText( tr( "Alarm Is On" ) );
172 alarmBool=TRUE; 179 alarmBool=TRUE;
173 snoozeBtn->show(); 180 snoozeBtn->show();
174 } else { 181 }
182 else {
175 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 183 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
176 alarmBool=FALSE; 184 alarmBool=FALSE;
177 snoozeBtn->hide(); 185 snoozeBtn->hide();
@@ -200,7 +208,8 @@ void Clock::updateClock()
200 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); 208 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() );
201 ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" ); 209 ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" );
202 ampmLabel->show(); 210 ampmLabel->show();
203 } else { 211 }
212 else {
204 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); 213 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
205 ampmLabel->hide(); 214 ampmLabel->hide();
206 } 215 }
@@ -208,7 +217,8 @@ void Clock::updateClock()
208 lcd->repaint( FALSE ); 217 lcd->repaint( FALSE );
209 aclock->display( QTime::currentTime() ); 218 aclock->display( QTime::currentTime() );
210 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 219 date->setText( TimeString::longDateString( QDate::currentDate() ) );
211 } else { 220 }
221 else {
212 QTime swatch_time; 222 QTime swatch_time;
213 QString lcdtext; 223 QString lcdtext;
214 int totalms = swatch_totalms; 224 int totalms = swatch_totalms;
@@ -241,14 +251,17 @@ void Clock::slotSet()
241{ 251{
242 if ( t->isActive() ) { 252 if ( t->isActive() ) {
243 swatch_totalms += swatch_start.elapsed(); 253 swatch_totalms += swatch_start.elapsed();
244 set->setText( tr( "Start" ) ); 254 set
255 ->setText( tr( "Start" ) );
245 t->stop(); 256 t->stop();
246 swatch_running = FALSE; 257 swatch_running = FALSE;
247 toggleScreenSaver( TRUE ); 258 toggleScreenSaver( TRUE );
248 updateClock(); 259 updateClock();
249 } else { 260 }
261 else {
250 swatch_start.start(); 262 swatch_start.start();
251 set->setText( tr( "Stop" ) ); 263 set
264 ->setText( tr( "Stop" ) );
252 t->start( 1000 ); 265 t->start( 1000 );
253 swatch_running = TRUE; 266 swatch_running = TRUE;
254 // disable screensaver while stop watch is running 267 // disable screensaver while stop watch is running
@@ -273,16 +286,19 @@ void Clock::modeSelect( int m )
273 if ( m ) { 286 if ( m ) {
274 lcd->setNumDigits( 8+1+sw_prec ); 287 lcd->setNumDigits( 8+1+sw_prec );
275 lcd->setMinimumWidth( lcd->sizeHint().width() ); 288 lcd->setMinimumWidth( lcd->sizeHint().width() );
276 set->setEnabled( TRUE ); 289 set
290 ->setEnabled( TRUE );
277 reset->setEnabled( TRUE ); 291 reset->setEnabled( TRUE );
278 ampmLabel->hide(); 292 ampmLabel->hide();
279 293
280 if ( !swatch_running ) 294 if ( !swatch_running )
281 t->stop(); 295 t->stop();
282 } else { 296 }
297 else {
283 lcd->setNumDigits( 5 ); 298 lcd->setNumDigits( 5 );
284 lcd->setMinimumWidth( lcd->sizeHint().width() ); 299 lcd->setMinimumWidth( lcd->sizeHint().width() );
285 set->setEnabled( FALSE ); 300 set
301 ->setEnabled( FALSE );
286 reset->setEnabled( FALSE ); 302 reset->setEnabled( FALSE );
287 t->start(1000); 303 t->start(1000);
288 } 304 }
@@ -342,7 +358,8 @@ void Clock::slotToggleAlarm()
342 snoozeBtn->hide(); 358 snoozeBtn->hide();
343 alarmBool=FALSE; 359 alarmBool=FALSE;
344 alarmOff(); 360 alarmOff();
345 } else { 361 }
362 else {
346 config.writeEntry("clockAlarmSet","TRUE"); 363 config.writeEntry("clockAlarmSet","TRUE");
347 alarmOffBtn->setText( tr( "Alarm Is On" ) ); 364 alarmOffBtn->setText( tr( "Alarm Is On" ) );
348 snoozeBtn->show(); 365 snoozeBtn->show();
@@ -380,7 +397,7 @@ void Clock::alarmOff()
380 setCaption("Clock"); 397 setCaption("Clock");
381} 398}
382 399
383void Clock::appMessage(const QCString& msg, const QByteArray& data) 400void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
384{ 401{
385 int stopTimer = 0; 402 int stopTimer = 0;
386 int timerStay = 5000; 403 int timerStay = 5000;
@@ -393,7 +410,8 @@ void Clock::appMessage(const QCString& msg, const QByteArray& data)
393 410
394 QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)"); 411 QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)");
395 e<<config.readEntry("mp3File",""); 412 e<<config.readEntry("mp3File","");
396 } else { 413 }
414 else {
397 415
398 Sound::soundAlarm(); 416 Sound::soundAlarm();
399 stopTimer = startTimer( timerStay); 417 stopTimer = startTimer( timerStay);
@@ -411,7 +429,8 @@ void Clock::timerEvent( QTimerEvent *e )
411 if ( stop < 120 && bSound) { 429 if ( stop < 120 && bSound) {
412 Sound::soundAlarm(); 430 Sound::soundAlarm();
413 stop++; 431 stop++;
414 } else { 432 }
433 else {
415 stop = 0; 434 stop = 0;
416 killTimer( e->timerId() ); 435 killTimer( e->timerId() );
417 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 436 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
@@ -447,8 +466,8 @@ void AnalogClock::drawContents( QPainter *p )
447 QColor color( clear ? backgroundColor() : black ); 466 QColor color( clear ? backgroundColor() : black );
448 QTime time = clear ? prevTime : currTime; 467 QTime time = clear ? prevTime : currTime;
449 468
450 if ( clear && prevTime.secsTo(currTime) > 1 ) { 469 if ( clear ) {
451 p->eraseRect( rect() ); 470 erase( rect() );
452 return; 471 return;
453 } 472 }
454 473
@@ -505,7 +524,8 @@ QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
505 return QPoint( nx, ny ); 524 return QPoint( nx, ny );
506} 525}
507 526
508void Clock::slotAdjustTime() { 527void Clock::slotAdjustTime()
528{
509 QCopEnvelope e("QPE/System", "execute(QString)"); 529 QCopEnvelope e("QPE/System", "execute(QString)");
510 e << QString("systemtime"); 530 e << QString("systemtime");
511} 531}