summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clockapplet/clock.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp
index 52d285b..19d3f6c 100644
--- a/core/applets/clockapplet/clock.cpp
+++ b/core/applets/clockapplet/clock.cpp
@@ -32,72 +32,69 @@
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38 38
39LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) 39LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent )
40{ 40{
41 // If you want a sunken border around the clock do this: 41 // If you want a sunken border around the clock do this:
42 // setFrameStyle( QFrame::Panel | QFrame::Sunken ); 42 // setFrameStyle( QFrame::Panel | QFrame::Sunken );
43 setFont( QFont( "Helvetica", 10, QFont::Normal ) ); 43 setFont( QFont( "Helvetica", 10, QFont::Normal ) );
44 connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) ); 44 connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) );
45 connect( qApp, SIGNAL( clockChanged( bool ) ), 45 connect( qApp, SIGNAL( clockChanged( bool ) ),
46 this, SLOT( slotClockChanged( bool ) ) ); 46 this, SLOT( slotClockChanged( bool ) ) );
47 readConfig(); 47 readConfig();
48 timerId = 0; 48 timerId = 0;
49 timerEvent( 0 ); 49 timerEvent( 0 );
50 show(); 50 show();
51} 51}
52 52
53void LauncherClock::readConfig() { 53void LauncherClock::readConfig() {
54 Config config( "qpe" ); 54 Config config( "qpe" );
55 config.setGroup( "Time" ); 55 config.setGroup( "Time" );
56 ampmFormat = config.readBoolEntry( "AMPM", TRUE ); 56 ampmFormat = config.readBoolEntry( "AMPM", TRUE );
57 config.setGroup( "Date" ); 57 config.setGroup( "Date" );
58 format = config.readNumEntry("ClockApplet",0); 58 format = config.readNumEntry("ClockApplet",0);
59} 59}
60 60
61void LauncherClock::mouseReleaseEvent( QMouseEvent * ) 61void LauncherClock::mouseReleaseEvent( QMouseEvent * )
62{ 62{
63 QCString setTimeApp; 63 QCString setTimeApp;
64 if (QFile::exists(QPEApplication::qpeDir()+"bin/netsystemtime")) 64 setTimeApp="systemtime";
65 setTimeApp="netsystemtime";
66 else setTimeApp="systemtime";
67 QCopEnvelope e("QPE/Application/"+setTimeApp, "setDocument(QString)"); 65 QCopEnvelope e("QPE/Application/"+setTimeApp, "setDocument(QString)");
68 QString lf = QString::null; 66 QString lf = QString::null;
69 67
70 e << lf; 68 e << lf;
71
72} 69}
73 70
74 71
75void LauncherClock::timerEvent( QTimerEvent *e ) 72void LauncherClock::timerEvent( QTimerEvent *e )
76{ 73{
77 if ( !e || e->timerId() == timerId ) { 74 if ( !e || e->timerId() == timerId ) {
78 killTimer( timerId ); 75 killTimer( timerId );
79 changeTime(); 76 changeTime();
80 QTime t = QTime::currentTime(); 77 QTime t = QTime::currentTime();
81 int ms = (60 - t.second())*1000 - t.msec(); 78 int ms = (60 - t.second())*1000 - t.msec();
82 timerId = startTimer( ms ); 79 timerId = startTimer( ms );
83 } else { 80 } else {
84 QLabel::timerEvent( e ); 81 QLabel::timerEvent( e );
85 } 82 }
86} 83}
87 84
88void LauncherClock::updateTime( void ) 85void LauncherClock::updateTime( void )
89{ 86{
90 changeTime(); 87 changeTime();
91} 88}
92 89
93void LauncherClock::changeTime( void ) 90void LauncherClock::changeTime( void )
94{ 91{
95 QTime tm = QDateTime::currentDateTime().time(); 92 QTime tm = QDateTime::currentDateTime().time();
96 QString s; 93 QString s;
97 if( ampmFormat ) { 94 if( ampmFormat ) {
98 int hour = tm.hour(); 95 int hour = tm.hour();
99 if (hour == 0) 96 if (hour == 0)
100 hour = 12; 97 hour = 12;
101 if (hour > 12) 98 if (hour > 12)
102 hour -= 12; 99 hour -= 12;
103 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 100 s.sprintf( "%2d:%02d %s", hour, tm.minute(),