summaryrefslogtreecommitdiff
authortille <tille>2002-10-21 19:18:53 (UTC)
committer tille <tille>2002-10-21 19:18:53 (UTC)
commit95a908dba86f7588e3130094e7d292f3df6a3a42 (patch) (unidiff)
treeed84d7763b33a6ae95fbbafa54262aca56fc4d4e
parentc3eedd530dc9675caa4ce98d1c0814ba61a746ed (diff)
downloadopie-95a908dba86f7588e3130094e7d292f3df6a3a42.zip
opie-95a908dba86f7588e3130094e7d292f3df6a3a42.tar.gz
opie-95a908dba86f7588e3130094e7d292f3df6a3a42.tar.bz2
now working...
desiger 3 is much more useable -> ui file gone ;)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/netsystemtime.pro6
-rw-r--r--noncore/settings/netsystemtime/ntpbase.cpp328
-rw-r--r--noncore/settings/netsystemtime/ntpbase.h93
-rw-r--r--noncore/settings/netsystemtime/settime.cpp8
4 files changed, 428 insertions, 7 deletions
diff --git a/noncore/settings/netsystemtime/netsystemtime.pro b/noncore/settings/netsystemtime/netsystemtime.pro
index 026b8da..0530ea5 100644
--- a/noncore/settings/netsystemtime/netsystemtime.pro
+++ b/noncore/settings/netsystemtime/netsystemtime.pro
@@ -1,26 +1,26 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 #CONFIG = qt warn_on release 3 #CONFIG = qt warn_on release
4 HEADERS = ntp.h settime.h 4 HEADERS = ntp.h settime.h ntpbase.h
5 SOURCES = main.cpp ntp.cpp settime.cpp 5 SOURCES = main.cpp ntp.cpp settime.cpp ntpbase.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include 6 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include 7 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe -lopie 8LIBS += -lqpe -lopie
9 INTERFACES= ntpbase.ui 9 INTERFACES=
10DESTDIR = $(OPIEDIR)/bin 10DESTDIR = $(OPIEDIR)/bin
11 TARGET = netsystemtime 11 TARGET = netsystemtime
12 12
13TRANSLATIONS = ../../../i18n/de/netsystemtime.ts \ 13TRANSLATIONS = ../../../i18n/de/netsystemtime.ts \
14 ../../../i18n/en/netsystemtime.ts \ 14 ../../../i18n/en/netsystemtime.ts \
15 ../../../i18n/es/netsystemtime.ts \ 15 ../../../i18n/es/netsystemtime.ts \
16 ../../../i18n/fr/netsystemtime.ts \ 16 ../../../i18n/fr/netsystemtime.ts \
17 ../../../i18n/hu/netsystemtime.ts \ 17 ../../../i18n/hu/netsystemtime.ts \
18 ../../../i18n/ja/netsystemtime.ts \ 18 ../../../i18n/ja/netsystemtime.ts \
19 ../../../i18n/ko/netsystemtime.ts \ 19 ../../../i18n/ko/netsystemtime.ts \
20 ../../../i18n/no/netsystemtime.ts \ 20 ../../../i18n/no/netsystemtime.ts \
21 ../../../i18n/pl/netsystemtime.ts \ 21 ../../../i18n/pl/netsystemtime.ts \
22 ../../../i18n/pt/netsystemtime.ts \ 22 ../../../i18n/pt/netsystemtime.ts \
23 ../../../i18n/pt_BR/netsystemtime.ts \ 23 ../../../i18n/pt_BR/netsystemtime.ts \
24 ../../../i18n/sl/netsystemtime.ts \ 24 ../../../i18n/sl/netsystemtime.ts \
25 ../../../i18n/zh_CN/netsystemtime.ts \ 25 ../../../i18n/zh_CN/netsystemtime.ts \
26 ../../../i18n/zh_TW/netsystemtime.ts 26 ../../../i18n/zh_TW/netsystemtime.ts
diff --git a/noncore/settings/netsystemtime/ntpbase.cpp b/noncore/settings/netsystemtime/ntpbase.cpp
new file mode 100644
index 0000000..7762e93
--- a/dev/null
+++ b/noncore/settings/netsystemtime/ntpbase.cpp
@@ -0,0 +1,328 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'ntpbase.ui'
3**
4** Created: Mon Oct 21 21:06:08 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "ntpbase.h"
10
11#include <qcombobox.h>
12#include <qframe.h>
13#include <qlabel.h>
14#include <qmultilineedit.h>
15#include <qpushbutton.h>
16#include <qspinbox.h>
17#include <qtable.h>
18#include <qtabwidget.h>
19#include <qlayout.h>
20#include <qvariant.h>
21#include <qtooltip.h>
22#include <qwhatsthis.h>
23
24/*
25 * Constructs a NtpBase which is a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'
27 */
28NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl )
29 : QWidget( parent, name, fl )
30{
31 if ( !name )
32 setName( "NtpBase" );
33 resize( 320, 411 );
34 setCaption( tr( "Network Time" ) );
35 NtpBaseLayout = new QGridLayout( this );
36 NtpBaseLayout->setSpacing( 2 );
37 NtpBaseLayout->setMargin( 2 );
38
39 TabWidgetMain = new QTabWidget( this, "TabWidgetMain" );
40
41 tabMain = new QWidget( TabWidgetMain, "tabMain" );
42 tabMainLayout = new QGridLayout( tabMain );
43 tabMainLayout->setSpacing( 2 );
44 tabMainLayout->setMargin( 2 );
45
46 FrameSystemTime = new QFrame( tabMain, "FrameSystemTime" );
47 FrameSystemTime->setFrameShape( QFrame::StyledPanel );
48 FrameSystemTime->setFrameShadow( QFrame::Raised );
49
50 tabMainLayout->addWidget( FrameSystemTime, 0, 0 );
51
52 tabNtp = new QWidget( TabWidgetMain, "tabNtp" );
53 tabNtpLayout = new QGridLayout( tabNtp );
54 tabNtpLayout->setSpacing( 2 );
55 tabNtpLayout->setMargin( 1 );
56
57 runNtp = new QPushButton( tabNtp, "runNtp" );
58 runNtp->setText( tr( "Get time from network" ) );
59
60 tabNtpLayout->addWidget( runNtp, 1, 0 );
61
62 FrameNtp = new QFrame( tabNtp, "FrameNtp" );
63 FrameNtp->setFrameShape( QFrame::StyledPanel );
64 FrameNtp->setFrameShadow( QFrame::Raised );
65 FrameNtpLayout = new QGridLayout( FrameNtp );
66 FrameNtpLayout->setSpacing( 2 );
67 FrameNtpLayout->setMargin( 2 );
68
69 Layout4 = new QVBoxLayout;
70 Layout4->setSpacing( 6 );
71 Layout4->setMargin( 0 );
72
73 TextLabel1 = new QLabel( FrameNtp, "TextLabel1" );
74 TextLabel1->setAutoMask( FALSE );
75 TextLabel1->setText( tr( "Start Time:" ) );
76 Layout4->addWidget( TextLabel1 );
77
78 TextLabelStartTime = new QLabel( FrameNtp, "TextLabelStartTime" );
79 TextLabelStartTime->setText( tr( "nan" ) );
80 Layout4->addWidget( TextLabelStartTime );
81
82 TextLabel3 = new QLabel( FrameNtp, "TextLabel3" );
83 TextLabel3->setText( tr( "Time Shift:" ) );
84 Layout4->addWidget( TextLabel3 );
85
86 TextLabelTimeShift = new QLabel( FrameNtp, "TextLabelTimeShift" );
87 TextLabelTimeShift->setText( tr( "nan" ) );
88 Layout4->addWidget( TextLabelTimeShift );
89
90 TextLabel5 = new QLabel( FrameNtp, "TextLabel5" );
91 TextLabel5->setText( tr( "New Time:" ) );
92 Layout4->addWidget( TextLabel5 );
93
94 TextLabelNewTime = new QLabel( FrameNtp, "TextLabelNewTime" );
95 TextLabelNewTime->setText( tr( "nan" ) );
96 Layout4->addWidget( TextLabelNewTime );
97 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
98 Layout4->addItem( spacer );
99
100 FrameNtpLayout->addLayout( Layout4, 0, 0 );
101
102 MultiLineEditntpOutPut = new QMultiLineEdit( FrameNtp, "MultiLineEditntpOutPut" );
103 QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
104 MultiLineEditntpOutPut_font.setPointSize( 7 );
105 MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font );
106 MultiLineEditntpOutPut->setWordWrap( QMultiLineEdit::WidgetWidth );
107 MultiLineEditntpOutPut->setText( tr( "" ) );
108
109 FrameNtpLayout->addWidget( MultiLineEditntpOutPut, 1, 0 );
110
111 tabNtpLayout->addWidget( FrameNtp, 0, 0 );
112
113 tabPredict = new QWidget( TabWidgetMain, "tabPredict" );
114 tabPredictLayout = new QGridLayout( tabPredict );
115 tabPredictLayout->setSpacing( 6 );
116 tabPredictLayout->setMargin( 5 );
117
118 TableLookups = new QTable( tabPredict, "TableLookups" );
119 QFont TableLookups_font( TableLookups->font() );
120 TableLookups_font.setPointSize( 8 );
121 TableLookups->setFont( TableLookups_font );
122 TableLookups->setNumRows( 2 );
123 TableLookups->setNumCols( 2 );
124
125 tabPredictLayout->addWidget( TableLookups, 0, 0 );
126
127 Layout9 = new QGridLayout;
128 Layout9->setSpacing( 6 );
129 Layout9->setMargin( 0 );
130
131 TextLabelShift = new QLabel( tabPredict, "TextLabelShift" );
132 TextLabelShift->setText( tr( "nan" ) );
133
134 Layout9->addWidget( TextLabelShift, 0, 1 );
135
136 TextLabel4 = new QLabel( tabPredict, "TextLabel4" );
137 TextLabel4->setText( tr( "Esimated Shift:" ) );
138
139 Layout9->addWidget( TextLabel4, 1, 0 );
140
141 TextLabelEstimatedShift = new QLabel( tabPredict, "TextLabelEstimatedShift" );
142 TextLabelEstimatedShift->setText( tr( "nan" ) );
143
144 Layout9->addWidget( TextLabelEstimatedShift, 1, 1 );
145
146 TextLabel3_2 = new QLabel( tabPredict, "TextLabel3_2" );
147 TextLabel3_2->setText( tr( "Predicted Time:" ) );
148
149 Layout9->addWidget( TextLabel3_2, 2, 0 );
150
151 Mean_shift_label = new QLabel( tabPredict, "Mean_shift_label" );
152 Mean_shift_label->setText( tr( "Mean shift:" ) );
153
154 Layout9->addWidget( Mean_shift_label, 0, 0 );
155
156 TextLabelPredTime = new QLabel( tabPredict, "TextLabelPredTime" );
157 TextLabelPredTime->setText( tr( "nan" ) );
158
159 Layout9->addWidget( TextLabelPredTime, 2, 1 );
160
161 tabPredictLayout->addLayout( Layout9, 1, 0 );
162
163 Layout11 = new QHBoxLayout;
164 Layout11->setSpacing( 6 );
165 Layout11->setMargin( 0 );
166
167 PushButtonSetPredTime = new QPushButton( tabPredict, "PushButtonSetPredTime" );
168 PushButtonSetPredTime->setText( tr( "Set predicted time" ) );
169 Layout11->addWidget( PushButtonSetPredTime );
170
171 PushButtonPredict = new QPushButton( tabPredict, "PushButtonPredict" );
172 PushButtonPredict->setText( tr( "Predict time" ) );
173 Layout11->addWidget( PushButtonPredict );
174
175 tabPredictLayout->addLayout( Layout11, 2, 0 );
176
177 TabSettings = new QWidget( TabWidgetMain, "TabSettings" );
178 TabSettingsLayout = new QGridLayout( TabSettings );
179 TabSettingsLayout->setSpacing( 2 );
180 TabSettingsLayout->setMargin( 2 );
181
182 FrameSettings = new QFrame( TabSettings, "FrameSettings" );
183 FrameSettings->setFrameShape( QFrame::StyledPanel );
184 FrameSettings->setFrameShadow( QFrame::Raised );
185 FrameSettingsLayout = new QGridLayout( FrameSettings );
186 FrameSettingsLayout->setSpacing( 11 );
187 FrameSettingsLayout->setMargin( 3 );
188
189 Layout6 = new QGridLayout;
190 Layout6->setSpacing( 6 );
191 Layout6->setMargin( 0 );
192
193 TextLabel7_2 = new QLabel( FrameSettings, "TextLabel7_2" );
194 TextLabel7_2->setText( tr( "Use" ) );
195
196 Layout6->addWidget( TextLabel7_2, 0, 0 );
197
198 TextLabel2_2 = new QLabel( FrameSettings, "TextLabel2_2" );
199 TextLabel2_2->setText( tr( "as" ) );
200
201 Layout6->addWidget( TextLabel2_2, 0, 2 );
202
203 TextLabel1_3 = new QLabel( FrameSettings, "TextLabel1_3" );
204 TextLabel1_3->setText( tr( "NTP server to get the time from the network." ) );
205 TextLabel1_3->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
206
207 Layout6->addMultiCellWidget( TextLabel1_3, 1, 1, 0, 1 );
208
209 ComboNtpSrv = new QComboBox( FALSE, FrameSettings, "ComboNtpSrv" );
210 ComboNtpSrv->setEditable( TRUE );
211
212 Layout6->addWidget( ComboNtpSrv, 0, 1 );
213
214 FrameSettingsLayout->addLayout( Layout6, 0, 0 );
215 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
216 FrameSettingsLayout->addItem( spacer_2, 3, 0 );
217
218 Layout7 = new QGridLayout;
219 Layout7->setSpacing( 6 );
220 Layout7->setMargin( 0 );
221
222 TextLabel1_2 = new QLabel( FrameSettings, "TextLabel1_2" );
223 TextLabel1_2->setText( tr( "Insure a delay of" ) );
224
225 Layout7->addWidget( TextLabel1_2, 0, 0 );
226
227 TextLabel2 = new QLabel( FrameSettings, "TextLabel2" );
228 TextLabel2->setText( tr( "minutes until" ) );
229
230 Layout7->addWidget( TextLabel2, 0, 2 );
231
232 TextLabel3_3 = new QLabel( FrameSettings, "TextLabel3_3" );
233 TextLabel3_3->setText( tr( "a new NTP lookup will be used to predict the time." ) );
234 TextLabel3_3->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
235
236 Layout7->addMultiCellWidget( TextLabel3_3, 1, 1, 0, 2 );
237
238 SpinBoxMinLookupDelay = new QSpinBox( FrameSettings, "SpinBoxMinLookupDelay" );
239 SpinBoxMinLookupDelay->setMaxValue( 9999999 );
240 SpinBoxMinLookupDelay->setMinValue( 42 );
241
242 Layout7->addWidget( SpinBoxMinLookupDelay, 0, 1 );
243
244 FrameSettingsLayout->addLayout( Layout7, 2, 0 );
245
246 Layout7_2 = new QGridLayout;
247 Layout7_2->setSpacing( 6 );
248 Layout7_2->setMargin( 0 );
249
250 TextLabel1_2_2 = new QLabel( FrameSettings, "TextLabel1_2_2" );
251 TextLabel1_2_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel1_2_2->sizePolicy().hasHeightForWidth() ) );
252 TextLabel1_2_2->setText( tr( "Wait for " ) );
253
254 Layout7_2->addWidget( TextLabel1_2_2, 0, 0 );
255
256 TextLabel2_3 = new QLabel( FrameSettings, "TextLabel2_3" );
257 TextLabel2_3->setText( tr( "minutes until" ) );
258
259 Layout7_2->addWidget( TextLabel2_3, 0, 2 );
260
261 TextLabel3_3_2 = new QLabel( FrameSettings, "TextLabel3_3_2" );
262 TextLabel3_3_2->setText( tr( "NTP tries to syncronises the clock with the network." ) );
263 TextLabel3_3_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
264
265 Layout7_2->addMultiCellWidget( TextLabel3_3_2, 1, 1, 0, 2 );
266
267 SpinBoxNtpDelay = new QSpinBox( FrameSettings, "SpinBoxNtpDelay" );
268 SpinBoxNtpDelay->setMaxValue( 9999999 );
269 SpinBoxNtpDelay->setMinValue( 0 );
270
271 Layout7_2->addWidget( SpinBoxNtpDelay, 0, 1 );
272
273 FrameSettingsLayout->addLayout( Layout7_2, 1, 0 );
274
275 TabSettingsLayout->addWidget( FrameSettings, 0, 0 );
276
277 tabManualSetTime = new QWidget( TabWidgetMain, "tabManualSetTime" );
278 tabManualSetTimeLayout = new QVBoxLayout( tabManualSetTime );
279 tabManualSetTimeLayout->setSpacing( 2 );
280 tabManualSetTimeLayout->setMargin( 2 );
281
282 FrameSetTime = new QFrame( tabManualSetTime, "FrameSetTime" );
283 FrameSetTime->setFrameShape( QFrame::StyledPanel );
284 FrameSetTime->setFrameShadow( QFrame::Raised );
285 tabManualSetTimeLayout->addWidget( FrameSetTime );
286
287 PushButtonSetManualTime = new QPushButton( tabManualSetTime, "PushButtonSetManualTime" );
288 PushButtonSetManualTime->setText( tr( "Set time" ) );
289 tabManualSetTimeLayout->addWidget( PushButtonSetManualTime );
290
291 TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
292
293 TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
294
295 TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
296
297 TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) );
298 TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
299
300 NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 );
301}
302
303/*
304 * Destroys the object and frees any allocated resources
305 */
306NtpBase::~NtpBase()
307{
308 // no need to delete child widgets, Qt does it all for us
309}
310
311/*
312 * Main event handler. Reimplemented to handle application
313 * font changes
314 */
315bool NtpBase::event( QEvent* ev )
316{
317 bool ret = QWidget::event( ev );
318 if ( ev->type() == QEvent::ApplicationFontChange ) {
319 QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
320 MultiLineEditntpOutPut_font.setPointSize( 7 );
321 MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font );
322 QFont TableLookups_font( TableLookups->font() );
323 TableLookups_font.setPointSize( 8 );
324 TableLookups->setFont( TableLookups_font );
325 }
326 return ret;
327}
328
diff --git a/noncore/settings/netsystemtime/ntpbase.h b/noncore/settings/netsystemtime/ntpbase.h
new file mode 100644
index 0000000..b337822
--- a/dev/null
+++ b/noncore/settings/netsystemtime/ntpbase.h
@@ -0,0 +1,93 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'ntpbase.ui'
3**
4** Created: Mon Oct 21 21:05:47 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef NTPBASE_H
10#define NTPBASE_H
11
12#include <qvariant.h>
13#include <qwidget.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QComboBox;
18class QFrame;
19class QLabel;
20class QMultiLineEdit;
21class QPushButton;
22class QSpinBox;
23class QTabWidget;
24class QTable;
25
26class NtpBase : public QWidget
27{
28 Q_OBJECT
29
30public:
31 NtpBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
32 ~NtpBase();
33
34 QTabWidget* TabWidgetMain;
35 QWidget* tabMain;
36 QFrame* FrameSystemTime;
37 QWidget* tabNtp;
38 QPushButton* runNtp;
39 QFrame* FrameNtp;
40 QLabel* TextLabel1;
41 QLabel* TextLabelStartTime;
42 QLabel* TextLabel3;
43 QLabel* TextLabelTimeShift;
44 QLabel* TextLabel5;
45 QLabel* TextLabelNewTime;
46 QMultiLineEdit* MultiLineEditntpOutPut;
47 QWidget* tabPredict;
48 QTable* TableLookups;
49 QLabel* TextLabelShift;
50 QLabel* TextLabel4;
51 QLabel* TextLabelEstimatedShift;
52 QLabel* TextLabel3_2;
53 QLabel* Mean_shift_label;
54 QLabel* TextLabelPredTime;
55 QPushButton* PushButtonSetPredTime;
56 QPushButton* PushButtonPredict;
57 QWidget* TabSettings;
58 QFrame* FrameSettings;
59 QLabel* TextLabel7_2;
60 QLabel* TextLabel2_2;
61 QLabel* TextLabel1_3;
62 QComboBox* ComboNtpSrv;
63 QLabel* TextLabel1_2;
64 QLabel* TextLabel2;
65 QLabel* TextLabel3_3;
66 QSpinBox* SpinBoxMinLookupDelay;
67 QLabel* TextLabel1_2_2;
68 QLabel* TextLabel2_3;
69 QLabel* TextLabel3_3_2;
70 QSpinBox* SpinBoxNtpDelay;
71 QWidget* tabManualSetTime;
72 QFrame* FrameSetTime;
73 QPushButton* PushButtonSetManualTime;
74
75protected:
76 QGridLayout* NtpBaseLayout;
77 QGridLayout* tabMainLayout;
78 QGridLayout* tabNtpLayout;
79 QGridLayout* FrameNtpLayout;
80 QVBoxLayout* Layout4;
81 QGridLayout* tabPredictLayout;
82 QGridLayout* Layout9;
83 QHBoxLayout* Layout11;
84 QGridLayout* TabSettingsLayout;
85 QGridLayout* FrameSettingsLayout;
86 QGridLayout* Layout6;
87 QGridLayout* Layout7;
88 QGridLayout* Layout7_2;
89 QVBoxLayout* tabManualSetTimeLayout;
90 bool event( QEvent* );
91};
92
93#endif // NTPBASE_H
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index f6e02d5..949fcb3 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -1,502 +1,502 @@
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
54SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) 54SetDateTime::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 65
66 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); 66 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" );
67 67
68 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); 68 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" );
69 lblZone->setMaximumSize( lblZone->sizeHint() ); 69 lblZone->setMaximumSize( lblZone->sizeHint() );
70 hb->addWidget( lblZone ); 70 hb->addWidget( lblZone );
71 71
72 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); 72 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" );
73 tz->setMinimumSize( tz->sizeHint() ); 73 tz->setMinimumSize( tz->sizeHint() );
74 hb->addWidget( tz ); 74 hb->addWidget( tz );
75 75
76 timeButton = new SetTime( FrameSetTime ); 76 timeButton = new SetTime( FrameSetTime );
77 vb2->addWidget( timeButton ); 77 vb2->addWidget( timeButton );
78 78
79 QHBoxLayout *db = new QHBoxLayout( vb2 ); 79 QHBoxLayout *db = new QHBoxLayout( vb2 );
80 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); 80 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime );
81 db->addWidget( dateLabel, 1 ); 81 db->addWidget( dateLabel, 1 );
82 dateButton = new DateButton( TRUE, FrameSetTime ); 82 dateButton = new DateButton( TRUE, FrameSetTime );
83 db->addWidget( dateButton, 2 ); 83 db->addWidget( dateButton, 2 );
84 84
85 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 85 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
86 vb2->addItem( spacer ); 86 vb2->addItem( spacer );
87 87
88 hline = new QFrame( FrameSystemTime ); 88 QFrame *hline = new QFrame( FrameSystemTime );
89 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 89 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
90 vb->addWidget( hline ); 90 vb->addWidget( hline );
91 91
92 Config config("qpe"); 92 Config config("qpe");
93 config.setGroup( "Time" ); 93 config.setGroup( "Time" );
94 94
95 QHBoxLayout *hb1 = new QHBoxLayout( vb ); 95 QHBoxLayout *hb1 = new QHBoxLayout( vb );
96 96
97 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); 97 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime );
98 hb1->addWidget( l, 1 ); 98 hb1->addWidget( l, 1 );
99 99
100 100
101 ampmCombo = new QComboBox( FrameSystemTime ); 101 ampmCombo = new QComboBox( FrameSystemTime );
102 ampmCombo->insertItem( tr("24 hour"), 0 ); 102 ampmCombo->insertItem( tr("24 hour"), 0 );
103 ampmCombo->insertItem( tr("12 hour"), 1 ); 103 ampmCombo->insertItem( tr("12 hour"), 1 );
104 hb1->addWidget( ampmCombo, 2 ); 104 hb1->addWidget( ampmCombo, 2 );
105 105
106 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; 106 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0;
107 ampmCombo->setCurrentItem( show12hr ); 107 ampmCombo->setCurrentItem( show12hr );
108 timeButton->show12hourTime( show12hr ); 108 timeButton->show12hourTime( show12hr );
109 109
110 connect(ampmCombo, SIGNAL(activated(int)), 110 connect(ampmCombo, SIGNAL(activated(int)),
111 timeButton, SLOT(show12hourTime(int))); 111 timeButton, SLOT(show12hourTime(int)));
112 112
113 113
114 114
115 QHBoxLayout *hb2 = new QHBoxLayout( vb ); 115 QHBoxLayout *hb2 = new QHBoxLayout( vb );
116 l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); 116 l = new QLabel( tr("Weeks start on" ), FrameSystemTime );
117 //l->setAlignment( AlignRight | AlignVCenter ); 117 //l->setAlignment( AlignRight | AlignVCenter );
118 hb2->addWidget( l, 1 ); 118 hb2->addWidget( l, 1 );
119 119
120 weekStartCombo = new QComboBox( FrameSystemTime ); 120 weekStartCombo = new QComboBox( FrameSystemTime );
121 weekStartCombo->insertItem( tr("Sunday"), 0 ); 121 weekStartCombo->insertItem( tr("Sunday"), 0 );
122 weekStartCombo->insertItem( tr("Monday"), 1 ); 122 weekStartCombo->insertItem( tr("Monday"), 1 );
123 123
124 hb2->addWidget( weekStartCombo, 2 ); 124 hb2->addWidget( weekStartCombo, 2 );
125 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; 125 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0;
126 dateButton->setWeekStartsMonday( startMonday ); 126 dateButton->setWeekStartsMonday( startMonday );
127 weekStartCombo->setCurrentItem( startMonday ); 127 weekStartCombo->setCurrentItem( startMonday );
128 128
129 connect( weekStartCombo, SIGNAL( activated(int)), 129 connect( weekStartCombo, SIGNAL( activated(int)),
130 dateButton, SLOT(setWeekStartsMonday(int))); 130 dateButton, SLOT(setWeekStartsMonday(int)));
131 131
132 132
133 QHBoxLayout *hb3 = new QHBoxLayout( vb ); 133 QHBoxLayout *hb3 = new QHBoxLayout( vb );
134 l = new QLabel( tr("Date format" ), FrameSystemTime ); 134 l = new QLabel( tr("Date format" ), FrameSystemTime );
135 hb3->addWidget( l, 1 ); 135 hb3->addWidget( l, 1 );
136 dateFormatCombo = new QComboBox( FrameSystemTime ); 136 dateFormatCombo = new QComboBox( FrameSystemTime );
137 hb3->addWidget( dateFormatCombo, 2 ); 137 hb3->addWidget( dateFormatCombo, 2 );
138 138
139 config.setGroup( "Date" ); 139 config.setGroup( "Date" );
140 DateFormat df(QChar(config.readEntry("Separator", "/")[0]), 140 DateFormat df(QChar(config.readEntry("Separator", "/")[0]),
141 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), 141 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
142 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); 142 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
143 143
144 int currentdf = 0; 144 int currentdf = 0;
145 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); 145 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear);
146 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); 146 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) );
147 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); 147 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear);
148 if (df == date_formats[1]) 148 if (df == date_formats[1])
149 currentdf = 1; 149 currentdf = 1;
150 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); 150 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) );
151 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, 151 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay,
152 DateFormat::DayMonthYear); 152 DateFormat::DayMonthYear);
153 if (df == date_formats[2]) 153 if (df == date_formats[2])
154 currentdf = 2; 154 currentdf = 2;
155 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 155 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601
156 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); 156 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear);
157 if (df == date_formats[3]) 157 if (df == date_formats[3])
158 currentdf = 3; 158 currentdf = 3;
159 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); 159 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) );
160 160
161 dateFormatCombo->setCurrentItem( currentdf ); 161 dateFormatCombo->setCurrentItem( currentdf );
162 dateButton->setDateFormat( df ); 162 dateButton->setDateFormat( df );
163 163
164 connect( dateFormatCombo, SIGNAL( activated(int)), 164 connect( dateFormatCombo, SIGNAL( activated(int)),
165 SLOT(formatChanged(int))); 165 SLOT(formatChanged(int)));
166 166
167 QHBoxLayout *hb4 = new QHBoxLayout( vb ); 167 QHBoxLayout *hb4 = new QHBoxLayout( vb );
168 l = new QLabel( tr("Applet format" ), FrameSystemTime ); 168 l = new QLabel( tr("Applet format" ), FrameSystemTime );
169 hb4->addWidget( l, 1 ); 169 hb4->addWidget( l, 1 );
170 170
171 clockAppletCombo = new QComboBox( FrameSystemTime ); 171 clockAppletCombo = new QComboBox( FrameSystemTime );
172 clockAppletCombo->insertItem( tr("hh:mm"), 0 ); 172 clockAppletCombo->insertItem( tr("hh:mm"), 0 );
173 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); 173 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
174 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); 174 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
175 175
176 hb4->addWidget( clockAppletCombo, 2 ); 176 hb4->addWidget( clockAppletCombo, 2 );
177 int clockApplet = config.readNumEntry("ClockApplet",0); 177 int clockApplet = config.readNumEntry("ClockApplet",0);
178 clockAppletCombo->setCurrentItem( clockApplet ); 178 clockAppletCombo->setCurrentItem( clockApplet );
179 179
180 vb->addStretch( 0 ); 180 vb->addStretch( 0 );
181 181
182 QFrame *hline = new QFrame( FrameSystemTime ); 182 hline = new QFrame( FrameSystemTime );
183 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 183 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
184 vb->addWidget( hline ); 184 vb->addWidget( hline );
185 185
186 ButtonSetTime = new QPushButton( FrameSystemTime ); 186 ButtonSetTime = new QPushButton( FrameSystemTime );
187 vb->addWidget( ButtonSetTime, 1, 0 ); 187 vb->addWidget( ButtonSetTime, 1, 0 );
188 188
189 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), 189 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
190 this, SLOT(commitTime())); 190 this, SLOT(commitTime()));
191 191
192 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 192 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
193 timeButton, SLOT( slotTzChange( const QString& ) ) ); 193 timeButton, SLOT( slotTzChange( const QString& ) ) );
194 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 194 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
195 SLOT( tzChange( const QString& ) ) ); 195 SLOT( tzChange( const QString& ) ) );
196 196
197 QObject::connect( weekStartCombo, SIGNAL( activated ( int )), 197 QObject::connect( weekStartCombo, SIGNAL( activated ( int )),
198 SLOT(updateSystem(int ) )); 198 SLOT(updateSystem(int ) ));
199 QObject::connect( ampmCombo, SIGNAL( activated ( int )), 199 QObject::connect( ampmCombo, SIGNAL( activated ( int )),
200 SLOT(updateSystem(int ) )); 200 SLOT(updateSystem(int ) ));
201 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), 201 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )),
202 SLOT(updateSystem(int ) )); 202 SLOT(updateSystem(int ) ));
203 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), 203 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )),
204 SLOT(updateSystem(int ) )); 204 SLOT(updateSystem(int ) ));
205} 205}
206 206
207SetDateTime::~SetDateTime() 207SetDateTime::~SetDateTime()
208{ 208{
209 writeSettings(); 209 writeSettings();
210 210
211} 211}
212 212
213void SetDateTime::writeSettings() 213void SetDateTime::writeSettings()
214{ 214{
215 Config config("qpe"); 215 Config config("qpe");
216 config.setGroup( "Time" ); 216 config.setGroup( "Time" );
217 config.writeEntry( "AMPM", ampmCombo->currentItem() ); 217 config.writeEntry( "AMPM", ampmCombo->currentItem() );
218 config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); 218 config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
219 config.setGroup( "Date" ); 219 config.setGroup( "Date" );
220 DateFormat df = date_formats[dateFormatCombo->currentItem()]; 220 DateFormat df = date_formats[dateFormatCombo->currentItem()];
221 config.writeEntry( "Separator", QString(df.separator())); 221 config.writeEntry( "Separator", QString(df.separator()));
222 config.writeEntry( "ShortOrder", df.shortOrder()); 222 config.writeEntry( "ShortOrder", df.shortOrder());
223 config.writeEntry( "LongOrder", df.longOrder()); 223 config.writeEntry( "LongOrder", df.longOrder());
224 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); 224 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
225 225
226 Config lconfig("locale"); 226 Config lconfig("locale");
227 lconfig.setGroup( "Location" ); 227 lconfig.setGroup( "Location" );
228 lconfig.writeEntry( "Timezone", tz->currentZone() ); 228 lconfig.writeEntry( "Timezone", tz->currentZone() );
229 229
230} 230}
231 231
232void SetDateTime::commitTime() 232void SetDateTime::commitTime()
233{ 233{
234 Config cfg("ntp",Config::User); 234 Config cfg("ntp",Config::User);
235 cfg.setGroup("lookups"); 235 cfg.setGroup("lookups");
236 cfg.writeEntry("lastNtp",false); 236 cfg.writeEntry("lastNtp",false);
237 tz->setFocus(); 237 tz->setFocus();
238 // Need to process the QCOP event generated above before proceeding 238 // Need to process the QCOP event generated above before proceeding
239 qApp->processEvents(); 239 qApp->processEvents();
240 240
241 // before we progress further, set our TZ! 241 // before we progress further, set our TZ!
242 setenv( "TZ", tz->currentZone(), 1 ); 242 setenv( "TZ", tz->currentZone(), 1 );
243 // now set the time... 243 // now set the time...
244 QDateTime dt( dateButton->date(), timeButton->time() ); 244 QDateTime dt( dateButton->date(), timeButton->time() );
245 245
246 if ( dt.isValid() ) setTime(dt); 246 if ( dt.isValid() ) setTime(dt);
247} 247}
248 248
249void SetDateTime::setTime(QDateTime dt) 249void SetDateTime::setTime(QDateTime dt)
250{ 250{
251 // really turn off the screensaver before doing anything 251 // really turn off the screensaver before doing anything
252 { 252 {
253 // Needs to be encased in { } so that it deconstructs and sends 253 // Needs to be encased in { } so that it deconstructs and sends
254 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 254 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
255 disableScreenSaver << 0 << 0 << 0; 255 disableScreenSaver << 0 << 0 << 0;
256 } 256 }
257 Config cfg("ntp",Config::User); 257 Config cfg("ntp",Config::User);
258 cfg.setGroup("correction"); 258 cfg.setGroup("correction");
259 int t = TimeConversion::toUTC(dt); 259 int t = TimeConversion::toUTC(dt);
260 struct timeval myTv; 260 struct timeval myTv;
261 myTv.tv_sec = t; 261 myTv.tv_sec = t;
262 cfg.writeEntry("time", t ); 262 cfg.writeEntry("time", t );
263 myTv.tv_usec = 0; 263 myTv.tv_usec = 0;
264 264
265 if ( myTv.tv_sec != -1 ) 265 if ( myTv.tv_sec != -1 )
266 ::settimeofday( &myTv, 0 ); 266 ::settimeofday( &myTv, 0 );
267 Global::writeHWClock(); 267 Global::writeHWClock();
268 // since time has changed quickly load in the datebookdb 268 // since time has changed quickly load in the datebookdb
269 // to allow the alarm server to get a better grip on itself 269 // to allow the alarm server to get a better grip on itself
270 // (example re-trigger alarms for when we travel back in time) 270 // (example re-trigger alarms for when we travel back in time)
271 DateBookDB db; 271 DateBookDB db;
272 //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); 272 //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
273 //timeApplet << ""; 273 //timeApplet << "";
274 // Restore screensaver 274 // Restore screensaver
275 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 275 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
276 enableScreenSaver << -1 << -1 << -1; 276 enableScreenSaver << -1 << -1 << -1;
277} 277}
278 278
279void SetDateTime::updateSystem(int i) 279void SetDateTime::updateSystem(int i)
280{ 280{
281 // really turn off the screensaver before doing anything 281 // really turn off the screensaver before doing anything
282 { 282 {
283 // Needs to be encased in { } so that it deconstructs and sends 283 // Needs to be encased in { } so that it deconstructs and sends
284 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 284 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
285 disableScreenSaver << 0 << 0 << 0; 285 disableScreenSaver << 0 << 0 << 0;
286 } 286 }
287 qDebug("SetDateTime::updateSystem(int %i)",i); 287 qDebug("SetDateTime::updateSystem(int %i)",i);
288 writeSettings(); 288 writeSettings();
289 289
290 // set the timezone for everyone else... 290 // set the timezone for everyone else...
291 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 291 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
292 setTimeZone << tz->currentZone(); 292 setTimeZone << tz->currentZone();
293 293
294 // AM/PM setting and notify time changed 294 // AM/PM setting and notify time changed
295 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); 295 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
296 setClock << ampmCombo->currentItem(); 296 setClock << ampmCombo->currentItem();
297 297
298 // Notify everyone what day we prefer to start the week on. 298 // Notify everyone what day we prefer to start the week on.
299 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); 299 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
300 setWeek << weekStartCombo->currentItem(); 300 setWeek << weekStartCombo->currentItem();
301 301
302 // Notify everyone what date format to use 302 // Notify everyone what date format to use
303 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); 303 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
304 setDateFormat << date_formats[dateFormatCombo->currentItem()]; 304 setDateFormat << date_formats[dateFormatCombo->currentItem()];
305 305
306 // Restore screensaver 306 // Restore screensaver
307 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 307 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
308 enableScreenSaver << -1 << -1 << -1; 308 enableScreenSaver << -1 << -1 << -1;
309 // since time has changed quickly load in the datebookdb 309 // since time has changed quickly load in the datebookdb
310 // to allow the alarm server to get a better grip on itself 310 // to allow the alarm server to get a better grip on itself
311 // (example re-trigger alarms for when we travel back in time) 311 // (example re-trigger alarms for when we travel back in time)
312 DateBookDB db; 312 DateBookDB db;
313 313
314} 314}
315 315
316void SetDateTime::tzChange( const QString &tz ) 316void SetDateTime::tzChange( const QString &tz )
317{ 317{
318 // set the TZ get the time and leave gracefully... 318 // set the TZ get the time and leave gracefully...
319 QString strSave; 319 QString strSave;
320 strSave = getenv( "TZ" ); 320 strSave = getenv( "TZ" );
321 setenv( "TZ", tz, 1 ); 321 setenv( "TZ", tz, 1 );
322 322
323 QDate d = QDate::currentDate(); 323 QDate d = QDate::currentDate();
324 // reset the time. 324 // reset the time.
325 if ( !strSave.isNull() ) { 325 if ( !strSave.isNull() ) {
326 setenv( "TZ", strSave, 1 ); 326 setenv( "TZ", strSave, 1 );
327 } 327 }
328 dateButton->setDate( d ); 328 dateButton->setDate( d );
329 updateSystem(); 329 updateSystem();
330} 330}
331 331
332void SetDateTime::formatChanged(int i) 332void SetDateTime::formatChanged(int i)
333{ 333{
334 dateButton->setDateFormat(date_formats[i]); 334 dateButton->setDateFormat(date_formats[i]);
335} 335}
336 336
337static const int ValueAM = 0; 337static const int ValueAM = 0;
338static const int ValuePM = 1; 338static const int ValuePM = 1;
339 339
340 340
341 341
342SetTime::SetTime( QWidget *parent, const char *name ) 342SetTime::SetTime( QWidget *parent, const char *name )
343 : QWidget( parent, name ) 343 : QWidget( parent, name )
344{ 344{
345 use12hourTime = FALSE; 345 use12hourTime = FALSE;
346 346
347 QTime currTime = QTime::currentTime(); 347 QTime currTime = QTime::currentTime();
348 hour = currTime.hour(); 348 hour = currTime.hour();
349 minute = currTime.minute(); 349 minute = currTime.minute();
350 350
351 QHBoxLayout *hb2 = new QHBoxLayout( this ); 351 QHBoxLayout *hb2 = new QHBoxLayout( this );
352 hb2->setSpacing( 3 ); 352 hb2->setSpacing( 3 );
353 353
354 QLabel *l = new QLabel( tr("Hour"), this ); 354 QLabel *l = new QLabel( tr("Hour"), this );
355 // l->setAlignment( AlignRight | AlignVCenter ); 355 // l->setAlignment( AlignRight | AlignVCenter );
356 hb2->addWidget( l ); 356 hb2->addWidget( l );
357 357
358 sbHour = new QSpinBox( this ); 358 sbHour = new QSpinBox( this );
359 sbHour->setMinimumWidth( 30 ); 359 sbHour->setMinimumWidth( 30 );
360 if(use12hourTime) { 360 if(use12hourTime) {
361 sbHour->setMinValue(1); 361 sbHour->setMinValue(1);
362 sbHour->setMaxValue( 12 ); 362 sbHour->setMaxValue( 12 );
363 int show_hour = hour; 363 int show_hour = hour;
364 if (hour > 12) 364 if (hour > 12)
365 show_hour -= 12; 365 show_hour -= 12;
366 if (show_hour == 0) 366 if (show_hour == 0)
367 show_hour = 12; 367 show_hour = 12;
368 368
369 sbHour->setValue( show_hour ); 369 sbHour->setValue( show_hour );
370 } else { 370 } else {
371 sbHour->setMinValue( 0 ); 371 sbHour->setMinValue( 0 );
372 sbHour->setMaxValue( 23 ); 372 sbHour->setMaxValue( 23 );
373 sbHour->setValue( hour ); 373 sbHour->setValue( hour );
374 } 374 }
375 sbHour->setWrapping(TRUE); 375 sbHour->setWrapping(TRUE);
376 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); 376 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) );
377 hb2->addWidget( sbHour ); 377 hb2->addWidget( sbHour );
378 378
379 hb2->addStretch( 1 ); 379 hb2->addStretch( 1 );
380 380
381 l = new QLabel( tr("Minute"), this ); 381 l = new QLabel( tr("Minute"), this );
382 //l->setAlignment( AlignRight | AlignVCenter ); 382 //l->setAlignment( AlignRight | AlignVCenter );
383 hb2->addWidget( l ); 383 hb2->addWidget( l );
384 384
385 sbMin = new QSpinBox( this ); 385 sbMin = new QSpinBox( this );
386 sbMin->setMinValue( 0 ); 386 sbMin->setMinValue( 0 );
387 sbMin->setMaxValue( 59 ); 387 sbMin->setMaxValue( 59 );
388 sbMin->setWrapping(TRUE); 388 sbMin->setWrapping(TRUE);
389 sbMin->setValue( minute ); 389 sbMin->setValue( minute );
390 sbMin->setMinimumWidth( 30 ); 390 sbMin->setMinimumWidth( 30 );
391 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); 391 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) );
392 hb2->addWidget( sbMin ); 392 hb2->addWidget( sbMin );
393 393
394 hb2->addStretch( 1 ); 394 hb2->addStretch( 1 );
395 395
396 ampm = new QComboBox( this ); 396 ampm = new QComboBox( this );
397 ampm->insertItem( tr("AM"), ValueAM ); 397 ampm->insertItem( tr("AM"), ValueAM );
398 ampm->insertItem( tr("PM"), ValuePM ); 398 ampm->insertItem( tr("PM"), ValuePM );
399 connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); 399 connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) );
400 hb2->addWidget( ampm ); 400 hb2->addWidget( ampm );
401 401
402 hb2->addStretch( 1 ); 402 hb2->addStretch( 1 );
403 403
404} 404}
405 405
406QTime SetTime::time() const 406QTime SetTime::time() const
407{ 407{
408 return QTime( hour, minute, 0 ); 408 return QTime( hour, minute, 0 );
409} 409}
410 410
411void SetTime::hourChanged( int value ) 411void SetTime::hourChanged( int value )
412{ 412{
413 if(use12hourTime) { 413 if(use12hourTime) {
414 int realhour = value; 414 int realhour = value;
415 if (realhour == 12) 415 if (realhour == 12)
416 realhour = 0; 416 realhour = 0;
417 if (ampm->currentItem() == ValuePM ) 417 if (ampm->currentItem() == ValuePM )
418 realhour += 12; 418 realhour += 12;
419 hour = realhour; 419 hour = realhour;
420 } else 420 } else
421 hour = value; 421 hour = value;
422} 422}
423 423
424void SetTime::minuteChanged( int value ) 424void SetTime::minuteChanged( int value )
425{ 425{
426 minute = value; 426 minute = value;
427} 427}
428 428
429void SetTime::show12hourTime( int on ) 429void SetTime::show12hourTime( int on )
430{ 430{
431 use12hourTime = on; 431 use12hourTime = on;
432 ampm->setEnabled(on); 432 ampm->setEnabled(on);
433 433
434 int show_hour = hour; 434 int show_hour = hour;
435 if ( on ) { 435 if ( on ) {
436 /* this might change the value of hour */ 436 /* this might change the value of hour */
437 sbHour->setMinValue(1); 437 sbHour->setMinValue(1);
438 sbHour->setMaxValue( 12 ); 438 sbHour->setMaxValue( 12 );
439 439
440 /* so use one we saved earlier */ 440 /* so use one we saved earlier */
441 if (show_hour >= 12) { 441 if (show_hour >= 12) {
442 show_hour -= 12; 442 show_hour -= 12;
443 ampm->setCurrentItem( ValuePM ); 443 ampm->setCurrentItem( ValuePM );
444 } else { 444 } else {
445 ampm->setCurrentItem( ValueAM ); 445 ampm->setCurrentItem( ValueAM );
446 } 446 }
447 if (show_hour == 0) 447 if (show_hour == 0)
448 show_hour = 12; 448 show_hour = 12;
449 449
450 } else { 450 } else {
451 sbHour->setMinValue( 0 ); 451 sbHour->setMinValue( 0 );
452 sbHour->setMaxValue( 23 ); 452 sbHour->setMaxValue( 23 );
453 } 453 }
454 454
455 455
456 sbHour->setValue( show_hour ); 456 sbHour->setValue( show_hour );
457} 457}
458 458
459void SetTime::checkedPM( int c ) 459void SetTime::checkedPM( int c )
460{ 460{
461 int show_hour = sbHour->value(); 461 int show_hour = sbHour->value();
462 if (show_hour == 12) 462 if (show_hour == 12)
463 show_hour = 0; 463 show_hour = 0;
464 464
465 if ( c == ValuePM ) 465 if ( c == ValuePM )
466 show_hour += 12; 466 show_hour += 12;
467 467
468 hour = show_hour; 468 hour = show_hour;
469} 469}
470 470
471void SetTime::slotTzChange( const QString &tz ) 471void SetTime::slotTzChange( const QString &tz )
472{ 472{
473 // set the TZ get the time and leave gracefully... 473 // set the TZ get the time and leave gracefully...
474 QString strSave; 474 QString strSave;
475 strSave = getenv( "TZ" ); 475 strSave = getenv( "TZ" );
476 setenv( "TZ", tz, 1 ); 476 setenv( "TZ", tz, 1 );
477 477
478 QTime t = QTime::currentTime(); 478 QTime t = QTime::currentTime();
479 // reset the time. 479 // reset the time.
480 if ( !strSave.isNull() ) { 480 if ( !strSave.isNull() ) {
481 setenv( "TZ", strSave, 1 ); 481 setenv( "TZ", strSave, 1 );
482 } 482 }
483 483
484 // just set the spinboxes and let it propage through 484 // just set the spinboxes and let it propage through
485 if(use12hourTime) { 485 if(use12hourTime) {
486 int show_hour = t.hour(); 486 int show_hour = t.hour();
487 if (t.hour() >= 12) { 487 if (t.hour() >= 12) {
488 show_hour -= 12; 488 show_hour -= 12;
489 ampm->setCurrentItem( ValuePM ); 489 ampm->setCurrentItem( ValuePM );
490 } else { 490 } else {
491 ampm->setCurrentItem( ValueAM ); 491 ampm->setCurrentItem( ValueAM );
492 } 492 }
493 if (show_hour == 0) 493 if (show_hour == 0)
494 show_hour = 12; 494 show_hour = 12;
495 sbHour->setValue( show_hour ); 495 sbHour->setValue( show_hour );
496 } else { 496 } else {
497 sbHour->setValue( t.hour() ); 497 sbHour->setValue( t.hour() );
498 } 498 }
499 sbMin->setValue( t.minute() ); 499 sbMin->setValue( t.minute() );
500} 500}
501 501
502 502