summaryrefslogtreecommitdiff
path: root/noncore
authorkergoth <kergoth>2003-04-24 21:04:40 (UTC)
committer kergoth <kergoth>2003-04-24 21:04:40 (UTC)
commitf7ed0f1e02fa05b330d94b2a4928f3e249edb98f (patch) (unidiff)
tree300a828ddf7f4d8c7441f394c0cd828cd5200be2 /noncore
parentb59b200a00486bc68810317eb7f14c565604a475 (diff)
downloadopie-f7ed0f1e02fa05b330d94b2a4928f3e249edb98f.zip
opie-f7ed0f1e02fa05b330d94b2a4928f3e249edb98f.tar.gz
opie-f7ed0f1e02fa05b330d94b2a4928f3e249edb98f.tar.bz2
Add background to the clock.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp6
-rw-r--r--noncore/tools/clock/clock.h5
2 files changed, 9 insertions, 2 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 74b7147..41c99a8 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -495,59 +495,65 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
495 495
496 show(); 496 show();
497 raise(); 497 raise();
498 QPEApplication::setKeepRunning(); 498 QPEApplication::setKeepRunning();
499 setActiveWindow(); 499 setActiveWindow();
500} 500}
501 501
502void Clock::timerEvent( QTimerEvent *e ) 502void Clock::timerEvent( QTimerEvent *e )
503{ 503{
504 static int stop = 0; 504 static int stop = 0;
505 if ( stop < 120 && bSound ) 505 if ( stop < 120 && bSound )
506 { 506 {
507 Sound::soundAlarm(); 507 Sound::soundAlarm();
508 stop++; 508 stop++;
509 } 509 }
510 else 510 else
511 { 511 {
512 stop = 0; 512 stop = 0;
513 killTimer( e->timerId() ); 513 killTimer( e->timerId() );
514 clearTimer(); 514 clearTimer();
515 setCaption( tr( "Clock: Alarm was missed." ) ); 515 setCaption( tr( "Clock: Alarm was missed." ) );
516 } 516 }
517} 517}
518 518
519AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true)
520{
521 bg = Resource::loadPixmap("clock/bg");
522}
519 523
520QSizePolicy AnalogClock::sizePolicy() const 524QSizePolicy AnalogClock::sizePolicy() const
521{ 525{
522 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); 526 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
523} 527}
524 528
525void AnalogClock::drawContents( QPainter *p ) 529void AnalogClock::drawContents( QPainter *p )
526{ 530{
527 QRect r = contentsRect(); 531 QRect r = contentsRect();
528 QRect fr; 532 QRect fr;
529 533
534 p->drawPixmap(QPoint(0, 0), bg, r);
535
530 if ( r. width ( ) > r. height ( )) 536 if ( r. width ( ) > r. height ( ))
531 fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); 537 fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( ));
532 else 538 else
533 fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); 539 fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( ));
534 540
535 QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); 541 QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 );
536 QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); 542 QPoint l1 ( center. x ( ), fr. y ( ) + 2 );
537 QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); 543 QPoint l2 ( center. x ( ), fr. y ( ) + 8 );
538 544
539 545
540 546
541 if ( clear ) 547 if ( clear )
542 { 548 {
543 erase ( r ); 549 erase ( r );
544 p-> setPen ( NoPen ); 550 p-> setPen ( NoPen );
545 p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); 551 p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base ));
546 p-> drawEllipse ( fr ); 552 p-> drawEllipse ( fr );
547 p-> setBrush ( NoBrush ); 553 p-> setBrush ( NoBrush );
548 554
549 // draw ticks 555 // draw ticks
550 p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); 556 p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) );
551 for ( int i = 0; i < 12; i++ ) 557 for ( int i = 0; i < 12; i++ )
552 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); 558 p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
553 } 559 }
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index 1e5aa2c..fa12b61 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -1,73 +1,74 @@
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#include <qpixmap.h>
25 26
26class QLCDNumber; 27class QLCDNumber;
27class QLabel; 28class QLabel;
28class QTimer; 29class QTimer;
29class QRadioButton; 30class QRadioButton;
30class QPushButton; 31class QPushButton;
31class QDateTime; 32class QDateTime;
32 33
33class AnalogClock : public QFrame 34class AnalogClock : public QFrame
34{ 35{
35 Q_OBJECT 36 Q_OBJECT
36 37
37public: 38public:
38 AnalogClock( QWidget * parent = 0, const char * name = 0 ) 39 AnalogClock( QWidget * parent = 0, const char * name = 0 );
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
45protected: 45protected:
46 void drawContents( QPainter *p ); 46 void drawContents( QPainter *p );
47 47
48private: 48private:
49 49
50 QPixmap bg;
50 QTime currTime; 51 QTime currTime;
51 QTime prevTime; 52 QTime prevTime;
52 bool clear; 53 bool clear;
53 54
54 QPoint rotate( QPoint center, QPoint p, int angle ); 55 QPoint rotate( QPoint center, QPoint p, int angle );
55 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); 56 void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
56 57
57}; 58};
58 59
59class Clock : public QVBox 60class Clock : public QVBox
60{ 61{
61 Q_OBJECT 62 Q_OBJECT
62 63
63public: 64public:
64 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); 65 Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 );
65 ~Clock(); 66 ~Clock();
66 QDateTime when; 67 QDateTime when;
67 bool bSound; 68 bool bSound;
68 int hour, minute, snoozeTime; 69 int hour, minute, snoozeTime;
69private slots: 70private slots:
70 void slotSet(); 71 void slotSet();
71 void slotReset(); 72 void slotReset();
72 void modeSelect(int); 73 void modeSelect(int);
73 void updateClock(); 74 void updateClock();