author | tille <tille> | 2002-11-16 17:42:37 (UTC) |
---|---|---|
committer | tille <tille> | 2002-11-16 17:42:37 (UTC) |
commit | 0861a25d4f28be8a3ba794eafca9f29eac3cc7c1 (patch) (unidiff) | |
tree | 0e78a2019fa62f803f6d61683b0daaeb4e810fd7 | |
parent | 55f437bb3caaeec328bce4e2d00818780f1b4aa2 (diff) | |
download | opie-0861a25d4f28be8a3ba794eafca9f29eac3cc7c1.zip opie-0861a25d4f28be8a3ba794eafca9f29eac3cc7c1.tar.gz opie-0861a25d4f28be8a3ba794eafca9f29eac3cc7c1.tar.bz2 |
first try to revert timezones on reject...
... not working i am too stupid ;)
-rw-r--r-- | noncore/settings/netsystemtime/TODO | 1 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 11 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.h | 1 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.h | 2 |
5 files changed, 16 insertions, 8 deletions
diff --git a/noncore/settings/netsystemtime/TODO b/noncore/settings/netsystemtime/TODO index fb003a2..c6106c3 100644 --- a/noncore/settings/netsystemtime/TODO +++ b/noncore/settings/netsystemtime/TODO | |||
@@ -1,3 +1,2 @@ | |||
1 | - handle hour > 24 in SetTime::slotClockTick | ||
2 | - improve tz setting | 1 | - improve tz setting |
3 | atm the tz gets written to the system as soon as changed... | 2 | atm the tz gets written to the system as soon as changed... |
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 53dbe46..551cedc 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -1,426 +1,435 @@ | |||
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 <qcheckbox.h> | 10 | #include <qcheckbox.h> |
11 | #include <qtabwidget.h> | 11 | #include <qtabwidget.h> |
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qmultilineedit.h> | 14 | #include <qmultilineedit.h> |
15 | #include <opie/oprocess.h> | 15 | #include <opie/oprocess.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/global.h> | 18 | #include <qpe/global.h> |
19 | #include <qpe/timeconversion.h> | 19 | #include <qpe/timeconversion.h> |
20 | #include <qpe/tzselect.h> | 20 | #include <qpe/tzselect.h> |
21 | #include <qpe/timestring.h> | 21 | #include <qpe/timestring.h> |
22 | #include <qpe/qpedialog.h> | 22 | #include <qpe/qpedialog.h> |
23 | #include <qpe/datebookdb.h> | 23 | #include <qpe/datebookdb.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | 28 | ||
29 | 29 | ||
30 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | 30 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) |
31 | : SetDateTime( parent, name, fl ) | 31 | : SetDateTime( parent, name, fl ) |
32 | { | 32 | { |
33 | _interactive = false; | 33 | _interactive = false; |
34 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); | 34 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); |
35 | ntpSrvs.setGroup("servers"); | 35 | ntpSrvs.setGroup("servers"); |
36 | int srvCount = ntpSrvs.readNumEntry("count", 0 ); | 36 | int srvCount = ntpSrvs.readNumEntry("count", 0 ); |
37 | for (int i = 0; i < srvCount; i++) | 37 | for (int i = 0; i < srvCount; i++) |
38 | { | 38 | { |
39 | ntpSrvs.setGroup(QString::number(i)); | 39 | ntpSrvs.setGroup(QString::number(i)); |
40 | ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); | 40 | ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); |
41 | } | 41 | } |
42 | if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); | 42 | if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); |
43 | 43 | ||
44 | Config cfg("ntp",Config::User); | 44 | Config cfg("ntp",Config::User); |
45 | cfg.setGroup("settings"); | 45 | cfg.setGroup("settings"); |
46 | SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) ); | 46 | SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) ); |
47 | SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) ); | 47 | SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) ); |
48 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); | 48 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); |
49 | 49 | ||
50 | //make tab order | 50 | //make tab order |
51 | 51 | ||
52 | TabWidgetMain->removePage( tabMain ); | 52 | TabWidgetMain->removePage( tabMain ); |
53 | TabWidgetMain->removePage( tabManualSetTime ); | 53 | TabWidgetMain->removePage( tabManualSetTime ); |
54 | TabWidgetMain->removePage( TabSettings ); | 54 | TabWidgetMain->removePage( TabSettings ); |
55 | TabWidgetMain->removePage( tabPredict ); | 55 | TabWidgetMain->removePage( tabPredict ); |
56 | TabWidgetMain->removePage( tabNtp ); | 56 | TabWidgetMain->removePage( tabNtp ); |
57 | 57 | ||
58 | TabWidgetMain->insertTab( tabMain, tr( "Main" ) ); | 58 | TabWidgetMain->insertTab( tabMain, tr( "Main" ) ); |
59 | TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) ); | 59 | TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) ); |
60 | TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) ); | 60 | TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) ); |
61 | TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) ); | 61 | TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) ); |
62 | NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 ); | 62 | NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 ); |
63 | 63 | ||
64 | 64 | ||
65 | 65 | ||
66 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); | 66 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); |
67 | showAdvancedFeatures(advMode); | 67 | showAdvancedFeatures(advMode); |
68 | CheckBoxAdvSettings->setChecked( advMode ); | 68 | CheckBoxAdvSettings->setChecked( advMode ); |
69 | connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), | 69 | connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), |
70 | SLOT( showAdvancedFeatures( bool ) ) ); | 70 | SLOT( showAdvancedFeatures( bool ) ) ); |
71 | 71 | ||
72 | makeChannel(); | 72 | makeChannel(); |
73 | 73 | ||
74 | ntpTimer = new QTimer(this); | 74 | ntpTimer = new QTimer(this); |
75 | 75 | ||
76 | ntpProcess = new OProcess( ); | 76 | ntpProcess = new OProcess( ); |
77 | connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), | 77 | connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), |
78 | SLOT(slotNtpDelayChanged(int)) ); | 78 | SLOT(slotNtpDelayChanged(int)) ); |
79 | 79 | ||
80 | ntpSock = new QSocket( this ); | 80 | ntpSock = new QSocket( this ); |
81 | connect( ntpSock, SIGNAL( error(int) ),SLOT(slotCheckNtp(int)) ); | 81 | connect( ntpSock, SIGNAL( error(int) ),SLOT(slotCheckNtp(int)) ); |
82 | slotProbeNtpServer(); | 82 | slotProbeNtpServer(); |
83 | 83 | ||
84 | connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 84 | connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
85 | this, SLOT(getNtpOutput(OProcess*,char*,int))); | 85 | this, SLOT(getNtpOutput(OProcess*,char*,int))); |
86 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), | 86 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), |
87 | this, SLOT(ntpFinished(OProcess*))); | 87 | this, SLOT(ntpFinished(OProcess*))); |
88 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp())); | 88 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp())); |
89 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); | 89 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); |
90 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); | 90 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); |
91 | slotCheckNtp(-1); | 91 | slotCheckNtp(-1); |
92 | readLookups(); | 92 | readLookups(); |
93 | } | 93 | } |
94 | 94 | ||
95 | Ntp::~Ntp() | 95 | Ntp::~Ntp() |
96 | { | 96 | { |
97 | delete ntpProcess; | 97 | delete ntpProcess; |
98 | } | 98 | } |
99 | 99 | ||
100 | void Ntp::saveConfig(){ | 100 | void Ntp::saveConfig(){ |
101 | int srvCount = ComboNtpSrv->count(); | 101 | int srvCount = ComboNtpSrv->count(); |
102 | bool serversChanged = true; | 102 | bool serversChanged = true; |
103 | QString edit = ComboNtpSrv->currentText(); | 103 | QString edit = ComboNtpSrv->currentText(); |
104 | for (int i = 0; i < srvCount; i++){ | 104 | for (int i = 0; i < srvCount; i++){ |
105 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; | 105 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; |
106 | } | 106 | } |
107 | if (serversChanged){ | 107 | if (serversChanged){ |
108 | Config ntpSrvs("/etc/ntpservers",Config::File); | 108 | Config ntpSrvs("/etc/ntpservers",Config::File); |
109 | ntpSrvs.setGroup("servers"); | 109 | ntpSrvs.setGroup("servers"); |
110 | ntpSrvs.writeEntry("count", srvCount); | 110 | ntpSrvs.writeEntry("count", srvCount); |
111 | for (int i = 0; i < srvCount; i++){ | 111 | for (int i = 0; i < srvCount; i++){ |
112 | qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1()); | 112 | qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1()); |
113 | ntpSrvs.setGroup(QString::number(i)); | 113 | ntpSrvs.setGroup(QString::number(i)); |
114 | ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); | 114 | ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | Config cfg("ntp",Config::User); | 117 | Config cfg("ntp",Config::User); |
118 | cfg.setGroup("settings"); | 118 | cfg.setGroup("settings"); |
119 | cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); | 119 | cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); |
120 | cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); | 120 | cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); |
121 | cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); | 121 | cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); |
122 | cfg.writeEntry( "advancedFeatures", CheckBoxAdvSettings->isChecked() ); | 122 | cfg.writeEntry( "advancedFeatures", CheckBoxAdvSettings->isChecked() ); |
123 | } | 123 | } |
124 | 124 | ||
125 | bool Ntp::ntpDelayElapsed() | 125 | bool Ntp::ntpDelayElapsed() |
126 | { | 126 | { |
127 | Config cfg("ntp",Config::User); | 127 | Config cfg("ntp",Config::User); |
128 | cfg.setGroup("lookups"); | 128 | cfg.setGroup("lookups"); |
129 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); | 129 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); |
130 | if (_lookupDiff < 0) return true; | 130 | if (_lookupDiff < 0) return true; |
131 | int i =_lookupDiff - (SpinBoxNtpDelay->value()*60); | 131 | int i =_lookupDiff - (SpinBoxNtpDelay->value()*60); |
132 | return i > -60; | 132 | return i > -60; |
133 | } | 133 | } |
134 | 134 | ||
135 | QString Ntp::getNtpServer() | 135 | QString Ntp::getNtpServer() |
136 | { | 136 | { |
137 | return ComboNtpSrv->currentText(); | 137 | return ComboNtpSrv->currentText(); |
138 | } | 138 | } |
139 | 139 | ||
140 | void Ntp::slotButtonRunNtp() | 140 | void Ntp::slotButtonRunNtp() |
141 | { | 141 | { |
142 | _interactive = true; | 142 | _interactive = true; |
143 | slotRunNtp(); | 143 | slotRunNtp(); |
144 | } | 144 | } |
145 | 145 | ||
146 | void Ntp::slotTimerRunNtp() | 146 | void Ntp::slotTimerRunNtp() |
147 | { | 147 | { |
148 | _interactive = false; | 148 | _interactive = false; |
149 | slotRunNtp(); | 149 | slotRunNtp(); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | void Ntp::slotRunNtp() | 153 | void Ntp::slotRunNtp() |
154 | { | 154 | { |
155 | if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() ) | 155 | if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() ) |
156 | { | 156 | { |
157 | switch ( | 157 | switch ( |
158 | QMessageBox::warning(this, tr("Run NTP?"), | 158 | QMessageBox::warning(this, tr("Run NTP?"), |
159 | tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ | 159 | tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ |
160 | QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ | 160 | QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ |
161 | "<br>"+tr("Rerun NTP?"), | 161 | "<br>"+tr("Rerun NTP?"), |
162 | QMessageBox::Ok,QMessageBox::Cancel) | 162 | QMessageBox::Ok,QMessageBox::Cancel) |
163 | ) { | 163 | ) { |
164 | case QMessageBox::Ok: break; | 164 | case QMessageBox::Ok: break; |
165 | case QMessageBox::Cancel: return; | 165 | case QMessageBox::Cancel: return; |
166 | default: return; | 166 | default: return; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); | 169 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); |
170 | ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); | 170 | ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); |
171 | 171 | ||
172 | ntpProcess->clearArguments(); | 172 | ntpProcess->clearArguments(); |
173 | *ntpProcess << "ntpdate" << getNtpServer(); | 173 | *ntpProcess << "ntpdate" << getNtpServer(); |
174 | bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | 174 | bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); |
175 | if ( !ret ) { | 175 | if ( !ret ) { |
176 | QMessageBox::critical(this, tr("ntp error"), | 176 | QMessageBox::critical(this, tr("ntp error"), |
177 | tr("Error while getting time form network!")); | 177 | tr("Error while getting time form network!")); |
178 | qDebug("Error while executing ntpdate"); | 178 | qDebug("Error while executing ntpdate"); |
179 | ntpOutPut( tr("Error while executing ntpdate")); | 179 | ntpOutPut( tr("Error while executing ntpdate")); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) | 183 | void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) |
184 | { | 184 | { |
185 | if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null"); | 185 | if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null"); |
186 | QString lineStr, lineStrOld; | 186 | QString lineStr, lineStrOld; |
187 | lineStr = buffer; | 187 | lineStr = buffer; |
188 | lineStr=lineStr.left(buflen); | 188 | lineStr=lineStr.left(buflen); |
189 | if (lineStr!=lineStrOld) | 189 | if (lineStr!=lineStrOld) |
190 | { | 190 | { |
191 | ntpOutPut(lineStr); | 191 | ntpOutPut(lineStr); |
192 | _ntpOutput += lineStr; | 192 | _ntpOutput += lineStr; |
193 | } | 193 | } |
194 | lineStrOld = lineStr; | 194 | lineStrOld = lineStr; |
195 | } | 195 | } |
196 | 196 | ||
197 | void Ntp::ntpFinished(OProcess *p) | 197 | void Ntp::ntpFinished(OProcess *p) |
198 | { | 198 | { |
199 | qDebug("p->exitStatus() %i",p->exitStatus()); | 199 | qDebug("p->exitStatus() %i",p->exitStatus()); |
200 | if (p->exitStatus()!=0 || !p->normalExit()) | 200 | if (p->exitStatus()!=0 || !p->normalExit()) |
201 | { | 201 | { |
202 | if ( isVisible() && _interactive ){ | 202 | if ( isVisible() && _interactive ){ |
203 | QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); | 203 | QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); |
204 | } | 204 | } |
205 | // slotCheckNtp(-1); | 205 | // slotCheckNtp(-1); |
206 | return; | 206 | return; |
207 | } | 207 | } |
208 | 208 | ||
209 | Config cfg("ntp",Config::User); | 209 | Config cfg("ntp",Config::User); |
210 | cfg.setGroup("lookups"); | 210 | cfg.setGroup("lookups"); |
211 | int lastLookup = cfg.readNumEntry("time",0); | 211 | int lastLookup = cfg.readNumEntry("time",0); |
212 | int lookupCount = cfg.readNumEntry("count",0); | 212 | int lookupCount = cfg.readNumEntry("count",0); |
213 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); | 213 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); |
214 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 214 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
215 | cfg.writeEntry("time", time); | 215 | cfg.writeEntry("time", time); |
216 | 216 | ||
217 | float timeShift = getTimeShift(); | 217 | float timeShift = getTimeShift(); |
218 | if (timeShift == 0.0) return; | 218 | if (timeShift == 0.0) return; |
219 | int secsSinceLast = time - lastLookup; | 219 | int secsSinceLast = time - lastLookup; |
220 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); | 220 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); |
221 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); | 221 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); |
222 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) | 222 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) |
223 | { | 223 | { |
224 | cfg.setGroup("lookup_"+QString::number(lookupCount)); | 224 | cfg.setGroup("lookup_"+QString::number(lookupCount)); |
225 | lookupCount++; | 225 | lookupCount++; |
226 | _shiftPerSec = timeShift / secsSinceLast; | 226 | _shiftPerSec = timeShift / secsSinceLast; |
227 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); | 227 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); |
228 | cfg.writeEntry("secsSinceLast",secsSinceLast); | 228 | cfg.writeEntry("secsSinceLast",secsSinceLast); |
229 | cfg.writeEntry("timeShift",QString::number(timeShift)); | 229 | cfg.writeEntry("timeShift",QString::number(timeShift)); |
230 | cfg.setGroup("lookups"); | 230 | cfg.setGroup("lookups"); |
231 | cfg.writeEntry("count",lookupCount); | 231 | cfg.writeEntry("count",lookupCount); |
232 | cfg.writeEntry("lastNtp",true); | 232 | cfg.writeEntry("lastNtp",true); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | float Ntp::getTimeShift() | 237 | float Ntp::getTimeShift() |
238 | { | 238 | { |
239 | QString _offset = "offset"; | 239 | QString _offset = "offset"; |
240 | QString _sec = "sec"; | 240 | QString _sec = "sec"; |
241 | QRegExp _reOffset = QRegExp(_offset); | 241 | QRegExp _reOffset = QRegExp(_offset); |
242 | QRegExp _reEndOffset = QRegExp(_sec); | 242 | QRegExp _reEndOffset = QRegExp(_sec); |
243 | int posOffset = _reOffset.match( _ntpOutput ); | 243 | int posOffset = _reOffset.match( _ntpOutput ); |
244 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); | 244 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); |
245 | posOffset += _offset.length() + 1; | 245 | posOffset += _offset.length() + 1; |
246 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); | 246 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); |
247 | qDebug("%s", _ntpOutput.latin1()); | 247 | qDebug("%s", _ntpOutput.latin1()); |
248 | qDebug("diff = >%s<",diff.latin1()); | 248 | qDebug("diff = >%s<",diff.latin1()); |
249 | return diff.toFloat(); | 249 | return diff.toFloat(); |
250 | } | 250 | } |
251 | 251 | ||
252 | void Ntp::readLookups() | 252 | void Ntp::readLookups() |
253 | { | 253 | { |
254 | Config cfg("ntp",Config::User); | 254 | Config cfg("ntp",Config::User); |
255 | cfg.setGroup("lookups"); | 255 | cfg.setGroup("lookups"); |
256 | int lookupCount = cfg.readNumEntry("count",0); | 256 | int lookupCount = cfg.readNumEntry("count",0); |
257 | float last, shift, shiftPerSec; | 257 | float last, shift, shiftPerSec; |
258 | qDebug("lookupCount = %i",lookupCount); | 258 | qDebug("lookupCount = %i",lookupCount); |
259 | TableLookups->setNumCols( 3 ); | 259 | TableLookups->setNumCols( 3 ); |
260 | TableLookups->setNumRows( lookupCount); | 260 | TableLookups->setNumRows( lookupCount); |
261 | TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); | 261 | TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); |
262 | TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); | 262 | TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); |
263 | TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); | 263 | TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); |
264 | int cw = TableLookups->width()/4; | 264 | int cw = TableLookups->width()/4; |
265 | qDebug("column width %i",cw); | 265 | qDebug("column width %i",cw); |
266 | cw = 50; | 266 | cw = 50; |
267 | TableLookups->setColumnWidth( 0, cw+30 ); | 267 | TableLookups->setColumnWidth( 0, cw+30 ); |
268 | TableLookups->setColumnWidth( 1, cw ); | 268 | TableLookups->setColumnWidth( 1, cw ); |
269 | TableLookups->setColumnWidth( 2, cw ); | 269 | TableLookups->setColumnWidth( 2, cw ); |
270 | TableLookups->sortColumn(0, false, true ); | 270 | TableLookups->sortColumn(0, false, true ); |
271 | // TableLookups->setSorting( true ); | 271 | // TableLookups->setSorting( true ); |
272 | _shiftPerSec = 0; | 272 | _shiftPerSec = 0; |
273 | for (int i=0; i < lookupCount; i++) | 273 | for (int i=0; i < lookupCount; i++) |
274 | { | 274 | { |
275 | cfg.setGroup("lookup_"+QString::number(i)); | 275 | cfg.setGroup("lookup_"+QString::number(i)); |
276 | last = cfg.readEntry("secsSinceLast",0).toFloat(); | 276 | last = cfg.readEntry("secsSinceLast",0).toFloat(); |
277 | shift = QString(cfg.readEntry("timeShift",0)).toFloat(); | 277 | shift = QString(cfg.readEntry("timeShift",0)).toFloat(); |
278 | shiftPerSec = shift / last; | 278 | shiftPerSec = shift / last; |
279 | qDebug("%i shift %f",i,shiftPerSec); | 279 | qDebug("%i shift %f",i,shiftPerSec); |
280 | _shiftPerSec += shiftPerSec; | 280 | _shiftPerSec += shiftPerSec; |
281 | TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); | 281 | TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); |
282 | TableLookups->setText( i,2,QString::number(shift)); | 282 | TableLookups->setText( i,2,QString::number(shift)); |
283 | TableLookups->setText( i,1,QString::number(last/(60*60))); | 283 | TableLookups->setText( i,1,QString::number(last/(60*60))); |
284 | } | 284 | } |
285 | _shiftPerSec /= lookupCount; | 285 | _shiftPerSec /= lookupCount; |
286 | TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); | 286 | TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); |
287 | } | 287 | } |
288 | 288 | ||
289 | void Ntp::preditctTime() | 289 | void Ntp::preditctTime() |
290 | { | 290 | { |
291 | Config cfg("ntp",Config::User); | 291 | Config cfg("ntp",Config::User); |
292 | cfg.setGroup("lookups"); | 292 | cfg.setGroup("lookups"); |
293 | int lastTime = cfg.readNumEntry("time",0); | 293 | int lastTime = cfg.readNumEntry("time",0); |
294 | cfg.writeEntry("lastNtp",true); | 294 | cfg.writeEntry("lastNtp",true); |
295 | setenv( "TZ", tz->currentZone(), 1 ); | 295 | setenv( "TZ", tz->currentZone(), 1 ); |
296 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 296 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
297 | int corr = int((now - lastTime) * _shiftPerSec); | 297 | int corr = int((now - lastTime) * _shiftPerSec); |
298 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); | 298 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); |
299 | predictedTime = QDateTime::currentDateTime().addSecs(corr); | 299 | predictedTime = QDateTime::currentDateTime().addSecs(corr); |
300 | TextLabelPredTime->setText(predictedTime.toString()); | 300 | TextLabelPredTime->setText(predictedTime.toString()); |
301 | // TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); | 301 | // TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); |
302 | } | 302 | } |
303 | 303 | ||
304 | void Ntp::setPredictTime() | 304 | void Ntp::setPredictTime() |
305 | { | 305 | { |
306 | qDebug("Ntp::setPredictTime"); | 306 | qDebug("Ntp::setPredictTime"); |
307 | preditctTime(); | 307 | preditctTime(); |
308 | timeButton->setTime( predictedTime ); | 308 | timeButton->setTime( predictedTime ); |
309 | } | 309 | } |
310 | 310 | ||
311 | void Ntp::slotCheckNtp(int i) | 311 | void Ntp::slotCheckNtp(int i) |
312 | { | 312 | { |
313 | qDebug(" Ntp::slotCheckNtp(%i)",i); | 313 | qDebug(" Ntp::slotCheckNtp(%i)",i); |
314 | if (i == 0) | 314 | if (i == 0) |
315 | { | 315 | { |
316 | // TextLabelMainPredTime->hide(); | 316 | // TextLabelMainPredTime->hide(); |
317 | ButtonSetTime->setText( tr("Get time from network") ); | 317 | ButtonSetTime->setText( tr("Get time from network") ); |
318 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); | 318 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); |
319 | if ( ntpDelayElapsed() ) | 319 | if ( ntpDelayElapsed() ) |
320 | { | 320 | { |
321 | slotRunNtp(); | 321 | slotRunNtp(); |
322 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); | 322 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); |
323 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); | 323 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); |
324 | }else{ | 324 | }else{ |
325 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); | 325 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); |
326 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 326 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
327 | } | 327 | } |
328 | }else{ | 328 | }else{ |
329 | preditctTime(); | 329 | preditctTime(); |
330 | ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() ); | 330 | ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() ); |
331 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); | 331 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); |
332 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); | 332 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); |
333 | connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 333 | connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | void Ntp::slotProbeNtpServer() | 337 | void Ntp::slotProbeNtpServer() |
338 | { | 338 | { |
339 | ntpSock->connectToHost( getNtpServer() ,123); | 339 | ntpSock->connectToHost( getNtpServer() ,123); |
340 | } | 340 | } |
341 | 341 | ||
342 | void Ntp::slotNtpDelayChanged(int delay) | 342 | void Ntp::slotNtpDelayChanged(int delay) |
343 | { | 343 | { |
344 | ntpTimer->changeInterval( delay*1000*60 ); | 344 | ntpTimer->changeInterval( delay*1000*60 ); |
345 | } | 345 | } |
346 | 346 | ||
347 | void Ntp::ntpOutPut(QString out) | 347 | void Ntp::ntpOutPut(QString out) |
348 | { | 348 | { |
349 | 349 | ||
350 | MultiLineEditntpOutPut->append(out); | 350 | MultiLineEditntpOutPut->append(out); |
351 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); | 351 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | void Ntp::makeChannel() | 355 | void Ntp::makeChannel() |
356 | { | 356 | { |
357 | channel = new QCopChannel( "QPE/Application/netsystemtime", this ); | 357 | channel = new QCopChannel( "QPE/Application/netsystemtime", this ); |
358 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 358 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
359 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 359 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | 363 | ||
364 | void Ntp::receive(const QCString &msg, const QByteArray &arg) | 364 | void Ntp::receive(const QCString &msg, const QByteArray &arg) |
365 | { | 365 | { |
366 | qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); | 366 | qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); |
367 | if ( msg == "ntpLookup(QString)" ) | 367 | if ( msg == "ntpLookup(QString)" ) |
368 | { | 368 | { |
369 | _interactive = false; | 369 | _interactive = false; |
370 | slotRunNtp(); | 370 | slotRunNtp(); |
371 | } | 371 | } |
372 | if ( msg == "setPredictedTime(QString)" ) | 372 | if ( msg == "setPredictedTime(QString)" ) |
373 | { | 373 | { |
374 | setPredictTime(); | 374 | setPredictTime(); |
375 | }else{ | 375 | }else{ |
376 | qDebug("Ntp::receive: Huh what do ya want"); | 376 | qDebug("Ntp::receive: Huh what do ya want"); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | void Ntp::setDocument(const QString &fileName) | 380 | void Ntp::setDocument(const QString &fileName) |
381 | { | 381 | { |
382 | qDebug("Ntp::setDocument( %s )",fileName.latin1()); | 382 | qDebug("Ntp::setDocument( %s )",fileName.latin1()); |
383 | } | 383 | } |
384 | 384 | ||
385 | void Ntp::showAdvancedFeatures(bool advMode) | 385 | void Ntp::showAdvancedFeatures(bool advMode) |
386 | { | 386 | { |
387 | if (advMode) { | 387 | if (advMode) { |
388 | 388 | ||
389 | TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); | 389 | TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); |
390 | TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); | 390 | TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); |
391 | TextLabel1_2_2->show(); | 391 | TextLabel1_2_2->show(); |
392 | TextLabel2_3->show(); | 392 | TextLabel2_3->show(); |
393 | TextLabel3_3_2->show(); | 393 | TextLabel3_3_2->show(); |
394 | TextLabel1_2->show(); | 394 | TextLabel1_2->show(); |
395 | SpinBoxMinLookupDelay->show(); | 395 | SpinBoxMinLookupDelay->show(); |
396 | TextLabel2->show(); | 396 | TextLabel2->show(); |
397 | TextLabel3_3->show(); | 397 | TextLabel3_3->show(); |
398 | SpinBoxNtpDelay->show(); | 398 | SpinBoxNtpDelay->show(); |
399 | Line1->show(); | 399 | Line1->show(); |
400 | }else{ | 400 | }else{ |
401 | TabWidgetMain->removePage( tabPredict ); | 401 | TabWidgetMain->removePage( tabPredict ); |
402 | TabWidgetMain->removePage( tabNtp ); | 402 | TabWidgetMain->removePage( tabNtp ); |
403 | TextLabel1_2_2->hide(); | 403 | TextLabel1_2_2->hide(); |
404 | TextLabel2_3->hide(); | 404 | TextLabel2_3->hide(); |
405 | TextLabel3_3_2->hide(); | 405 | TextLabel3_3_2->hide(); |
406 | TextLabel1_2->hide(); | 406 | TextLabel1_2->hide(); |
407 | SpinBoxMinLookupDelay->hide(); | 407 | SpinBoxMinLookupDelay->hide(); |
408 | TextLabel2->hide(); | 408 | TextLabel2->hide(); |
409 | TextLabel3_3->hide(); | 409 | TextLabel3_3->hide(); |
410 | SpinBoxNtpDelay->hide(); | 410 | SpinBoxNtpDelay->hide(); |
411 | Line1->hide(); | 411 | Line1->hide(); |
412 | }; | 412 | }; |
413 | TabWidgetMain->show(); | 413 | TabWidgetMain->show(); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void Ntp::accept( ){ | 417 | void Ntp::accept( ){ |
418 | qDebug("accepted"); | 418 | qDebug("saving"); |
419 | //SetTimeDate | 419 | //SetTimeDate |
420 | commitTime(); | 420 | commitTime(); |
421 | writeSettings(); | 421 | writeSettings(); |
422 | updateSystem(); | 422 | updateSystem(); |
423 | // Ntp | 423 | // Ntp |
424 | saveConfig(); | 424 | saveConfig(); |
425 | qApp->quit(); | 425 | qApp->quit(); |
426 | } | ||
427 | |||
428 | void Ntp::reject( ){ | ||
429 | qDebug("_oldTimeZone %s",_oldTimeZone.latin1()); | ||
430 | if (!_oldTimeZone.isEmpty()){ | ||
431 | qDebug("reverting timezone"); | ||
432 | tzChange(_oldTimeZone); | ||
433 | commitTime(); | ||
434 | } | ||
426 | } \ No newline at end of file | 435 | } \ No newline at end of file |
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h index a4573f8..150140e 100644 --- a/noncore/settings/netsystemtime/ntp.h +++ b/noncore/settings/netsystemtime/ntp.h | |||
@@ -1,57 +1,58 @@ | |||
1 | #ifndef NTP_H | 1 | #ifndef NTP_H |
2 | #define NTP_H | 2 | #define NTP_H |
3 | #include "settime.h" | 3 | #include "settime.h" |
4 | #include <qdatetime.h> | 4 | #include <qdatetime.h> |
5 | 5 | ||
6 | class OProcess; | 6 | class OProcess; |
7 | class QString; | 7 | class QString; |
8 | class QTimer; | 8 | class QTimer; |
9 | class QSocket; | 9 | class QSocket; |
10 | class QCopChannel; | 10 | class QCopChannel; |
11 | 11 | ||
12 | class Ntp : public SetDateTime | 12 | class Ntp : public SetDateTime |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 17 | Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
18 | ~Ntp(); | 18 | ~Ntp(); |
19 | 19 | ||
20 | public slots: | 20 | public slots: |
21 | void setDocument (const QString &); | 21 | void setDocument (const QString &); |
22 | protected: | 22 | protected: |
23 | virtual void accept( ); | 23 | virtual void accept( ); |
24 | virtual void reject( ); | ||
24 | QDateTime predictedTime; | 25 | QDateTime predictedTime; |
25 | void makeChannel(); | 26 | void makeChannel(); |
26 | protected slots: | 27 | protected slots: |
27 | void receive(const QCString &msg, const QByteArray &arg); | 28 | void receive(const QCString &msg, const QByteArray &arg); |
28 | private: | 29 | private: |
29 | QString _ntpOutput; | 30 | QString _ntpOutput; |
30 | float _shiftPerSec; | 31 | float _shiftPerSec; |
31 | int _lookupDiff; | 32 | int _lookupDiff; |
32 | OProcess *ntpProcess; | 33 | OProcess *ntpProcess; |
33 | QTimer *ntpTimer; | 34 | QTimer *ntpTimer; |
34 | QSocket *ntpSock; | 35 | QSocket *ntpSock; |
35 | QCopChannel *channel; | 36 | QCopChannel *channel; |
36 | bool _interactive; | 37 | bool _interactive; |
37 | float getTimeShift(); | 38 | float getTimeShift(); |
38 | void readLookups(); | 39 | void readLookups(); |
39 | void ntpOutPut(QString); | 40 | void ntpOutPut(QString); |
40 | bool ntpDelayElapsed(); | 41 | bool ntpDelayElapsed(); |
41 | QString getNtpServer(); | 42 | QString getNtpServer(); |
42 | void saveConfig(); | 43 | void saveConfig(); |
43 | private slots: | 44 | private slots: |
44 | void slotTimerRunNtp(); | 45 | void slotTimerRunNtp(); |
45 | void slotButtonRunNtp(); | 46 | void slotButtonRunNtp(); |
46 | void slotRunNtp(); | 47 | void slotRunNtp(); |
47 | void getNtpOutput(OProcess *proc, char *buffer, int buflen); | 48 | void getNtpOutput(OProcess *proc, char *buffer, int buflen); |
48 | void ntpFinished(OProcess*); | 49 | void ntpFinished(OProcess*); |
49 | void preditctTime(); | 50 | void preditctTime(); |
50 | void slotCheckNtp(int); | 51 | void slotCheckNtp(int); |
51 | void setPredictTime(); | 52 | void setPredictTime(); |
52 | void showAdvancedFeatures(bool); | 53 | void showAdvancedFeatures(bool); |
53 | void slotProbeNtpServer(); | 54 | void slotProbeNtpServer(); |
54 | void slotNtpDelayChanged(int); | 55 | void slotNtpDelayChanged(int); |
55 | }; | 56 | }; |
56 | 57 | ||
57 | #endif | 58 | #endif |
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 36166ae..6a28989 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -1,534 +1,533 @@ | |||
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 <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qbuttongroup.h> | 39 | #include <qbuttongroup.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
44 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
45 | #include <qtoolbutton.h> | 45 | #include <qtoolbutton.h> |
46 | #include <qwindowsystem_qws.h> | 46 | #include <qwindowsystem_qws.h> |
47 | #include <qcombobox.h> | 47 | #include <qcombobox.h> |
48 | 48 | ||
49 | #include <sys/time.h> | 49 | #include <sys/time.h> |
50 | #include <time.h> | 50 | #include <time.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <stdio.h> | 52 | #include <stdio.h> |
53 | 53 | ||
54 | 54 | ||
55 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | 55 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) |
56 | : NtpBase( parent, name, true, f ) | 56 | : NtpBase( parent, name, true, f ) |
57 | { | 57 | { |
58 | setCaption( tr("System Time") ); | 58 | setCaption( tr("System Time") ); |
59 | 59 | _oldTimeZone=""; | |
60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); | 60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); |
61 | 61 | ||
62 | // TextLabelMainPredTime = new QLabel( FrameSystemTime ); | 62 | // TextLabelMainPredTime = new QLabel( FrameSystemTime ); |
63 | // vb->addWidget( TextLabelMainPredTime, 1, 0 ); | 63 | // vb->addWidget( TextLabelMainPredTime, 1, 0 ); |
64 | 64 | ||
65 | timeButton = new SetTime( FrameSystemTime ); | 65 | timeButton = new SetTime( FrameSystemTime ); |
66 | vb->addWidget( timeButton ); | 66 | vb->addWidget( timeButton ); |
67 | 67 | ||
68 | QHBoxLayout *db = new QHBoxLayout( vb ); | 68 | QHBoxLayout *db = new QHBoxLayout( vb ); |
69 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSystemTime ); | 69 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSystemTime ); |
70 | db->addWidget( dateLabel, 1 ); | 70 | db->addWidget( dateLabel, 1 ); |
71 | dateButton = new DateButton( TRUE, FrameSystemTime ); | 71 | dateButton = new DateButton( TRUE, FrameSystemTime ); |
72 | db->addWidget( dateButton, 2 ); | 72 | db->addWidget( dateButton, 2 ); |
73 | 73 | ||
74 | ButtonSetTime = new QPushButton( FrameSystemTime ); | 74 | ButtonSetTime = new QPushButton( FrameSystemTime ); |
75 | vb->addWidget( ButtonSetTime, 1, 0 ); | 75 | vb->addWidget( ButtonSetTime, 1, 0 ); |
76 | 76 | ||
77 | QFrame *hline = new QFrame( FrameSystemTime ); | 77 | QFrame *hline = new QFrame( FrameSystemTime ); |
78 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 78 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
79 | vb->addWidget( hline ); | 79 | vb->addWidget( hline ); |
80 | 80 | ||
81 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); | 81 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); |
82 | 82 | ||
83 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); | 83 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); |
84 | lblZone->setMaximumSize( lblZone->sizeHint() ); | 84 | lblZone->setMaximumSize( lblZone->sizeHint() ); |
85 | hb->addWidget( lblZone ); | 85 | hb->addWidget( lblZone ); |
86 | 86 | ||
87 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); | 87 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); |
88 | tz->setMinimumSize( tz->sizeHint() ); | 88 | tz->setMinimumSize( tz->sizeHint() ); |
89 | hb->addWidget( tz ); | 89 | hb->addWidget( tz ); |
90 | 90 | ||
91 | hline = new QFrame( FrameSystemTime ); | 91 | hline = new QFrame( FrameSystemTime ); |
92 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 92 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
93 | vb->addWidget( hline ); | 93 | vb->addWidget( hline ); |
94 | 94 | ||
95 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 95 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
96 | vb->addItem( spacer ); | 96 | vb->addItem( spacer ); |
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 | // hline = new QFrame( FrameSystemTime ); | 188 | // hline = new QFrame( FrameSystemTime ); |
189 | // hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 189 | // hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
190 | // vb->addWidget( hline ); | 190 | // vb->addWidget( hline ); |
191 | // | 191 | // |
192 | // ButtonSetTime = new QPushButton( FrameSystemTime ); | 192 | // ButtonSetTime = new QPushButton( FrameSystemTime ); |
193 | // vb->addWidget( ButtonSetTime, 1, 0 ); | 193 | // vb->addWidget( ButtonSetTime, 1, 0 ); |
194 | 194 | ||
195 | 195 | ||
196 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 196 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
197 | timeButton, SLOT( slotTzChange( const QString& ) ) ); | 197 | timeButton, SLOT( slotTzChange( const QString& ) ) ); |
198 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 198 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
199 | SLOT( tzChange( const QString& ) ) ); | 199 | SLOT( tzChange( const QString& ) ) ); |
200 | 200 | ||
201 | // QObject::connect( weekStartCombo, SIGNAL( activated ( int )), | 201 | // QObject::connect( weekStartCombo, SIGNAL( activated ( int )), |
202 | // SLOT(updateSystem(int ) )); | 202 | // SLOT(updateSystem(int ) )); |
203 | // QObject::connect( ampmCombo, SIGNAL( activated ( int )), | 203 | // QObject::connect( ampmCombo, SIGNAL( activated ( int )), |
204 | // SLOT(updateSystem(int ) )); | 204 | // SLOT(updateSystem(int ) )); |
205 | // QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), | 205 | // QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), |
206 | // SLOT(updateSystem(int ) )); | 206 | // SLOT(updateSystem(int ) )); |
207 | // QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), | 207 | // QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), |
208 | // SLOT(updateSystem(int ) )); | 208 | // SLOT(updateSystem(int ) )); |
209 | } | 209 | } |
210 | 210 | ||
211 | SetDateTime::~SetDateTime() | 211 | SetDateTime::~SetDateTime() |
212 | { | 212 | { |
213 | } | 213 | } |
214 | 214 | ||
215 | void SetDateTime::writeSettings() | 215 | void SetDateTime::writeSettings() |
216 | { | 216 | { |
217 | Config config("qpe"); | 217 | Config config("qpe"); |
218 | config.setGroup( "Time" ); | 218 | config.setGroup( "Time" ); |
219 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); | 219 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); |
220 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); | 220 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); |
221 | config.setGroup( "Date" ); | 221 | config.setGroup( "Date" ); |
222 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; | 222 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; |
223 | config.writeEntry( "Separator", QString(df.separator())); | 223 | config.writeEntry( "Separator", QString(df.separator())); |
224 | config.writeEntry( "ShortOrder", df.shortOrder()); | 224 | config.writeEntry( "ShortOrder", df.shortOrder()); |
225 | config.writeEntry( "LongOrder", df.longOrder()); | 225 | config.writeEntry( "LongOrder", df.longOrder()); |
226 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); | 226 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); |
227 | 227 | ||
228 | Config lconfig("locale"); | 228 | Config lconfig("locale"); |
229 | lconfig.setGroup( "Location" ); | 229 | lconfig.setGroup( "Location" ); |
230 | lconfig.writeEntry( "Timezone", tz->currentZone() ); | 230 | lconfig.writeEntry( "Timezone", tz->currentZone() ); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | void SetDateTime::commitTime() | 234 | void SetDateTime::commitTime() |
235 | { | 235 | { |
236 | Config cfg("ntp",Config::User); | 236 | Config cfg("ntp",Config::User); |
237 | cfg.setGroup("lookups"); | 237 | cfg.setGroup("lookups"); |
238 | cfg.writeEntry("lastNtp",false); | 238 | cfg.writeEntry("lastNtp",false); |
239 | tz->setFocus(); | 239 | tz->setFocus(); |
240 | // Need to process the QCOP event generated above before proceeding | 240 | // Need to process the QCOP event generated above before proceeding |
241 | qApp->processEvents(); | 241 | qApp->processEvents(); |
242 | 242 | ||
243 | // before we progress further, set our TZ! | 243 | // before we progress further, set our TZ! |
244 | setenv( "TZ", tz->currentZone(), 1 ); | 244 | setenv( "TZ", tz->currentZone(), 1 ); |
245 | // now set the time... | 245 | // now set the time... |
246 | QDateTime dt( dateButton->date(), timeButton->time() ); | 246 | QDateTime dt( dateButton->date(), timeButton->time() ); |
247 | 247 | ||
248 | if ( dt.isValid() ) setTime(dt); | 248 | if ( dt.isValid() ) setTime(dt); |
249 | } | 249 | } |
250 | 250 | ||
251 | void SetDateTime::setTime(QDateTime dt) | 251 | void SetDateTime::setTime(QDateTime dt) |
252 | { | 252 | { |
253 | // really turn off the screensaver before doing anything | 253 | // really turn off the screensaver before doing anything |
254 | { | 254 | { |
255 | // Needs to be encased in { } so that it deconstructs and sends | 255 | // Needs to be encased in { } so that it deconstructs and sends |
256 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 256 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
257 | disableScreenSaver << 0 << 0 << 0; | 257 | disableScreenSaver << 0 << 0 << 0; |
258 | } | 258 | } |
259 | Config cfg("ntp",Config::User); | 259 | Config cfg("ntp",Config::User); |
260 | cfg.setGroup("correction"); | 260 | cfg.setGroup("correction"); |
261 | int t = TimeConversion::toUTC(dt); | 261 | int t = TimeConversion::toUTC(dt); |
262 | struct timeval myTv; | 262 | struct timeval myTv; |
263 | myTv.tv_sec = t; | 263 | myTv.tv_sec = t; |
264 | cfg.writeEntry("time", t ); | 264 | cfg.writeEntry("time", t ); |
265 | myTv.tv_usec = 0; | 265 | myTv.tv_usec = 0; |
266 | 266 | ||
267 | if ( myTv.tv_sec != -1 ) | 267 | if ( myTv.tv_sec != -1 ) |
268 | ::settimeofday( &myTv, 0 ); | 268 | ::settimeofday( &myTv, 0 ); |
269 | Global::writeHWClock(); | 269 | Global::writeHWClock(); |
270 | // since time has changed quickly load in the datebookdb | 270 | // since time has changed quickly load in the datebookdb |
271 | // 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 |
272 | // (example re-trigger alarms for when we travel back in time) | 272 | // (example re-trigger alarms for when we travel back in time) |
273 | DateBookDB db; | 273 | DateBookDB db; |
274 | //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); | 274 | //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); |
275 | //timeApplet << ""; | 275 | //timeApplet << ""; |
276 | // Restore screensaver | 276 | // Restore screensaver |
277 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 277 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
278 | enableScreenSaver << -1 << -1 << -1; | 278 | enableScreenSaver << -1 << -1 << -1; |
279 | } | 279 | } |
280 | 280 | ||
281 | void SetDateTime::updateSystem() | 281 | void SetDateTime::updateSystem() |
282 | { | 282 | { |
283 | // really turn off the screensaver before doing anything | 283 | // really turn off the screensaver before doing anything |
284 | { | 284 | { |
285 | // Needs to be encased in { } so that it deconstructs and sends | 285 | // Needs to be encased in { } so that it deconstructs and sends |
286 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 286 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
287 | disableScreenSaver << 0 << 0 << 0; | 287 | disableScreenSaver << 0 << 0 << 0; |
288 | } | 288 | } |
289 | qDebug("SetDateTime::updateSystem()"); | 289 | qDebug("SetDateTime::updateSystem()"); |
290 | writeSettings(); | 290 | writeSettings(); |
291 | 291 | ||
292 | // set the timezone for everyone else... | 292 | // set the timezone for everyone else... |
293 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 293 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
294 | setTimeZone << tz->currentZone(); | 294 | setTimeZone << tz->currentZone(); |
295 | 295 | ||
296 | // AM/PM setting and notify time changed | 296 | // AM/PM setting and notify time changed |
297 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 297 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
298 | setClock << ampmCombo->currentItem(); | 298 | setClock << ampmCombo->currentItem(); |
299 | 299 | ||
300 | // Notify everyone what day we prefer to start the week on. | 300 | // Notify everyone what day we prefer to start the week on. |
301 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 301 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
302 | setWeek << weekStartCombo->currentItem(); | 302 | setWeek << weekStartCombo->currentItem(); |
303 | 303 | ||
304 | // Notify everyone what date format to use | 304 | // Notify everyone what date format to use |
305 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); | 305 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); |
306 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; | 306 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; |
307 | 307 | ||
308 | // Restore screensaver | 308 | // Restore screensaver |
309 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 309 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
310 | enableScreenSaver << -1 << -1 << -1; | 310 | enableScreenSaver << -1 << -1 << -1; |
311 | // since time has changed quickly load in the datebookdb | 311 | // since time has changed quickly load in the datebookdb |
312 | // to allow the alarm server to get a better grip on itself | 312 | // to allow the alarm server to get a better grip on itself |
313 | // (example re-trigger alarms for when we travel back in time) | 313 | // (example re-trigger alarms for when we travel back in time) |
314 | DateBookDB db; | 314 | DateBookDB db; |
315 | 315 | ||
316 | } | 316 | } |
317 | 317 | ||
318 | void SetDateTime::tzChange( const QString &tz ) | 318 | void SetDateTime::tzChange( const QString &tz ) |
319 | { | 319 | { |
320 | // set the TZ get the time and leave gracefully... | 320 | // set the TZ get the time and leave gracefully... |
321 | QString strSave; | 321 | _oldTimeZone = getenv( "TZ" ); |
322 | strSave = getenv( "TZ" ); | ||
323 | setenv( "TZ", tz, 1 ); | 322 | setenv( "TZ", tz, 1 ); |
324 | 323 | ||
325 | QDate d = QDate::currentDate(); | 324 | QDate d = QDate::currentDate(); |
326 | // reset the time. | 325 | // reset the time. |
327 | if ( !strSave.isNull() ) { | 326 | if ( !_oldTimeZone.isNull() ) { |
328 | setenv( "TZ", strSave, 1 ); | 327 | setenv( "TZ", _oldTimeZone, 1 ); |
329 | } | 328 | } |
330 | dateButton->setDate( d ); | 329 | dateButton->setDate( d ); |
331 | updateSystem(); | 330 | updateSystem(); |
332 | } | 331 | } |
333 | 332 | ||
334 | void SetDateTime::formatChanged(int i) | 333 | void SetDateTime::formatChanged(int i) |
335 | { | 334 | { |
336 | dateButton->setDateFormat(date_formats[i]); | 335 | dateButton->setDateFormat(date_formats[i]); |
337 | } | 336 | } |
338 | 337 | ||
339 | static const int ValueAM = 0; | 338 | static const int ValueAM = 0; |
340 | static const int ValuePM = 1; | 339 | static const int ValuePM = 1; |
341 | 340 | ||
342 | 341 | ||
343 | 342 | ||
344 | SetTime::SetTime( QWidget *parent, const char *name ) | 343 | SetTime::SetTime( QWidget *parent, const char *name ) |
345 | : QWidget( parent, name ) | 344 | : QWidget( parent, name ) |
346 | { | 345 | { |
347 | clock = new QTimer(this, "clock" ); | 346 | clock = new QTimer(this, "clock" ); |
348 | connect(clock, SIGNAL( timeout() ), SLOT(slotClockTick()) ); | 347 | connect(clock, SIGNAL( timeout() ), SLOT(slotClockTick()) ); |
349 | clock->start( 1000 * 60 ); | 348 | clock->start( 1000 * 60 ); |
350 | 349 | ||
351 | use12hourTime = FALSE; | 350 | use12hourTime = FALSE; |
352 | 351 | ||
353 | _time = QDateTime::currentDateTime(); | 352 | _time = QDateTime::currentDateTime(); |
354 | hour = _time.time().hour(); | 353 | hour = _time.time().hour(); |
355 | minute = _time.time().minute(); | 354 | minute = _time.time().minute(); |
356 | 355 | ||
357 | QHBoxLayout *hb2 = new QHBoxLayout( this ); | 356 | QHBoxLayout *hb2 = new QHBoxLayout( this ); |
358 | hb2->setSpacing( 3 ); | 357 | hb2->setSpacing( 3 ); |
359 | 358 | ||
360 | QLabel *l = new QLabel( tr("Hour"), this ); | 359 | QLabel *l = new QLabel( tr("Hour"), this ); |
361 | // l->setAlignment( AlignRight | AlignVCenter ); | 360 | // l->setAlignment( AlignRight | AlignVCenter ); |
362 | hb2->addWidget( l ); | 361 | hb2->addWidget( l ); |
363 | 362 | ||
364 | sbHour = new QSpinBox( this ); | 363 | sbHour = new QSpinBox( this ); |
365 | sbHour->setMinimumWidth( 30 ); | 364 | sbHour->setMinimumWidth( 30 ); |
366 | if(use12hourTime) { | 365 | if(use12hourTime) { |
367 | sbHour->setMinValue(1); | 366 | sbHour->setMinValue(1); |
368 | sbHour->setMaxValue( 12 ); | 367 | sbHour->setMaxValue( 12 ); |
369 | int show_hour = hour; | 368 | int show_hour = hour; |
370 | if (hour > 12) | 369 | if (hour > 12) |
371 | show_hour -= 12; | 370 | show_hour -= 12; |
372 | if (show_hour == 0) | 371 | if (show_hour == 0) |
373 | show_hour = 12; | 372 | show_hour = 12; |
374 | 373 | ||
375 | sbHour->setValue( show_hour ); | 374 | sbHour->setValue( show_hour ); |
376 | } else { | 375 | } else { |
377 | sbHour->setMinValue( 0 ); | 376 | sbHour->setMinValue( 0 ); |
378 | sbHour->setMaxValue( 23 ); | 377 | sbHour->setMaxValue( 23 ); |
379 | sbHour->setValue( hour ); | 378 | sbHour->setValue( hour ); |
380 | } | 379 | } |
381 | sbHour->setWrapping(TRUE); | 380 | sbHour->setWrapping(TRUE); |
382 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); | 381 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); |
383 | hb2->addWidget( sbHour ); | 382 | hb2->addWidget( sbHour ); |
384 | 383 | ||
385 | hb2->addStretch( 1 ); | 384 | hb2->addStretch( 1 ); |
386 | 385 | ||
387 | l = new QLabel( tr("Minute"), this ); | 386 | l = new QLabel( tr("Minute"), this ); |
388 | //l->setAlignment( AlignRight | AlignVCenter ); | 387 | //l->setAlignment( AlignRight | AlignVCenter ); |
389 | hb2->addWidget( l ); | 388 | hb2->addWidget( l ); |
390 | 389 | ||
391 | sbMin = new QSpinBox( this ); | 390 | sbMin = new QSpinBox( this ); |
392 | sbMin->setMinValue( 0 ); | 391 | sbMin->setMinValue( 0 ); |
393 | sbMin->setMaxValue( 59 ); | 392 | sbMin->setMaxValue( 59 ); |
394 | sbMin->setWrapping(TRUE); | 393 | sbMin->setWrapping(TRUE); |
395 | sbMin->setValue( minute ); | 394 | sbMin->setValue( minute ); |
396 | sbMin->setMinimumWidth( 30 ); | 395 | sbMin->setMinimumWidth( 30 ); |
397 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); | 396 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); |
398 | hb2->addWidget( sbMin ); | 397 | hb2->addWidget( sbMin ); |
399 | 398 | ||
400 | hb2->addStretch( 1 ); | 399 | hb2->addStretch( 1 ); |
401 | 400 | ||
402 | ampm = new QComboBox( this ); | 401 | ampm = new QComboBox( this ); |
403 | ampm->insertItem( tr("AM"), ValueAM ); | 402 | ampm->insertItem( tr("AM"), ValueAM ); |
404 | ampm->insertItem( tr("PM"), ValuePM ); | 403 | ampm->insertItem( tr("PM"), ValuePM ); |
405 | connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); | 404 | connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); |
406 | hb2->addWidget( ampm ); | 405 | hb2->addWidget( ampm ); |
407 | 406 | ||
408 | hb2->addStretch( 1 ); | 407 | hb2->addStretch( 1 ); |
409 | 408 | ||
410 | } | 409 | } |
411 | 410 | ||
412 | QTime SetTime::time() const | 411 | QTime SetTime::time() const |
413 | { | 412 | { |
414 | return QTime( hour, minute, 0 ); | 413 | return QTime( hour, minute, 0 ); |
415 | } | 414 | } |
416 | 415 | ||
417 | void SetTime::hourChanged( int value ) | 416 | void SetTime::hourChanged( int value ) |
418 | { | 417 | { |
419 | if(use12hourTime) { | 418 | if(use12hourTime) { |
420 | int realhour = value; | 419 | int realhour = value; |
421 | if (realhour == 12) | 420 | if (realhour == 12) |
422 | realhour = 0; | 421 | realhour = 0; |
423 | if (ampm->currentItem() == ValuePM ) | 422 | if (ampm->currentItem() == ValuePM ) |
424 | realhour += 12; | 423 | realhour += 12; |
425 | hour = realhour; | 424 | hour = realhour; |
426 | } else | 425 | } else |
427 | hour = value; | 426 | hour = value; |
428 | } | 427 | } |
429 | 428 | ||
430 | void SetTime::minuteChanged( int value ) | 429 | void SetTime::minuteChanged( int value ) |
431 | { | 430 | { |
432 | minute = value; | 431 | minute = value; |
433 | } | 432 | } |
434 | 433 | ||
435 | void SetTime::show12hourTime( int on ) | 434 | void SetTime::show12hourTime( int on ) |
436 | { | 435 | { |
437 | use12hourTime = on; | 436 | use12hourTime = on; |
438 | ampm->setEnabled(on); | 437 | ampm->setEnabled(on); |
439 | 438 | ||
440 | int show_hour = hour; | 439 | int show_hour = hour; |
441 | if ( on ) { | 440 | if ( on ) { |
442 | /* this might change the value of hour */ | 441 | /* this might change the value of hour */ |
443 | sbHour->setMinValue(1); | 442 | sbHour->setMinValue(1); |
444 | sbHour->setMaxValue( 12 ); | 443 | sbHour->setMaxValue( 12 ); |
445 | 444 | ||
446 | /* so use one we saved earlier */ | 445 | /* so use one we saved earlier */ |
447 | if (show_hour >= 12) { | 446 | if (show_hour >= 12) { |
448 | show_hour -= 12; | 447 | show_hour -= 12; |
449 | ampm->setCurrentItem( ValuePM ); | 448 | ampm->setCurrentItem( ValuePM ); |
450 | } else { | 449 | } else { |
451 | ampm->setCurrentItem( ValueAM ); | 450 | ampm->setCurrentItem( ValueAM ); |
452 | } | 451 | } |
453 | if (show_hour == 0) | 452 | if (show_hour == 0) |
454 | show_hour = 12; | 453 | show_hour = 12; |
455 | 454 | ||
456 | } else { | 455 | } else { |
457 | sbHour->setMinValue( 0 ); | 456 | sbHour->setMinValue( 0 ); |
458 | sbHour->setMaxValue( 23 ); | 457 | sbHour->setMaxValue( 23 ); |
459 | } | 458 | } |
460 | 459 | ||
461 | 460 | ||
462 | sbHour->setValue( show_hour ); | 461 | sbHour->setValue( show_hour ); |
463 | } | 462 | } |
464 | 463 | ||
465 | void SetTime::checkedPM( int c ) | 464 | void SetTime::checkedPM( int c ) |
466 | { | 465 | { |
467 | int show_hour = sbHour->value(); | 466 | int show_hour = sbHour->value(); |
468 | if (show_hour == 12) | 467 | if (show_hour == 12) |
469 | show_hour = 0; | 468 | show_hour = 0; |
470 | 469 | ||
471 | if ( c == ValuePM ) | 470 | if ( c == ValuePM ) |
472 | show_hour += 12; | 471 | show_hour += 12; |
473 | 472 | ||
474 | hour = show_hour; | 473 | hour = show_hour; |
475 | } | 474 | } |
476 | 475 | ||
477 | void SetTime::slotTzChange( const QString &tz ) | 476 | void SetTime::slotTzChange( const QString &tz ) |
478 | { | 477 | { |
479 | // set the TZ get the time and leave gracefully... | 478 | // set the TZ get the time and leave gracefully... |
480 | QString strSave; | 479 | QString strSave; |
481 | strSave = getenv( "TZ" ); | 480 | strSave = getenv( "TZ" ); |
482 | setenv( "TZ", tz, 1 ); | 481 | setenv( "TZ", tz, 1 ); |
483 | 482 | ||
484 | QTime t = QTime::currentTime(); | 483 | QTime t = QTime::currentTime(); |
485 | // reset the time. | 484 | // reset the time. |
486 | if ( !strSave.isNull() ) { | 485 | if ( !strSave.isNull() ) { |
487 | setenv( "TZ", strSave, 1 ); | 486 | setenv( "TZ", strSave, 1 ); |
488 | } | 487 | } |
489 | 488 | ||
490 | // just set the spinboxes and let it propage through | 489 | // just set the spinboxes and let it propage through |
491 | if(use12hourTime) { | 490 | if(use12hourTime) { |
492 | int show_hour = t.hour(); | 491 | int show_hour = t.hour(); |
493 | if (t.hour() >= 12) { | 492 | if (t.hour() >= 12) { |
494 | show_hour -= 12; | 493 | show_hour -= 12; |
495 | ampm->setCurrentItem( ValuePM ); | 494 | ampm->setCurrentItem( ValuePM ); |
496 | } else { | 495 | } else { |
497 | ampm->setCurrentItem( ValueAM ); | 496 | ampm->setCurrentItem( ValueAM ); |
498 | } | 497 | } |
499 | if (show_hour == 0) | 498 | if (show_hour == 0) |
500 | show_hour = 12; | 499 | show_hour = 12; |
501 | sbHour->setValue( show_hour ); | 500 | sbHour->setValue( show_hour ); |
502 | } else { | 501 | } else { |
503 | sbHour->setValue( t.hour() ); | 502 | sbHour->setValue( t.hour() ); |
504 | } | 503 | } |
505 | sbMin->setValue( t.minute() ); | 504 | sbMin->setValue( t.minute() ); |
506 | } | 505 | } |
507 | 506 | ||
508 | void SetTime::setTime( QDateTime dt ) | 507 | void SetTime::setTime( QDateTime dt ) |
509 | { | 508 | { |
510 | _time = dt; | 509 | _time = dt; |
511 | QTime t = dt.time(); | 510 | QTime t = dt.time(); |
512 | // just set the spinboxes and let it propage through | 511 | // just set the spinboxes and let it propage through |
513 | if(use12hourTime) { | 512 | if(use12hourTime) { |
514 | int show_hour = t.hour(); | 513 | int show_hour = t.hour(); |
515 | if (t.hour() >= 12) { | 514 | if (t.hour() >= 12) { |
516 | show_hour -= 12; | 515 | show_hour -= 12; |
517 | ampm->setCurrentItem( ValuePM ); | 516 | ampm->setCurrentItem( ValuePM ); |
518 | } else { | 517 | } else { |
519 | ampm->setCurrentItem( ValueAM ); | 518 | ampm->setCurrentItem( ValueAM ); |
520 | } | 519 | } |
521 | if (show_hour == 0) | 520 | if (show_hour == 0) |
522 | show_hour = 12; | 521 | show_hour = 12; |
523 | sbHour->setValue( show_hour ); | 522 | sbHour->setValue( show_hour ); |
524 | } else { | 523 | } else { |
525 | sbHour->setValue( t.hour() ); | 524 | sbHour->setValue( t.hour() ); |
526 | } | 525 | } |
527 | sbMin->setValue( t.minute() ); | 526 | sbMin->setValue( t.minute() ); |
528 | } | 527 | } |
529 | 528 | ||
530 | void SetTime::slotClockTick() | 529 | void SetTime::slotClockTick() |
531 | { | 530 | { |
532 | setTime( _time.addSecs(60) ); | 531 | setTime( _time.addSecs(60) ); |
533 | qDebug("SetTime::slotClockTick %s",_time.toString().latin1()); | 532 | qDebug("SetTime::slotClockTick %s",_time.toString().latin1()); |
534 | } | 533 | } |
diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h index 3c3a162..58d1006 100644 --- a/noncore/settings/netsystemtime/settime.h +++ b/noncore/settings/netsystemtime/settime.h | |||
@@ -1,102 +1,102 @@ | |||
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 | #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 | ||
30 | class QToolButton; | 30 | class QToolButton; |
31 | class QSpinBox; | 31 | class QSpinBox; |
32 | class QLabel; | 32 | class QLabel; |
33 | class TimeZoneSelector; | 33 | class TimeZoneSelector; |
34 | class DateBookMonth; | 34 | class DateBookMonth; |
35 | class QComboBox; | 35 | class QComboBox; |
36 | 36 | ||
37 | class SetTime : public QWidget | 37 | class SetTime : public QWidget |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
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 | void setTime( QDateTime ); | 44 | void setTime( QDateTime ); |
45 | 45 | ||
46 | public slots: | 46 | public slots: |
47 | void slotTzChange( const QString& tz ); | 47 | void slotTzChange( const QString& tz ); |
48 | void show12hourTime( int ); | 48 | void show12hourTime( int ); |
49 | 49 | ||
50 | protected slots: | 50 | protected slots: |
51 | void slotClockTick(); | 51 | void slotClockTick(); |
52 | void hourChanged( int value ); | 52 | void hourChanged( int value ); |
53 | void minuteChanged( int value ); | 53 | void minuteChanged( int value ); |
54 | 54 | ||
55 | void checkedPM( int ); | 55 | void checkedPM( int ); |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | int hour; | 58 | int hour; |
59 | int minute; | 59 | int minute; |
60 | bool use12hourTime; | 60 | bool use12hourTime; |
61 | QDateTime _time; | 61 | QDateTime _time; |
62 | QTimer *clock; | 62 | QTimer *clock; |
63 | QComboBox *ampm; | 63 | QComboBox *ampm; |
64 | QSpinBox *sbHour; | 64 | QSpinBox *sbHour; |
65 | QSpinBox *sbMin; | 65 | QSpinBox *sbMin; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | class DateButton; | 68 | class DateButton; |
69 | 69 | ||
70 | class SetDateTime : public NtpBase | 70 | class SetDateTime : public NtpBase |
71 | { | 71 | { |
72 | Q_OBJECT | 72 | Q_OBJECT |
73 | public: | 73 | public: |
74 | SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 ); | 74 | SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 ); |
75 | ~SetDateTime(); | 75 | ~SetDateTime(); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void commitTime(); | 78 | void commitTime(); |
79 | void tzChange( const QString &tz ); | 79 | void tzChange( const QString &tz ); |
80 | void formatChanged(int); | 80 | void formatChanged(int); |
81 | void updateSystem(); | 81 | void updateSystem(); |
82 | 82 | ||
83 | protected: | 83 | protected: |
84 | void setTime(QDateTime dt); | 84 | void setTime(QDateTime dt); |
85 | void writeSettings(); | 85 | void writeSettings(); |
86 | 86 | ||
87 | SetTime *timeButton; | 87 | SetTime *timeButton; |
88 | DateButton *dateButton; | 88 | DateButton *dateButton; |
89 | TimeZoneSelector *tz; | 89 | TimeZoneSelector *tz; |
90 | QString _oldTimeZone; | ||
90 | QComboBox *weekStartCombo; | 91 | QComboBox *weekStartCombo; |
91 | QComboBox *ampmCombo; | 92 | QComboBox *ampmCombo; |
92 | QComboBox *dateFormatCombo; | 93 | QComboBox *dateFormatCombo; |
93 | QComboBox *clockAppletCombo; | 94 | QComboBox *clockAppletCombo; |
94 | QPushButton *ButtonSetTime; | 95 | QPushButton *ButtonSetTime; |
95 | // QLabel *TextLabelMainPredTime; | ||
96 | 96 | ||
97 | DateFormat date_formats[4]; | 97 | DateFormat date_formats[4]; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | 100 | ||
101 | #endif | 101 | #endif |
102 | 102 | ||