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