summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clockapplet/clock.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp
index 5fb8f44..aadd9b6 100644
--- a/core/applets/clockapplet/clock.cpp
+++ b/core/applets/clockapplet/clock.cpp
@@ -1,112 +1,109 @@
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 20
21#include "clock.h" 21#include "clock.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26 26
27LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) 27LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent )
28{ 28{
29 // If you want a sunken border around the clock do this: 29 // If you want a sunken border around the clock do this:
30 // setFrameStyle( QFrame::Panel | QFrame::Sunken ); 30 // setFrameStyle( QFrame::Panel | QFrame::Sunken );
31 //setFont( QFont( "Helvetica", , QFont::Normal ) ); 31 //setFont( QFont( "Helvetica", , QFont::Normal ) );
32 connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) ); 32 connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) );
33 connect( qApp, SIGNAL( clockChanged( bool ) ), 33 connect( qApp, SIGNAL( clockChanged( bool ) ),
34 this, SLOT( slotClockChanged( bool ) ) ); 34 this, SLOT( slotClockChanged( bool ) ) );
35 readConfig(); 35 readConfig();
36 timerId = 0; 36 timerId = 0;
37 timerEvent( 0 ); 37 timerEvent( 0 );
38 show(); 38 show();
39} 39}
40 40
41void LauncherClock::readConfig() { 41void LauncherClock::readConfig() {
42 Config config( "qpe" ); 42 Config config( "qpe" );
43 config.setGroup( "Time" ); 43 config.setGroup( "Time" );
44 ampmFormat = config.readBoolEntry( "AMPM", TRUE ); 44 ampmFormat = config.readBoolEntry( "AMPM", TRUE );
45 config.setGroup( "Date" ); 45 config.setGroup( "Date" );
46 format = config.readNumEntry("ClockApplet",0); 46 format = config.readNumEntry("ClockApplet",0);
47} 47}
48 48
49void LauncherClock::mouseReleaseEvent( QMouseEvent * ) 49void LauncherClock::mouseReleaseEvent( QMouseEvent * )
50{ 50{
51 QCString setTimeApp; 51 QCString setTimeApp;
52 setTimeApp="systemtime"; 52 setTimeApp="systemtime";
53 QCopEnvelope e("QPE/Application/"+setTimeApp, "setDocument(QString)"); 53 QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()");
54 QString lf = QString::null;
55
56 e << lf;
57} 54}
58 55
59 56
60void LauncherClock::timerEvent( QTimerEvent *e ) 57void LauncherClock::timerEvent( QTimerEvent *e )
61{ 58{
62 if ( !e || e->timerId() == timerId ) { 59 if ( !e || e->timerId() == timerId ) {
63 killTimer( timerId ); 60 killTimer( timerId );
64 changeTime(); 61 changeTime();
65 QTime t = QTime::currentTime(); 62 QTime t = QTime::currentTime();
66 int ms = (60 - t.second())*1000 - t.msec(); 63 int ms = (60 - t.second())*1000 - t.msec();
67 timerId = startTimer( ms ); 64 timerId = startTimer( ms );
68 } else { 65 } else {
69 QLabel::timerEvent( e ); 66 QLabel::timerEvent( e );
70 } 67 }
71} 68}
72 69
73void LauncherClock::updateTime( void ) 70void LauncherClock::updateTime( void )
74{ 71{
75 changeTime(); 72 changeTime();
76} 73}
77 74
78void LauncherClock::changeTime( void ) 75void LauncherClock::changeTime( void )
79{ 76{
80 QTime tm = QDateTime::currentDateTime().time(); 77 QTime tm = QDateTime::currentDateTime().time();
81 QString s; 78 QString s;
82 if( ampmFormat ) { 79 if( ampmFormat ) {
83 int hour = tm.hour(); 80 int hour = tm.hour();
84 if (hour == 0) 81 if (hour == 0)
85 hour = 12; 82 hour = 12;
86 if (hour > 12) 83 if (hour > 12)
87 hour -= 12; 84 hour -= 12;
88 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 85 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
89 (tm.hour() >= 12) ? "PM" : "AM" ); 86 (tm.hour() >= 12) ? "PM" : "AM" );
90 } else 87 } else
91 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 88 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
92 89
93 if (format==1) { 90 if (format==1) {
94 QDate dm = QDate::currentDate(); 91 QDate dm = QDate::currentDate();
95 QString d; 92 QString d;
96 d.sprintf("%d/%d ", dm.day(), dm.month()); 93 d.sprintf("%d/%d ", dm.day(), dm.month());
97 setText( d+s ); 94 setText( d+s );
98 } else if (format==2) { 95 } else if (format==2) {
99 QDate dm = QDate::currentDate(); 96 QDate dm = QDate::currentDate();
100 QString d; 97 QString d;
101 d.sprintf("%d/%d ", dm.month(), dm.day()); 98 d.sprintf("%d/%d ", dm.month(), dm.day());
102 setText( d+s ); 99 setText( d+s );
103 } else { 100 } else {
104 setText( s ); 101 setText( s );
105 } 102 }
106} 103}
107 104
108void LauncherClock::slotClockChanged( bool pm ) 105void LauncherClock::slotClockChanged( bool pm )
109{ 106{
110 readConfig(); 107 readConfig();
111 updateTime(); 108 updateTime();
112} 109}