31
KdmClock::KdmClock( QWidget *parent )
31
KdmClock::KdmClock(QWidget *parent)
34
QTimer *timer = new QTimer( this );
35
connect( timer, SIGNAL(timeout()), SLOT(timeout()) );
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 );
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 );
55
setFixedSize(100, 100);
61
void KdmClock::showEvent( QShowEvent * )
61
void KdmClock::showEvent(QShowEvent *)
67
67
void KdmClock::timeout()
72
void KdmClock::paintEvent( QPaintEvent * )
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
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);
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);
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);
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
148
#include "kdmclock.moc"