Diffstat (limited to 'noncore/settings/networksettings/ppp/conwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/conwindow.cpp | 243 |
1 files changed, 120 insertions, 123 deletions
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp index 20d705d..9136ca0 100644 --- a/noncore/settings/networksettings/ppp/conwindow.cpp +++ b/noncore/settings/networksettings/ppp/conwindow.cpp | |||
@@ -32,8 +32,7 @@ | |||
32 | // #include <kglobal.h> | 32 | // #include <kglobal.h> |
33 | 33 | ||
34 | extern PPPData gpppdata; | ||
35 | 34 | ||
36 | ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget ) | 35 | ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, |
37 | // PPPStats *st) | 36 | QDialog *mainwidget ) |
38 | : QWidget(parent, name, 0), | 37 | : QWidget(parent, name, 0), |
39 | minutes(0), | 38 | minutes(0), |
@@ -42,7 +41,5 @@ ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget ) | |||
42 | days(0), | 41 | days(0), |
43 | tl1(0), | 42 | tl1(0), |
44 | // stats(st), | 43 | _pppdata(pd) |
45 | accountingEnabled(false), | ||
46 | volumeAccountingEnabled(false) | ||
47 | { | 44 | { |
48 | info1 = new QLabel(i18n("Connected at:"), this); | 45 | info1 = new QLabel(i18n("Connected at:"), this); |
@@ -116,120 +113,120 @@ QString ConWindow::prettyPrintVolume(unsigned int n) { | |||
116 | } | 113 | } |
117 | 114 | ||
118 | void ConWindow::accounting(bool on) { | 115 | // void ConWindow::accounting(bool on) { |
119 | // cache accounting settings | 116 | // // cache accounting settings |
120 | accountingEnabled = on; | 117 | // accountingEnabled = on; |
121 | volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); | 118 | // // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); |
122 | |||
123 | // delete old layout | ||
124 | if(tl1 != 0) | ||
125 | delete tl1; | ||
126 | |||
127 | // add layout now | ||
128 | tl1 = new QVBoxLayout(this, 10, 10); | ||
129 | tl1->addSpacing(5); | ||
130 | QHBoxLayout *tl = new QHBoxLayout; | ||
131 | tl1->addLayout(tl); | ||
132 | tl->addSpacing(20); | ||
133 | QGridLayout *l1; | ||
134 | |||
135 | int vol_lines = 0; | ||
136 | if(PPPData::data()->VolAcctEnabled()) | ||
137 | vol_lines = 1; | ||
138 | |||
139 | if(accountingEnabled) | ||
140 | l1 = new QGridLayout(4 + vol_lines, 2, 5); | ||
141 | else | ||
142 | l1 = new QGridLayout(2 + vol_lines, 2, 5); | ||
143 | tl->addLayout(l1); | ||
144 | l1->setColStretch(0, 0); | ||
145 | l1->setColStretch(1, 1); | ||
146 | |||
147 | info2->setAlignment(AlignRight|AlignVCenter); | ||
148 | timelabel2->setAlignment(AlignRight|AlignVCenter); | ||
149 | session_bill->setAlignment(AlignRight|AlignVCenter); | ||
150 | total_bill->setAlignment(AlignRight|AlignVCenter); | ||
151 | volinfo->setAlignment(AlignRight|AlignVCenter); | ||
152 | // make sure that there's enough space for the bills | ||
153 | QString s1 = session_bill->text(); | ||
154 | QString s2 = total_bill->text(); | ||
155 | QString s3 = volinfo->text(); | ||
156 | |||
157 | session_bill->setText("888888.88 XXX"); | ||
158 | total_bill->setText("888888.88 XXX"); | ||
159 | volinfo->setText("8888.8 MB"); | ||
160 | session_bill->setFixedSize(session_bill->sizeHint()); | ||
161 | total_bill->setFixedSize(total_bill->sizeHint()); | ||
162 | volinfo->setFixedSize(volinfo->sizeHint()); | ||
163 | session_bill->setText(s1); | ||
164 | total_bill->setText(s2); | ||
165 | volinfo->setText(s3); | ||
166 | |||
167 | l1->addWidget(info1, 0, 0); | ||
168 | l1->addWidget(info2, 0, 1); | ||
169 | l1->addWidget(timelabel1, 1, 0); | ||
170 | l1->addWidget(timelabel2, 1, 1); | ||
171 | if(accountingEnabled) { | ||
172 | session_bill_l->show(); | ||
173 | session_bill->show(); | ||
174 | total_bill_l->show(); | ||
175 | total_bill->show(); | ||
176 | l1->addWidget(session_bill_l, 2, 0); | ||
177 | l1->addWidget(session_bill, 2, 1); | ||
178 | l1->addWidget(total_bill_l, 3, 0); | ||
179 | l1->addWidget(total_bill, 3, 1); | ||
180 | |||
181 | if(volumeAccountingEnabled) { | ||
182 | vollabel->show(); | ||
183 | volinfo->show(); | ||
184 | l1->addWidget(vollabel, 4, 0); | ||
185 | l1->addWidget(volinfo, 4, 1); | ||
186 | } else { | ||
187 | vollabel->hide(); | ||
188 | volinfo->hide(); | ||
189 | } | ||
190 | 119 | ||
191 | } else { | 120 | // // delete old layout |
192 | session_bill_l->hide(); | 121 | // if(tl1 != 0) |
193 | session_bill->hide(); | 122 | // delete tl1; |
194 | total_bill_l->hide(); | ||
195 | total_bill->hide(); | ||
196 | |||
197 | if(volumeAccountingEnabled) { | ||
198 | vollabel->show(); | ||
199 | volinfo->show(); | ||
200 | l1->addWidget(vollabel, 2, 0); | ||
201 | l1->addWidget(volinfo, 2, 1); | ||
202 | } else { | ||
203 | vollabel->hide(); | ||
204 | volinfo->hide(); | ||
205 | } | ||
206 | } | ||
207 | 123 | ||
208 | tl->addSpacing(10); | 124 | // // add layout now |
209 | QVBoxLayout *l2 = new QVBoxLayout(5); | 125 | // tl1 = new QVBoxLayout(this, 10, 10); |
210 | tl->addLayout(l2); | 126 | // tl1->addSpacing(5); |
211 | l2->addStretch(1); | 127 | // QHBoxLayout *tl = new QHBoxLayout; |
212 | // l2->addWidget(statsbutton); | 128 | // tl1->addLayout(tl); |
213 | l2->addWidget(cancelbutton); | 129 | // tl->addSpacing(20); |
130 | // QGridLayout *l1; | ||
214 | 131 | ||
215 | l2->addStretch(1); | 132 | // int vol_lines = 0; |
133 | // // if(_pppdata->VolAcctEnabled()) | ||
134 | // // vol_lines = 1; | ||
216 | 135 | ||
217 | tl1->addSpacing(5); | 136 | // if(accountingEnabled) |
137 | // l1 = new QGridLayout(4 + vol_lines, 2, 5); | ||
138 | // else | ||
139 | // l1 = new QGridLayout(2 + vol_lines, 2, 5); | ||
140 | // tl->addLayout(l1); | ||
141 | // l1->setColStretch(0, 0); | ||
142 | // l1->setColStretch(1, 1); | ||
143 | |||
144 | // info2->setAlignment(AlignRight|AlignVCenter); | ||
145 | // timelabel2->setAlignment(AlignRight|AlignVCenter); | ||
146 | // session_bill->setAlignment(AlignRight|AlignVCenter); | ||
147 | // total_bill->setAlignment(AlignRight|AlignVCenter); | ||
148 | // volinfo->setAlignment(AlignRight|AlignVCenter); | ||
149 | // // make sure that there's enough space for the bills | ||
150 | // QString s1 = session_bill->text(); | ||
151 | // QString s2 = total_bill->text(); | ||
152 | // QString s3 = volinfo->text(); | ||
153 | |||
154 | // session_bill->setText("888888.88 XXX"); | ||
155 | // total_bill->setText("888888.88 XXX"); | ||
156 | // volinfo->setText("8888.8 MB"); | ||
157 | // session_bill->setFixedSize(session_bill->sizeHint()); | ||
158 | // total_bill->setFixedSize(total_bill->sizeHint()); | ||
159 | // volinfo->setFixedSize(volinfo->sizeHint()); | ||
160 | // session_bill->setText(s1); | ||
161 | // total_bill->setText(s2); | ||
162 | // volinfo->setText(s3); | ||
163 | |||
164 | // l1->addWidget(info1, 0, 0); | ||
165 | // l1->addWidget(info2, 0, 1); | ||
166 | // l1->addWidget(timelabel1, 1, 0); | ||
167 | // l1->addWidget(timelabel2, 1, 1); | ||
168 | // if(accountingEnabled) { | ||
169 | // session_bill_l->show(); | ||
170 | // session_bill->show(); | ||
171 | // total_bill_l->show(); | ||
172 | // total_bill->show(); | ||
173 | // l1->addWidget(session_bill_l, 2, 0); | ||
174 | // l1->addWidget(session_bill, 2, 1); | ||
175 | // l1->addWidget(total_bill_l, 3, 0); | ||
176 | // l1->addWidget(total_bill, 3, 1); | ||
218 | 177 | ||
219 | setFixedSize(sizeHint()); | 178 | // if(volumeAccountingEnabled) { |
220 | /* | 179 | // vollabel->show(); |
221 | do not overwrite position read from config | 180 | // volinfo->show(); |
222 | setGeometry((QApplication::desktop()->width() - width()) / 2, | 181 | // l1->addWidget(vollabel, 4, 0); |
223 | (QApplication::desktop()->height() - height())/2, | 182 | // l1->addWidget(volinfo, 4, 1); |
224 | width(), | 183 | // } else { |
225 | height()); | 184 | // vollabel->hide(); |
226 | */ | 185 | // volinfo->hide(); |
227 | } | 186 | // } |
228 | 187 | ||
188 | // } else { | ||
189 | // session_bill_l->hide(); | ||
190 | // session_bill->hide(); | ||
191 | // total_bill_l->hide(); | ||
192 | // total_bill->hide(); | ||
229 | 193 | ||
230 | void ConWindow::dock() { | 194 | // if(volumeAccountingEnabled) { |
231 | // DockWidget::dock_widget->show(); | 195 | // vollabel->show(); |
232 | this->hide(); | 196 | // volinfo->show(); |
233 | } | 197 | // l1->addWidget(vollabel, 2, 0); |
198 | // l1->addWidget(volinfo, 2, 1); | ||
199 | // } else { | ||
200 | // vollabel->hide(); | ||
201 | // volinfo->hide(); | ||
202 | // } | ||
203 | // } | ||
204 | |||
205 | // tl->addSpacing(10); | ||
206 | // QVBoxLayout *l2 = new QVBoxLayout(5); | ||
207 | // tl->addLayout(l2); | ||
208 | // l2->addStretch(1); | ||
209 | // // l2->addWidget(statsbutton); | ||
210 | // l2->addWidget(cancelbutton); | ||
211 | |||
212 | // l2->addStretch(1); | ||
213 | |||
214 | // tl1->addSpacing(5); | ||
215 | |||
216 | // setFixedSize(sizeHint()); | ||
217 | // /* | ||
218 | // do not overwrite position read from config | ||
219 | // setGeometry((QApplication::desktop()->width() - width()) / 2, | ||
220 | // (QApplication::desktop()->height() - height())/2, | ||
221 | // width(), | ||
222 | // height()); | ||
223 | // */ | ||
224 | // } | ||
225 | |||
226 | |||
227 | // void ConWindow::dock() { | ||
228 | // // DockWidget::dock_widget->show(); | ||
229 | // this->hide(); | ||
230 | // } | ||
234 | 231 | ||
235 | 232 | ||
@@ -240,7 +237,7 @@ void ConWindow::startClock() { | |||
240 | QString title ; | 237 | QString title ; |
241 | 238 | ||
242 | title = PPPData::data()->accname(); | 239 | title = _pppdata->accname(); |
243 | 240 | ||
244 | if(PPPData::data()->get_show_clock_on_caption()){ | 241 | if(_pppdata->get_show_clock_on_caption()){ |
245 | title += " 00:00" ; | 242 | title += " 00:00" ; |
246 | } | 243 | } |
@@ -266,5 +263,5 @@ void ConWindow::timeclick() { | |||
266 | // "Connected at: %2\n" | 263 | // "Connected at: %2\n" |
267 | // "Time connected: %3") | 264 | // "Time connected: %3") |
268 | // .arg(PPPData::data()->accname()).arg(info2->text()) | 265 | // .arg(_pppdata->accname()).arg(info2->text()) |
269 | // .arg(time_string2); | 266 | // .arg(time_string2); |
270 | 267 | ||
@@ -276,5 +273,5 @@ void ConWindow::timeclick() { | |||
276 | 273 | ||
277 | // volinfo->setEnabled(TRUE); | 274 | // volinfo->setEnabled(TRUE); |
278 | // int bytes = PPPData::data()->totalBytes(); | 275 | // int bytes = _pppdata->totalBytes(); |
279 | // volinfo->setText(prettyPrintVolume(bytes)); | 276 | // volinfo->setText(prettyPrintVolume(bytes)); |
280 | // } | 277 | // } |
@@ -306,5 +303,5 @@ void ConWindow::timeclick() { | |||
306 | // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); | 303 | // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); |
307 | 304 | ||
308 | // caption_string = PPPData::data()->accname(); | 305 | // caption_string = _pppdata->accname(); |
309 | // caption_string += " "; | 306 | // caption_string += " "; |
310 | // caption_string += time_string; | 307 | // caption_string += time_string; |
@@ -313,5 +310,5 @@ void ConWindow::timeclick() { | |||
313 | // timelabel2->setText(time_string2); | 310 | // timelabel2->setText(time_string2); |
314 | 311 | ||
315 | // if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){ | 312 | // if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){ |
316 | // // we update the Caption only once per minute not every second | 313 | // // we update the Caption only once per minute not every second |
317 | // // otherwise I get a flickering icon | 314 | // // otherwise I get a flickering icon |
@@ -329,6 +326,6 @@ void ConWindow::closeEvent( QCloseEvent *e ){ | |||
329 | e->ignore(); | 326 | e->ignore(); |
330 | 327 | ||
331 | if(PPPData::data()->get_dock_into_panel()) | 328 | // if(_pppdata->get_dock_into_panel()) |
332 | dock(); | 329 | // dock(); |
333 | } | 330 | } |
334 | 331 | ||