author | tille <tille> | 2002-06-27 11:05:15 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-27 11:05:15 (UTC) |
commit | 4301065a4e43b0860774dca358a8027790a42f4f (patch) (unidiff) | |
tree | 52e8abb5e859636b6b651727fb1dcf94350ba158 | |
parent | f2cd92301181f3bc895b0d1701183e4da7b52812 (diff) | |
download | opie-4301065a4e43b0860774dca358a8027790a42f4f.zip opie-4301065a4e43b0860774dca358a8027790a42f4f.tar.gz opie-4301065a4e43b0860774dca358a8027790a42f4f.tar.bz2 |
if postinst works, clicking on clockapplet should work too
5 files changed, 34 insertions, 13 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 083b50f..830c0c3 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -1,287 +1,287 @@ | |||
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 <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qtable.h> | 5 | #include <qtable.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qsocket.h> | 7 | #include <qsocket.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include <qmultilineedit.h> | 11 | #include <qmultilineedit.h> |
12 | #include <opie/oprocess.h> | 12 | #include <opie/oprocess.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | #include <qpe/config.h> | 14 | #include <qpe/config.h> |
15 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | #include <qpe/tzselect.h> | 17 | #include <qpe/tzselect.h> |
18 | #include <qpe/timestring.h> | 18 | #include <qpe/timestring.h> |
19 | #include <qpe/qpedialog.h> | 19 | #include <qpe/qpedialog.h> |
20 | #include <sys/time.h> | 20 | #include <sys/time.h> |
21 | #include <time.h> | 21 | #include <time.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | 23 | ||
24 | 24 | ||
25 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | 25 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) |
26 | : SetDateTime( parent, name, fl ) | 26 | : SetDateTime( parent, name, fl ) |
27 | { | 27 | { |
28 | qDebug("%s", QPEApplication::qpeDir().latin1()); | ||
29 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); | 28 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); |
30 | ntpSrvs.setGroup("servers"); | 29 | ntpSrvs.setGroup("servers"); |
31 | int srvCount = ntpSrvs.readNumEntry("count", 0 ); | 30 | int srvCount = ntpSrvs.readNumEntry("count", 0 ); |
32 | for (int i = 0; i < srvCount; i++) | 31 | for (int i = 0; i < srvCount; i++) |
33 | { | 32 | { |
34 | ntpSrvs.setGroup(QString::number(i)); | 33 | ntpSrvs.setGroup(QString::number(i)); |
35 | ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); | 34 | ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); |
36 | } | 35 | } |
37 | if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); | 36 | if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); |
38 | 37 | ||
39 | Config cfg("ntp",Config::User); | 38 | Config cfg("ntp",Config::User); |
40 | cfg.setGroup("settings"); | 39 | cfg.setGroup("settings"); |
41 | SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); | 40 | SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); |
42 | SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); | 41 | SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); |
43 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); | 42 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); |
44 | 43 | ||
45 | ntpTimer = new QTimer(this); | 44 | ntpTimer = new QTimer(this); |
46 | 45 | ||
47 | ntpProcess = new OProcess( ); | 46 | ntpProcess = new OProcess( ); |
48 | connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), | 47 | connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), |
49 | SLOT(slotNtpDelayChanged(int)) ); | 48 | SLOT(slotNtpDelayChanged(int)) ); |
50 | 49 | ||
51 | ntpSock = new QSocket( this ); | 50 | ntpSock = new QSocket( this ); |
52 | connect( ntpSock, SIGNAL( error(int) ), | 51 | connect( ntpSock, SIGNAL( error(int) ), |
53 | SLOT(slotCheckNtp(int)) ); | 52 | SLOT(slotCheckNtp(int)) ); |
54 | slotProbeNtpServer(); | 53 | slotProbeNtpServer(); |
55 | 54 | ||
56 | connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 55 | connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
57 | this, SLOT(getNtpOutput(OProcess*,char*,int))); | 56 | this, SLOT(getNtpOutput(OProcess*,char*,int))); |
58 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), | 57 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), |
59 | this, SLOT(ntpFinished(OProcess*))); | 58 | this, SLOT(ntpFinished(OProcess*))); |
60 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); | 59 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); |
61 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); | 60 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); |
62 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); | 61 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); |
63 | slotCheckNtp(-1); | 62 | slotCheckNtp(-1); |
64 | readLookups(); | 63 | readLookups(); |
65 | } | 64 | } |
66 | 65 | ||
67 | Ntp::~Ntp() | 66 | Ntp::~Ntp() |
68 | { | 67 | { |
69 | delete ntpProcess; | 68 | delete ntpProcess; |
70 | Config ntpSrvs("/etc/ntpservers",Config::File); | 69 | Config ntpSrvs("/etc/ntpservers",Config::File); |
71 | ntpSrvs.setGroup("servers"); | 70 | ntpSrvs.setGroup("servers"); |
72 | int srvCount = ComboNtpSrv->count(); | 71 | int srvCount = ComboNtpSrv->count(); |
73 | ntpSrvs.writeEntry("count", srvCount); | 72 | ntpSrvs.writeEntry("count", srvCount); |
74 | for (int i = 0; i < srvCount; i++) | 73 | for (int i = 0; i < srvCount; i++) |
75 | { | 74 | { |
76 | ntpSrvs.setGroup(QString::number(i)); | 75 | ntpSrvs.setGroup(QString::number(i)); |
77 | ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); | 76 | ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); |
78 | } | 77 | } |
79 | Config cfg("ntp",Config::User); | 78 | Config cfg("ntp",Config::User); |
80 | cfg.setGroup("settings"); | 79 | cfg.setGroup("settings"); |
81 | cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); | 80 | cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); |
82 | cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); | 81 | cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); |
83 | cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); | 82 | cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); |
84 | } | 83 | } |
85 | 84 | ||
86 | bool Ntp::ntpDelayElapsed() | 85 | bool Ntp::ntpDelayElapsed() |
87 | { | 86 | { |
88 | Config cfg("ntp",Config::User); | 87 | Config cfg("ntp",Config::User); |
89 | cfg.setGroup("lookups"); | 88 | cfg.setGroup("lookups"); |
90 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); | 89 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); |
91 | return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; | 90 | return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; |
92 | } | 91 | } |
93 | 92 | ||
94 | QString Ntp::getNtpServer() | 93 | QString Ntp::getNtpServer() |
95 | { | 94 | { |
96 | return ComboNtpSrv->currentText(); | 95 | return ComboNtpSrv->currentText(); |
97 | } | 96 | } |
98 | 97 | ||
99 | void Ntp::slotRunNtp() | 98 | void Ntp::slotRunNtp() |
100 | { | 99 | { |
101 | if ( !ntpDelayElapsed() ) | 100 | if ( !ntpDelayElapsed() ) |
102 | { | 101 | { |
103 | switch ( | 102 | switch ( |
104 | QMessageBox::warning(this, tr("Run NTP?"), | 103 | QMessageBox::warning(this, tr("Run NTP?"), |
105 | tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ | 104 | tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ |
106 | QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+ | 105 | QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+ |
107 | "<br>"+tr("Rerun NTP?"), | 106 | "<br>"+tr("Rerun NTP?"), |
108 | QMessageBox::Ok,QMessageBox::Cancel) | 107 | QMessageBox::Ok,QMessageBox::Cancel) |
109 | ) { | 108 | ) { |
110 | case QMessageBox::Ok: break; | 109 | case QMessageBox::Ok: break; |
111 | case QMessageBox::Cancel: return; | 110 | case QMessageBox::Cancel: return; |
112 | default: return; | 111 | default: return; |
113 | } | 112 | } |
114 | } | 113 | } |
115 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); | 114 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); |
116 | ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); | 115 | ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); |
117 | 116 | ||
118 | ntpProcess->clearArguments(); | 117 | ntpProcess->clearArguments(); |
119 | *ntpProcess << "ntpdate" << getNtpServer(); | 118 | *ntpProcess << "ntpdate" << getNtpServer(); |
120 | bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | 119 | bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); |
121 | if ( !ret ) { | 120 | if ( !ret ) { |
122 | qDebug("Error while executing ntpdate"); | 121 | qDebug("Error while executing ntpdate"); |
123 | ntpOutPut( tr("Error while executing ntpdate")); | 122 | ntpOutPut( tr("Error while executing ntpdate")); |
124 | } | 123 | } |
125 | } | 124 | } |
126 | 125 | ||
127 | void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) | 126 | void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) |
128 | { | 127 | { |
129 | QString lineStr, lineStrOld; | 128 | QString lineStr, lineStrOld; |
130 | lineStr = buffer; | 129 | lineStr = buffer; |
131 | lineStr=lineStr.left(buflen); | 130 | lineStr=lineStr.left(buflen); |
132 | if (lineStr!=lineStrOld) | 131 | if (lineStr!=lineStrOld) |
133 | { | 132 | { |
134 | ntpOutPut(lineStr); | 133 | ntpOutPut(lineStr); |
135 | _ntpOutput += lineStr; | 134 | _ntpOutput += lineStr; |
136 | } | 135 | } |
137 | lineStrOld = lineStr; | 136 | lineStrOld = lineStr; |
138 | } | 137 | } |
139 | 138 | ||
140 | void Ntp::ntpFinished(OProcess *p) | 139 | void Ntp::ntpFinished(OProcess *p) |
141 | { | 140 | { |
142 | qDebug("p->exitStatus() %i",p->exitStatus()); | 141 | qDebug("p->exitStatus() %i",p->exitStatus()); |
143 | if (p->exitStatus()!=0 || !p->normalExit()) | 142 | if (p->exitStatus()!=0 || !p->normalExit()) |
144 | { | 143 | { |
145 | slotProbeNtpServer(); | 144 | slotProbeNtpServer(); |
146 | return; | 145 | return; |
147 | } | 146 | } |
148 | Config cfg("ntp",Config::User); | 147 | Config cfg("ntp",Config::User); |
149 | cfg.setGroup("lookups"); | 148 | cfg.setGroup("lookups"); |
150 | int lastLookup = cfg.readNumEntry("time",0); | 149 | int lastLookup = cfg.readNumEntry("time",0); |
151 | int lookupCount = cfg.readNumEntry("count",0); | 150 | int lookupCount = cfg.readNumEntry("count",0); |
152 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 151 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
153 | cfg.writeEntry("time", time); | 152 | cfg.writeEntry("time", time); |
154 | cfg.setGroup("correction"); | 153 | cfg.setGroup("correction"); |
155 | cfg.writeEntry("time", time); | 154 | cfg.writeEntry("time", time); |
156 | 155 | ||
157 | float timeShift = getTimeShift(); | 156 | float timeShift = getTimeShift(); |
158 | if (timeShift == 0.0) return; | 157 | if (timeShift == 0.0) return; |
159 | int secsSinceLast = time - lastLookup; | 158 | int secsSinceLast = time - lastLookup; |
160 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); | 159 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); |
161 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); | 160 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); |
162 | if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) | 161 | if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) |
163 | { | 162 | { |
164 | lookupCount++; | 163 | lookupCount++; |
165 | cfg.writeEntry("count",lookupCount); | 164 | cfg.writeEntry("count",lookupCount); |
166 | cfg.setGroup("lookup_"+QString::number(lookupCount)); | 165 | cfg.setGroup("lookup_"+QString::number(lookupCount)); |
167 | _shiftPerSec = timeShift / secsSinceLast; | 166 | _shiftPerSec = timeShift / secsSinceLast; |
168 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); | 167 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); |
169 | cfg.writeEntry("secsSinceLast",secsSinceLast); | 168 | cfg.writeEntry("secsSinceLast",secsSinceLast); |
170 | cfg.writeEntry("timeShift",QString::number(timeShift)); | 169 | cfg.writeEntry("timeShift",QString::number(timeShift)); |
171 | } | 170 | } |
172 | } | 171 | } |
173 | 172 | ||
174 | 173 | ||
175 | float Ntp::getTimeShift() | 174 | float Ntp::getTimeShift() |
176 | { | 175 | { |
177 | QString _offset = "offset"; | 176 | QString _offset = "offset"; |
178 | QString _sec = "sec"; | 177 | QString _sec = "sec"; |
179 | QRegExp _reOffset = QRegExp(_offset); | 178 | QRegExp _reOffset = QRegExp(_offset); |
180 | QRegExp _reEndOffset = QRegExp(_sec); | 179 | QRegExp _reEndOffset = QRegExp(_sec); |
181 | int posOffset = _reOffset.match( _ntpOutput ); | 180 | int posOffset = _reOffset.match( _ntpOutput ); |
182 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); | 181 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); |
183 | posOffset += _offset.length() + 1; | 182 | posOffset += _offset.length() + 1; |
184 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); | 183 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); |
185 | qDebug("%s", _ntpOutput.latin1()); | 184 | qDebug("%s", _ntpOutput.latin1()); |
186 | qDebug("diff = >%s<",diff.latin1()); | 185 | qDebug("diff = >%s<",diff.latin1()); |
187 | return diff.toFloat(); | 186 | return diff.toFloat(); |
188 | } | 187 | } |
189 | 188 | ||
190 | void Ntp::readLookups() | 189 | void Ntp::readLookups() |
191 | { | 190 | { |
192 | Config cfg("ntp",Config::User); | 191 | Config cfg("ntp",Config::User); |
193 | cfg.setGroup("lookups"); | 192 | cfg.setGroup("lookups"); |
194 | int lookupCount = cfg.readNumEntry("count",0); | 193 | int lookupCount = cfg.readNumEntry("count",0); |
195 | float last, shift, shiftPerSec; | 194 | float last, shift, shiftPerSec; |
196 | qDebug("lookupCount = %i",lookupCount); | 195 | qDebug("lookupCount = %i",lookupCount); |
197 | TableLookups->setNumCols( 3 ); | 196 | TableLookups->setNumCols( 3 ); |
198 | TableLookups->setNumRows( lookupCount); | 197 | TableLookups->setNumRows( lookupCount); |
199 | TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); | 198 | TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); |
200 | TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); | 199 | TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); |
201 | TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); | 200 | TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); |
202 | int cw = 50;//TableLookups->width()/4; | 201 | int cw = TableLookups->width()/4; |
203 | qDebug("column width %i",cw); | 202 | qDebug("column width %i",cw); |
203 | cw = 50; | ||
204 | TableLookups->setColumnWidth( 0, cw+30 ); | 204 | TableLookups->setColumnWidth( 0, cw+30 ); |
205 | TableLookups->setColumnWidth( 1, cw ); | 205 | TableLookups->setColumnWidth( 1, cw ); |
206 | TableLookups->setColumnWidth( 2, cw ); | 206 | TableLookups->setColumnWidth( 2, cw ); |
207 | TableLookups->sortColumn(0, false, true ); | 207 | TableLookups->sortColumn(0, false, true ); |
208 | // TableLookups->setSorting( true ); | 208 | // TableLookups->setSorting( true ); |
209 | for (int i=0; i < lookupCount; i++) | 209 | for (int i=0; i < lookupCount; i++) |
210 | { | 210 | { |
211 | cfg.setGroup("lookup_"+QString::number(i)); | 211 | cfg.setGroup("lookup_"+QString::number(i)); |
212 | last = cfg.readEntry("secsSinceLast",0).toFloat(); | 212 | last = cfg.readEntry("secsSinceLast",0).toFloat(); |
213 | shift = QString(cfg.readEntry("timeShift",0)).toFloat(); | 213 | shift = QString(cfg.readEntry("timeShift",0)).toFloat(); |
214 | // qDebug("%i last %f",i,last); | 214 | // qDebug("%i last %f",i,last); |
215 | // qDebug("%i shift %f",i,shift); | 215 | // qDebug("%i shift %f",i,shift); |
216 | shiftPerSec = shift / last; | 216 | shiftPerSec = shift / last; |
217 | _shiftPerSec += shiftPerSec; | 217 | _shiftPerSec += shiftPerSec; |
218 | TableLookups->setText( i,0,QString::number(shiftPerSec*60)); | 218 | TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); |
219 | TableLookups->setText( i,2,QString::number(shift)); | 219 | TableLookups->setText( i,2,QString::number(shift)); |
220 | TableLookups->setText( i,1,QString::number(last/60)); | 220 | TableLookups->setText( i,1,QString::number(last/(60*60))); |
221 | } | 221 | } |
222 | _shiftPerSec /= lookupCount+1; | 222 | _shiftPerSec /= lookupCount; |
223 | TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds")); | 223 | TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); |
224 | } | 224 | } |
225 | 225 | ||
226 | void Ntp::preditctTime() | 226 | void Ntp::preditctTime() |
227 | { | 227 | { |
228 | Config cfg("ntp",Config::User); | 228 | Config cfg("ntp",Config::User); |
229 | cfg.setGroup("lookups"); | 229 | cfg.setGroup("lookups"); |
230 | int lastTime = cfg.readNumEntry("time",0); | 230 | int lastTime = cfg.readNumEntry("time",0); |
231 | setenv( "TZ", tz->currentZone(), 1 ); | 231 | setenv( "TZ", tz->currentZone(), 1 ); |
232 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 232 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
233 | int corr = int((now - lastTime) * _shiftPerSec); | 233 | int corr = int((now - lastTime) * _shiftPerSec); |
234 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); | 234 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); |
235 | predictedTime = QDateTime::currentDateTime().addSecs(corr); | 235 | predictedTime = QDateTime::currentDateTime().addSecs(corr); |
236 | TextLabelPredTime->setText(predictedTime.toString()); | 236 | TextLabelPredTime->setText(predictedTime.toString()); |
237 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); | 237 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); |
238 | } | 238 | } |
239 | 239 | ||
240 | void Ntp::setPredictTime() | 240 | void Ntp::setPredictTime() |
241 | { | 241 | { |
242 | preditctTime(); | 242 | preditctTime(); |
243 | setTime( predictedTime ); | 243 | setTime( predictedTime ); |
244 | } | 244 | } |
245 | 245 | ||
246 | void Ntp::slotCheckNtp(int i) | 246 | void Ntp::slotCheckNtp(int i) |
247 | { | 247 | { |
248 | if (i == 0) | 248 | if (i == 0) |
249 | { | 249 | { |
250 | TextLabelMainPredTime->hide(); | 250 | TextLabelMainPredTime->hide(); |
251 | ButtonSetTime->setText( tr("Get time from network") ); | 251 | ButtonSetTime->setText( tr("Get time from network") ); |
252 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); | 252 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); |
253 | if ( ntpDelayElapsed() ) | 253 | if ( ntpDelayElapsed() ) |
254 | { | 254 | { |
255 | slotRunNtp(); | 255 | slotRunNtp(); |
256 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); | 256 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); |
257 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); | 257 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); |
258 | }else{ | 258 | }else{ |
259 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); | 259 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); |
260 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 260 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
261 | } | 261 | } |
262 | }else{ | 262 | }else{ |
263 | preditctTime(); | 263 | preditctTime(); |
264 | ButtonSetTime->setText( tr("Set predicted time") ); | 264 | ButtonSetTime->setText( tr("Set predicted time") ); |
265 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); | 265 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); |
266 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); | 266 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); |
267 | connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 267 | connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | void Ntp::slotProbeNtpServer() | 271 | void Ntp::slotProbeNtpServer() |
272 | { | 272 | { |
273 | qDebug("Ntp::slotProbeNtpServer()"); | 273 | qDebug("Ntp::slotProbeNtpServer()"); |
274 | ntpSock->connectToHost( getNtpServer() ,123); | 274 | ntpSock->connectToHost( getNtpServer() ,123); |
275 | } | 275 | } |
276 | 276 | ||
277 | void Ntp::slotNtpDelayChanged(int delay) | 277 | void Ntp::slotNtpDelayChanged(int delay) |
278 | { | 278 | { |
279 | ntpTimer->changeInterval( delay*1000*60 ); | 279 | ntpTimer->changeInterval( delay*1000*60 ); |
280 | } | 280 | } |
281 | 281 | ||
282 | void Ntp::ntpOutPut(QString out) | 282 | void Ntp::ntpOutPut(QString out) |
283 | { | 283 | { |
284 | MultiLineEditntpOutPut->append(out); | 284 | MultiLineEditntpOutPut->append(out); |
285 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); | 285 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); |
286 | } | 286 | } |
287 | 287 | ||
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control index d3290e9..8fd7da5 100644 --- a/noncore/settings/netsystemtime/opie-netsystemtime.control +++ b/noncore/settings/netsystemtime/opie-netsystemtime.control | |||
@@ -1,11 +1,12 @@ | |||
1 | Packagename: opie-netsystemtime | ||
1 | Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers | 2 | Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers |
2 | Priority: optional | 3 | Priority: optional |
3 | Section: opie/settings | 4 | Section: opie/settings |
4 | Depends: ntpdate | 5 | Depends: ntpdate |
5 | Conflicts: opie-systemtime | 6 | Conflicts: opie-systemtime |
6 | Maintainer: Patrick S. Vogt <tille@handhelds.org> | 7 | Maintainer: Patrick S. Vogt <tille@handhelds.org> |
7 | Architecture: arm | 8 | Architecture: arm |
8 | Version: $QPE_VERSION-$SUB_VERSION | 9 | Version: $QPE_VERSION-$SUB_VERSION |
9 | Depends: opie-base ($QPE_VERSION), ntpdate | 10 | Depends: opie-base ($QPE_VERSION), ntpdate |
10 | Description: ntp ( Network Time Protocol) gui | 11 | Description: ntp (Network Time Protocol) gui |
11 | This utility syncs system time with a atomic timerserver via internet | 12 | This utility syncs system time with a atomic timerserver via internet |
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.postinst b/noncore/settings/netsystemtime/opie-netsystemtime.postinst new file mode 100644 index 0000000..233cd31 --- a/dev/null +++ b/noncore/settings/netsystemtime/opie-netsystemtime.postinst | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh -v | ||
2 | |||
3 | systime=`ipkg status | grep Package | grep -i systemtime | sed "s/Package://"` | ||
4 | ipkg remove $pack | ||
5 | |||
6 | cd $QPEDIR/bin/ | ||
7 | ln -s netsystemtime systemtime | ||
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.postrm b/noncore/settings/netsystemtime/opie-netsystemtime.postrm new file mode 100644 index 0000000..4b2ab7c --- a/dev/null +++ b/noncore/settings/netsystemtime/opie-netsystemtime.postrm | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh -v | ||
2 | |||
3 | cd $QPEDIR/bin/ | ||
4 | rm systemtime | ||
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 93543cd..e7e604f 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -1,487 +1,496 @@ | |||
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 "settime.h" | 21 | #include "settime.h" |
22 | 22 | ||
23 | #include <qpe/alarmserver.h> | 23 | #include <qpe/alarmserver.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/datebookdb.h> | 26 | #include <qpe/datebookdb.h> |
27 | #include <qpe/datebookmonth.h> | 27 | #include <qpe/datebookmonth.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | #include <qpe/timeconversion.h> | 30 | #include <qpe/timeconversion.h> |
31 | #include <qpe/tzselect.h> | 31 | #include <qpe/tzselect.h> |
32 | #include <qpe/timestring.h> | 32 | #include <qpe/timestring.h> |
33 | #include <qpe/qpedialog.h> | 33 | #include <qpe/qpedialog.h> |
34 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 34 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <qbuttongroup.h> | 38 | #include <qbuttongroup.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qradiobutton.h> | 42 | #include <qradiobutton.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
45 | #include <qwindowsystem_qws.h> | 45 | #include <qwindowsystem_qws.h> |
46 | #include <qcombobox.h> | 46 | #include <qcombobox.h> |
47 | 47 | ||
48 | #include <sys/time.h> | 48 | #include <sys/time.h> |
49 | #include <time.h> | 49 | #include <time.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <stdio.h> | 51 | #include <stdio.h> |
52 | 52 | ||
53 | 53 | ||
54 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | 54 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) |
55 | : NtpBase( parent, name, f ) | 55 | : NtpBase( parent, name, f ) |
56 | { | 56 | { |
57 | // setCaption( tr("Set System Time") ); | 57 | // setCaption( tr("Set System Time") ); |
58 | 58 | ||
59 | // QVBoxLayout *vb = new QVBoxLayout( this, 5 ); | 59 | // QVBoxLayout *vb = new QVBoxLayout( this, 5 ); |
60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); | 60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); |
61 | QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); | 61 | QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); |
62 | 62 | ||
63 | TextLabelMainPredTime = new QLabel( FrameSystemTime ); | 63 | TextLabelMainPredTime = new QLabel( FrameSystemTime ); |
64 | vb->addWidget( TextLabelMainPredTime, 1, 0 ); | 64 | vb->addWidget( TextLabelMainPredTime, 1, 0 ); |
65 | ButtonSetTime = new QPushButton( FrameSystemTime ); | 65 | ButtonSetTime = new QPushButton( FrameSystemTime ); |
66 | vb->addWidget( ButtonSetTime, 1, 0 ); | 66 | vb->addWidget( ButtonSetTime, 1, 0 ); |
67 | 67 | ||
68 | QFrame *hline = new QFrame( FrameSystemTime ); | 68 | QFrame *hline = new QFrame( FrameSystemTime ); |
69 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 69 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
70 | vb->addWidget( hline ); | 70 | vb->addWidget( hline ); |
71 | 71 | ||
72 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); | 72 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); |
73 | 73 | ||
74 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); | 74 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); |
75 | lblZone->setMaximumSize( lblZone->sizeHint() ); | 75 | lblZone->setMaximumSize( lblZone->sizeHint() ); |
76 | hb->addWidget( lblZone ); | 76 | hb->addWidget( lblZone ); |
77 | 77 | ||
78 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); | 78 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); |
79 | tz->setMinimumSize( tz->sizeHint() ); | 79 | tz->setMinimumSize( tz->sizeHint() ); |
80 | hb->addWidget( tz ); | 80 | hb->addWidget( tz ); |
81 | 81 | ||
82 | timeButton = new SetTime( FrameSetTime ); | 82 | timeButton = new SetTime( FrameSetTime ); |
83 | vb2->addWidget( timeButton ); | 83 | vb2->addWidget( timeButton ); |
84 | 84 | ||
85 | QHBoxLayout *db = new QHBoxLayout( vb2 ); | 85 | QHBoxLayout *db = new QHBoxLayout( vb2 ); |
86 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); | 86 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); |
87 | db->addWidget( dateLabel, 1 ); | 87 | db->addWidget( dateLabel, 1 ); |
88 | dateButton = new DateButton( TRUE, FrameSetTime ); | 88 | dateButton = new DateButton( TRUE, FrameSetTime ); |
89 | db->addWidget( dateButton, 2 ); | 89 | db->addWidget( dateButton, 2 ); |
90 | 90 | ||
91 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 91 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
92 | vb2->addItem( spacer ); | 92 | vb2->addItem( spacer ); |
93 | 93 | ||
94 | hline = new QFrame( FrameSystemTime ); | 94 | hline = new QFrame( FrameSystemTime ); |
95 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 95 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
96 | vb->addWidget( hline ); | 96 | vb->addWidget( hline ); |
97 | 97 | ||
98 | Config config("qpe"); | 98 | Config config("qpe"); |
99 | config.setGroup( "Time" ); | 99 | config.setGroup( "Time" ); |
100 | 100 | ||
101 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); | 101 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); |
102 | 102 | ||
103 | QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); | 103 | QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); |
104 | hb1->addWidget( l, 1 ); | 104 | hb1->addWidget( l, 1 ); |
105 | 105 | ||
106 | 106 | ||
107 | ampmCombo = new QComboBox( FrameSystemTime ); | 107 | ampmCombo = new QComboBox( FrameSystemTime ); |
108 | ampmCombo->insertItem( tr("24 hour"), 0 ); | 108 | ampmCombo->insertItem( tr("24 hour"), 0 ); |
109 | ampmCombo->insertItem( tr("12 hour"), 1 ); | 109 | ampmCombo->insertItem( tr("12 hour"), 1 ); |
110 | hb1->addWidget( ampmCombo, 2 ); | 110 | hb1->addWidget( ampmCombo, 2 ); |
111 | 111 | ||
112 | int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; | 112 | int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; |
113 | ampmCombo->setCurrentItem( show12hr ); | 113 | ampmCombo->setCurrentItem( show12hr ); |
114 | timeButton->show12hourTime( show12hr ); | 114 | timeButton->show12hourTime( show12hr ); |
115 | 115 | ||
116 | connect(ampmCombo, SIGNAL(activated(int)), | 116 | connect(ampmCombo, SIGNAL(activated(int)), |
117 | timeButton, SLOT(show12hourTime(int))); | 117 | timeButton, SLOT(show12hourTime(int))); |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | QHBoxLayout *hb2 = new QHBoxLayout( vb ); | 121 | QHBoxLayout *hb2 = new QHBoxLayout( vb ); |
122 | l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); | 122 | l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); |
123 | //l->setAlignment( AlignRight | AlignVCenter ); | 123 | //l->setAlignment( AlignRight | AlignVCenter ); |
124 | hb2->addWidget( l, 1 ); | 124 | hb2->addWidget( l, 1 ); |
125 | 125 | ||
126 | weekStartCombo = new QComboBox( FrameSystemTime ); | 126 | weekStartCombo = new QComboBox( FrameSystemTime ); |
127 | weekStartCombo->insertItem( tr("Sunday"), 0 ); | 127 | weekStartCombo->insertItem( tr("Sunday"), 0 ); |
128 | weekStartCombo->insertItem( tr("Monday"), 1 ); | 128 | weekStartCombo->insertItem( tr("Monday"), 1 ); |
129 | 129 | ||
130 | hb2->addWidget( weekStartCombo, 2 ); | 130 | hb2->addWidget( weekStartCombo, 2 ); |
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 | 195 | ||
196 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), | 196 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), |
197 | SLOT(updateSystem(int ) )); | 197 | SLOT(updateSystem(int ) )); |
198 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), | 198 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), |
199 | SLOT(updateSystem(int ) )); | 199 | SLOT(updateSystem(int ) )); |
200 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), | 200 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), |
201 | SLOT(updateSystem(int ) )); | 201 | SLOT(updateSystem(int ) )); |
202 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), | 202 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), |
203 | SLOT(updateSystem(int ) )); | 203 | SLOT(updateSystem(int ) )); |
204 | } | 204 | } |
205 | 205 | ||
206 | SetDateTime::~SetDateTime() | 206 | SetDateTime::~SetDateTime() |
207 | { | 207 | { |
208 | writeSettings(); | 208 | writeSettings(); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | void SetDateTime::writeSettings() | 212 | void SetDateTime::writeSettings() |
213 | { | 213 | { |
214 | Config config("qpe"); | 214 | Config config("qpe"); |
215 | config.setGroup( "Time" ); | 215 | config.setGroup( "Time" ); |
216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); | 216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); |
217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); | 217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); |
218 | config.setGroup( "Date" ); | 218 | config.setGroup( "Date" ); |
219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; | 219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; |
220 | config.writeEntry( "Separator", QString(df.separator())); | 220 | config.writeEntry( "Separator", QString(df.separator())); |
221 | config.writeEntry( "ShortOrder", df.shortOrder()); | 221 | config.writeEntry( "ShortOrder", df.shortOrder()); |
222 | config.writeEntry( "LongOrder", df.longOrder()); | 222 | config.writeEntry( "LongOrder", df.longOrder()); |
223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); | 223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); |
224 | 224 | ||
225 | Config lconfig("locale"); | 225 | Config lconfig("locale"); |
226 | lconfig.setGroup( "Location" ); | 226 | lconfig.setGroup( "Location" ); |
227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); | 227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); |
228 | 228 | ||
229 | } | 229 | } |
230 | 230 | ||
231 | void SetDateTime::commitTime() | 231 | void SetDateTime::commitTime() |
232 | { | 232 | { |
233 | tz->setFocus(); | 233 | tz->setFocus(); |
234 | // really turn off the screensaver before doing anything | ||
235 | { | ||
236 | // Needs to be encased in { } so that it deconstructs and sends | ||
237 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
238 | disableScreenSaver << 0 << 0 << 0; | ||
239 | } | ||
240 | // Need to process the QCOP event generated above before proceeding | 234 | // Need to process the QCOP event generated above before proceeding |
241 | qApp->processEvents(); | 235 | qApp->processEvents(); |
242 | 236 | ||
243 | // before we progress further, set our TZ! | 237 | // before we progress further, set our TZ! |
244 | setenv( "TZ", tz->currentZone(), 1 ); | 238 | setenv( "TZ", tz->currentZone(), 1 ); |
245 | // now set the time... | 239 | // now set the time... |
246 | QDateTime dt( dateButton->date(), timeButton->time() ); | 240 | QDateTime dt( dateButton->date(), timeButton->time() ); |
247 | 241 | ||
248 | if ( dt.isValid() ) setTime(dt); | 242 | if ( dt.isValid() ) setTime(dt); |
249 | } | 243 | } |
250 | 244 | ||
251 | void SetDateTime::setTime(QDateTime dt) | 245 | void SetDateTime::setTime(QDateTime dt) |
252 | { | 246 | { |
247 | // really turn off the screensaver before doing anything | ||
248 | { | ||
249 | // Needs to be encased in { } so that it deconstructs and sends | ||
250 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
251 | disableScreenSaver << 0 << 0 << 0; | ||
252 | } | ||
253 | Config cfg("ntp",Config::User); | 253 | Config cfg("ntp",Config::User); |
254 | cfg.setGroup("correction"); | 254 | cfg.setGroup("correction"); |
255 | int t = TimeConversion::toUTC(dt); | 255 | int t = TimeConversion::toUTC(dt); |
256 | struct timeval myTv; | 256 | struct timeval myTv; |
257 | myTv.tv_sec = t; | 257 | myTv.tv_sec = t; |
258 | cfg.writeEntry("time", t ); | 258 | cfg.writeEntry("time", t ); |
259 | myTv.tv_usec = 0; | 259 | myTv.tv_usec = 0; |
260 | 260 | ||
261 | if ( myTv.tv_sec != -1 ) | 261 | if ( myTv.tv_sec != -1 ) |
262 | ::settimeofday( &myTv, 0 ); | 262 | ::settimeofday( &myTv, 0 ); |
263 | Global::writeHWClock(); | 263 | Global::writeHWClock(); |
264 | // since time has changed quickly load in the datebookdb | 264 | // since time has changed quickly load in the datebookdb |
265 | // to allow the alarm server to get a better grip on itself | 265 | // to allow the alarm server to get a better grip on itself |
266 | // (example re-trigger alarms for when we travel back in time) | 266 | // (example re-trigger alarms for when we travel back in time) |
267 | DateBookDB db; | 267 | DateBookDB db; |
268 | // Restore screensaver | ||
269 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
270 | enableScreenSaver << -1 << -1 << -1; | ||
268 | } | 271 | } |
269 | 272 | ||
270 | void SetDateTime::updateSystem(int i) | 273 | void SetDateTime::updateSystem(int i) |
271 | { | 274 | { |
275 | // really turn off the screensaver before doing anything | ||
276 | { | ||
277 | // Needs to be encased in { } so that it deconstructs and sends | ||
278 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
279 | disableScreenSaver << 0 << 0 << 0; | ||
280 | } | ||
272 | qDebug("SetDateTime::updateSystem(int %i)",i); | 281 | qDebug("SetDateTime::updateSystem(int %i)",i); |
273 | writeSettings(); | 282 | writeSettings(); |
274 | 283 | ||
275 | // set the timezone for everyone else... | 284 | // set the timezone for everyone else... |
276 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 285 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
277 | setTimeZone << tz->currentZone(); | 286 | setTimeZone << tz->currentZone(); |
278 | 287 | ||
279 | // AM/PM setting and notify time changed | 288 | // AM/PM setting and notify time changed |
280 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 289 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
281 | setClock << ampmCombo->currentItem(); | 290 | setClock << ampmCombo->currentItem(); |
282 | 291 | ||
283 | // Notify everyone what day we prefer to start the week on. | 292 | // Notify everyone what day we prefer to start the week on. |
284 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 293 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
285 | setWeek << weekStartCombo->currentItem(); | 294 | setWeek << weekStartCombo->currentItem(); |
286 | 295 | ||
287 | // Notify everyone what date format to use | 296 | // Notify everyone what date format to use |
288 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); | 297 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); |
289 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; | 298 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; |
290 | 299 | ||
291 | // Restore screensaver | 300 | // Restore screensaver |
292 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 301 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
293 | enableScreenSaver << -1 << -1 << -1; | 302 | enableScreenSaver << -1 << -1 << -1; |
294 | // since time has changed quickly load in the datebookdb | 303 | // since time has changed quickly load in the datebookdb |
295 | // to allow the alarm server to get a better grip on itself | 304 | // to allow the alarm server to get a better grip on itself |
296 | // (example re-trigger alarms for when we travel back in time) | 305 | // (example re-trigger alarms for when we travel back in time) |
297 | DateBookDB db; | 306 | DateBookDB db; |
298 | 307 | ||
299 | } | 308 | } |
300 | 309 | ||
301 | void SetDateTime::tzChange( const QString &tz ) | 310 | void SetDateTime::tzChange( const QString &tz ) |
302 | { | 311 | { |
303 | // set the TZ get the time and leave gracefully... | 312 | // set the TZ get the time and leave gracefully... |
304 | QString strSave; | 313 | QString strSave; |
305 | strSave = getenv( "TZ" ); | 314 | strSave = getenv( "TZ" ); |
306 | setenv( "TZ", tz, 1 ); | 315 | setenv( "TZ", tz, 1 ); |
307 | 316 | ||
308 | QDate d = QDate::currentDate(); | 317 | QDate d = QDate::currentDate(); |
309 | // reset the time. | 318 | // reset the time. |
310 | if ( !strSave.isNull() ) { | 319 | if ( !strSave.isNull() ) { |
311 | setenv( "TZ", strSave, 1 ); | 320 | setenv( "TZ", strSave, 1 ); |
312 | } | 321 | } |
313 | dateButton->setDate( d ); | 322 | dateButton->setDate( d ); |
314 | updateSystem(); | 323 | updateSystem(); |
315 | } | 324 | } |
316 | 325 | ||
317 | void SetDateTime::formatChanged(int i) | 326 | void SetDateTime::formatChanged(int i) |
318 | { | 327 | { |
319 | dateButton->setDateFormat(date_formats[i]); | 328 | dateButton->setDateFormat(date_formats[i]); |
320 | } | 329 | } |
321 | 330 | ||
322 | static const int ValueAM = 0; | 331 | static const int ValueAM = 0; |
323 | static const int ValuePM = 1; | 332 | static const int ValuePM = 1; |
324 | 333 | ||
325 | 334 | ||
326 | 335 | ||
327 | SetTime::SetTime( QWidget *parent, const char *name ) | 336 | SetTime::SetTime( QWidget *parent, const char *name ) |
328 | : QWidget( parent, name ) | 337 | : QWidget( parent, name ) |
329 | { | 338 | { |
330 | use12hourTime = FALSE; | 339 | use12hourTime = FALSE; |
331 | 340 | ||
332 | QTime currTime = QTime::currentTime(); | 341 | QTime currTime = QTime::currentTime(); |
333 | hour = currTime.hour(); | 342 | hour = currTime.hour(); |
334 | minute = currTime.minute(); | 343 | minute = currTime.minute(); |
335 | 344 | ||
336 | QHBoxLayout *hb2 = new QHBoxLayout( this ); | 345 | QHBoxLayout *hb2 = new QHBoxLayout( this ); |
337 | hb2->setSpacing( 3 ); | 346 | hb2->setSpacing( 3 ); |
338 | 347 | ||
339 | QLabel *l = new QLabel( tr("Hour"), this ); | 348 | QLabel *l = new QLabel( tr("Hour"), this ); |
340 | // l->setAlignment( AlignRight | AlignVCenter ); | 349 | // l->setAlignment( AlignRight | AlignVCenter ); |
341 | hb2->addWidget( l ); | 350 | hb2->addWidget( l ); |
342 | 351 | ||
343 | sbHour = new QSpinBox( this ); | 352 | sbHour = new QSpinBox( this ); |
344 | sbHour->setMinimumWidth( 30 ); | 353 | sbHour->setMinimumWidth( 30 ); |
345 | if(use12hourTime) { | 354 | if(use12hourTime) { |
346 | sbHour->setMinValue(1); | 355 | sbHour->setMinValue(1); |
347 | sbHour->setMaxValue( 12 ); | 356 | sbHour->setMaxValue( 12 ); |
348 | int show_hour = hour; | 357 | int show_hour = hour; |
349 | if (hour > 12) | 358 | if (hour > 12) |
350 | show_hour -= 12; | 359 | show_hour -= 12; |
351 | if (show_hour == 0) | 360 | if (show_hour == 0) |
352 | show_hour = 12; | 361 | show_hour = 12; |
353 | 362 | ||
354 | sbHour->setValue( show_hour ); | 363 | sbHour->setValue( show_hour ); |
355 | } else { | 364 | } else { |
356 | sbHour->setMinValue( 0 ); | 365 | sbHour->setMinValue( 0 ); |
357 | sbHour->setMaxValue( 23 ); | 366 | sbHour->setMaxValue( 23 ); |
358 | sbHour->setValue( hour ); | 367 | sbHour->setValue( hour ); |
359 | } | 368 | } |
360 | sbHour->setWrapping(TRUE); | 369 | sbHour->setWrapping(TRUE); |
361 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); | 370 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); |
362 | hb2->addWidget( sbHour ); | 371 | hb2->addWidget( sbHour ); |
363 | 372 | ||
364 | hb2->addStretch( 1 ); | 373 | hb2->addStretch( 1 ); |
365 | 374 | ||
366 | l = new QLabel( tr("Minute"), this ); | 375 | l = new QLabel( tr("Minute"), this ); |
367 | //l->setAlignment( AlignRight | AlignVCenter ); | 376 | //l->setAlignment( AlignRight | AlignVCenter ); |
368 | hb2->addWidget( l ); | 377 | hb2->addWidget( l ); |
369 | 378 | ||
370 | sbMin = new QSpinBox( this ); | 379 | sbMin = new QSpinBox( this ); |
371 | sbMin->setMinValue( 0 ); | 380 | sbMin->setMinValue( 0 ); |
372 | sbMin->setMaxValue( 59 ); | 381 | sbMin->setMaxValue( 59 ); |
373 | sbMin->setWrapping(TRUE); | 382 | sbMin->setWrapping(TRUE); |
374 | sbMin->setValue( minute ); | 383 | sbMin->setValue( minute ); |
375 | sbMin->setMinimumWidth( 30 ); | 384 | sbMin->setMinimumWidth( 30 ); |
376 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); | 385 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); |
377 | hb2->addWidget( sbMin ); | 386 | hb2->addWidget( sbMin ); |
378 | 387 | ||
379 | hb2->addStretch( 1 ); | 388 | hb2->addStretch( 1 ); |
380 | 389 | ||
381 | ampm = new QComboBox( this ); | 390 | ampm = new QComboBox( this ); |
382 | ampm->insertItem( tr("AM"), ValueAM ); | 391 | ampm->insertItem( tr("AM"), ValueAM ); |
383 | ampm->insertItem( tr("PM"), ValuePM ); | 392 | ampm->insertItem( tr("PM"), ValuePM ); |
384 | connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); | 393 | connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); |
385 | hb2->addWidget( ampm ); | 394 | hb2->addWidget( ampm ); |
386 | 395 | ||
387 | hb2->addStretch( 1 ); | 396 | hb2->addStretch( 1 ); |
388 | 397 | ||
389 | } | 398 | } |
390 | 399 | ||
391 | QTime SetTime::time() const | 400 | QTime SetTime::time() const |
392 | { | 401 | { |
393 | return QTime( hour, minute, 0 ); | 402 | return QTime( hour, minute, 0 ); |
394 | } | 403 | } |
395 | 404 | ||
396 | void SetTime::hourChanged( int value ) | 405 | void SetTime::hourChanged( int value ) |
397 | { | 406 | { |
398 | if(use12hourTime) { | 407 | if(use12hourTime) { |
399 | int realhour = value; | 408 | int realhour = value; |
400 | if (realhour == 12) | 409 | if (realhour == 12) |
401 | realhour = 0; | 410 | realhour = 0; |
402 | if (ampm->currentItem() == ValuePM ) | 411 | if (ampm->currentItem() == ValuePM ) |
403 | realhour += 12; | 412 | realhour += 12; |
404 | hour = realhour; | 413 | hour = realhour; |
405 | } else | 414 | } else |
406 | hour = value; | 415 | hour = value; |
407 | } | 416 | } |
408 | 417 | ||
409 | void SetTime::minuteChanged( int value ) | 418 | void SetTime::minuteChanged( int value ) |
410 | { | 419 | { |
411 | minute = value; | 420 | minute = value; |
412 | } | 421 | } |
413 | 422 | ||
414 | void SetTime::show12hourTime( int on ) | 423 | void SetTime::show12hourTime( int on ) |
415 | { | 424 | { |
416 | use12hourTime = on; | 425 | use12hourTime = on; |
417 | ampm->setEnabled(on); | 426 | ampm->setEnabled(on); |
418 | 427 | ||
419 | int show_hour = hour; | 428 | int show_hour = hour; |
420 | if ( on ) { | 429 | if ( on ) { |
421 | /* this might change the value of hour */ | 430 | /* this might change the value of hour */ |
422 | sbHour->setMinValue(1); | 431 | sbHour->setMinValue(1); |
423 | sbHour->setMaxValue( 12 ); | 432 | sbHour->setMaxValue( 12 ); |
424 | 433 | ||
425 | /* so use one we saved earlier */ | 434 | /* so use one we saved earlier */ |
426 | if (show_hour >= 12) { | 435 | if (show_hour >= 12) { |
427 | show_hour -= 12; | 436 | show_hour -= 12; |
428 | ampm->setCurrentItem( ValuePM ); | 437 | ampm->setCurrentItem( ValuePM ); |
429 | } else { | 438 | } else { |
430 | ampm->setCurrentItem( ValueAM ); | 439 | ampm->setCurrentItem( ValueAM ); |
431 | } | 440 | } |
432 | if (show_hour == 0) | 441 | if (show_hour == 0) |
433 | show_hour = 12; | 442 | show_hour = 12; |
434 | 443 | ||
435 | } else { | 444 | } else { |
436 | sbHour->setMinValue( 0 ); | 445 | sbHour->setMinValue( 0 ); |
437 | sbHour->setMaxValue( 23 ); | 446 | sbHour->setMaxValue( 23 ); |
438 | } | 447 | } |
439 | 448 | ||
440 | 449 | ||
441 | sbHour->setValue( show_hour ); | 450 | sbHour->setValue( show_hour ); |
442 | } | 451 | } |
443 | 452 | ||
444 | void SetTime::checkedPM( int c ) | 453 | void SetTime::checkedPM( int c ) |
445 | { | 454 | { |
446 | int show_hour = sbHour->value(); | 455 | int show_hour = sbHour->value(); |
447 | if (show_hour == 12) | 456 | if (show_hour == 12) |
448 | show_hour = 0; | 457 | show_hour = 0; |
449 | 458 | ||
450 | if ( c == ValuePM ) | 459 | if ( c == ValuePM ) |
451 | show_hour += 12; | 460 | show_hour += 12; |
452 | 461 | ||
453 | hour = show_hour; | 462 | hour = show_hour; |
454 | } | 463 | } |
455 | 464 | ||
456 | void SetTime::slotTzChange( const QString &tz ) | 465 | void SetTime::slotTzChange( const QString &tz ) |
457 | { | 466 | { |
458 | // set the TZ get the time and leave gracefully... | 467 | // set the TZ get the time and leave gracefully... |
459 | QString strSave; | 468 | QString strSave; |
460 | strSave = getenv( "TZ" ); | 469 | strSave = getenv( "TZ" ); |
461 | setenv( "TZ", tz, 1 ); | 470 | setenv( "TZ", tz, 1 ); |
462 | 471 | ||
463 | QTime t = QTime::currentTime(); | 472 | QTime t = QTime::currentTime(); |
464 | // reset the time. | 473 | // reset the time. |
465 | if ( !strSave.isNull() ) { | 474 | if ( !strSave.isNull() ) { |
466 | setenv( "TZ", strSave, 1 ); | 475 | setenv( "TZ", strSave, 1 ); |
467 | } | 476 | } |
468 | 477 | ||
469 | // just set the spinboxes and let it propage through | 478 | // just set the spinboxes and let it propage through |
470 | if(use12hourTime) { | 479 | if(use12hourTime) { |
471 | int show_hour = t.hour(); | 480 | int show_hour = t.hour(); |
472 | if (t.hour() >= 12) { | 481 | if (t.hour() >= 12) { |
473 | show_hour -= 12; | 482 | show_hour -= 12; |
474 | ampm->setCurrentItem( ValuePM ); | 483 | ampm->setCurrentItem( ValuePM ); |
475 | } else { | 484 | } else { |
476 | ampm->setCurrentItem( ValueAM ); | 485 | ampm->setCurrentItem( ValueAM ); |
477 | } | 486 | } |
478 | if (show_hour == 0) | 487 | if (show_hour == 0) |
479 | show_hour = 12; | 488 | show_hour = 12; |
480 | sbHour->setValue( show_hour ); | 489 | sbHour->setValue( show_hour ); |
481 | } else { | 490 | } else { |
482 | sbHour->setValue( t.hour() ); | 491 | sbHour->setValue( t.hour() ); |
483 | } | 492 | } |
484 | sbMin->setValue( t.minute() ); | 493 | sbMin->setValue( t.minute() ); |
485 | } | 494 | } |
486 | 495 | ||
487 | 496 | ||