-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index e3b2ddd..d1dc5b8 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -1,501 +1,501 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "settime.h" | 21 | #include "settime.h" |
22 | 22 | ||
23 | #include <qpe/alarmserver.h> | 23 | #include <qpe/alarmserver.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/datebookdb.h> | 26 | #include <qpe/datebookdb.h> |
27 | #include <qpe/datebookmonth.h> | 27 | #include <qpe/datebookmonth.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | #include <qpe/timeconversion.h> | 30 | #include <qpe/timeconversion.h> |
31 | #include <qpe/tzselect.h> | 31 | #include <qpe/tzselect.h> |
32 | #include <qpe/timestring.h> | 32 | #include <qpe/timestring.h> |
33 | #include <qpe/qpedialog.h> | 33 | #include <qpe/qpedialog.h> |
34 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 34 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <qbuttongroup.h> | 38 | #include <qbuttongroup.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qradiobutton.h> | 42 | #include <qradiobutton.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
45 | #include <qwindowsystem_qws.h> | 45 | #include <qwindowsystem_qws.h> |
46 | #include <qcombobox.h> | 46 | #include <qcombobox.h> |
47 | 47 | ||
48 | #include <sys/time.h> | 48 | #include <sys/time.h> |
49 | #include <time.h> | 49 | #include <time.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <stdio.h> | 51 | #include <stdio.h> |
52 | 52 | ||
53 | 53 | ||
54 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | 54 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) |
55 | : NtpBase( parent, name, f ) | 55 | : NtpBase( parent, name, f ) |
56 | { | 56 | { |
57 | // setCaption( tr("Set System Time") ); | 57 | // setCaption( tr("Set System Time") ); |
58 | 58 | ||
59 | // QVBoxLayout *vb = new QVBoxLayout( this, 5 ); | 59 | // QVBoxLayout *vb = new QVBoxLayout( this, 5 ); |
60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); | 60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); |
61 | QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); | 61 | QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); |
62 | 62 | ||
63 | TextLabelMainPredTime = new QLabel( FrameSystemTime ); | 63 | TextLabelMainPredTime = new QLabel( FrameSystemTime ); |
64 | vb->addWidget( TextLabelMainPredTime, 1, 0 ); | 64 | vb->addWidget( TextLabelMainPredTime, 1, 0 ); |
65 | ButtonSetTime = new QPushButton( FrameSystemTime ); | 65 | ButtonSetTime = new QPushButton( FrameSystemTime ); |
66 | vb->addWidget( ButtonSetTime, 1, 0 ); | 66 | vb->addWidget( ButtonSetTime, 1, 0 ); |
67 | 67 | ||
68 | QFrame *hline = new QFrame( FrameSystemTime ); | 68 | QFrame *hline = new QFrame( FrameSystemTime ); |
69 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 69 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
70 | vb->addWidget( hline ); | 70 | vb->addWidget( hline ); |
71 | 71 | ||
72 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); | 72 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); |
73 | 73 | ||
74 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); | 74 | QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); |
75 | lblZone->setMaximumSize( lblZone->sizeHint() ); | 75 | lblZone->setMaximumSize( lblZone->sizeHint() ); |
76 | hb->addWidget( lblZone ); | 76 | hb->addWidget( lblZone ); |
77 | 77 | ||
78 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); | 78 | tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); |
79 | tz->setMinimumSize( tz->sizeHint() ); | 79 | tz->setMinimumSize( tz->sizeHint() ); |
80 | hb->addWidget( tz ); | 80 | hb->addWidget( tz ); |
81 | 81 | ||
82 | timeButton = new SetTime( FrameSetTime ); | 82 | timeButton = new SetTime( FrameSetTime ); |
83 | vb2->addWidget( timeButton ); | 83 | vb2->addWidget( timeButton ); |
84 | 84 | ||
85 | QHBoxLayout *db = new QHBoxLayout( vb2 ); | 85 | QHBoxLayout *db = new QHBoxLayout( vb2 ); |
86 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); | 86 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); |
87 | db->addWidget( dateLabel, 1 ); | 87 | db->addWidget( dateLabel, 1 ); |
88 | dateButton = new DateButton( TRUE, FrameSetTime ); | 88 | dateButton = new DateButton( TRUE, FrameSetTime ); |
89 | db->addWidget( dateButton, 2 ); | 89 | db->addWidget( dateButton, 2 ); |
90 | 90 | ||
91 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 91 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
92 | vb2->addItem( spacer ); | 92 | vb2->addItem( spacer ); |
93 | 93 | ||
94 | hline = new QFrame( FrameSystemTime ); | 94 | hline = new QFrame( FrameSystemTime ); |
95 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 95 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
96 | vb->addWidget( hline ); | 96 | vb->addWidget( hline ); |
97 | 97 | ||
98 | Config config("qpe"); | 98 | Config config("qpe"); |
99 | config.setGroup( "Time" ); | 99 | config.setGroup( "Time" ); |
100 | 100 | ||
101 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); | 101 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); |
102 | 102 | ||
103 | QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); | 103 | QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); |
104 | hb1->addWidget( l, 1 ); | 104 | hb1->addWidget( l, 1 ); |
105 | 105 | ||
106 | 106 | ||
107 | ampmCombo = new QComboBox( FrameSystemTime ); | 107 | ampmCombo = new QComboBox( FrameSystemTime ); |
108 | ampmCombo->insertItem( tr("24 hour"), 0 ); | 108 | ampmCombo->insertItem( tr("24 hour"), 0 ); |
109 | ampmCombo->insertItem( tr("12 hour"), 1 ); | 109 | ampmCombo->insertItem( tr("12 hour"), 1 ); |
110 | hb1->addWidget( ampmCombo, 2 ); | 110 | hb1->addWidget( ampmCombo, 2 ); |
111 | 111 | ||
112 | int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; | 112 | int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; |
113 | ampmCombo->setCurrentItem( show12hr ); | 113 | ampmCombo->setCurrentItem( show12hr ); |
114 | timeButton->show12hourTime( show12hr ); | 114 | timeButton->show12hourTime( show12hr ); |
115 | 115 | ||
116 | connect(ampmCombo, SIGNAL(activated(int)), | 116 | connect(ampmCombo, SIGNAL(activated(int)), |
117 | timeButton, SLOT(show12hourTime(int))); | 117 | timeButton, SLOT(show12hourTime(int))); |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | QHBoxLayout *hb2 = new QHBoxLayout( vb ); | 121 | QHBoxLayout *hb2 = new QHBoxLayout( vb ); |
122 | l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); | 122 | l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); |
123 | //l->setAlignment( AlignRight | AlignVCenter ); | 123 | //l->setAlignment( AlignRight | AlignVCenter ); |
124 | hb2->addWidget( l, 1 ); | 124 | hb2->addWidget( l, 1 ); |
125 | 125 | ||
126 | weekStartCombo = new QComboBox( FrameSystemTime ); | 126 | weekStartCombo = new QComboBox( FrameSystemTime ); |
127 | weekStartCombo->insertItem( tr("Sunday"), 0 ); | 127 | weekStartCombo->insertItem( tr("Sunday"), 0 ); |
128 | weekStartCombo->insertItem( tr("Monday"), 1 ); | 128 | weekStartCombo->insertItem( tr("Monday"), 1 ); |
129 | 129 | ||
130 | hb2->addWidget( weekStartCombo, 2 ); | 130 | hb2->addWidget( weekStartCombo, 2 ); |
131 | int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; | 131 | int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; |
132 | dateButton->setWeekStartsMonday( startMonday ); | 132 | dateButton->setWeekStartsMonday( startMonday ); |
133 | weekStartCombo->setCurrentItem( startMonday ); | 133 | weekStartCombo->setCurrentItem( startMonday ); |
134 | 134 | ||
135 | connect( weekStartCombo, SIGNAL( activated(int)), | 135 | connect( weekStartCombo, SIGNAL( activated(int)), |
136 | dateButton, SLOT(setWeekStartsMonday(int))); | 136 | dateButton, SLOT(setWeekStartsMonday(int))); |
137 | 137 | ||
138 | 138 | ||
139 | QHBoxLayout *hb3 = new QHBoxLayout( vb ); | 139 | QHBoxLayout *hb3 = new QHBoxLayout( vb ); |
140 | l = new QLabel( tr("Date format" ), FrameSystemTime ); | 140 | l = new QLabel( tr("Date format" ), FrameSystemTime ); |
141 | hb3->addWidget( l, 1 ); | 141 | hb3->addWidget( l, 1 ); |
142 | dateFormatCombo = new QComboBox( FrameSystemTime ); | 142 | dateFormatCombo = new QComboBox( FrameSystemTime ); |
143 | hb3->addWidget( dateFormatCombo, 2 ); | 143 | hb3->addWidget( dateFormatCombo, 2 ); |
144 | 144 | ||
145 | config.setGroup( "Date" ); | 145 | config.setGroup( "Date" ); |
146 | DateFormat df(QChar(config.readEntry("Separator", "/")[0]), | 146 | DateFormat df(QChar(config.readEntry("Separator", "/")[0]), |
147 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), | 147 | (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), |
148 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); | 148 | (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); |
149 | 149 | ||
150 | int currentdf = 0; | 150 | int currentdf = 0; |
151 | date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); | 151 | date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); |
152 | dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); | 152 | dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); |
153 | date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); | 153 | date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); |
154 | if (df == date_formats[1]) | 154 | if (df == date_formats[1]) |
155 | currentdf = 1; | 155 | currentdf = 1; |
156 | dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); | 156 | dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); |
157 | date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, | 157 | date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, |
158 | DateFormat::DayMonthYear); | 158 | DateFormat::DayMonthYear); |
159 | if (df == date_formats[2]) | 159 | if (df == date_formats[2]) |
160 | currentdf = 2; | 160 | currentdf = 2; |
161 | dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 | 161 | dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 |
162 | date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); | 162 | date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); |
163 | if (df == date_formats[3]) | 163 | if (df == date_formats[3]) |
164 | currentdf = 3; | 164 | currentdf = 3; |
165 | dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); | 165 | dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); |
166 | 166 | ||
167 | dateFormatCombo->setCurrentItem( currentdf ); | 167 | dateFormatCombo->setCurrentItem( currentdf ); |
168 | dateButton->setDateFormat( df ); | 168 | dateButton->setDateFormat( df ); |
169 | 169 | ||
170 | connect( dateFormatCombo, SIGNAL( activated(int)), | 170 | connect( dateFormatCombo, SIGNAL( activated(int)), |
171 | SLOT(formatChanged(int))); | 171 | SLOT(formatChanged(int))); |
172 | 172 | ||
173 | QHBoxLayout *hb4 = new QHBoxLayout( vb ); | 173 | QHBoxLayout *hb4 = new QHBoxLayout( vb ); |
174 | l = new QLabel( tr("Applet format" ), FrameSystemTime ); | 174 | l = new QLabel( tr("Applet format" ), FrameSystemTime ); |
175 | hb4->addWidget( l, 1 ); | 175 | hb4->addWidget( l, 1 ); |
176 | 176 | ||
177 | clockAppletCombo = new QComboBox( FrameSystemTime ); | 177 | clockAppletCombo = new QComboBox( FrameSystemTime ); |
178 | clockAppletCombo->insertItem( tr("hh:mm"), 0 ); | 178 | clockAppletCombo->insertItem( tr("hh:mm"), 0 ); |
179 | clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); | 179 | clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); |
180 | clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); | 180 | clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); |
181 | 181 | ||
182 | hb4->addWidget( clockAppletCombo, 2 ); | 182 | hb4->addWidget( clockAppletCombo, 2 ); |
183 | int clockApplet = config.readNumEntry("ClockApplet",0); | 183 | int clockApplet = config.readNumEntry("ClockApplet",0); |
184 | clockAppletCombo->setCurrentItem( clockApplet ); | 184 | clockAppletCombo->setCurrentItem( clockApplet ); |
185 | 185 | ||
186 | vb->addStretch( 0 ); | 186 | vb->addStretch( 0 ); |
187 | 187 | ||
188 | QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), | 188 | QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), |
189 | this, SLOT(commitTime())); | 189 | this, SLOT(commitTime())); |
190 | 190 | ||
191 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 191 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
192 | timeButton, SLOT( slotTzChange( const QString& ) ) ); | 192 | timeButton, SLOT( slotTzChange( const QString& ) ) ); |
193 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 193 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
194 | SLOT( tzChange( const QString& ) ) ); | 194 | SLOT( tzChange( const QString& ) ) ); |
195 | 195 | ||
196 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), | 196 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), |
197 | SLOT(updateSystem(int ) )); | 197 | SLOT(updateSystem(int ) )); |
198 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), | 198 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), |
199 | SLOT(updateSystem(int ) )); | 199 | SLOT(updateSystem(int ) )); |
200 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), | 200 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), |
201 | SLOT(updateSystem(int ) )); | 201 | SLOT(updateSystem(int ) )); |
202 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), | 202 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), |
203 | SLOT(updateSystem(int ) )); | 203 | SLOT(updateSystem(int ) )); |
204 | } | 204 | } |
205 | 205 | ||
206 | SetDateTime::~SetDateTime() | 206 | SetDateTime::~SetDateTime() |
207 | { | 207 | { |
208 | writeSettings(); | 208 | writeSettings(); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | void SetDateTime::writeSettings() | 212 | void SetDateTime::writeSettings() |
213 | { | 213 | { |
214 | Config config("qpe"); | 214 | Config config("qpe"); |
215 | config.setGroup( "Time" ); | 215 | config.setGroup( "Time" ); |
216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); | 216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); |
217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); | 217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); |
218 | config.setGroup( "Date" ); | 218 | config.setGroup( "Date" ); |
219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; | 219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; |
220 | config.writeEntry( "Separator", QString(df.separator())); | 220 | config.writeEntry( "Separator", QString(df.separator())); |
221 | config.writeEntry( "ShortOrder", df.shortOrder()); | 221 | config.writeEntry( "ShortOrder", df.shortOrder()); |
222 | config.writeEntry( "LongOrder", df.longOrder()); | 222 | config.writeEntry( "LongOrder", df.longOrder()); |
223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); | 223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); |
224 | 224 | ||
225 | Config lconfig("locale"); | 225 | Config lconfig("locale"); |
226 | lconfig.setGroup( "Location" ); | 226 | lconfig.setGroup( "Location" ); |
227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); | 227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); |
228 | 228 | ||
229 | } | 229 | } |
230 | 230 | ||
231 | void SetDateTime::commitTime() | 231 | void SetDateTime::commitTime() |
232 | { | 232 | { |
233 | Config cfg("ntp",Config::User); | 233 | Config cfg("ntp",Config::User); |
234 | cfg.setGroup("lookups"); | 234 | cfg.setGroup("lookups"); |
235 | cfg.writeEntry("lastNtp",false); | 235 | cfg.writeEntry("lastNtp",false); |
236 | tz->setFocus(); | 236 | tz->setFocus(); |
237 | // Need to process the QCOP event generated above before proceeding | 237 | // Need to process the QCOP event generated above before proceeding |
238 | qApp->processEvents(); | 238 | qApp->processEvents(); |
239 | 239 | ||
240 | // before we progress further, set our TZ! | 240 | // before we progress further, set our TZ! |
241 | setenv( "TZ", tz->currentZone(), 1 ); | 241 | setenv( "TZ", tz->currentZone(), 1 ); |
242 | // now set the time... | 242 | // now set the time... |
243 | QDateTime dt( dateButton->date(), timeButton->time() ); | 243 | QDateTime dt( dateButton->date(), timeButton->time() ); |
244 | 244 | ||
245 | if ( dt.isValid() ) setTime(dt); | 245 | if ( dt.isValid() ) setTime(dt); |
246 | } | 246 | } |
247 | 247 | ||
248 | void SetDateTime::setTime(QDateTime dt) | 248 | void SetDateTime::setTime(QDateTime dt) |
249 | { | 249 | { |
250 | // really turn off the screensaver before doing anything | 250 | // really turn off the screensaver before doing anything |
251 | { | 251 | { |
252 | // Needs to be encased in { } so that it deconstructs and sends | 252 | // Needs to be encased in { } so that it deconstructs and sends |
253 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 253 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
254 | disableScreenSaver << 0 << 0 << 0; | 254 | disableScreenSaver << 0 << 0 << 0; |
255 | } | 255 | } |
256 | Config cfg("ntp",Config::User); | 256 | Config cfg("ntp",Config::User); |
257 | cfg.setGroup("correction"); | 257 | cfg.setGroup("correction"); |
258 | int t = TimeConversion::toUTC(dt); | 258 | int t = TimeConversion::toUTC(dt); |
259 | struct timeval myTv; | 259 | struct timeval myTv; |
260 | myTv.tv_sec = t; | 260 | myTv.tv_sec = t; |
261 | cfg.writeEntry("time", t ); | 261 | cfg.writeEntry("time", t ); |
262 | myTv.tv_usec = 0; | 262 | myTv.tv_usec = 0; |
263 | 263 | ||
264 | if ( myTv.tv_sec != -1 ) | 264 | if ( myTv.tv_sec != -1 ) |
265 | ::settimeofday( &myTv, 0 ); | 265 | ::settimeofday( &myTv, 0 ); |
266 | Global::writeHWClock(); | 266 | Global::writeHWClock(); |
267 | // since time has changed quickly load in the datebookdb | 267 | // since time has changed quickly load in the datebookdb |
268 | // to allow the alarm server to get a better grip on itself | 268 | // to allow the alarm server to get a better grip on itself |
269 | // (example re-trigger alarms for when we travel back in time) | 269 | // (example re-trigger alarms for when we travel back in time) |
270 | DateBookDB db; | 270 | DateBookDB db; |
271 | QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); | 271 | //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); |
272 | timeApplet << ""; | 272 | //timeApplet << ""; |
273 | // Restore screensaver | 273 | // Restore screensaver |
274 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 274 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
275 | enableScreenSaver << -1 << -1 << -1; | 275 | enableScreenSaver << -1 << -1 << -1; |
276 | } | 276 | } |
277 | 277 | ||
278 | void SetDateTime::updateSystem(int i) | 278 | void SetDateTime::updateSystem(int i) |
279 | { | 279 | { |
280 | // really turn off the screensaver before doing anything | 280 | // really turn off the screensaver before doing anything |
281 | { | 281 | { |
282 | // Needs to be encased in { } so that it deconstructs and sends | 282 | // Needs to be encased in { } so that it deconstructs and sends |
283 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 283 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
284 | disableScreenSaver << 0 << 0 << 0; | 284 | disableScreenSaver << 0 << 0 << 0; |
285 | } | 285 | } |
286 | qDebug("SetDateTime::updateSystem(int %i)",i); | 286 | qDebug("SetDateTime::updateSystem(int %i)",i); |
287 | writeSettings(); | 287 | writeSettings(); |
288 | 288 | ||
289 | // set the timezone for everyone else... | 289 | // set the timezone for everyone else... |
290 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 290 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
291 | setTimeZone << tz->currentZone(); | 291 | setTimeZone << tz->currentZone(); |
292 | 292 | ||
293 | // AM/PM setting and notify time changed | 293 | // AM/PM setting and notify time changed |
294 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 294 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
295 | setClock << ampmCombo->currentItem(); | 295 | setClock << ampmCombo->currentItem(); |
296 | 296 | ||
297 | // Notify everyone what day we prefer to start the week on. | 297 | // Notify everyone what day we prefer to start the week on. |
298 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 298 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
299 | setWeek << weekStartCombo->currentItem(); | 299 | setWeek << weekStartCombo->currentItem(); |
300 | 300 | ||
301 | // Notify everyone what date format to use | 301 | // Notify everyone what date format to use |
302 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); | 302 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); |
303 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; | 303 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; |
304 | 304 | ||
305 | // Restore screensaver | 305 | // Restore screensaver |
306 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 306 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
307 | enableScreenSaver << -1 << -1 << -1; | 307 | enableScreenSaver << -1 << -1 << -1; |
308 | // since time has changed quickly load in the datebookdb | 308 | // since time has changed quickly load in the datebookdb |
309 | // to allow the alarm server to get a better grip on itself | 309 | // to allow the alarm server to get a better grip on itself |
310 | // (example re-trigger alarms for when we travel back in time) | 310 | // (example re-trigger alarms for when we travel back in time) |
311 | DateBookDB db; | 311 | DateBookDB db; |
312 | 312 | ||
313 | } | 313 | } |
314 | 314 | ||
315 | void SetDateTime::tzChange( const QString &tz ) | 315 | void SetDateTime::tzChange( const QString &tz ) |
316 | { | 316 | { |
317 | // set the TZ get the time and leave gracefully... | 317 | // set the TZ get the time and leave gracefully... |
318 | QString strSave; | 318 | QString strSave; |
319 | strSave = getenv( "TZ" ); | 319 | strSave = getenv( "TZ" ); |
320 | setenv( "TZ", tz, 1 ); | 320 | setenv( "TZ", tz, 1 ); |
321 | 321 | ||
322 | QDate d = QDate::currentDate(); | 322 | QDate d = QDate::currentDate(); |
323 | // reset the time. | 323 | // reset the time. |
324 | if ( !strSave.isNull() ) { | 324 | if ( !strSave.isNull() ) { |
325 | setenv( "TZ", strSave, 1 ); | 325 | setenv( "TZ", strSave, 1 ); |
326 | } | 326 | } |
327 | dateButton->setDate( d ); | 327 | dateButton->setDate( d ); |
328 | updateSystem(); | 328 | updateSystem(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void SetDateTime::formatChanged(int i) | 331 | void SetDateTime::formatChanged(int i) |
332 | { | 332 | { |
333 | dateButton->setDateFormat(date_formats[i]); | 333 | dateButton->setDateFormat(date_formats[i]); |
334 | } | 334 | } |
335 | 335 | ||
336 | static const int ValueAM = 0; | 336 | static const int ValueAM = 0; |
337 | static const int ValuePM = 1; | 337 | static const int ValuePM = 1; |
338 | 338 | ||
339 | 339 | ||
340 | 340 | ||
341 | SetTime::SetTime( QWidget *parent, const char *name ) | 341 | SetTime::SetTime( QWidget *parent, const char *name ) |
342 | : QWidget( parent, name ) | 342 | : QWidget( parent, name ) |
343 | { | 343 | { |
344 | use12hourTime = FALSE; | 344 | use12hourTime = FALSE; |
345 | 345 | ||
346 | QTime currTime = QTime::currentTime(); | 346 | QTime currTime = QTime::currentTime(); |
347 | hour = currTime.hour(); | 347 | hour = currTime.hour(); |
348 | minute = currTime.minute(); | 348 | minute = currTime.minute(); |
349 | 349 | ||
350 | QHBoxLayout *hb2 = new QHBoxLayout( this ); | 350 | QHBoxLayout *hb2 = new QHBoxLayout( this ); |
351 | hb2->setSpacing( 3 ); | 351 | hb2->setSpacing( 3 ); |
352 | 352 | ||
353 | QLabel *l = new QLabel( tr("Hour"), this ); | 353 | QLabel *l = new QLabel( tr("Hour"), this ); |
354 | // l->setAlignment( AlignRight | AlignVCenter ); | 354 | // l->setAlignment( AlignRight | AlignVCenter ); |
355 | hb2->addWidget( l ); | 355 | hb2->addWidget( l ); |
356 | 356 | ||
357 | sbHour = new QSpinBox( this ); | 357 | sbHour = new QSpinBox( this ); |
358 | sbHour->setMinimumWidth( 30 ); | 358 | sbHour->setMinimumWidth( 30 ); |
359 | if(use12hourTime) { | 359 | if(use12hourTime) { |
360 | sbHour->setMinValue(1); | 360 | sbHour->setMinValue(1); |
361 | sbHour->setMaxValue( 12 ); | 361 | sbHour->setMaxValue( 12 ); |
362 | int show_hour = hour; | 362 | int show_hour = hour; |
363 | if (hour > 12) | 363 | if (hour > 12) |
364 | show_hour -= 12; | 364 | show_hour -= 12; |
365 | if (show_hour == 0) | 365 | if (show_hour == 0) |
366 | show_hour = 12; | 366 | show_hour = 12; |
367 | 367 | ||
368 | sbHour->setValue( show_hour ); | 368 | sbHour->setValue( show_hour ); |
369 | } else { | 369 | } else { |
370 | sbHour->setMinValue( 0 ); | 370 | sbHour->setMinValue( 0 ); |
371 | sbHour->setMaxValue( 23 ); | 371 | sbHour->setMaxValue( 23 ); |
372 | sbHour->setValue( hour ); | 372 | sbHour->setValue( hour ); |
373 | } | 373 | } |
374 | sbHour->setWrapping(TRUE); | 374 | sbHour->setWrapping(TRUE); |
375 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); | 375 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); |
376 | hb2->addWidget( sbHour ); | 376 | hb2->addWidget( sbHour ); |
377 | 377 | ||
378 | hb2->addStretch( 1 ); | 378 | hb2->addStretch( 1 ); |
379 | 379 | ||
380 | l = new QLabel( tr("Minute"), this ); | 380 | l = new QLabel( tr("Minute"), this ); |
381 | //l->setAlignment( AlignRight | AlignVCenter ); | 381 | //l->setAlignment( AlignRight | AlignVCenter ); |
382 | hb2->addWidget( l ); | 382 | hb2->addWidget( l ); |
383 | 383 | ||
384 | sbMin = new QSpinBox( this ); | 384 | sbMin = new QSpinBox( this ); |
385 | sbMin->setMinValue( 0 ); | 385 | sbMin->setMinValue( 0 ); |
386 | sbMin->setMaxValue( 59 ); | 386 | sbMin->setMaxValue( 59 ); |
387 | sbMin->setWrapping(TRUE); | 387 | sbMin->setWrapping(TRUE); |
388 | sbMin->setValue( minute ); | 388 | sbMin->setValue( minute ); |
389 | sbMin->setMinimumWidth( 30 ); | 389 | sbMin->setMinimumWidth( 30 ); |
390 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); | 390 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); |
391 | hb2->addWidget( sbMin ); | 391 | hb2->addWidget( sbMin ); |
392 | 392 | ||
393 | hb2->addStretch( 1 ); | 393 | hb2->addStretch( 1 ); |
394 | 394 | ||
395 | ampm = new QComboBox( this ); | 395 | ampm = new QComboBox( this ); |
396 | ampm->insertItem( tr("AM"), ValueAM ); | 396 | ampm->insertItem( tr("AM"), ValueAM ); |
397 | ampm->insertItem( tr("PM"), ValuePM ); | 397 | ampm->insertItem( tr("PM"), ValuePM ); |
398 | connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); | 398 | connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); |
399 | hb2->addWidget( ampm ); | 399 | hb2->addWidget( ampm ); |
400 | 400 | ||
401 | hb2->addStretch( 1 ); | 401 | hb2->addStretch( 1 ); |
402 | 402 | ||
403 | } | 403 | } |
404 | 404 | ||
405 | QTime SetTime::time() const | 405 | QTime SetTime::time() const |
406 | { | 406 | { |
407 | return QTime( hour, minute, 0 ); | 407 | return QTime( hour, minute, 0 ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void SetTime::hourChanged( int value ) | 410 | void SetTime::hourChanged( int value ) |
411 | { | 411 | { |
412 | if(use12hourTime) { | 412 | if(use12hourTime) { |
413 | int realhour = value; | 413 | int realhour = value; |
414 | if (realhour == 12) | 414 | if (realhour == 12) |
415 | realhour = 0; | 415 | realhour = 0; |
416 | if (ampm->currentItem() == ValuePM ) | 416 | if (ampm->currentItem() == ValuePM ) |
417 | realhour += 12; | 417 | realhour += 12; |
418 | hour = realhour; | 418 | hour = realhour; |
419 | } else | 419 | } else |
420 | hour = value; | 420 | hour = value; |
421 | } | 421 | } |
422 | 422 | ||
423 | void SetTime::minuteChanged( int value ) | 423 | void SetTime::minuteChanged( int value ) |
424 | { | 424 | { |
425 | minute = value; | 425 | minute = value; |
426 | } | 426 | } |
427 | 427 | ||
428 | void SetTime::show12hourTime( int on ) | 428 | void SetTime::show12hourTime( int on ) |
429 | { | 429 | { |
430 | use12hourTime = on; | 430 | use12hourTime = on; |
431 | ampm->setEnabled(on); | 431 | ampm->setEnabled(on); |
432 | 432 | ||
433 | int show_hour = hour; | 433 | int show_hour = hour; |
434 | if ( on ) { | 434 | if ( on ) { |
435 | /* this might change the value of hour */ | 435 | /* this might change the value of hour */ |
436 | sbHour->setMinValue(1); | 436 | sbHour->setMinValue(1); |
437 | sbHour->setMaxValue( 12 ); | 437 | sbHour->setMaxValue( 12 ); |
438 | 438 | ||
439 | /* so use one we saved earlier */ | 439 | /* so use one we saved earlier */ |
440 | if (show_hour >= 12) { | 440 | if (show_hour >= 12) { |
441 | show_hour -= 12; | 441 | show_hour -= 12; |
442 | ampm->setCurrentItem( ValuePM ); | 442 | ampm->setCurrentItem( ValuePM ); |
443 | } else { | 443 | } else { |
444 | ampm->setCurrentItem( ValueAM ); | 444 | ampm->setCurrentItem( ValueAM ); |
445 | } | 445 | } |
446 | if (show_hour == 0) | 446 | if (show_hour == 0) |
447 | show_hour = 12; | 447 | show_hour = 12; |
448 | 448 | ||
449 | } else { | 449 | } else { |
450 | sbHour->setMinValue( 0 ); | 450 | sbHour->setMinValue( 0 ); |
451 | sbHour->setMaxValue( 23 ); | 451 | sbHour->setMaxValue( 23 ); |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | sbHour->setValue( show_hour ); | 455 | sbHour->setValue( show_hour ); |
456 | } | 456 | } |
457 | 457 | ||
458 | void SetTime::checkedPM( int c ) | 458 | void SetTime::checkedPM( int c ) |
459 | { | 459 | { |
460 | int show_hour = sbHour->value(); | 460 | int show_hour = sbHour->value(); |
461 | if (show_hour == 12) | 461 | if (show_hour == 12) |
462 | show_hour = 0; | 462 | show_hour = 0; |
463 | 463 | ||
464 | if ( c == ValuePM ) | 464 | if ( c == ValuePM ) |
465 | show_hour += 12; | 465 | show_hour += 12; |
466 | 466 | ||
467 | hour = show_hour; | 467 | hour = show_hour; |
468 | } | 468 | } |
469 | 469 | ||
470 | void SetTime::slotTzChange( const QString &tz ) | 470 | void SetTime::slotTzChange( const QString &tz ) |
471 | { | 471 | { |
472 | // set the TZ get the time and leave gracefully... | 472 | // set the TZ get the time and leave gracefully... |
473 | QString strSave; | 473 | QString strSave; |
474 | strSave = getenv( "TZ" ); | 474 | strSave = getenv( "TZ" ); |
475 | setenv( "TZ", tz, 1 ); | 475 | setenv( "TZ", tz, 1 ); |
476 | 476 | ||
477 | QTime t = QTime::currentTime(); | 477 | QTime t = QTime::currentTime(); |
478 | // reset the time. | 478 | // reset the time. |
479 | if ( !strSave.isNull() ) { | 479 | if ( !strSave.isNull() ) { |
480 | setenv( "TZ", strSave, 1 ); | 480 | setenv( "TZ", strSave, 1 ); |
481 | } | 481 | } |
482 | 482 | ||
483 | // just set the spinboxes and let it propage through | 483 | // just set the spinboxes and let it propage through |
484 | if(use12hourTime) { | 484 | if(use12hourTime) { |
485 | int show_hour = t.hour(); | 485 | int show_hour = t.hour(); |
486 | if (t.hour() >= 12) { | 486 | if (t.hour() >= 12) { |
487 | show_hour -= 12; | 487 | show_hour -= 12; |
488 | ampm->setCurrentItem( ValuePM ); | 488 | ampm->setCurrentItem( ValuePM ); |
489 | } else { | 489 | } else { |
490 | ampm->setCurrentItem( ValueAM ); | 490 | ampm->setCurrentItem( ValueAM ); |
491 | } | 491 | } |
492 | if (show_hour == 0) | 492 | if (show_hour == 0) |
493 | show_hour = 12; | 493 | show_hour = 12; |
494 | sbHour->setValue( show_hour ); | 494 | sbHour->setValue( show_hour ); |
495 | } else { | 495 | } else { |
496 | sbHour->setValue( t.hour() ); | 496 | sbHour->setValue( t.hour() ); |
497 | } | 497 | } |
498 | sbMin->setValue( t.minute() ); | 498 | sbMin->setValue( t.minute() ); |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||