Diffstat (limited to 'noncore/settings/netsystemtime/settime.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 116 |
1 files changed, 74 insertions, 42 deletions
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 949fcb3..36166ae 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -36,4 +36,5 @@ | |||
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <qtimer.h> | ||
38 | #include <qbuttongroup.h> | 39 | #include <qbuttongroup.h> |
39 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
@@ -53,14 +54,28 @@ | |||
53 | 54 | ||
54 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | 55 | SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) |
55 | : NtpBase( parent, name, f ) | 56 | : NtpBase( parent, name, true, f ) |
56 | { | 57 | { |
57 | // setCaption( tr("Set System Time") ); | 58 | setCaption( tr("System Time") ); |
58 | 59 | ||
59 | // QVBoxLayout *vb = new QVBoxLayout( this, 5 ); | ||
60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); | 60 | QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); |
61 | QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); | ||
62 | 61 | ||
63 | TextLabelMainPredTime = new QLabel( FrameSystemTime ); | 62 | // TextLabelMainPredTime = new QLabel( FrameSystemTime ); |
64 | vb->addWidget( TextLabelMainPredTime, 1, 0 ); | 63 | // vb->addWidget( TextLabelMainPredTime, 1, 0 ); |
64 | |||
65 | timeButton = new SetTime( FrameSystemTime ); | ||
66 | vb->addWidget( timeButton ); | ||
67 | |||
68 | QHBoxLayout *db = new QHBoxLayout( vb ); | ||
69 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSystemTime ); | ||
70 | db->addWidget( dateLabel, 1 ); | ||
71 | dateButton = new DateButton( TRUE, FrameSystemTime ); | ||
72 | db->addWidget( dateButton, 2 ); | ||
73 | |||
74 | ButtonSetTime = new QPushButton( FrameSystemTime ); | ||
75 | vb->addWidget( ButtonSetTime, 1, 0 ); | ||
76 | |||
77 | QFrame *hline = new QFrame( FrameSystemTime ); | ||
78 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | ||
79 | vb->addWidget( hline ); | ||
65 | 80 | ||
66 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); | 81 | QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); |
@@ -74,20 +89,11 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | |||
74 | hb->addWidget( tz ); | 89 | hb->addWidget( tz ); |
75 | 90 | ||
76 | timeButton = new SetTime( FrameSetTime ); | 91 | hline = new QFrame( FrameSystemTime ); |
77 | vb2->addWidget( timeButton ); | ||
78 | |||
79 | QHBoxLayout *db = new QHBoxLayout( vb2 ); | ||
80 | QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); | ||
81 | db->addWidget( dateLabel, 1 ); | ||
82 | dateButton = new DateButton( TRUE, FrameSetTime ); | ||
83 | db->addWidget( dateButton, 2 ); | ||
84 | |||
85 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
86 | vb2->addItem( spacer ); | ||
87 | |||
88 | QFrame *hline = new QFrame( FrameSystemTime ); | ||
89 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 92 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
90 | vb->addWidget( hline ); | 93 | vb->addWidget( hline ); |
91 | 94 | ||
95 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
96 | vb->addItem( spacer ); | ||
97 | |||
92 | Config config("qpe"); | 98 | Config config("qpe"); |
93 | config.setGroup( "Time" ); | 99 | config.setGroup( "Time" ); |
@@ -180,13 +186,11 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | |||
180 | vb->addStretch( 0 ); | 186 | vb->addStretch( 0 ); |
181 | 187 | ||
182 | hline = new QFrame( FrameSystemTime ); | 188 | // hline = new QFrame( FrameSystemTime ); |
183 | hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 189 | // hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
184 | vb->addWidget( hline ); | 190 | // vb->addWidget( hline ); |
185 | 191 | // | |
186 | ButtonSetTime = new QPushButton( FrameSystemTime ); | 192 | // ButtonSetTime = new QPushButton( FrameSystemTime ); |
187 | vb->addWidget( ButtonSetTime, 1, 0 ); | 193 | // vb->addWidget( ButtonSetTime, 1, 0 ); |
188 | 194 | ||
189 | QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), | ||
190 | this, SLOT(commitTime())); | ||
191 | 195 | ||
192 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 196 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
@@ -195,18 +199,16 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | |||
195 | SLOT( tzChange( const QString& ) ) ); | 199 | SLOT( tzChange( const QString& ) ) ); |
196 | 200 | ||
197 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), | 201 | // QObject::connect( weekStartCombo, SIGNAL( activated ( int )), |
198 | SLOT(updateSystem(int ) )); | 202 | // SLOT(updateSystem(int ) )); |
199 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), | 203 | // QObject::connect( ampmCombo, SIGNAL( activated ( int )), |
200 | SLOT(updateSystem(int ) )); | 204 | // SLOT(updateSystem(int ) )); |
201 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), | 205 | // QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), |
202 | SLOT(updateSystem(int ) )); | 206 | // SLOT(updateSystem(int ) )); |
203 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), | 207 | // QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), |
204 | SLOT(updateSystem(int ) )); | 208 | // SLOT(updateSystem(int ) )); |
205 | } | 209 | } |
206 | 210 | ||
207 | SetDateTime::~SetDateTime() | 211 | SetDateTime::~SetDateTime() |
208 | { | 212 | { |
209 | writeSettings(); | ||
210 | |||
211 | } | 213 | } |
212 | 214 | ||
@@ -277,5 +279,5 @@ void SetDateTime::setTime(QDateTime dt) | |||
277 | } | 279 | } |
278 | 280 | ||
279 | void SetDateTime::updateSystem(int i) | 281 | void SetDateTime::updateSystem() |
280 | { | 282 | { |
281 | // really turn off the screensaver before doing anything | 283 | // really turn off the screensaver before doing anything |
@@ -285,5 +287,5 @@ void SetDateTime::updateSystem(int i) | |||
285 | disableScreenSaver << 0 << 0 << 0; | 287 | disableScreenSaver << 0 << 0 << 0; |
286 | } | 288 | } |
287 | qDebug("SetDateTime::updateSystem(int %i)",i); | 289 | qDebug("SetDateTime::updateSystem()"); |
288 | writeSettings(); | 290 | writeSettings(); |
289 | 291 | ||
@@ -343,9 +345,13 @@ SetTime::SetTime( QWidget *parent, const char *name ) | |||
343 | : QWidget( parent, name ) | 345 | : QWidget( parent, name ) |
344 | { | 346 | { |
347 | clock = new QTimer(this, "clock" ); | ||
348 | connect(clock, SIGNAL( timeout() ), SLOT(slotClockTick()) ); | ||
349 | clock->start( 1000 * 60 ); | ||
350 | |||
345 | use12hourTime = FALSE; | 351 | use12hourTime = FALSE; |
346 | 352 | ||
347 | QTime currTime = QTime::currentTime(); | 353 | _time = QDateTime::currentDateTime(); |
348 | hour = currTime.hour(); | 354 | hour = _time.time().hour(); |
349 | minute = currTime.minute(); | 355 | minute = _time.time().minute(); |
350 | 356 | ||
351 | QHBoxLayout *hb2 = new QHBoxLayout( this ); | 357 | QHBoxLayout *hb2 = new QHBoxLayout( this ); |
@@ -500,3 +506,29 @@ void SetTime::slotTzChange( const QString &tz ) | |||
500 | } | 506 | } |
501 | 507 | ||
508 | void SetTime::setTime( QDateTime dt ) | ||
509 | { | ||
510 | _time = dt; | ||
511 | QTime t = dt.time(); | ||
512 | // just set the spinboxes and let it propage through | ||
513 | if(use12hourTime) { | ||
514 | int show_hour = t.hour(); | ||
515 | if (t.hour() >= 12) { | ||
516 | show_hour -= 12; | ||
517 | ampm->setCurrentItem( ValuePM ); | ||
518 | } else { | ||
519 | ampm->setCurrentItem( ValueAM ); | ||
520 | } | ||
521 | if (show_hour == 0) | ||
522 | show_hour = 12; | ||
523 | sbHour->setValue( show_hour ); | ||
524 | } else { | ||
525 | sbHour->setValue( t.hour() ); | ||
526 | } | ||
527 | sbMin->setValue( t.minute() ); | ||
528 | } | ||
502 | 529 | ||
530 | void SetTime::slotClockTick() | ||
531 | { | ||
532 | setTime( _time.addSecs(60) ); | ||
533 | qDebug("SetTime::slotClockTick %s",_time.toString().latin1()); | ||
534 | } | ||