summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp2
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.control3
-rw-r--r--noncore/settings/netsystemtime/settime.cpp25
-rw-r--r--noncore/settings/netsystemtime/settime.h2
4 files changed, 29 insertions, 3 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 4a7959e..b2f192a 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,109 +1,109 @@
1#include "ntp.h" 1#include "ntp.h"
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qregexp.h> 3#include <qregexp.h>
4#include <qtable.h> 4#include <qtable.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qsocket.h> 6#include <qsocket.h>
7#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qspinbox.h> 8#include <qspinbox.h>
9#include <qmultilineedit.h> 9#include <qmultilineedit.h>
10#include <opie/oprocess.h> 10#include <opie/oprocess.h>
11#include <qpe/config.h> 11#include <qpe/config.h>
12#include <qpe/global.h> 12#include <qpe/global.h>
13#include <qpe/timeconversion.h> 13#include <qpe/timeconversion.h>
14#include <qpe/tzselect.h> 14#include <qpe/tzselect.h>
15#include <qpe/timestring.h> 15#include <qpe/timestring.h>
16#include <qpe/qpedialog.h> 16#include <qpe/qpedialog.h>
17#include <sys/time.h> 17#include <sys/time.h>
18#include <time.h> 18#include <time.h>
19#include <stdlib.h> 19#include <stdlib.h>
20 20
21 21
22Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 22Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
23 : SetDateTime( parent, name, fl ) 23 : SetDateTime( parent, name, fl )
24{ 24{
25 Config cfg("ntp",Config::User); 25 Config cfg("ntp",Config::User);
26 cfg.setGroup("settings"); 26 cfg.setGroup("settings");
27 // _maxOffset = cfg.readNumEntry("maxOffset",5); 27 // _maxOffset = cfg.readNumEntry("maxOffset",5);
28// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10); 28// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10);
29 SpinBoxMinDelay->setValue( cfg.readNumEntry("minLookupDiff",10) ); 29 SpinBoxMinDelay->setValue( cfg.readNumEntry("minLookupDiff",10) );
30 SpinBoxMinDelay->setMinValue( 7 ); 30 SpinBoxMinDelay->setMinValue( 7 );
31 LineEditNtpSrv->setText( cfg.readEntry("ntpServer", tr("time.fu-berlin.de")) ); 31 LineEditNtpSrv->setText( cfg.readEntry("ntpServer", tr("time.fu-berlin.de")) );
32 ntpProcess = new OProcess( ); 32 ntpProcess = new OProcess( );
33 33
34 QSocket *ntpSock = new QSocket( this ); 34 QSocket *ntpSock = new QSocket( this );
35 ntpSock->connectToHost( LineEditNtpSrv->text() ,123); 35 ntpSock->connectToHost( LineEditNtpSrv->text() ,123);
36 connect( ntpSock, SIGNAL( error(int) ), 36 connect( ntpSock, SIGNAL( error(int) ),
37 SLOT(slotCheckNtp(int)) ); 37 SLOT(slotCheckNtp(int)) );
38 38
39 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 39 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
40 this, SLOT(getNtpOutput(OProcess*,char*,int))); 40 this, SLOT(getNtpOutput(OProcess*,char*,int)));
41 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 41 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
42 this, SLOT(ntpFinished(OProcess*))); 42 this, SLOT(ntpFinished(OProcess*)));
43 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 43 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
44 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 44 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
45 45 slotCheckNtp(-1);
46// slotRunNtp(); 46// slotRunNtp();
47 readLookups(); 47 readLookups();
48} 48}
49 49
50Ntp::~Ntp() 50Ntp::~Ntp()
51{ 51{
52 Config cfg("ntp",Config::User); 52 Config cfg("ntp",Config::User);
53 cfg.setGroup("settings"); 53 cfg.setGroup("settings");
54 cfg.writeEntry("ntpServer", LineEditNtpSrv->text()); 54 cfg.writeEntry("ntpServer", LineEditNtpSrv->text());
55 cfg.writeEntry( "minLookupDiff", SpinBoxMinDelay->value() ); 55 cfg.writeEntry( "minLookupDiff", SpinBoxMinDelay->value() );
56} 56}
57 57
58 58
59void Ntp::slotRunNtp() 59void Ntp::slotRunNtp()
60{ 60{
61 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 61 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
62 ntpProcess->clearArguments(); 62 ntpProcess->clearArguments();
63 *ntpProcess << "ntpdate" << LineEditNtpSrv->text(); 63 *ntpProcess << "ntpdate" << LineEditNtpSrv->text();
64 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 64 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
65 if ( !ret ) { 65 if ( !ret ) {
66 qDebug("Error while executing ntp"); 66 qDebug("Error while executing ntp");
67 } 67 }
68} 68}
69 69
70void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 70void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
71{ 71{
72 QString lineStr, lineStrOld; 72 QString lineStr, lineStrOld;
73 lineStr = buffer; 73 lineStr = buffer;
74 lineStr=lineStr.left(buflen); 74 lineStr=lineStr.left(buflen);
75 if (lineStr!=lineStrOld) 75 if (lineStr!=lineStrOld)
76 { 76 {
77 MultiLineEditntpOutPut->append(lineStr); 77 MultiLineEditntpOutPut->append(lineStr);
78 _ntpOutput += lineStr; 78 _ntpOutput += lineStr;
79 } 79 }
80 lineStrOld = lineStr; 80 lineStrOld = lineStr;
81} 81}
82 82
83void Ntp::ntpFinished(OProcess*) 83void Ntp::ntpFinished(OProcess*)
84{ 84{
85 Config cfg("ntp",Config::User); 85 Config cfg("ntp",Config::User);
86 cfg.setGroup("lookups"); 86 cfg.setGroup("lookups");
87 int lastLookup = cfg.readNumEntry("time",0); 87 int lastLookup = cfg.readNumEntry("time",0);
88 int lookupCount = cfg.readNumEntry("count",-1); 88 int lookupCount = cfg.readNumEntry("count",-1);
89 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 89 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
90 cfg.writeEntry("time", time); 90 cfg.writeEntry("time", time);
91 cfg.setGroup("correction"); 91 cfg.setGroup("correction");
92 cfg.writeEntry("time", time); 92 cfg.writeEntry("time", time);
93 93
94 float timeShift = getTimeShift(); 94 float timeShift = getTimeShift();
95 if (timeShift == 0.0) return; 95 if (timeShift == 0.0) return;
96 int secsSinceLast = time - lastLookup; 96 int secsSinceLast = time - lastLookup;
97 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 97 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
98 if ( lastLookup > 0 && secsSinceLast > 60*24* SpinBoxMinDelay->value()) 98 if ( lastLookup > 0 && secsSinceLast > 60*24* SpinBoxMinDelay->value())
99 { 99 {
100 lookupCount++; 100 lookupCount++;
101 cfg.writeEntry("count",lookupCount); 101 cfg.writeEntry("count",lookupCount);
102 cfg.setGroup("lookup_"+QString::number(lookupCount)); 102 cfg.setGroup("lookup_"+QString::number(lookupCount));
103 _shiftPerSec = timeShift / secsSinceLast; 103 _shiftPerSec = timeShift / secsSinceLast;
104// float nextCorr = _maxOffset / _shiftPerSec; 104// float nextCorr = _maxOffset / _shiftPerSec;
105 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 105 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
106 cfg.writeEntry("secsSinceLast",secsSinceLast); 106 cfg.writeEntry("secsSinceLast",secsSinceLast);
107 cfg.writeEntry("timeShift",QString::number(timeShift)); 107 cfg.writeEntry("timeShift",QString::number(timeShift));
108 } 108 }
109} 109}
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control
index a5809b0..406d7b0 100644
--- a/noncore/settings/netsystemtime/opie-netsystemtime.control
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.control
@@ -1,10 +1,11 @@
1Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop 1Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop
2Priority: optional 2Priority: optional
3Section: opie/settings 3Section: opie/settings
4Depends: ntpdate 4Depends: ntpdate
5Conflicts: opie-systemtime
5Maintainer: Patrick S. Vogt <tille@handhelds.org> 6Maintainer: Patrick S. Vogt <tille@handhelds.org>
6Architecture: arm 7Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 8Version: $QPE_VERSION-$SUB_VERSION
8Depends: opie-base ($QPE_VERSION), ntpdate 9Depends: opie-base ($QPE_VERSION), ntpdate
9Description: ntp ( Network Time Protocol) gui 10Description: ntp ( Network Time Protocol) gui
10This utility syncs system time with a atomic timerserver via internet \ No newline at end of file 11This utility syncs system time with a atomic timerserver via internet
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index 2cef6e8..b456012 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -131,223 +131,245 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f )
131 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; 131 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0;
132 dateButton->setWeekStartsMonday( startMonday ); 132 dateButton->setWeekStartsMonday( startMonday );
133 weekStartCombo->setCurrentItem( startMonday ); 133 weekStartCombo->setCurrentItem( startMonday );
134 134
135 connect( weekStartCombo, SIGNAL( activated(int)), 135 connect( weekStartCombo, SIGNAL( activated(int)),
136 dateButton, SLOT(setWeekStartsMonday(int))); 136 dateButton, SLOT(setWeekStartsMonday(int)));
137 137
138 138
139 QHBoxLayout *hb3 = new QHBoxLayout( vb ); 139 QHBoxLayout *hb3 = new QHBoxLayout( vb );
140 l = new QLabel( tr("Date format" ), FrameSystemTime ); 140 l = new QLabel( tr("Date format" ), FrameSystemTime );
141 hb3->addWidget( l, 1 ); 141 hb3->addWidget( l, 1 );
142 dateFormatCombo = new QComboBox( FrameSystemTime ); 142 dateFormatCombo = new QComboBox( FrameSystemTime );
143 hb3->addWidget( dateFormatCombo, 2 ); 143 hb3->addWidget( dateFormatCombo, 2 );
144 144
145 config.setGroup( "Date" ); 145 config.setGroup( "Date" );
146 DateFormat df(QChar(config.readEntry("Separator", "/")[0]), 146 DateFormat df(QChar(config.readEntry("Separator", "/")[0]),
147 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), 147 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
148 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); 148 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
149 149
150 int currentdf = 0; 150 int currentdf = 0;
151 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); 151 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear);
152 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); 152 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) );
153 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); 153 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear);
154 if (df == date_formats[1]) 154 if (df == date_formats[1])
155 currentdf = 1; 155 currentdf = 1;
156 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); 156 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) );
157 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, 157 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay,
158 DateFormat::DayMonthYear); 158 DateFormat::DayMonthYear);
159 if (df == date_formats[2]) 159 if (df == date_formats[2])
160 currentdf = 2; 160 currentdf = 2;
161 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 161 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601
162 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); 162 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear);
163 if (df == date_formats[3]) 163 if (df == date_formats[3])
164 currentdf = 3; 164 currentdf = 3;
165 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); 165 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) );
166 166
167 dateFormatCombo->setCurrentItem( currentdf ); 167 dateFormatCombo->setCurrentItem( currentdf );
168 dateButton->setDateFormat( df ); 168 dateButton->setDateFormat( df );
169 169
170 connect( dateFormatCombo, SIGNAL( activated(int)), 170 connect( dateFormatCombo, SIGNAL( activated(int)),
171 SLOT(formatChanged(int))); 171 SLOT(formatChanged(int)));
172 172
173 QHBoxLayout *hb4 = new QHBoxLayout( vb ); 173 QHBoxLayout *hb4 = new QHBoxLayout( vb );
174 l = new QLabel( tr("Applet format" ), FrameSystemTime ); 174 l = new QLabel( tr("Applet format" ), FrameSystemTime );
175 hb4->addWidget( l, 1 ); 175 hb4->addWidget( l, 1 );
176 176
177 clockAppletCombo = new QComboBox( FrameSystemTime ); 177 clockAppletCombo = new QComboBox( FrameSystemTime );
178 clockAppletCombo->insertItem( tr("hh:mm"), 0 ); 178 clockAppletCombo->insertItem( tr("hh:mm"), 0 );
179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); 179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); 180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
181 181
182 hb4->addWidget( clockAppletCombo, 2 ); 182 hb4->addWidget( clockAppletCombo, 2 );
183 int clockApplet = config.readNumEntry("ClockApplet",0); 183 int clockApplet = config.readNumEntry("ClockApplet",0);
184 clockAppletCombo->setCurrentItem( clockApplet ); 184 clockAppletCombo->setCurrentItem( clockApplet );
185 185
186 vb->addStretch( 0 ); 186 vb->addStretch( 0 );
187 187
188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), 188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
189 this, SLOT(commitTime())); 189 this, SLOT(commitTime()));
190 190
191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
192 timeButton, SLOT( slotTzChange( const QString& ) ) ); 192 timeButton, SLOT( slotTzChange( const QString& ) ) );
193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
194 SLOT( tzChange( const QString& ) ) ); 194 SLOT( tzChange( const QString& ) ) );
195
196 QObject::connect( weekStartCombo, SIGNAL( activated ( int )),
197 SLOT(updateSystem(int ) ));
198 QObject::connect( ampmCombo, SIGNAL( activated ( int )),
199 SLOT(updateSystem(int ) ));
200 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )),
201 SLOT(updateSystem(int ) ));
202 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )),
203 SLOT(updateSystem(int ) ));
195} 204}
196 205
197SetDateTime::~SetDateTime() 206SetDateTime::~SetDateTime()
198{ 207{
208 writeSettings();
209
210}
199 211
212void SetDateTime::writeSettings()
213{
200 Config config("qpe"); 214 Config config("qpe");
201 config.setGroup( "Time" ); 215 config.setGroup( "Time" );
202 config.writeEntry( "AMPM", ampmCombo->currentItem() ); 216 config.writeEntry( "AMPM", ampmCombo->currentItem() );
203 config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); 217 config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
204 config.setGroup( "Date" ); 218 config.setGroup( "Date" );
205 DateFormat df = date_formats[dateFormatCombo->currentItem()]; 219 DateFormat df = date_formats[dateFormatCombo->currentItem()];
206 config.writeEntry( "Separator", QString(df.separator())); 220 config.writeEntry( "Separator", QString(df.separator()));
207 config.writeEntry( "ShortOrder", df.shortOrder()); 221 config.writeEntry( "ShortOrder", df.shortOrder());
208 config.writeEntry( "LongOrder", df.longOrder()); 222 config.writeEntry( "LongOrder", df.longOrder());
209 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); 223 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
210 224
211 Config lconfig("locale"); 225 Config lconfig("locale");
212 lconfig.setGroup( "Location" ); 226 lconfig.setGroup( "Location" );
213 lconfig.writeEntry( "Timezone", tz->currentZone() ); 227 lconfig.writeEntry( "Timezone", tz->currentZone() );
214 228
215} 229}
216 230
217void SetDateTime::commitTime() 231void SetDateTime::commitTime()
218{ 232{
219 tz->setFocus(); 233 tz->setFocus();
220 // really turn off the screensaver before doing anything 234 // really turn off the screensaver before doing anything
221 { 235 {
222 // Needs to be encased in { } so that it deconstructs and sends 236 // Needs to be encased in { } so that it deconstructs and sends
223 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 237 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
224 disableScreenSaver << 0 << 0 << 0; 238 disableScreenSaver << 0 << 0 << 0;
225 } 239 }
226 // Need to process the QCOP event generated above before proceeding 240 // Need to process the QCOP event generated above before proceeding
227 qApp->processEvents(); 241 qApp->processEvents();
228 242
229 // before we progress further, set our TZ! 243 // before we progress further, set our TZ!
230 setenv( "TZ", tz->currentZone(), 1 ); 244 setenv( "TZ", tz->currentZone(), 1 );
231 // now set the time... 245 // now set the time...
232 QDateTime dt( dateButton->date(), timeButton->time() ); 246 QDateTime dt( dateButton->date(), timeButton->time() );
233 247
234 if ( dt.isValid() ) setTime(dt); 248 if ( dt.isValid() ) setTime(dt);
235} 249}
236 250
237void SetDateTime::setTime(QDateTime dt) 251void SetDateTime::setTime(QDateTime dt)
238{ 252{
239 Config cfg("ntp",Config::User); 253 Config cfg("ntp",Config::User);
240 cfg.setGroup("correction"); 254 cfg.setGroup("correction");
241 int t = TimeConversion::toUTC(dt); 255 int t = TimeConversion::toUTC(dt);
242 struct timeval myTv; 256 struct timeval myTv;
243 myTv.tv_sec = t; 257 myTv.tv_sec = t;
244 cfg.writeEntry("time", t ); 258 cfg.writeEntry("time", t );
245 myTv.tv_usec = 0; 259 myTv.tv_usec = 0;
246 260
247 if ( myTv.tv_sec != -1 ) 261 if ( myTv.tv_sec != -1 )
248 ::settimeofday( &myTv, 0 ); 262 ::settimeofday( &myTv, 0 );
249 Global::writeHWClock(); 263 Global::writeHWClock();
264}
265
266void SetDateTime::updateSystem(int i)
267{
268 qDebug("SetDateTime::updateSystem(int %i)",i);
269 writeSettings();
250 // since time has changed quickly load in the datebookdb 270 // since time has changed quickly load in the datebookdb
251 // to allow the alarm server to get a better grip on itself 271 // to allow the alarm server to get a better grip on itself
252 // (example re-trigger alarms for when we travel back in time) 272 // (example re-trigger alarms for when we travel back in time)
253 DateBookDB db; 273 // DateBookDB db;
254 274
255 // set the timezone for everyone else... 275 // set the timezone for everyone else...
256 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 276 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
257 setTimeZone << tz->currentZone(); 277 setTimeZone << tz->currentZone();
258 278
259 // AM/PM setting and notify time changed 279 // AM/PM setting and notify time changed
260 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); 280 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
261 setClock << ampmCombo->currentItem(); 281 setClock << ampmCombo->currentItem();
262 282
263 // Notify everyone what day we prefer to start the week on. 283 // Notify everyone what day we prefer to start the week on.
264 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); 284 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
265 setWeek << weekStartCombo->currentItem(); 285 setWeek << weekStartCombo->currentItem();
266 286
267 // Notify everyone what date format to use 287 // Notify everyone what date format to use
268 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); 288 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
269 setDateFormat << date_formats[dateFormatCombo->currentItem()]; 289 setDateFormat << date_formats[dateFormatCombo->currentItem()];
270 290
271 // Restore screensaver 291 // Restore screensaver
272 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 292 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
273 enableScreenSaver << -1 << -1 << -1; 293 enableScreenSaver << -1 << -1 << -1;
274 294
275} 295}
276 296
277void SetDateTime::tzChange( const QString &tz ) 297void SetDateTime::tzChange( const QString &tz )
278{ 298{
299 qDebug("SetDateTime::tzChange");
279 // set the TZ get the time and leave gracefully... 300 // set the TZ get the time and leave gracefully...
280 QString strSave; 301 QString strSave;
281 strSave = getenv( "TZ" ); 302 strSave = getenv( "TZ" );
282 setenv( "TZ", tz, 1 ); 303 setenv( "TZ", tz, 1 );
283 304
284 QDate d = QDate::currentDate(); 305 QDate d = QDate::currentDate();
285 // reset the time. 306 // reset the time.
286 if ( !strSave.isNull() ) { 307 if ( !strSave.isNull() ) {
287 setenv( "TZ", strSave, 1 ); 308 setenv( "TZ", strSave, 1 );
288 } 309 }
289 dateButton->setDate( d ); 310 dateButton->setDate( d );
311 updateSystem();
290} 312}
291 313
292void SetDateTime::formatChanged(int i) 314void SetDateTime::formatChanged(int i)
293{ 315{
294 dateButton->setDateFormat(date_formats[i]); 316 dateButton->setDateFormat(date_formats[i]);
295} 317}
296 318
297static const int ValueAM = 0; 319static const int ValueAM = 0;
298static const int ValuePM = 1; 320static const int ValuePM = 1;
299 321
300 322
301 323
302SetTime::SetTime( QWidget *parent, const char *name ) 324SetTime::SetTime( QWidget *parent, const char *name )
303 : QWidget( parent, name ) 325 : QWidget( parent, name )
304{ 326{
305 use12hourTime = FALSE; 327 use12hourTime = FALSE;
306 328
307 QTime currTime = QTime::currentTime(); 329 QTime currTime = QTime::currentTime();
308 hour = currTime.hour(); 330 hour = currTime.hour();
309 minute = currTime.minute(); 331 minute = currTime.minute();
310 332
311 QHBoxLayout *hb2 = new QHBoxLayout( this ); 333 QHBoxLayout *hb2 = new QHBoxLayout( this );
312 hb2->setSpacing( 3 ); 334 hb2->setSpacing( 3 );
313 335
314 QLabel *l = new QLabel( tr("Hour"), this ); 336 QLabel *l = new QLabel( tr("Hour"), this );
315 // l->setAlignment( AlignRight | AlignVCenter ); 337 // l->setAlignment( AlignRight | AlignVCenter );
316 hb2->addWidget( l ); 338 hb2->addWidget( l );
317 339
318 sbHour = new QSpinBox( this ); 340 sbHour = new QSpinBox( this );
319 sbHour->setMinimumWidth( 30 ); 341 sbHour->setMinimumWidth( 30 );
320 if(use12hourTime) { 342 if(use12hourTime) {
321 sbHour->setMinValue(1); 343 sbHour->setMinValue(1);
322 sbHour->setMaxValue( 12 ); 344 sbHour->setMaxValue( 12 );
323 int show_hour = hour; 345 int show_hour = hour;
324 if (hour > 12) 346 if (hour > 12)
325 show_hour -= 12; 347 show_hour -= 12;
326 if (show_hour == 0) 348 if (show_hour == 0)
327 show_hour = 12; 349 show_hour = 12;
328 350
329 sbHour->setValue( show_hour ); 351 sbHour->setValue( show_hour );
330 } else { 352 } else {
331 sbHour->setMinValue( 0 ); 353 sbHour->setMinValue( 0 );
332 sbHour->setMaxValue( 23 ); 354 sbHour->setMaxValue( 23 );
333 sbHour->setValue( hour ); 355 sbHour->setValue( hour );
334 } 356 }
335 sbHour->setWrapping(TRUE); 357 sbHour->setWrapping(TRUE);
336 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); 358 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) );
337 hb2->addWidget( sbHour ); 359 hb2->addWidget( sbHour );
338 360
339 hb2->addStretch( 1 ); 361 hb2->addStretch( 1 );
340 362
341 l = new QLabel( tr("Minute"), this ); 363 l = new QLabel( tr("Minute"), this );
342 //l->setAlignment( AlignRight | AlignVCenter ); 364 //l->setAlignment( AlignRight | AlignVCenter );
343 hb2->addWidget( l ); 365 hb2->addWidget( l );
344 366
345 sbMin = new QSpinBox( this ); 367 sbMin = new QSpinBox( this );
346 sbMin->setMinValue( 0 ); 368 sbMin->setMinValue( 0 );
347 sbMin->setMaxValue( 59 ); 369 sbMin->setMaxValue( 59 );
348 sbMin->setWrapping(TRUE); 370 sbMin->setWrapping(TRUE);
349 sbMin->setValue( minute ); 371 sbMin->setValue( minute );
350 sbMin->setMinimumWidth( 30 ); 372 sbMin->setMinimumWidth( 30 );
351 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); 373 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) );
352 hb2->addWidget( sbMin ); 374 hb2->addWidget( sbMin );
353 375
@@ -369,94 +391,95 @@ QTime SetTime::time() const
369} 391}
370 392
371void SetTime::hourChanged( int value ) 393void SetTime::hourChanged( int value )
372{ 394{
373 if(use12hourTime) { 395 if(use12hourTime) {
374 int realhour = value; 396 int realhour = value;
375 if (realhour == 12) 397 if (realhour == 12)
376 realhour = 0; 398 realhour = 0;
377 if (ampm->currentItem() == ValuePM ) 399 if (ampm->currentItem() == ValuePM )
378 realhour += 12; 400 realhour += 12;
379 hour = realhour; 401 hour = realhour;
380 } else 402 } else
381 hour = value; 403 hour = value;
382} 404}
383 405
384void SetTime::minuteChanged( int value ) 406void SetTime::minuteChanged( int value )
385{ 407{
386 minute = value; 408 minute = value;
387} 409}
388 410
389void SetTime::show12hourTime( int on ) 411void SetTime::show12hourTime( int on )
390{ 412{
391 use12hourTime = on; 413 use12hourTime = on;
392 ampm->setEnabled(on); 414 ampm->setEnabled(on);
393 415
394 int show_hour = hour; 416 int show_hour = hour;
395 if ( on ) { 417 if ( on ) {
396 /* this might change the value of hour */ 418 /* this might change the value of hour */
397 sbHour->setMinValue(1); 419 sbHour->setMinValue(1);
398 sbHour->setMaxValue( 12 ); 420 sbHour->setMaxValue( 12 );
399 421
400 /* so use one we saved earlier */ 422 /* so use one we saved earlier */
401 if (show_hour >= 12) { 423 if (show_hour >= 12) {
402 show_hour -= 12; 424 show_hour -= 12;
403 ampm->setCurrentItem( ValuePM ); 425 ampm->setCurrentItem( ValuePM );
404 } else { 426 } else {
405 ampm->setCurrentItem( ValueAM ); 427 ampm->setCurrentItem( ValueAM );
406 } 428 }
407 if (show_hour == 0) 429 if (show_hour == 0)
408 show_hour = 12; 430 show_hour = 12;
409 431
410 } else { 432 } else {
411 sbHour->setMinValue( 0 ); 433 sbHour->setMinValue( 0 );
412 sbHour->setMaxValue( 23 ); 434 sbHour->setMaxValue( 23 );
413 } 435 }
414 436
415 437
416 sbHour->setValue( show_hour ); 438 sbHour->setValue( show_hour );
417} 439}
418 440
419void SetTime::checkedPM( int c ) 441void SetTime::checkedPM( int c )
420{ 442{
421 int show_hour = sbHour->value(); 443 int show_hour = sbHour->value();
422 if (show_hour == 12) 444 if (show_hour == 12)
423 show_hour = 0; 445 show_hour = 0;
424 446
425 if ( c == ValuePM ) 447 if ( c == ValuePM )
426 show_hour += 12; 448 show_hour += 12;
427 449
428 hour = show_hour; 450 hour = show_hour;
429} 451}
430 452
431void SetTime::slotTzChange( const QString &tz ) 453void SetTime::slotTzChange( const QString &tz )
432{ 454{
455 qDebug("SetTime::slotTzChange");
433 // set the TZ get the time and leave gracefully... 456 // set the TZ get the time and leave gracefully...
434 QString strSave; 457 QString strSave;
435 strSave = getenv( "TZ" ); 458 strSave = getenv( "TZ" );
436 setenv( "TZ", tz, 1 ); 459 setenv( "TZ", tz, 1 );
437 460
438 QTime t = QTime::currentTime(); 461 QTime t = QTime::currentTime();
439 // reset the time. 462 // reset the time.
440 if ( !strSave.isNull() ) { 463 if ( !strSave.isNull() ) {
441 setenv( "TZ", strSave, 1 ); 464 setenv( "TZ", strSave, 1 );
442 } 465 }
443 466
444 // just set the spinboxes and let it propage through 467 // just set the spinboxes and let it propage through
445 if(use12hourTime) { 468 if(use12hourTime) {
446 int show_hour = t.hour(); 469 int show_hour = t.hour();
447 if (t.hour() >= 12) { 470 if (t.hour() >= 12) {
448 show_hour -= 12; 471 show_hour -= 12;
449 ampm->setCurrentItem( ValuePM ); 472 ampm->setCurrentItem( ValuePM );
450 } else { 473 } else {
451 ampm->setCurrentItem( ValueAM ); 474 ampm->setCurrentItem( ValueAM );
452 } 475 }
453 if (show_hour == 0) 476 if (show_hour == 0)
454 show_hour = 12; 477 show_hour = 12;
455 sbHour->setValue( show_hour ); 478 sbHour->setValue( show_hour );
456 } else { 479 } else {
457 sbHour->setValue( t.hour() ); 480 sbHour->setValue( t.hour() );
458 } 481 }
459 sbMin->setValue( t.minute() ); 482 sbMin->setValue( t.minute() );
460} 483}
461 484
462 485
diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h
index 60423e7..778cb9c 100644
--- a/noncore/settings/netsystemtime/settime.h
+++ b/noncore/settings/netsystemtime/settime.h
@@ -13,84 +13,86 @@
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#ifndef SYSTEM_TIME_H 20#ifndef SYSTEM_TIME_H
21#define SYSTEM_TIME_H 21#define SYSTEM_TIME_H
22 22
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qdialog.h> 25#include <qdialog.h>
26 26
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28#include "ntpbase.h" 28#include "ntpbase.h"
29 29
30class QToolButton; 30class QToolButton;
31class QSpinBox; 31class QSpinBox;
32class QLabel; 32class QLabel;
33class TimeZoneSelector; 33class TimeZoneSelector;
34class DateBookMonth; 34class DateBookMonth;
35class QComboBox; 35class QComboBox;
36 36
37class SetTime : public QWidget 37class SetTime : public QWidget
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40public: 40public:
41 SetTime( QWidget *parent=0, const char *name=0 ); 41 SetTime( QWidget *parent=0, const char *name=0 );
42 42
43 QTime time() const; 43 QTime time() const;
44 44
45public slots: 45public slots:
46 void slotTzChange( const QString& tz ); 46 void slotTzChange( const QString& tz );
47 void show12hourTime( int ); 47 void show12hourTime( int );
48 48
49protected slots: 49protected slots:
50 void hourChanged( int value ); 50 void hourChanged( int value );
51 void minuteChanged( int value ); 51 void minuteChanged( int value );
52 52
53 void checkedPM( int ); 53 void checkedPM( int );
54 54
55protected: 55protected:
56 int hour; 56 int hour;
57 int minute; 57 int minute;
58 bool use12hourTime; 58 bool use12hourTime;
59 QComboBox *ampm; 59 QComboBox *ampm;
60 QSpinBox *sbHour; 60 QSpinBox *sbHour;
61 QSpinBox *sbMin; 61 QSpinBox *sbMin;
62}; 62};
63 63
64class DateButton; 64class DateButton;
65 65
66class SetDateTime : public NtpBase 66class SetDateTime : public NtpBase
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69public: 69public:
70 SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 ); 70 SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 );
71 ~SetDateTime(); 71 ~SetDateTime();
72 72
73protected slots: 73protected slots:
74 void commitTime(); 74 void commitTime();
75 void tzChange( const QString &tz ); 75 void tzChange( const QString &tz );
76 void formatChanged(int); 76 void formatChanged(int);
77 void updateSystem(int i=0);
77 78
78protected: 79protected:
79 void setTime(QDateTime dt); 80 void setTime(QDateTime dt);
81 void writeSettings();
80 82
81 SetTime *timeButton; 83 SetTime *timeButton;
82 DateButton *dateButton; 84 DateButton *dateButton;
83 TimeZoneSelector *tz; 85 TimeZoneSelector *tz;
84 QComboBox *weekStartCombo; 86 QComboBox *weekStartCombo;
85 QComboBox *ampmCombo; 87 QComboBox *ampmCombo;
86 QComboBox *dateFormatCombo; 88 QComboBox *dateFormatCombo;
87 QComboBox *clockAppletCombo; 89 QComboBox *clockAppletCombo;
88 QPushButton *ButtonSetTime; 90 QPushButton *ButtonSetTime;
89 QLabel *TextLabelMainPredTime; 91 QLabel *TextLabelMainPredTime;
90 92
91 DateFormat date_formats[4]; 93 DateFormat date_formats[4];
92}; 94};
93 95
94 96
95#endif 97#endif
96 98