5 Copyright (C) 2000 Espen Sand, espen@kde.org
6 Based on work by NN(yet to be determined)
7 flicker free code by Remi Guyomarch <rguyom@mail.dotcom.fr>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 KdmClock::KdmClock( QWidget
*parent
)
34 QTimer
*timer
= new QTimer( this );
35 connect( timer
, SIGNAL(timeout()), SLOT(timeout()) );
39 mDate
= false;//config->readEntry( "date", false );
40 mSecond
= true;//config->readEntry( "second", true );
41 mDigital
= false;//config->readEntry( "digital", false );
42 mBorder
= true;//config->readEntry( "border", false );
44 //config->setGroup( "Font" );
45 mFont
.setFamily( QString::fromLatin1("Utopia")/*config->readEntry( "Family", "Utopia" )*/ );
46 mFont
.setPointSize( 51/*config->readEntry( "Point Size", 51 )*/ );
47 mFont
.setWeight( 75/*config->readEntry( "Weight", 75 )*/ );
48 mFont
.setItalic( true/*config->readEntry( "Italic", true )*/ );
49 mFont
.setBold( true/*config->readEntry( "Bold", false )*/ );
52 setFrameStyle( WinPanel
|Sunken
);
55 setFixedSize( 100, 100 );
61 void KdmClock::showEvent( QShowEvent
* )
67 void KdmClock::timeout()
72 void KdmClock::paintEvent( QPaintEvent
* )
79 p
.setPen( palette().foreground().color() );
80 p
.setBrush( palette().foreground() );
82 QTime time
= QTime::currentTime();
88 buf
.sprintf( "%02d:%02d:%02d", time
.hour(), time
.minute(),
91 buf
.sprintf( "%02d:%02d", time
.hour(), time
.minute() );
92 mFont
.setPointSize( qMin( (int)(width() / buf
.length() * 1.5), height() ) );
94 p
.drawText( contentsRect(), Qt::AlignCenter
, buf
);
99 QPoint cp
= contentsRect().center();
100 matrix
.translate( cp
.x(), cp
.y() );
101 int d
= qMin( contentsRect().width() - 15, contentsRect().height() - 15 );
102 matrix
.scale( d
/1000.0F
, d
/1000.0F
);
107 float h_angle
= 30*(time
.hour()%12-3) + time
.minute()/2;
108 matrix
.rotate( h_angle
);
109 p
.setWorldTransform( matrix
);
110 pts
.setPoints( 4, -20,0, 0,-20, 300,0, 0,20 );
111 p
.drawPolygon( pts
);
112 matrix
.rotate( -h_angle
);
115 float m_angle
= (time
.minute()-15)*6;
116 matrix
.rotate( m_angle
);
117 p
.setWorldTransform( matrix
);
118 pts
.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 );
119 p
.drawPolygon( pts
);
120 matrix
.rotate( -m_angle
);
127 float s_angle
= (time
.second()-15)*6;
128 matrix
.rotate( s_angle
);
129 p
.setWorldTransform( matrix
);
130 pts
.setPoints( 4,0,0,0,0,400,0,0,0 );
131 p
.drawPolygon( pts
);
132 matrix
.rotate( -s_angle
);
136 for (int i
= 0; i
< 60; i
++) {
137 p
.setWorldTransform( matrix
);
139 p
.drawLine( 450,0, 500,0 ); // draw hour lines
141 p
.drawPoint( 480,0 ); // draw second lines
148 #include "kdmclock.moc"