summaryrefslogtreecommitdiff
path: root/noncore
authortille <tille>2002-11-16 16:43:02 (UTC)
committer tille <tille>2002-11-16 16:43:02 (UTC)
commit0633fb26123857509c9eb0e0a013b654667ca9ce (patch) (unidiff)
tree9187213cc22830c65dcba1923be9a8355c673b5a /noncore
parent88435a3192f09453e035a7f1cf73bbc8c24245c9 (diff)
downloadopie-0633fb26123857509c9eb0e0a013b654667ca9ce.zip
opie-0633fb26123857509c9eb0e0a013b654667ca9ce.tar.gz
opie-0633fb26123857509c9eb0e0a013b654667ca9ce.tar.bz2
usability:
made it a dialog that saves when exiting clock now running
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/TODO3
-rw-r--r--noncore/settings/netsystemtime/main.cpp2
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp36
-rw-r--r--noncore/settings/netsystemtime/ntp.h2
-rw-r--r--noncore/settings/netsystemtime/ntpbase.cpp12
-rw-r--r--noncore/settings/netsystemtime/ntpbase.h9
-rw-r--r--noncore/settings/netsystemtime/ntpbase.ui2
-rw-r--r--noncore/settings/netsystemtime/settime.cpp116
-rw-r--r--noncore/settings/netsystemtime/settime.h8
9 files changed, 121 insertions, 69 deletions
diff --git a/noncore/settings/netsystemtime/TODO b/noncore/settings/netsystemtime/TODO
new file mode 100644
index 0000000..fb003a2
--- a/dev/null
+++ b/noncore/settings/netsystemtime/TODO
@@ -0,0 +1,3 @@
1- handle hour > 24 in SetTime::slotClockTick
2- improve tz setting
3 atm the tz gets written to the system as soon as changed...
diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp
index c6d5f9a..80fbcb8 100644
--- a/noncore/settings/netsystemtime/main.cpp
+++ b/noncore/settings/netsystemtime/main.cpp
@@ -5,5 +5,5 @@
5int main( int argc, char ** argv ) 5int main( int argc, char ** argv )
6{ 6{
7 printf("This is netsystemtime\n"); 7 printf("This is netsystemtime ");
8 printf("$Id$\n"); 8 printf("$Id$\n");
9 9
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index c7e3b52..53dbe46 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -57,5 +57,4 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
57 57
58 TabWidgetMain->insertTab( tabMain, tr( "Main" ) ); 58 TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
59 TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
60 TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) ); 59 TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
61 TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) ); 60 TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
@@ -97,4 +96,7 @@ Ntp::~Ntp()
97{ 96{
98 delete ntpProcess; 97 delete ntpProcess;
98}
99
100void Ntp::saveConfig(){
99 int srvCount = ComboNtpSrv->count(); 101 int srvCount = ComboNtpSrv->count();
100 bool serversChanged = true; 102 bool serversChanged = true;
@@ -200,19 +202,9 @@ void Ntp::ntpFinished(OProcess *p)
200 if ( isVisible() && _interactive ){ 202 if ( isVisible() && _interactive ){
201 QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); 203 QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput );
202 TabWidgetMain->showPage( tabManualSetTime );
203 } 204 }
204 205// slotCheckNtp(-1);
205 return; 206 return;
206 } 207 }
207 208
208 Global::writeHWClock();
209 // since time has changed quickly load in the datebookdb
210 // to allow the alarm server to get a better grip on itself
211 // (example re-trigger alarms for when we travel back in time)
212 DateBookDB db;
213
214 // QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
215 // timeApplet << "";
216
217 Config cfg("ntp",Config::User); 209 Config cfg("ntp",Config::User);
218 cfg.setGroup("lookups"); 210 cfg.setGroup("lookups");
@@ -307,18 +299,20 @@ void Ntp::preditctTime()
307 predictedTime = QDateTime::currentDateTime().addSecs(corr); 299 predictedTime = QDateTime::currentDateTime().addSecs(corr);
308 TextLabelPredTime->setText(predictedTime.toString()); 300 TextLabelPredTime->setText(predictedTime.toString());
309 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); 301// TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
310} 302}
311 303
312void Ntp::setPredictTime() 304void Ntp::setPredictTime()
313{ 305{
306 qDebug("Ntp::setPredictTime");
314 preditctTime(); 307 preditctTime();
315 setTime( predictedTime ); 308 timeButton->setTime( predictedTime );
316} 309}
317 310
318void Ntp::slotCheckNtp(int i) 311void Ntp::slotCheckNtp(int i)
319{ 312{
313 qDebug(" Ntp::slotCheckNtp(%i)",i);
320 if (i == 0) 314 if (i == 0)
321 { 315 {
322 TextLabelMainPredTime->hide(); 316// TextLabelMainPredTime->hide();
323 ButtonSetTime->setText( tr("Get time from network") ); 317 ButtonSetTime->setText( tr("Get time from network") );
324 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); 318 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) );
@@ -419,2 +413,14 @@ void Ntp::showAdvancedFeatures(bool advMode)
419 TabWidgetMain->show(); 413 TabWidgetMain->show();
420} 414}
415
416
417void Ntp::accept( ){
418 qDebug("accepted");
419 //SetTimeDate
420 commitTime();
421 writeSettings();
422 updateSystem();
423 // Ntp
424 saveConfig();
425 qApp->quit();
426} \ No newline at end of file
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index 15cddbd..a4573f8 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -21,4 +21,5 @@ public slots:
21 void setDocument (const QString &); 21 void setDocument (const QString &);
22protected: 22protected:
23 virtual void accept( );
23 QDateTime predictedTime; 24 QDateTime predictedTime;
24 void makeChannel(); 25 void makeChannel();
@@ -39,4 +40,5 @@ private:
39 bool ntpDelayElapsed(); 40 bool ntpDelayElapsed();
40 QString getNtpServer(); 41 QString getNtpServer();
42 void saveConfig();
41private slots: 43private slots:
42 void slotTimerRunNtp(); 44 void slotTimerRunNtp();
diff --git a/noncore/settings/netsystemtime/ntpbase.cpp b/noncore/settings/netsystemtime/ntpbase.cpp
index 0a7a57e..878c158 100644
--- a/noncore/settings/netsystemtime/ntpbase.cpp
+++ b/noncore/settings/netsystemtime/ntpbase.cpp
@@ -2,5 +2,5 @@
2** Form implementation generated from reading ui file 'ntpbase.ui' 2** Form implementation generated from reading ui file 'ntpbase.ui'
3** 3**
4** Created: Sun Nov 10 17:59:14 2002 4** Created: Sat Nov 16 15:49:54 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
@@ -18,4 +18,5 @@
18#include <qtable.h> 18#include <qtable.h>
19#include <qtabwidget.h> 19#include <qtabwidget.h>
20#include <qwidget.h>
20#include <qlayout.h> 21#include <qlayout.h>
21#include <qvariant.h> 22#include <qvariant.h>
@@ -26,7 +27,10 @@
26 * Constructs a NtpBase which is a child of 'parent', with the 27 * Constructs a NtpBase which is a child of 'parent', with the
27 * name 'name' and widget flags set to 'f' 28 * name 'name' and widget flags set to 'f'
29 *
30 * The dialog will by default be modeless, unless you set 'modal' to
31 * TRUE to construct a modal dialog.
28 */ 32 */
29NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl ) 33NtpBase::NtpBase( QWidget* parent, const char* name, bool modal, WFlags fl )
30 : QWidget( parent, name, fl ) 34 : QDialog( parent, name, modal, fl )
31{ 35{
32 if ( !name ) 36 if ( !name )
@@ -318,5 +322,5 @@ NtpBase::~NtpBase()
318bool NtpBase::event( QEvent* ev ) 322bool NtpBase::event( QEvent* ev )
319{ 323{
320 bool ret = QWidget::event( ev ); 324 bool ret = QDialog::event( ev );
321 if ( ev->type() == QEvent::ApplicationFontChange ) { 325 if ( ev->type() == QEvent::ApplicationFontChange ) {
322 QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() ); 326 QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
diff --git a/noncore/settings/netsystemtime/ntpbase.h b/noncore/settings/netsystemtime/ntpbase.h
index 543cac1..68599c9 100644
--- a/noncore/settings/netsystemtime/ntpbase.h
+++ b/noncore/settings/netsystemtime/ntpbase.h
@@ -2,5 +2,5 @@
2** Form interface generated from reading ui file 'ntpbase.ui' 2** Form interface generated from reading ui file 'ntpbase.ui'
3** 3**
4** Created: Sun Nov 10 17:58:48 2002 4** Created: Sat Nov 16 15:49:32 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
@@ -11,5 +11,5 @@
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13#include <qwidget.h> 13#include <qdialog.h>
14class QVBoxLayout; 14class QVBoxLayout;
15class QHBoxLayout; 15class QHBoxLayout;
@@ -24,11 +24,12 @@ class QSpinBox;
24class QTabWidget; 24class QTabWidget;
25class QTable; 25class QTable;
26class QWidget;
26 27
27class NtpBase : public QWidget 28class NtpBase : public QDialog
28{ 29{
29 Q_OBJECT 30 Q_OBJECT
30 31
31public: 32public:
32 NtpBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 33 NtpBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
33 ~NtpBase(); 34 ~NtpBase();
34 35
diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui
index 6c38588..8c106be 100644
--- a/noncore/settings/netsystemtime/ntpbase.ui
+++ b/noncore/settings/netsystemtime/ntpbase.ui
@@ -2,5 +2,5 @@
2<class>NtpBase</class> 2<class>NtpBase</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
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
54SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) 55SetDateTime::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
207SetDateTime::~SetDateTime() 211SetDateTime::~SetDateTime()
208{ 212{
209 writeSettings();
210
211} 213}
212 214
@@ -277,5 +279,5 @@ void SetDateTime::setTime(QDateTime dt)
277} 279}
278 280
279void SetDateTime::updateSystem(int i) 281void 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
508void 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
530void SetTime::slotClockTick()
531{
532 setTime( _time.addSecs(60) );
533 qDebug("SetTime::slotClockTick %s",_time.toString().latin1());
534}
diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h
index 778cb9c..3c3a162 100644
--- a/noncore/settings/netsystemtime/settime.h
+++ b/noncore/settings/netsystemtime/settime.h
@@ -42,4 +42,5 @@ public:
42 42
43 QTime time() const; 43 QTime time() const;
44 void setTime( QDateTime );
44 45
45public slots: 46public slots:
@@ -48,4 +49,5 @@ public slots:
48 49
49protected slots: 50protected slots:
51 void slotClockTick();
50 void hourChanged( int value ); 52 void hourChanged( int value );
51 void minuteChanged( int value ); 53 void minuteChanged( int value );
@@ -57,4 +59,6 @@ protected:
57 int minute; 59 int minute;
58 bool use12hourTime; 60 bool use12hourTime;
61 QDateTime _time;
62 QTimer *clock;
59 QComboBox *ampm; 63 QComboBox *ampm;
60 QSpinBox *sbHour; 64 QSpinBox *sbHour;
@@ -75,5 +79,5 @@ protected slots:
75 void tzChange( const QString &tz ); 79 void tzChange( const QString &tz );
76 void formatChanged(int); 80 void formatChanged(int);
77 void updateSystem(int i=0); 81 void updateSystem();
78 82
79protected: 83protected:
@@ -89,5 +93,5 @@ protected:
89 QComboBox *clockAppletCombo; 93 QComboBox *clockAppletCombo;
90 QPushButton *ButtonSetTime; 94 QPushButton *ButtonSetTime;
91 QLabel *TextLabelMainPredTime; 95 // QLabel *TextLabelMainPredTime;
92 96
93 DateFormat date_formats[4]; 97 DateFormat date_formats[4];