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