author | tille <tille> | 2002-11-16 16:43:02 (UTC) |
---|---|---|
committer | tille <tille> | 2002-11-16 16:43:02 (UTC) |
commit | 0633fb26123857509c9eb0e0a013b654667ca9ce (patch) (unidiff) | |
tree | 9187213cc22830c65dcba1923be9a8355c673b5a /noncore | |
parent | 88435a3192f09453e035a7f1cf73bbc8c24245c9 (diff) | |
download | opie-0633fb26123857509c9eb0e0a013b654667ca9ce.zip opie-0633fb26123857509c9eb0e0a013b654667ca9ce.tar.gz opie-0633fb26123857509c9eb0e0a013b654667ca9ce.tar.bz2 |
usability:
made it a dialog that saves when exiting
clock now running
-rw-r--r-- | noncore/settings/netsystemtime/TODO | 3 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/main.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 36 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.h | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntpbase.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntpbase.h | 9 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntpbase.ui | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 116 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.h | 8 |
9 files changed, 121 insertions, 69 deletions
diff --git a/noncore/settings/netsystemtime/TODO b/noncore/settings/netsystemtime/TODO new file mode 100644 index 0000000..fb003a2 --- a/dev/null +++ b/noncore/settings/netsystemtime/TODO | |||
@@ -0,0 +1,3 @@ | |||
1 | - handle hour > 24 in SetTime::slotClockTick | ||
2 | - improve tz setting | ||
3 | atm the tz gets written to the system as soon as changed... | ||
diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp index c6d5f9a..80fbcb8 100644 --- a/noncore/settings/netsystemtime/main.cpp +++ b/noncore/settings/netsystemtime/main.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include "ntp.h" | 2 | #include "ntp.h" |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | 4 | ||
5 | int main( int argc, char ** argv ) | 5 | int main( int argc, char ** argv ) |
6 | { | 6 | { |
7 | printf("This is netsystemtime\n"); | 7 | printf("This is netsystemtime "); |
8 | printf("$Id$\n"); | 8 | printf("$Id$\n"); |
9 | 9 | ||
10 | QPEApplication a( argc, argv ); | 10 | QPEApplication a( argc, argv ); |
11 | 11 | ||
12 | Ntp mw; | 12 | Ntp mw; |
13 | a.showMainWidget( &mw ); | 13 | a.showMainWidget( &mw ); |
14 | 14 | ||
15 | return a.exec(); | 15 | return a.exec(); |
16 | } | 16 | } |
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index c7e3b52..53dbe46 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -47,25 +47,24 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
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( tabManualSetTime, tr( "Manual" ) ); | ||
60 | TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) ); | 59 | TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) ); |
61 | TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) ); | 60 | TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) ); |
62 | TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) ); | 61 | TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) ); |
63 | NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 ); | 62 | NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 ); |
64 | 63 | ||
65 | 64 | ||
66 | 65 | ||
67 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); | 66 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); |
68 | showAdvancedFeatures(advMode); | 67 | showAdvancedFeatures(advMode); |
69 | CheckBoxAdvSettings->setChecked( advMode ); | 68 | CheckBoxAdvSettings->setChecked( advMode ); |
70 | connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), | 69 | connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), |
71 | SLOT( showAdvancedFeatures( bool ) ) ); | 70 | SLOT( showAdvancedFeatures( bool ) ) ); |
@@ -87,24 +86,27 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
87 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), | 86 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), |
88 | this, SLOT(ntpFinished(OProcess*))); | 87 | this, SLOT(ntpFinished(OProcess*))); |
89 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp())); | 88 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp())); |
90 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); | 89 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); |
91 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); | 90 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); |
92 | slotCheckNtp(-1); | 91 | slotCheckNtp(-1); |
93 | readLookups(); | 92 | readLookups(); |
94 | } | 93 | } |
95 | 94 | ||
96 | Ntp::~Ntp() | 95 | Ntp::~Ntp() |
97 | { | 96 | { |
98 | delete ntpProcess; | 97 | delete ntpProcess; |
98 | } | ||
99 | |||
100 | void Ntp::saveConfig(){ | ||
99 | int srvCount = ComboNtpSrv->count(); | 101 | int srvCount = ComboNtpSrv->count(); |
100 | bool serversChanged = true; | 102 | bool serversChanged = true; |
101 | QString edit = ComboNtpSrv->currentText(); | 103 | QString edit = ComboNtpSrv->currentText(); |
102 | for (int i = 0; i < srvCount; i++){ | 104 | for (int i = 0; i < srvCount; i++){ |
103 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; | 105 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; |
104 | } | 106 | } |
105 | if (serversChanged){ | 107 | if (serversChanged){ |
106 | Config ntpSrvs("/etc/ntpservers",Config::File); | 108 | Config ntpSrvs("/etc/ntpservers",Config::File); |
107 | ntpSrvs.setGroup("servers"); | 109 | ntpSrvs.setGroup("servers"); |
108 | ntpSrvs.writeEntry("count", srvCount); | 110 | ntpSrvs.writeEntry("count", srvCount); |
109 | for (int i = 0; i < srvCount; i++){ | 111 | for (int i = 0; i < srvCount; i++){ |
110 | qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1()); | 112 | qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1()); |
@@ -190,39 +192,29 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) | |||
190 | _ntpOutput += lineStr; | 192 | _ntpOutput += lineStr; |
191 | } | 193 | } |
192 | lineStrOld = lineStr; | 194 | lineStrOld = lineStr; |
193 | } | 195 | } |
194 | 196 | ||
195 | void Ntp::ntpFinished(OProcess *p) | 197 | void Ntp::ntpFinished(OProcess *p) |
196 | { | 198 | { |
197 | qDebug("p->exitStatus() %i",p->exitStatus()); | 199 | qDebug("p->exitStatus() %i",p->exitStatus()); |
198 | if (p->exitStatus()!=0 || !p->normalExit()) | 200 | if (p->exitStatus()!=0 || !p->normalExit()) |
199 | { | 201 | { |
200 | if ( isVisible() && _interactive ){ | 202 | if ( isVisible() && _interactive ){ |
201 | 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 ); |
202 | TabWidgetMain->showPage( tabManualSetTime ); | ||
203 | } | 204 | } |
204 | 205 | // slotCheckNtp(-1); | |
205 | return; | 206 | return; |
206 | } | 207 | } |
207 | 208 | ||
208 | Global::writeHWClock(); | ||
209 | // since time has changed quickly load in the datebookdb | ||
210 | // to allow the alarm server to get a better grip on itself | ||
211 | // (example re-trigger alarms for when we travel back in time) | ||
212 | DateBookDB db; | ||
213 | |||
214 | // QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); | ||
215 | // timeApplet << ""; | ||
216 | |||
217 | Config cfg("ntp",Config::User); | 209 | Config cfg("ntp",Config::User); |
218 | cfg.setGroup("lookups"); | 210 | cfg.setGroup("lookups"); |
219 | int lastLookup = cfg.readNumEntry("time",0); | 211 | int lastLookup = cfg.readNumEntry("time",0); |
220 | int lookupCount = cfg.readNumEntry("count",0); | 212 | int lookupCount = cfg.readNumEntry("count",0); |
221 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); | 213 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); |
222 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 214 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
223 | cfg.writeEntry("time", time); | 215 | cfg.writeEntry("time", time); |
224 | 216 | ||
225 | float timeShift = getTimeShift(); | 217 | float timeShift = getTimeShift(); |
226 | if (timeShift == 0.0) return; | 218 | if (timeShift == 0.0) return; |
227 | int secsSinceLast = time - lastLookup; | 219 | int secsSinceLast = time - lastLookup; |
228 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); | 220 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); |
@@ -297,38 +289,40 @@ void Ntp::readLookups() | |||
297 | void Ntp::preditctTime() | 289 | void Ntp::preditctTime() |
298 | { | 290 | { |
299 | Config cfg("ntp",Config::User); | 291 | Config cfg("ntp",Config::User); |
300 | cfg.setGroup("lookups"); | 292 | cfg.setGroup("lookups"); |
301 | int lastTime = cfg.readNumEntry("time",0); | 293 | int lastTime = cfg.readNumEntry("time",0); |
302 | cfg.writeEntry("lastNtp",true); | 294 | cfg.writeEntry("lastNtp",true); |
303 | setenv( "TZ", tz->currentZone(), 1 ); | 295 | setenv( "TZ", tz->currentZone(), 1 ); |
304 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 296 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
305 | int corr = int((now - lastTime) * _shiftPerSec); | 297 | int corr = int((now - lastTime) * _shiftPerSec); |
306 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); | 298 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); |
307 | predictedTime = QDateTime::currentDateTime().addSecs(corr); | 299 | predictedTime = QDateTime::currentDateTime().addSecs(corr); |
308 | TextLabelPredTime->setText(predictedTime.toString()); | 300 | TextLabelPredTime->setText(predictedTime.toString()); |
309 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); | 301 | // TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); |
310 | } | 302 | } |
311 | 303 | ||
312 | void Ntp::setPredictTime() | 304 | void Ntp::setPredictTime() |
313 | { | 305 | { |
306 | qDebug("Ntp::setPredictTime"); | ||
314 | preditctTime(); | 307 | preditctTime(); |
315 | setTime( predictedTime ); | 308 | timeButton->setTime( predictedTime ); |
316 | } | 309 | } |
317 | 310 | ||
318 | void Ntp::slotCheckNtp(int i) | 311 | void Ntp::slotCheckNtp(int i) |
319 | { | 312 | { |
313 | qDebug(" Ntp::slotCheckNtp(%i)",i); | ||
320 | if (i == 0) | 314 | if (i == 0) |
321 | { | 315 | { |
322 | TextLabelMainPredTime->hide(); | 316 | // TextLabelMainPredTime->hide(); |
323 | ButtonSetTime->setText( tr("Get time from network") ); | 317 | ButtonSetTime->setText( tr("Get time from network") ); |
324 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); | 318 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); |
325 | if ( ntpDelayElapsed() ) | 319 | if ( ntpDelayElapsed() ) |
326 | { | 320 | { |
327 | slotRunNtp(); | 321 | slotRunNtp(); |
328 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); | 322 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); |
329 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); | 323 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); |
330 | }else{ | 324 | }else{ |
331 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); | 325 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); |
332 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 326 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
333 | } | 327 | } |
334 | }else{ | 328 | }else{ |
@@ -409,12 +403,24 @@ void Ntp::showAdvancedFeatures(bool advMode) | |||
409 | TextLabel1_2_2->hide(); | 403 | TextLabel1_2_2->hide(); |
410 | TextLabel2_3->hide(); | 404 | TextLabel2_3->hide(); |
411 | TextLabel3_3_2->hide(); | 405 | TextLabel3_3_2->hide(); |
412 | TextLabel1_2->hide(); | 406 | TextLabel1_2->hide(); |
413 | SpinBoxMinLookupDelay->hide(); | 407 | SpinBoxMinLookupDelay->hide(); |
414 | TextLabel2->hide(); | 408 | TextLabel2->hide(); |
415 | TextLabel3_3->hide(); | 409 | TextLabel3_3->hide(); |
416 | SpinBoxNtpDelay->hide(); | 410 | SpinBoxNtpDelay->hide(); |
417 | Line1->hide(); | 411 | Line1->hide(); |
418 | }; | 412 | }; |
419 | TabWidgetMain->show(); | 413 | TabWidgetMain->show(); |
420 | } | 414 | } |
415 | |||
416 | |||
417 | void Ntp::accept( ){ | ||
418 | qDebug("accepted"); | ||
419 | //SetTimeDate | ||
420 | commitTime(); | ||
421 | writeSettings(); | ||
422 | updateSystem(); | ||
423 | // Ntp | ||
424 | saveConfig(); | ||
425 | qApp->quit(); | ||
426 | } \ No newline at end of file | ||
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h index 15cddbd..a4573f8 100644 --- a/noncore/settings/netsystemtime/ntp.h +++ b/noncore/settings/netsystemtime/ntp.h | |||
@@ -11,42 +11,44 @@ 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 | QDateTime predictedTime; | 24 | QDateTime predictedTime; |
24 | void makeChannel(); | 25 | void makeChannel(); |
25 | protected slots: | 26 | protected slots: |
26 | void receive(const QCString &msg, const QByteArray &arg); | 27 | void receive(const QCString &msg, const QByteArray &arg); |
27 | private: | 28 | private: |
28 | QString _ntpOutput; | 29 | QString _ntpOutput; |
29 | float _shiftPerSec; | 30 | float _shiftPerSec; |
30 | int _lookupDiff; | 31 | int _lookupDiff; |
31 | OProcess *ntpProcess; | 32 | OProcess *ntpProcess; |
32 | QTimer *ntpTimer; | 33 | QTimer *ntpTimer; |
33 | QSocket *ntpSock; | 34 | QSocket *ntpSock; |
34 | QCopChannel *channel; | 35 | QCopChannel *channel; |
35 | bool _interactive; | 36 | bool _interactive; |
36 | float getTimeShift(); | 37 | float getTimeShift(); |
37 | void readLookups(); | 38 | void readLookups(); |
38 | void ntpOutPut(QString); | 39 | void ntpOutPut(QString); |
39 | bool ntpDelayElapsed(); | 40 | bool ntpDelayElapsed(); |
40 | QString getNtpServer(); | 41 | QString getNtpServer(); |
42 | void saveConfig(); | ||
41 | private slots: | 43 | private slots: |
42 | void slotTimerRunNtp(); | 44 | void slotTimerRunNtp(); |
43 | void slotButtonRunNtp(); | 45 | void slotButtonRunNtp(); |
44 | void slotRunNtp(); | 46 | void slotRunNtp(); |
45 | void getNtpOutput(OProcess *proc, char *buffer, int buflen); | 47 | void getNtpOutput(OProcess *proc, char *buffer, int buflen); |
46 | void ntpFinished(OProcess*); | 48 | void ntpFinished(OProcess*); |
47 | void preditctTime(); | 49 | void preditctTime(); |
48 | void slotCheckNtp(int); | 50 | void slotCheckNtp(int); |
49 | void setPredictTime(); | 51 | void setPredictTime(); |
50 | void showAdvancedFeatures(bool); | 52 | void showAdvancedFeatures(bool); |
51 | void slotProbeNtpServer(); | 53 | void slotProbeNtpServer(); |
52 | void slotNtpDelayChanged(int); | 54 | void slotNtpDelayChanged(int); |
diff --git a/noncore/settings/netsystemtime/ntpbase.cpp b/noncore/settings/netsystemtime/ntpbase.cpp index 0a7a57e..878c158 100644 --- a/noncore/settings/netsystemtime/ntpbase.cpp +++ b/noncore/settings/netsystemtime/ntpbase.cpp | |||
@@ -1,42 +1,46 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'ntpbase.ui' | 2 | ** Form implementation generated from reading ui file 'ntpbase.ui' |
3 | ** | 3 | ** |
4 | ** Created: Sun Nov 10 17:59:14 2002 | 4 | ** Created: Sat Nov 16 15:49:54 2002 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "ntpbase.h" | 9 | #include "ntpbase.h" |
10 | 10 | ||
11 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qframe.h> | 13 | #include <qframe.h> |
14 | #include <qlabel.h> | 14 | #include <qlabel.h> |
15 | #include <qmultilineedit.h> | 15 | #include <qmultilineedit.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | #include <qspinbox.h> | 17 | #include <qspinbox.h> |
18 | #include <qtable.h> | 18 | #include <qtable.h> |
19 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
20 | #include <qwidget.h> | ||
20 | #include <qlayout.h> | 21 | #include <qlayout.h> |
21 | #include <qvariant.h> | 22 | #include <qvariant.h> |
22 | #include <qtooltip.h> | 23 | #include <qtooltip.h> |
23 | #include <qwhatsthis.h> | 24 | #include <qwhatsthis.h> |
24 | 25 | ||
25 | /* | 26 | /* |
26 | * Constructs a NtpBase which is a child of 'parent', with the | 27 | * Constructs a NtpBase which is a child of 'parent', with the |
27 | * name 'name' and widget flags set to 'f' | 28 | * name 'name' and widget flags set to 'f' |
29 | * | ||
30 | * The dialog will by default be modeless, unless you set 'modal' to | ||
31 | * TRUE to construct a modal dialog. | ||
28 | */ | 32 | */ |
29 | NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl ) | 33 | NtpBase::NtpBase( QWidget* parent, const char* name, bool modal, WFlags fl ) |
30 | : QWidget( parent, name, fl ) | 34 | : QDialog( parent, name, modal, fl ) |
31 | { | 35 | { |
32 | if ( !name ) | 36 | if ( !name ) |
33 | setName( "NtpBase" ); | 37 | setName( "NtpBase" ); |
34 | resize( 317, 411 ); | 38 | resize( 317, 411 ); |
35 | setCaption( tr( "Network Time" ) ); | 39 | setCaption( tr( "Network Time" ) ); |
36 | NtpBaseLayout = new QGridLayout( this ); | 40 | NtpBaseLayout = new QGridLayout( this ); |
37 | NtpBaseLayout->setSpacing( 2 ); | 41 | NtpBaseLayout->setSpacing( 2 ); |
38 | NtpBaseLayout->setMargin( 2 ); | 42 | NtpBaseLayout->setMargin( 2 ); |
39 | 43 | ||
40 | TabWidgetMain = new QTabWidget( this, "TabWidgetMain" ); | 44 | TabWidgetMain = new QTabWidget( this, "TabWidgetMain" ); |
41 | 45 | ||
42 | tabMain = new QWidget( TabWidgetMain, "tabMain" ); | 46 | tabMain = new QWidget( TabWidgetMain, "tabMain" ); |
@@ -308,24 +312,24 @@ NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl ) | |||
308 | */ | 312 | */ |
309 | NtpBase::~NtpBase() | 313 | NtpBase::~NtpBase() |
310 | { | 314 | { |
311 | // no need to delete child widgets, Qt does it all for us | 315 | // no need to delete child widgets, Qt does it all for us |
312 | } | 316 | } |
313 | 317 | ||
314 | /* | 318 | /* |
315 | * Main event handler. Reimplemented to handle application | 319 | * Main event handler. Reimplemented to handle application |
316 | * font changes | 320 | * font changes |
317 | */ | 321 | */ |
318 | bool NtpBase::event( QEvent* ev ) | 322 | bool NtpBase::event( QEvent* ev ) |
319 | { | 323 | { |
320 | bool ret = QWidget::event( ev ); | 324 | bool ret = QDialog::event( ev ); |
321 | if ( ev->type() == QEvent::ApplicationFontChange ) { | 325 | if ( ev->type() == QEvent::ApplicationFontChange ) { |
322 | QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() ); | 326 | QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() ); |
323 | MultiLineEditntpOutPut_font.setPointSize( 7 ); | 327 | MultiLineEditntpOutPut_font.setPointSize( 7 ); |
324 | MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font ); | 328 | MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font ); |
325 | QFont TableLookups_font( TableLookups->font() ); | 329 | QFont TableLookups_font( TableLookups->font() ); |
326 | TableLookups_font.setPointSize( 8 ); | 330 | TableLookups_font.setPointSize( 8 ); |
327 | TableLookups->setFont( TableLookups_font ); | 331 | TableLookups->setFont( TableLookups_font ); |
328 | } | 332 | } |
329 | return ret; | 333 | return ret; |
330 | } | 334 | } |
331 | 335 | ||
diff --git a/noncore/settings/netsystemtime/ntpbase.h b/noncore/settings/netsystemtime/ntpbase.h index 543cac1..68599c9 100644 --- a/noncore/settings/netsystemtime/ntpbase.h +++ b/noncore/settings/netsystemtime/ntpbase.h | |||
@@ -1,44 +1,45 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'ntpbase.ui' | 2 | ** Form interface generated from reading ui file 'ntpbase.ui' |
3 | ** | 3 | ** |
4 | ** Created: Sun Nov 10 17:58:48 2002 | 4 | ** Created: Sat Nov 16 15:49:32 2002 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef NTPBASE_H | 9 | #ifndef NTPBASE_H |
10 | #define NTPBASE_H | 10 | #define NTPBASE_H |
11 | 11 | ||
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | #include <qwidget.h> | 13 | #include <qdialog.h> |
14 | class QVBoxLayout; | 14 | class QVBoxLayout; |
15 | class QHBoxLayout; | 15 | class QHBoxLayout; |
16 | class QGridLayout; | 16 | class QGridLayout; |
17 | class QCheckBox; | 17 | class QCheckBox; |
18 | class QComboBox; | 18 | class QComboBox; |
19 | class QFrame; | 19 | class QFrame; |
20 | class QLabel; | 20 | class QLabel; |
21 | class QMultiLineEdit; | 21 | class QMultiLineEdit; |
22 | class QPushButton; | 22 | class QPushButton; |
23 | class QSpinBox; | 23 | class QSpinBox; |
24 | class QTabWidget; | 24 | class QTabWidget; |
25 | class QTable; | 25 | class QTable; |
26 | class QWidget; | ||
26 | 27 | ||
27 | class NtpBase : public QWidget | 28 | class NtpBase : public QDialog |
28 | { | 29 | { |
29 | Q_OBJECT | 30 | Q_OBJECT |
30 | 31 | ||
31 | public: | 32 | public: |
32 | NtpBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 33 | NtpBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
33 | ~NtpBase(); | 34 | ~NtpBase(); |
34 | 35 | ||
35 | QTabWidget* TabWidgetMain; | 36 | QTabWidget* TabWidgetMain; |
36 | QWidget* tabMain; | 37 | QWidget* tabMain; |
37 | QFrame* FrameSystemTime; | 38 | QFrame* FrameSystemTime; |
38 | QWidget* tabNtp; | 39 | QWidget* tabNtp; |
39 | QPushButton* runNtp; | 40 | QPushButton* runNtp; |
40 | QWidget* FrameNtp; | 41 | QWidget* FrameNtp; |
41 | QLabel* TextLabel1; | 42 | QLabel* TextLabel1; |
42 | QLabel* TextLabelStartTime; | 43 | QLabel* TextLabelStartTime; |
43 | QLabel* TextLabel3; | 44 | QLabel* TextLabel3; |
44 | QLabel* TextLabelTimeShift; | 45 | QLabel* TextLabelTimeShift; |
diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui index 6c38588..8c106be 100644 --- a/noncore/settings/netsystemtime/ntpbase.ui +++ b/noncore/settings/netsystemtime/ntpbase.ui | |||
@@ -1,16 +1,16 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>NtpBase</class> | 2 | <class>NtpBase</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>NtpBase</cstring> | 7 | <cstring>NtpBase</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>317</width> | 14 | <width>317</width> |
15 | <height>411</height> | 15 | <height>411</height> |
16 | </rect> | 16 | </rect> |
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 949fcb3..36166ae 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -26,78 +26,84 @@ | |||
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 <qbuttongroup.h> | 39 | #include <qbuttongroup.h> |
39 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
40 | #include <qlabel.h> | 41 | #include <qlabel.h> |
41 | #include <qlayout.h> | 42 | #include <qlayout.h> |
42 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
43 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
44 | #include <qtoolbutton.h> | 45 | #include <qtoolbutton.h> |
45 | #include <qwindowsystem_qws.h> | 46 | #include <qwindowsystem_qws.h> |
46 | #include <qcombobox.h> | 47 | #include <qcombobox.h> |
47 | 48 | ||
48 | #include <sys/time.h> | 49 | #include <sys/time.h> |
49 | #include <time.h> | 50 | #include <time.h> |
50 | #include <stdlib.h> | 51 | #include <stdlib.h> |
51 | #include <stdio.h> | 52 | #include <stdio.h> |
52 | 53 | ||
53 | 54 | ||
54 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | 55 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) |
55 | : NtpBase( parent, name, f ) | 56 | : NtpBase( parent, name, true, f ) |
56 | { | 57 | { |
57 | // setCaption( tr("Set System Time") ); | 58 | setCaption( tr("System Time") ); |
58 | 59 | ||
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 ); | ||
62 | 61 | ||
63 | TextLabelMainPredTime = new QLabel( FrameSystemTime ); | 62 | // TextLabelMainPredTime = new QLabel( FrameSystemTime ); |
64 | vb->addWidget( TextLabelMainPredTime, 1, 0 ); | 63 | // vb->addWidget( TextLabelMainPredTime, 1, 0 ); |
64 | |||
65 | timeButton = new SetTime( FrameSystemTime ); | ||
66 | vb->addWidget( timeButton ); | ||
67 | |||
68 | QHBoxLayout *db = new QHBoxLayout( vb ); | ||
69 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSystemTime ); | ||
70 | db->addWidget( dateLabel, 1 ); | ||
71 | dateButton = new DateButton( TRUE, FrameSystemTime ); | ||
72 | db->addWidget( dateButton, 2 ); | ||
73 | |||
74 | ButtonSetTime = new QPushButton( FrameSystemTime ); | ||
75 | vb->addWidget( ButtonSetTime, 1, 0 ); | ||
76 | |||
77 | QFrame *hline = new QFrame( FrameSystemTime ); | ||
78 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | ||
79 | vb->addWidget( hline ); | ||
65 | 80 | ||
66 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); | 81 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); |
67 | 82 | ||
68 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); | 83 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); |
69 | lblZone->setMaximumSize( lblZone->sizeHint() ); | 84 | lblZone->setMaximumSize( lblZone->sizeHint() ); |
70 | hb->addWidget( lblZone ); | 85 | hb->addWidget( lblZone ); |
71 | 86 | ||
72 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); | 87 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); |
73 | tz->setMinimumSize( tz->sizeHint() ); | 88 | tz->setMinimumSize( tz->sizeHint() ); |
74 | hb->addWidget( tz ); | 89 | hb->addWidget( tz ); |
75 | 90 | ||
76 | timeButton = new SetTime( FrameSetTime ); | 91 | hline = new QFrame( FrameSystemTime ); |
77 | vb2->addWidget( timeButton ); | ||
78 | |||
79 | QHBoxLayout *db = new QHBoxLayout( vb2 ); | ||
80 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); | ||
81 | db->addWidget( dateLabel, 1 ); | ||
82 | dateButton = new DateButton( TRUE, FrameSetTime ); | ||
83 | db->addWidget( dateButton, 2 ); | ||
84 | |||
85 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
86 | vb2->addItem( spacer ); | ||
87 | |||
88 | QFrame *hline = new QFrame( FrameSystemTime ); | ||
89 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 92 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
90 | vb->addWidget( hline ); | 93 | vb->addWidget( hline ); |
91 | 94 | ||
95 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
96 | vb->addItem( spacer ); | ||
97 | |||
92 | Config config("qpe"); | 98 | Config config("qpe"); |
93 | config.setGroup( "Time" ); | 99 | config.setGroup( "Time" ); |
94 | 100 | ||
95 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); | 101 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); |
96 | 102 | ||
97 | QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); | 103 | QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); |
98 | hb1->addWidget( l, 1 ); | 104 | hb1->addWidget( l, 1 ); |
99 | 105 | ||
100 | 106 | ||
101 | ampmCombo = new QComboBox( FrameSystemTime ); | 107 | ampmCombo = new QComboBox( FrameSystemTime ); |
102 | ampmCombo->insertItem( tr("24 hour"), 0 ); | 108 | ampmCombo->insertItem( tr("24 hour"), 0 ); |
103 | ampmCombo->insertItem( tr("12 hour"), 1 ); | 109 | ampmCombo->insertItem( tr("12 hour"), 1 ); |
@@ -170,53 +176,49 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | |||
170 | 176 | ||
171 | clockAppletCombo = new QComboBox( FrameSystemTime ); | 177 | clockAppletCombo = new QComboBox( FrameSystemTime ); |
172 | clockAppletCombo->insertItem( tr("hh:mm"), 0 ); | 178 | clockAppletCombo->insertItem( tr("hh:mm"), 0 ); |
173 | clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); | 179 | clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); |
174 | clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); | 180 | clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); |
175 | 181 | ||
176 | hb4->addWidget( clockAppletCombo, 2 ); | 182 | hb4->addWidget( clockAppletCombo, 2 ); |
177 | int clockApplet = config.readNumEntry("ClockApplet",0); | 183 | int clockApplet = config.readNumEntry("ClockApplet",0); |
178 | clockAppletCombo->setCurrentItem( clockApplet ); | 184 | clockAppletCombo->setCurrentItem( clockApplet ); |
179 | 185 | ||
180 | vb->addStretch( 0 ); | 186 | vb->addStretch( 0 ); |
181 | 187 | ||
182 | hline = new QFrame( FrameSystemTime ); | 188 | // hline = new QFrame( FrameSystemTime ); |
183 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 189 | // hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
184 | vb->addWidget( hline ); | 190 | // vb->addWidget( hline ); |
185 | 191 | // | |
186 | ButtonSetTime = new QPushButton( FrameSystemTime ); | 192 | // ButtonSetTime = new QPushButton( FrameSystemTime ); |
187 | vb->addWidget( ButtonSetTime, 1, 0 ); | 193 | // vb->addWidget( ButtonSetTime, 1, 0 ); |
188 | 194 | ||
189 | QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), | ||
190 | this, SLOT(commitTime())); | ||
191 | 195 | ||
192 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 196 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
193 | timeButton, SLOT( slotTzChange( const QString& ) ) ); | 197 | timeButton, SLOT( slotTzChange( const QString& ) ) ); |
194 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 198 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
195 | SLOT( tzChange( const QString& ) ) ); | 199 | SLOT( tzChange( const QString& ) ) ); |
196 | 200 | ||
197 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), | 201 | // QObject::connect( weekStartCombo, SIGNAL( activated ( int )), |
198 | SLOT(updateSystem(int ) )); | 202 | // SLOT(updateSystem(int ) )); |
199 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), | 203 | // QObject::connect( ampmCombo, SIGNAL( activated ( int )), |
200 | SLOT(updateSystem(int ) )); | 204 | // SLOT(updateSystem(int ) )); |
201 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), | 205 | // QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), |
202 | SLOT(updateSystem(int ) )); | 206 | // SLOT(updateSystem(int ) )); |
203 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), | 207 | // QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), |
204 | SLOT(updateSystem(int ) )); | 208 | // SLOT(updateSystem(int ) )); |
205 | } | 209 | } |
206 | 210 | ||
207 | SetDateTime::~SetDateTime() | 211 | SetDateTime::~SetDateTime() |
208 | { | 212 | { |
209 | writeSettings(); | ||
210 | |||
211 | } | 213 | } |
212 | 214 | ||
213 | void SetDateTime::writeSettings() | 215 | void SetDateTime::writeSettings() |
214 | { | 216 | { |
215 | Config config("qpe"); | 217 | Config config("qpe"); |
216 | config.setGroup( "Time" ); | 218 | config.setGroup( "Time" ); |
217 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); | 219 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); |
218 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); | 220 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); |
219 | config.setGroup( "Date" ); | 221 | config.setGroup( "Date" ); |
220 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; | 222 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; |
221 | config.writeEntry( "Separator", QString(df.separator())); | 223 | config.writeEntry( "Separator", QString(df.separator())); |
222 | config.writeEntry( "ShortOrder", df.shortOrder()); | 224 | config.writeEntry( "ShortOrder", df.shortOrder()); |
@@ -267,33 +269,33 @@ void SetDateTime::setTime(QDateTime dt) | |||
267 | Global::writeHWClock(); | 269 | Global::writeHWClock(); |
268 | // since time has changed quickly load in the datebookdb | 270 | // since time has changed quickly load in the datebookdb |
269 | // 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 |
270 | // (example re-trigger alarms for when we travel back in time) | 272 | // (example re-trigger alarms for when we travel back in time) |
271 | DateBookDB db; | 273 | DateBookDB db; |
272 | //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); | 274 | //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); |
273 | //timeApplet << ""; | 275 | //timeApplet << ""; |
274 | // Restore screensaver | 276 | // Restore screensaver |
275 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 277 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
276 | enableScreenSaver << -1 << -1 << -1; | 278 | enableScreenSaver << -1 << -1 << -1; |
277 | } | 279 | } |
278 | 280 | ||
279 | void SetDateTime::updateSystem(int i) | 281 | void SetDateTime::updateSystem() |
280 | { | 282 | { |
281 | // really turn off the screensaver before doing anything | 283 | // really turn off the screensaver before doing anything |
282 | { | 284 | { |
283 | // Needs to be encased in { } so that it deconstructs and sends | 285 | // Needs to be encased in { } so that it deconstructs and sends |
284 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 286 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
285 | disableScreenSaver << 0 << 0 << 0; | 287 | disableScreenSaver << 0 << 0 << 0; |
286 | } | 288 | } |
287 | qDebug("SetDateTime::updateSystem(int %i)",i); | 289 | qDebug("SetDateTime::updateSystem()"); |
288 | writeSettings(); | 290 | writeSettings(); |
289 | 291 | ||
290 | // set the timezone for everyone else... | 292 | // set the timezone for everyone else... |
291 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 293 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
292 | setTimeZone << tz->currentZone(); | 294 | setTimeZone << tz->currentZone(); |
293 | 295 | ||
294 | // AM/PM setting and notify time changed | 296 | // AM/PM setting and notify time changed |
295 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 297 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
296 | setClock << ampmCombo->currentItem(); | 298 | setClock << ampmCombo->currentItem(); |
297 | 299 | ||
298 | // Notify everyone what day we prefer to start the week on. | 300 | // Notify everyone what day we prefer to start the week on. |
299 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 301 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
@@ -333,29 +335,33 @@ void SetDateTime::formatChanged(int i) | |||
333 | { | 335 | { |
334 | dateButton->setDateFormat(date_formats[i]); | 336 | dateButton->setDateFormat(date_formats[i]); |
335 | } | 337 | } |
336 | 338 | ||
337 | static const int ValueAM = 0; | 339 | static const int ValueAM = 0; |
338 | static const int ValuePM = 1; | 340 | static const int ValuePM = 1; |
339 | 341 | ||
340 | 342 | ||
341 | 343 | ||
342 | SetTime::SetTime( QWidget *parent, const char *name ) | 344 | SetTime::SetTime( QWidget *parent, const char *name ) |
343 | : QWidget( parent, name ) | 345 | : QWidget( parent, name ) |
344 | { | 346 | { |
347 | clock = new QTimer(this, "clock" ); | ||
348 | connect(clock, SIGNAL( timeout() ), SLOT(slotClockTick()) ); | ||
349 | clock->start( 1000 * 60 ); | ||
350 | |||
345 | use12hourTime = FALSE; | 351 | use12hourTime = FALSE; |
346 | 352 | ||
347 | QTime currTime = QTime::currentTime(); | 353 | _time = QDateTime::currentDateTime(); |
348 | hour = currTime.hour(); | 354 | hour = _time.time().hour(); |
349 | minute = currTime.minute(); | 355 | minute = _time.time().minute(); |
350 | 356 | ||
351 | QHBoxLayout *hb2 = new QHBoxLayout( this ); | 357 | QHBoxLayout *hb2 = new QHBoxLayout( this ); |
352 | hb2->setSpacing( 3 ); | 358 | hb2->setSpacing( 3 ); |
353 | 359 | ||
354 | QLabel *l = new QLabel( tr("Hour"), this ); | 360 | QLabel *l = new QLabel( tr("Hour"), this ); |
355 | // l->setAlignment( AlignRight | AlignVCenter ); | 361 | // l->setAlignment( AlignRight | AlignVCenter ); |
356 | hb2->addWidget( l ); | 362 | hb2->addWidget( l ); |
357 | 363 | ||
358 | sbHour = new QSpinBox( this ); | 364 | sbHour = new QSpinBox( this ); |
359 | sbHour->setMinimumWidth( 30 ); | 365 | sbHour->setMinimumWidth( 30 ); |
360 | if(use12hourTime) { | 366 | if(use12hourTime) { |
361 | sbHour->setMinValue(1); | 367 | sbHour->setMinValue(1); |
@@ -490,13 +496,39 @@ void SetTime::slotTzChange( const QString &tz ) | |||
490 | } else { | 496 | } else { |
491 | ampm->setCurrentItem( ValueAM ); | 497 | ampm->setCurrentItem( ValueAM ); |
492 | } | 498 | } |
493 | if (show_hour == 0) | 499 | if (show_hour == 0) |
494 | show_hour = 12; | 500 | show_hour = 12; |
495 | sbHour->setValue( show_hour ); | 501 | sbHour->setValue( show_hour ); |
496 | } else { | 502 | } else { |
497 | sbHour->setValue( t.hour() ); | 503 | sbHour->setValue( t.hour() ); |
498 | } | 504 | } |
499 | sbMin->setValue( t.minute() ); | 505 | sbMin->setValue( t.minute() ); |
500 | } | 506 | } |
501 | 507 | ||
508 | void SetTime::setTime( QDateTime dt ) | ||
509 | { | ||
510 | _time = dt; | ||
511 | QTime t = dt.time(); | ||
512 | // just set the spinboxes and let it propage through | ||
513 | if(use12hourTime) { | ||
514 | int show_hour = t.hour(); | ||
515 | if (t.hour() >= 12) { | ||
516 | show_hour -= 12; | ||
517 | ampm->setCurrentItem( ValuePM ); | ||
518 | } else { | ||
519 | ampm->setCurrentItem( ValueAM ); | ||
520 | } | ||
521 | if (show_hour == 0) | ||
522 | show_hour = 12; | ||
523 | sbHour->setValue( show_hour ); | ||
524 | } else { | ||
525 | sbHour->setValue( t.hour() ); | ||
526 | } | ||
527 | sbMin->setValue( t.minute() ); | ||
528 | } | ||
502 | 529 | ||
530 | void SetTime::slotClockTick() | ||
531 | { | ||
532 | setTime( _time.addSecs(60) ); | ||
533 | qDebug("SetTime::slotClockTick %s",_time.toString().latin1()); | ||
534 | } | ||
diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h index 778cb9c..3c3a162 100644 --- a/noncore/settings/netsystemtime/settime.h +++ b/noncore/settings/netsystemtime/settime.h | |||
@@ -32,67 +32,71 @@ 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 | 45 | ||
45 | public slots: | 46 | public slots: |
46 | void slotTzChange( const QString& tz ); | 47 | void slotTzChange( const QString& tz ); |
47 | void show12hourTime( int ); | 48 | void show12hourTime( int ); |
48 | 49 | ||
49 | protected slots: | 50 | protected slots: |
51 | void slotClockTick(); | ||
50 | void hourChanged( int value ); | 52 | void hourChanged( int value ); |
51 | void minuteChanged( int value ); | 53 | void minuteChanged( int value ); |
52 | 54 | ||
53 | void checkedPM( int ); | 55 | void checkedPM( int ); |
54 | 56 | ||
55 | protected: | 57 | protected: |
56 | int hour; | 58 | int hour; |
57 | int minute; | 59 | int minute; |
58 | bool use12hourTime; | 60 | bool use12hourTime; |
61 | QDateTime _time; | ||
62 | QTimer *clock; | ||
59 | QComboBox *ampm; | 63 | QComboBox *ampm; |
60 | QSpinBox *sbHour; | 64 | QSpinBox *sbHour; |
61 | QSpinBox *sbMin; | 65 | QSpinBox *sbMin; |
62 | }; | 66 | }; |
63 | 67 | ||
64 | class DateButton; | 68 | class DateButton; |
65 | 69 | ||
66 | class SetDateTime : public NtpBase | 70 | class SetDateTime : public NtpBase |
67 | { | 71 | { |
68 | Q_OBJECT | 72 | Q_OBJECT |
69 | public: | 73 | public: |
70 | SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 ); | 74 | SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 ); |
71 | ~SetDateTime(); | 75 | ~SetDateTime(); |
72 | 76 | ||
73 | protected slots: | 77 | protected slots: |
74 | void commitTime(); | 78 | void commitTime(); |
75 | void tzChange( const QString &tz ); | 79 | void tzChange( const QString &tz ); |
76 | void formatChanged(int); | 80 | void formatChanged(int); |
77 | void updateSystem(int i=0); | 81 | void updateSystem(); |
78 | 82 | ||
79 | protected: | 83 | protected: |
80 | void setTime(QDateTime dt); | 84 | void setTime(QDateTime dt); |
81 | void writeSettings(); | 85 | void writeSettings(); |
82 | 86 | ||
83 | SetTime *timeButton; | 87 | SetTime *timeButton; |
84 | DateButton *dateButton; | 88 | DateButton *dateButton; |
85 | TimeZoneSelector *tz; | 89 | TimeZoneSelector *tz; |
86 | QComboBox *weekStartCombo; | 90 | QComboBox *weekStartCombo; |
87 | QComboBox *ampmCombo; | 91 | QComboBox *ampmCombo; |
88 | QComboBox *dateFormatCombo; | 92 | QComboBox *dateFormatCombo; |
89 | QComboBox *clockAppletCombo; | 93 | QComboBox *clockAppletCombo; |
90 | QPushButton *ButtonSetTime; | 94 | QPushButton *ButtonSetTime; |
91 | QLabel *TextLabelMainPredTime; | 95 | // QLabel *TextLabelMainPredTime; |
92 | 96 | ||
93 | DateFormat date_formats[4]; | 97 | DateFormat date_formats[4]; |
94 | }; | 98 | }; |
95 | 99 | ||
96 | 100 | ||
97 | #endif | 101 | #endif |
98 | 102 | ||