summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-31 12:12:02 (UTC)
committer llornkcor <llornkcor>2002-05-31 12:12:02 (UTC)
commitdd08e7fa2ccbcc0489c17ed305b20a9a7d187161 (patch) (unidiff)
tree59399ddb7c89ad178c85e576018db9471d292b52
parent40eac37ff82dd4499a95adb786eb063fd0b81584 (diff)
downloadopie-dd08e7fa2ccbcc0489c17ed305b20a9a7d187161.zip
opie-dd08e7fa2ccbcc0489c17ed305b20a9a7d187161.tar.gz
opie-dd08e7fa2ccbcc0489c17ed305b20a9a7d187161.tar.bz2
add zeckes change in again *DOH*, and initialize some silly int's to get rid of silly compiler warnings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp253
-rw-r--r--noncore/tools/clock/clock.h2
2 files changed, 133 insertions, 122 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index a85cc19..0a21146 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -1,22 +1,21 @@
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// code added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002
21 20
22#include "clock.h" 21#include "clock.h"
@@ -33,4 +32,6 @@
33#include <qtimer.h> 32#include <qtimer.h>
34 33
34#include <opie/oclickablelabel.h>
35
35#include <qlcdnumber.h> 36#include <qlcdnumber.h>
36#include <qslider.h> 37#include <qslider.h>
@@ -57,5 +58,5 @@ static void toggleScreenSaver( bool on )
57 58
58Clock::Clock( QWidget * parent, const char * name, WFlags f ) 59Clock::Clock( QWidget * parent, const char * name, WFlags f )
59 : QVBox( parent, name , f ) 60 : QVBox( parent, name , f )
60{ 61{
61 setSpacing( 4 ); 62 setSpacing( 4 );
@@ -94,5 +95,5 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
94 95
95 QWidget *controls = new QWidget( this ); 96 QWidget *controls = new QWidget( this );
96 QGridLayout *gl = new QGridLayout( controls, 2, 2, 6, 4 ); 97 QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 );
97 98
98 QButtonGroup *grp = new QButtonGroup( controls ); 99 QButtonGroup *grp = new QButtonGroup( controls );
@@ -133,4 +134,9 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
133 alarmBtn->setText( tr( "Set Alarm" ) ); 134 alarmBtn->setText( tr( "Set Alarm" ) );
134 135
136 OClickableLabel *click = new OClickableLabel(controls, "label" );
137 click->setText(tr("Set date and time." ) );
138 gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter);
139 connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) );
140
135 connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); 141 connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) );
136 connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); 142 connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) );
@@ -141,5 +147,5 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
141 147
142 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 148 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
143 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 149 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
144 150
145 t = new QTimer( this ); 151 t = new QTimer( this );
@@ -169,5 +175,5 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
169 snoozeBtn->hide(); 175 snoozeBtn->hide();
170 } 176 }
171 177
172 QTimer::singleShot( 0, this, SLOT(updateClock()) ); 178 QTimer::singleShot( 0, this, SLOT(updateClock()) );
173 modeSelect(0); 179 modeSelect(0);
@@ -182,37 +188,37 @@ void Clock::updateClock()
182{ 188{
183 if ( clockRB->isChecked() ) { 189 if ( clockRB->isChecked() ) {
184 QTime tm = QDateTime::currentDateTime().time(); 190 QTime tm = QDateTime::currentDateTime().time();
185 QString s; 191 QString s;
186 if ( ampm ) { 192 if ( ampm ) {
187 int hour = tm.hour(); 193 int hour = tm.hour();
188 if (hour == 0) 194 if (hour == 0)
189 hour = 12; 195 hour = 12;
190 if (hour > 12) 196 if (hour > 12)
191 hour -= 12; 197 hour -= 12;
192 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); 198 s.sprintf( "%2d%c%02d", hour, ':', tm.minute() );
193 ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" ); 199 ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" );
194 ampmLabel->show(); 200 ampmLabel->show();
195 } else { 201 } else {
196 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); 202 s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
197 ampmLabel->hide(); 203 ampmLabel->hide();
198 } 204 }
199 lcd->display( s ); 205 lcd->display( s );
200 lcd->repaint( FALSE ); 206 lcd->repaint( FALSE );
201 aclock->display( QTime::currentTime() ); 207 aclock->display( QTime::currentTime() );
202 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 208 date->setText( TimeString::longDateString( QDate::currentDate() ) );
203 } else { 209 } else {
204 QTime swatch_time; 210 QTime swatch_time;
205 QString lcdtext; 211 QString lcdtext;
206 int totalms = swatch_totalms; 212 int totalms = swatch_totalms;
207 if ( swatch_running ) 213 if ( swatch_running )
208 totalms += swatch_start.elapsed(); 214 totalms += swatch_start.elapsed();
209 swatch_time = QTime(0,0,0).addMSecs(totalms); 215 swatch_time = QTime(0,0,0).addMSecs(totalms);
210 QString d = swatch_running ? QString(" ") 216 QString d = swatch_running ? QString(" ")
211 : QString::number(totalms%1000+1000); 217 : QString::number(totalms%1000+1000);
212 lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); 218 lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec);
213 lcd->display( lcdtext ); 219 lcd->display( lcdtext );
214 lcd->repaint( FALSE ); 220 lcd->repaint( FALSE );
215 aclock->display( swatch_time ); 221 aclock->display( swatch_time );
216 date->setText( TimeString::longDateString( QDate::currentDate() ) ); 222 date->setText( TimeString::longDateString( QDate::currentDate() ) );
217 } 223 }
218} 224}
@@ -233,17 +239,17 @@ void Clock::slotSet()
233{ 239{
234 if ( t->isActive() ) { 240 if ( t->isActive() ) {
235 swatch_totalms += swatch_start.elapsed(); 241 swatch_totalms += swatch_start.elapsed();
236 set->setText( tr( "Start" ) ); 242 set->setText( tr( "Start" ) );
237 t->stop(); 243 t->stop();
238 swatch_running = FALSE; 244 swatch_running = FALSE;
239 toggleScreenSaver( TRUE ); 245 toggleScreenSaver( TRUE );
240 updateClock(); 246 updateClock();
241 } else { 247 } else {
242 swatch_start.start(); 248 swatch_start.start();
243 set->setText( tr( "Stop" ) ); 249 set->setText( tr( "Stop" ) );
244 t->start( 1000 ); 250 t->start( 1000 );
245 swatch_running = TRUE; 251 swatch_running = TRUE;
246 // disable screensaver while stop watch is running 252 // disable screensaver while stop watch is running
247 toggleScreenSaver( FALSE ); 253 toggleScreenSaver( FALSE );
248 } 254 }
249} 255}
@@ -256,5 +262,5 @@ void Clock::slotReset()
256 262
257 if (swatch_running ) 263 if (swatch_running )
258 t->start(1000); 264 t->start(1000);
259 265
260 updateClock(); 266 updateClock();
@@ -264,18 +270,18 @@ void Clock::modeSelect( int m )
264{ 270{
265 if ( m ) { 271 if ( m ) {
266 lcd->setNumDigits( 8+1+sw_prec ); 272 lcd->setNumDigits( 8+1+sw_prec );
267 lcd->setMinimumWidth( lcd->sizeHint().width() ); 273 lcd->setMinimumWidth( lcd->sizeHint().width() );
268 set->setEnabled( TRUE ); 274 set->setEnabled( TRUE );
269 reset->setEnabled( TRUE ); 275 reset->setEnabled( TRUE );
270 ampmLabel->hide(); 276 ampmLabel->hide();
271 277
272 if ( !swatch_running ) 278 if ( !swatch_running )
273 t->stop(); 279 t->stop();
274 } else { 280 } else {
275 lcd->setNumDigits( 5 ); 281 lcd->setNumDigits( 5 );
276 lcd->setMinimumWidth( lcd->sizeHint().width() ); 282 lcd->setMinimumWidth( lcd->sizeHint().width() );
277 set->setEnabled( FALSE ); 283 set->setEnabled( FALSE );
278 reset->setEnabled( FALSE ); 284 reset->setEnabled( FALSE );
279 t->start(1000); 285 t->start(1000);
280 } 286 }
281 updateClock(); 287 updateClock();
@@ -283,5 +289,5 @@ void Clock::modeSelect( int m )
283 289
284//this sets the alarm time 290//this sets the alarm time
285void Clock::slotSetAlarm() 291void Clock::slotSetAlarm()
286{ 292{
287 if( !snoozeBtn->isHidden()) 293 if( !snoozeBtn->isHidden())
@@ -305,5 +311,5 @@ void Clock::slotSetAlarm()
305 config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10); 311 config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10);
306 config.write(); 312 config.write();
307 } 313 }
308} 314}
309 315
@@ -311,16 +317,16 @@ void Clock::slotSnooze()
311{ 317{
312 bSound=FALSE; 318 bSound=FALSE;
313 int warn; 319 int warn = 0;
314 QTime t = QTime::currentTime(); 320 QTime t = QTime::currentTime();
315 QDateTime whenl( when.date(), t.addSecs( snoozeTime*60)); 321 QDateTime whenl( when.date(), t.addSecs( snoozeTime*60));
316 when=whenl; 322 when=whenl;
317 AlarmServer::addAlarm( when, 323 AlarmServer::addAlarm( when,
318 "QPE/Application/clock", 324 "QPE/Application/clock",
319 "alarm(QDateTime,int)", warn ); 325 "alarm(QDateTime,int)", warn );
320 326
321} 327}
322 328
323//toggles alarm on/off 329//toggles alarm on/off
324void Clock::slotToggleAlarm() 330void Clock::slotToggleAlarm()
325{ 331{
326 Config config( "qpe" ); 332 Config config( "qpe" );
@@ -350,10 +356,10 @@ void Clock::alarmOn()
350 if( t > tm) 356 if( t > tm)
351 d = d.addDays(1); 357 d = d.addDays(1);
352 int warn; 358 int warn = 0;
353 QDateTime whenl(d,tm); 359 QDateTime whenl(d,tm);
354 when=whenl; 360 when=whenl;
355 AlarmServer::addAlarm( when, 361 AlarmServer::addAlarm( when,
356 "QPE/Application/clock", 362 "QPE/Application/clock",
357 "alarm(QDateTime,int)", warn ); 363 "alarm(QDateTime,int)", warn );
358 setCaption("Alarm set: "+ whenl.toString()); 364 setCaption("Alarm set: "+ whenl.toString());
359} 365}
@@ -361,11 +367,11 @@ void Clock::alarmOn()
361void Clock::alarmOff() 367void Clock::alarmOff()
362{ 368{
363 int warn; 369 int warn = 0;
364 bSound=FALSE; 370 bSound=FALSE;
365 AlarmServer::deleteAlarm( when, 371 AlarmServer::deleteAlarm( when,
366 "QPE/Application/clock", 372 "QPE/Application/clock",
367 "alarm(QDateTime,int)", warn ); 373 "alarm(QDateTime,int)", warn );
368 qDebug("Alarm Off "+ when.toString()); 374 qDebug("Alarm Off "+ when.toString());
369 setCaption("Clock"); 375 setCaption("Clock");
370} 376}
371 377
@@ -375,8 +381,8 @@ void Clock::appMessage(const QCString& msg, const QByteArray& data)
375 int timerStay = 5000; 381 int timerStay = 5000;
376 bSound=TRUE; 382 bSound=TRUE;
377 if ( msg == "alarm(QDateTime,int)" ) { 383 if ( msg == "alarm(QDateTime,int)" ) {
378 Sound::soundAlarm(); 384 Sound::soundAlarm();
379 stopTimer = startTimer( timerStay); 385 stopTimer = startTimer( timerStay);
380 } 386 }
381} 387}
382 388
@@ -424,33 +430,33 @@ void AnalogClock::drawContents( QPainter *p )
424 430
425 if ( clear && prevTime.secsTo(currTime) > 1 ) { 431 if ( clear && prevTime.secsTo(currTime) > 1 ) {
426 p->eraseRect( rect() ); 432 p->eraseRect( rect() );
427 return; 433 return;
428 } 434 }
429 435
430 if ( !clear ) { 436 if ( !clear ) {
431 // draw ticks 437 // draw ticks
432 p->setPen( QPen( color, 1 ) ); 438 p->setPen( QPen( color, 1 ) );
433 for ( int i = 0; i < 12; i++ ) 439 for ( int i = 0; i < 12; i++ )
434 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); 440 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
435 } 441 }
436 442
437 if ( !clear || prevTime.minute() != currTime.minute() || 443 if ( !clear || prevTime.minute() != currTime.minute() ||
438 prevTime.hour() != currTime.hour() ) { 444 prevTime.hour() != currTime.hour() ) {
439 // draw hour pointer 445 // draw hour pointer
440 h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); 446 h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
441 h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); 447 h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
442 p->setPen( QPen( color, 3 ) ); 448 p->setPen( QPen( color, 3 ) );
443 p->drawLine( h1, h2 ); 449 p->drawLine( h1, h2 );
444 } 450 }
445 451
446 if ( !clear || prevTime.minute() != currTime.minute() ) { 452 if ( !clear || prevTime.minute() != currTime.minute() ) {
447 // draw minute pointer 453 // draw minute pointer
448 m1 = rotate( center, m1, time.minute() * 6 ); 454 m1 = rotate( center, m1, time.minute() * 6 );
449 m2 = rotate( center, m2, time.minute() * 6 ); 455 m2 = rotate( center, m2, time.minute() * 6 );
450 p->setPen( QPen( color, 2 ) ); 456 p->setPen( QPen( color, 2 ) );
451 p->drawLine( m1, m2 ); 457 p->drawLine( m1, m2 );
452 } 458 }
453 459
454 // draw second pointer 460 // draw second pointer
455 s1 = rotate( center, s1, time.second() * 6 ); 461 s1 = rotate( center, s1, time.second() * 6 );
456 s2 = rotate( center, s2, time.second() * 6 ); 462 s2 = rotate( center, s2, time.second() * 6 );
@@ -459,5 +465,5 @@ void AnalogClock::drawContents( QPainter *p )
459 465
460 if ( !clear ) 466 if ( !clear )
461 prevTime = currTime; 467 prevTime = currTime;
462} 468}
463 469
@@ -475,7 +481,12 @@ QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
475 double angle = deg2rad * ( - a + 180 ); 481 double angle = deg2rad * ( - a + 180 );
476 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - 482 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
477 ( p.y() - c.y() ) * sin( angle ); 483 ( p.y() - c.y() ) * sin( angle );
478 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + 484 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
479 ( p.x() - c.x() ) * sin( angle ); 485 ( p.x() - c.x() ) * sin( angle );
480 return QPoint( nx, ny ); 486 return QPoint( nx, ny );
481} 487}
488void Clock::slotAdjustTime()
489{
490 QCopEnvelope e("QPE/System", "execute(QString)");
491 e << QString("systemtime");
492}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index e5ed13c..024dd28 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -77,5 +77,5 @@ private slots:
77 void appMessage(const QCString& msg, const QByteArray& data); 77 void appMessage(const QCString& msg, const QByteArray& data);
78 void timerEvent( QTimerEvent *e ); 78 void timerEvent( QTimerEvent *e );
79// void slotAdjustTime(); 79 void slotAdjustTime();
80 80
81private: 81private: