-rw-r--r-- | noncore/settings/netsystemtime/settingstabwidget.cpp | 18 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settingstabwidget.h | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/noncore/settings/netsystemtime/settingstabwidget.cpp b/noncore/settings/netsystemtime/settingstabwidget.cpp index b26e751..5b52a07 100644 --- a/noncore/settings/netsystemtime/settingstabwidget.cpp +++ b/noncore/settings/netsystemtime/settingstabwidget.cpp | |||
@@ -57,107 +57,119 @@ SettingsTabWidget::SettingsTabWidget( QWidget *parent ) | |||
57 | 57 | ||
58 | // Time server selector | 58 | // Time server selector |
59 | layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); | 59 | layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); |
60 | cbTimeServer = new QComboBox( TRUE, container ); | 60 | cbTimeServer = new QComboBox( TRUE, container ); |
61 | layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); | 61 | layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); |
62 | 62 | ||
63 | // Lookup delay selector | 63 | // Lookup delay selector |
64 | layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); | 64 | layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); |
65 | sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); | 65 | sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); |
66 | sbNtpDelay->setWrapping( TRUE ); | 66 | sbNtpDelay->setWrapping( TRUE ); |
67 | sbNtpDelay->setMaximumWidth( 50 ); | 67 | sbNtpDelay->setMaximumWidth( 50 ); |
68 | connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); | 68 | connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); |
69 | layout->addWidget( sbNtpDelay, 2, 0 ); | 69 | layout->addWidget( sbNtpDelay, 2, 0 ); |
70 | 70 | ||
71 | // Prediction delay selector | 71 | // Prediction delay selector |
72 | layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); | 72 | layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); |
73 | sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); | 73 | sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); |
74 | sbPredictDelay->setWrapping( TRUE ); | 74 | sbPredictDelay->setWrapping( TRUE ); |
75 | sbPredictDelay->setMaximumWidth( 50 ); | 75 | sbPredictDelay->setMaximumWidth( 50 ); |
76 | layout->addWidget( sbPredictDelay, 3, 0 ); | 76 | layout->addWidget( sbPredictDelay, 3, 0 ); |
77 | 77 | ||
78 | // Space filler | 78 | // Space filler |
79 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); | 79 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); |
80 | 80 | ||
81 | // Show system time options on every restart | ||
82 | chShowOnRestart = new QCheckBox( tr( "Show time settings on every restart" ), container ); | ||
83 | layout->addMultiCellWidget( chShowOnRestart, 5, 5, 0, 1 ); | ||
84 | |||
81 | // Display time server information selector | 85 | // Display time server information selector |
82 | chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); | 86 | chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); |
83 | connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) ); | 87 | connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) ); |
84 | layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 ); | 88 | layout->addMultiCellWidget( chNtpTab, 6, 6, 0, 1 ); |
85 | 89 | ||
86 | // Display time prediction information selector | 90 | // Display time prediction information selector |
87 | chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); | 91 | chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); |
88 | connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) ); | 92 | connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) ); |
89 | layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 ); | 93 | layout->addMultiCellWidget( chPredictTab, 7, 7, 0, 1 ); |
90 | 94 | ||
91 | // Space filler | 95 | // Space filler |
92 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); | 96 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 8, 0 ); |
93 | 97 | ||
94 | // Initialize values | 98 | // Initialize values |
95 | QString ntpSrvsFile = QPEApplication::qpeDir(); | 99 | QString ntpSrvsFile = QPEApplication::qpeDir(); |
96 | ntpSrvsFile.append( "etc/ntpservers" ); | 100 | ntpSrvsFile.append( "etc/ntpservers" ); |
97 | Config ntpSrvs( ntpSrvsFile, Config::File ); | 101 | Config ntpSrvs( ntpSrvsFile, Config::File ); |
98 | ntpSrvs.setGroup( "servers" ); | 102 | ntpSrvs.setGroup( "servers" ); |
99 | int srvCount = ntpSrvs.readNumEntry( "count", 0 ); | 103 | int srvCount = ntpSrvs.readNumEntry( "count", 0 ); |
100 | for ( int i = 0; i < srvCount; i++ ) | 104 | for ( int i = 0; i < srvCount; i++ ) |
101 | { | 105 | { |
102 | ntpSrvs.setGroup( QString::number( i ) ); | 106 | ntpSrvs.setGroup( QString::number( i ) ); |
103 | cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); | 107 | cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); |
104 | } | 108 | } |
105 | if ( srvCount==0 ) { | 109 | if ( srvCount==0 ) { |
106 | cbTimeServer->insertItem( "0.pool.ntp.org" ); | 110 | cbTimeServer->insertItem( "0.pool.ntp.org" ); |
107 | cbTimeServer->insertItem( "1.pool.ntp.org" ); | 111 | cbTimeServer->insertItem( "1.pool.ntp.org" ); |
108 | cbTimeServer->insertItem( "2.pool.ntp.org" ); | 112 | cbTimeServer->insertItem( "2.pool.ntp.org" ); |
109 | } | 113 | } |
110 | Config config( "ntp" ); | 114 | Config config( "ntp" ); |
111 | config.setGroup( "settings" ); | 115 | config.setGroup( "settings" ); |
112 | sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); | 116 | sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); |
113 | sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); | 117 | sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); |
114 | cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); | 118 | cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); |
115 | chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); | 119 | chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); |
116 | chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); | 120 | chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); |
121 | |||
122 | Config config_qpe( "qpe" ); | ||
123 | config_qpe.setGroup( "Startup" ); | ||
124 | chShowOnRestart->setChecked( config_qpe.readBoolEntry( "ShowTimeSettings", FALSE ) ); | ||
117 | } | 125 | } |
118 | 126 | ||
119 | SettingsTabWidget::~SettingsTabWidget() | 127 | SettingsTabWidget::~SettingsTabWidget() |
120 | { | 128 | { |
121 | } | 129 | } |
122 | 130 | ||
123 | void SettingsTabWidget::saveSettings() | 131 | void SettingsTabWidget::saveSettings() |
124 | { | 132 | { |
125 | int srvCount = cbTimeServer->count(); | 133 | int srvCount = cbTimeServer->count(); |
126 | bool serversChanged = TRUE; | 134 | bool serversChanged = TRUE; |
127 | int curSrv = cbTimeServer->currentItem(); | 135 | int curSrv = cbTimeServer->currentItem(); |
128 | QString edit = cbTimeServer->currentText(); | 136 | QString edit = cbTimeServer->currentText(); |
129 | for ( int i = 0; i < srvCount; i++ ) | 137 | for ( int i = 0; i < srvCount; i++ ) |
130 | { | 138 | { |
131 | if ( edit == cbTimeServer->text( i ) ) | 139 | if ( edit == cbTimeServer->text( i ) ) |
132 | serversChanged = FALSE; | 140 | serversChanged = FALSE; |
133 | } | 141 | } |
134 | if ( serversChanged ) | 142 | if ( serversChanged ) |
135 | { | 143 | { |
136 | QString ntpSrvsFile = QPEApplication::qpeDir(); | 144 | QString ntpSrvsFile = QPEApplication::qpeDir(); |
137 | ntpSrvsFile.append( "etc/ntpservers" ); | 145 | ntpSrvsFile.append( "etc/ntpservers" ); |
138 | Config ntpSrvs( ntpSrvsFile, Config::File ); | 146 | Config ntpSrvs( ntpSrvsFile, Config::File ); |
139 | ntpSrvs.setGroup( "servers" ); | 147 | ntpSrvs.setGroup( "servers" ); |
140 | ntpSrvs.writeEntry( "count", ++srvCount ); | 148 | ntpSrvs.writeEntry( "count", ++srvCount ); |
141 | ntpSrvs.setGroup( "0" ); | 149 | ntpSrvs.setGroup( "0" ); |
142 | ntpSrvs.writeEntry( "name", edit ); | 150 | ntpSrvs.writeEntry( "name", edit ); |
143 | curSrv = 0; | 151 | curSrv = 0; |
144 | for ( int i = 1; i < srvCount; i++ ) | 152 | for ( int i = 1; i < srvCount; i++ ) |
145 | { | 153 | { |
146 | // odebug << "ntpSrvs[" << i << "/" << srvCount << "]=" << cbTimeServer->text( i ).latin1() << "" << oendl; | 154 | // odebug << "ntpSrvs[" << i << "/" << srvCount << "]=" << cbTimeServer->text( i ).latin1() << "" << oendl; |
147 | ntpSrvs.setGroup( QString::number( i ) ); | 155 | ntpSrvs.setGroup( QString::number( i ) ); |
148 | ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); | 156 | ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); |
149 | } | 157 | } |
150 | } | 158 | } |
151 | Config config( "ntp", Config::User ); | 159 | Config config( "ntp", Config::User ); |
152 | config.setGroup( "settings" ); | 160 | config.setGroup( "settings" ); |
153 | config.writeEntry( "ntpServer", curSrv ); | 161 | config.writeEntry( "ntpServer", curSrv ); |
154 | config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); | 162 | config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); |
155 | config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); | 163 | config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); |
156 | config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); | 164 | config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); |
157 | config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); | 165 | config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); |
166 | |||
167 | Config config_qpe( "qpe" ); | ||
168 | config_qpe.setGroup( "Startup" ); | ||
169 | config_qpe.writeEntry( "ShowTimeSettings", chShowOnRestart->isChecked() ); | ||
158 | } | 170 | } |
159 | 171 | ||
160 | QString SettingsTabWidget::ntpServer() | 172 | QString SettingsTabWidget::ntpServer() |
161 | { | 173 | { |
162 | return cbTimeServer->currentText(); | 174 | return cbTimeServer->currentText(); |
163 | } | 175 | } |
diff --git a/noncore/settings/netsystemtime/settingstabwidget.h b/noncore/settings/netsystemtime/settingstabwidget.h index 9578245..17e7989 100644 --- a/noncore/settings/netsystemtime/settingstabwidget.h +++ b/noncore/settings/netsystemtime/settingstabwidget.h | |||
@@ -31,34 +31,35 @@ | |||
31 | #ifndef SETTINGSTABWIDGET_H | 31 | #ifndef SETTINGSTABWIDGET_H |
32 | #define SETTINGSTABWIDGET_H | 32 | #define SETTINGSTABWIDGET_H |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | 35 | ||
36 | class QCheckBox; | 36 | class QCheckBox; |
37 | class QComboBox; | 37 | class QComboBox; |
38 | class QSpinBox; | 38 | class QSpinBox; |
39 | 39 | ||
40 | class SettingsTabWidget : public QWidget | 40 | class SettingsTabWidget : public QWidget |
41 | { | 41 | { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | 43 | ||
44 | public: | 44 | public: |
45 | SettingsTabWidget( QWidget * = 0x0 ); | 45 | SettingsTabWidget( QWidget * = 0x0 ); |
46 | ~SettingsTabWidget(); | 46 | ~SettingsTabWidget(); |
47 | 47 | ||
48 | void saveSettings(); | 48 | void saveSettings(); |
49 | QString ntpServer(); | 49 | QString ntpServer(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | QComboBox *cbTimeServer; | 52 | QComboBox *cbTimeServer; |
53 | QSpinBox *sbNtpDelay; | 53 | QSpinBox *sbNtpDelay; |
54 | QSpinBox *sbPredictDelay; | 54 | QSpinBox *sbPredictDelay; |
55 | QCheckBox *chShowOnRestart; | ||
55 | QCheckBox *chNtpTab; | 56 | QCheckBox *chNtpTab; |
56 | QCheckBox *chPredictTab; | 57 | QCheckBox *chPredictTab; |
57 | 58 | ||
58 | signals: | 59 | signals: |
59 | void ntpDelayChanged( int ); | 60 | void ntpDelayChanged( int ); |
60 | void displayNTPTab( bool ); | 61 | void displayNTPTab( bool ); |
61 | void displayPredictTab( bool ); | 62 | void displayPredictTab( bool ); |
62 | }; | 63 | }; |
63 | 64 | ||
64 | #endif | 65 | #endif |