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 | |||
@@ -406,21 +406,30 @@ void Ntp::showAdvancedFeatures(bool advMode) | |||
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 | |||
@@ -12,24 +12,25 @@ class QCopChannel; | |||
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; |
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 | |||
@@ -47,25 +47,25 @@ | |||
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 ); |
@@ -309,32 +309,31 @@ void SetDateTime::updateSystem() | |||
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; |
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 | |||
@@ -78,25 +78,25 @@ 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 | ||