summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/conwindow.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/conwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index d6b3fbe..ad89005 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -66,38 +66,38 @@ ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget )
66 cancelbutton->setText(i18n("Disconnect")); 66 cancelbutton->setText(i18n("Disconnect"));
67 connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); 67 connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect()));
68 68
69 // statsbutton = new QPushButton(this); 69 // statsbutton = new QPushButton(this);
70// statsbutton->setText(i18n("Details")); 70// statsbutton->setText(i18n("Details"));
71// statsbutton->setFocus(); 71// statsbutton->setFocus();
72// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); 72// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats()));
73 73
74 clocktimer = new QTimer(this); 74 clocktimer = new QTimer(this);
75 connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); 75 connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick()));
76 76
77 // read window position from config file 77 // read window position from config file
78 int p_x, p_y; 78// int p_x, p_y;
79 gpppdata.winPosConWin(p_x, p_y); 79// PPPData::data()->winPosConWin(p_x, p_y);
80 setGeometry(p_x, p_y, 320, 110); 80// setGeometry(p_x, p_y, 320, 110);
81} 81}
82 82
83ConWindow::~ConWindow() { 83ConWindow::~ConWindow() {
84 stopClock(); 84 stopClock();
85} 85}
86 86
87// save window position when window was closed 87// save window position when window was closed
88bool ConWindow::event(QEvent *e) { 88bool ConWindow::event(QEvent *e) {
89 if (e->type() == QEvent::Hide) 89 if (e->type() == QEvent::Hide)
90 { 90 {
91 gpppdata.setWinPosConWin(x(), y()); 91// PPPData::data()->setWinPosConWin(x(), y());
92 return true; 92 return true;
93 } 93 }
94 else 94 else
95 return QWidget::event(e); 95 return QWidget::event(e);
96} 96}
97 97
98QString ConWindow::prettyPrintVolume(unsigned int n) { 98QString ConWindow::prettyPrintVolume(unsigned int n) {
99 int idx = 0; 99 int idx = 0;
100 const QString quant[] = {i18n("Byte"), i18n("KB"), 100 const QString quant[] = {i18n("Byte"), i18n("KB"),
101 i18n("MB"), i18n("GB"), QString::null}; 101 i18n("MB"), i18n("GB"), QString::null};
102 102
103 float n1 = n; 103 float n1 = n;
@@ -109,40 +109,40 @@ QString ConWindow::prettyPrintVolume(unsigned int n) {
109 int i = idx; 109 int i = idx;
110 while(i--) 110 while(i--)
111 n1 = n1 / 1024.0; 111 n1 = n1 / 1024.0;
112 112
113 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); 113 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
114 s += " " + quant[idx]; 114 s += " " + quant[idx];
115 return s; 115 return s;
116} 116}
117 117
118void ConWindow::accounting(bool on) { 118void ConWindow::accounting(bool on) {
119 // cache accounting settings 119 // cache accounting settings
120 accountingEnabled = on; 120 accountingEnabled = on;
121 volumeAccountingEnabled = gpppdata.VolAcctEnabled(); 121 volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
122 122
123 // delete old layout 123 // delete old layout
124 if(tl1 != 0) 124 if(tl1 != 0)
125 delete tl1; 125 delete tl1;
126 126
127 // add layout now 127 // add layout now
128 tl1 = new QVBoxLayout(this, 10, 10); 128 tl1 = new QVBoxLayout(this, 10, 10);
129 tl1->addSpacing(5); 129 tl1->addSpacing(5);
130 QHBoxLayout *tl = new QHBoxLayout; 130 QHBoxLayout *tl = new QHBoxLayout;
131 tl1->addLayout(tl); 131 tl1->addLayout(tl);
132 tl->addSpacing(20); 132 tl->addSpacing(20);
133 QGridLayout *l1; 133 QGridLayout *l1;
134 134
135 int vol_lines = 0; 135 int vol_lines = 0;
136 if(gpppdata.VolAcctEnabled()) 136 if(PPPData::data()->VolAcctEnabled())
137 vol_lines = 1; 137 vol_lines = 1;
138 138
139 if(accountingEnabled) 139 if(accountingEnabled)
140 l1 = new QGridLayout(4 + vol_lines, 2, 5); 140 l1 = new QGridLayout(4 + vol_lines, 2, 5);
141 else 141 else
142 l1 = new QGridLayout(2 + vol_lines, 2, 5); 142 l1 = new QGridLayout(2 + vol_lines, 2, 5);
143 tl->addLayout(l1); 143 tl->addLayout(l1);
144 l1->setColStretch(0, 0); 144 l1->setColStretch(0, 0);
145 l1->setColStretch(1, 1); 145 l1->setColStretch(1, 1);
146 146
147 info2->setAlignment(AlignRight|AlignVCenter); 147 info2->setAlignment(AlignRight|AlignVCenter);
148 timelabel2->setAlignment(AlignRight|AlignVCenter); 148 timelabel2->setAlignment(AlignRight|AlignVCenter);
@@ -230,61 +230,61 @@ void ConWindow::accounting(bool on) {
230void ConWindow::dock() { 230void ConWindow::dock() {
231// DockWidget::dock_widget->show(); 231// DockWidget::dock_widget->show();
232 this->hide(); 232 this->hide();
233} 233}
234 234
235 235
236void ConWindow::startClock() { 236void ConWindow::startClock() {
237 minutes = 0; 237 minutes = 0;
238 seconds = 0; 238 seconds = 0;
239 hours = 0; 239 hours = 0;
240 QString title ; 240 QString title ;
241 241
242 title = gpppdata.accname(); 242 title = PPPData::data()->accname();
243 243
244 if(gpppdata.get_show_clock_on_caption()){ 244 if(PPPData::data()->get_show_clock_on_caption()){
245 title += " 00:00" ; 245 title += " 00:00" ;
246 } 246 }
247 this->setCaption(title); 247 this->setCaption(title);
248 248
249 timelabel2->setText("00:00:00"); 249 timelabel2->setText("00:00:00");
250 clocktimer->start(1000); 250 clocktimer->start(1000);
251} 251}
252 252
253 253
254void ConWindow::setConnectionSpeed(const QString &speed) { 254void ConWindow::setConnectionSpeed(const QString &speed) {
255 info2->setText(speed); 255 info2->setText(speed);
256} 256}
257 257
258 258
259void ConWindow::stopClock() { 259void ConWindow::stopClock() {
260 clocktimer->stop(); 260 clocktimer->stop();
261} 261}
262 262
263 263
264void ConWindow::timeclick() { 264void ConWindow::timeclick() {
265 QString tooltip = i18n("Connection: %1\n" 265 QString tooltip = i18n("Connection: %1\n"
266 "Connected at: %2\n" 266 "Connected at: %2\n"
267 "Time connected: %3") 267 "Time connected: %3")
268 .arg(gpppdata.accname()).arg(info2->text()) 268 .arg(PPPData::data()->accname()).arg(info2->text())
269 .arg(time_string2); 269 .arg(time_string2);
270 270
271 if(accountingEnabled) 271 if(accountingEnabled)
272 tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") 272 tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
273 .arg(session_bill->text()).arg(total_bill->text()); 273 .arg(session_bill->text()).arg(total_bill->text());
274 // volume accounting 274 // volume accounting
275 if(volumeAccountingEnabled) { 275 if(volumeAccountingEnabled) {
276 276
277 volinfo->setEnabled(TRUE); 277 volinfo->setEnabled(TRUE);
278 int bytes = gpppdata.totalBytes(); 278 int bytes = PPPData::data()->totalBytes();
279 volinfo->setText(prettyPrintVolume(bytes)); 279 volinfo->setText(prettyPrintVolume(bytes));
280 } 280 }
281 281
282 seconds++; 282 seconds++;
283 283
284 if(seconds >= 60 ) { 284 if(seconds >= 60 ) {
285 minutes ++; 285 minutes ++;
286 seconds = 0; 286 seconds = 0;
287 } 287 }
288 288
289 if (minutes >= 60){ 289 if (minutes >= 60){
290 minutes = 0; 290 minutes = 0;
@@ -296,46 +296,46 @@ void ConWindow::timeclick() {
296 hours = 0; 296 hours = 0;
297 } 297 }
298 298
299 time_string.sprintf("%02d:%02d",hours,minutes); 299 time_string.sprintf("%02d:%02d",hours,minutes);
300 time_string2 = ""; 300 time_string2 = "";
301 if (days) 301 if (days)
302 time_string2.sprintf("%d d %02d:%02d:%02d", 302 time_string2.sprintf("%d d %02d:%02d:%02d",
303 days,hours,minutes,seconds); 303 days,hours,minutes,seconds);
304 304
305 else 305 else
306 time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); 306 time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
307 307
308 caption_string = gpppdata.accname(); 308 caption_string = PPPData::data()->accname();
309 caption_string += " "; 309 caption_string += " ";
310 caption_string += time_string; 310 caption_string += time_string;
311 311
312 312
313 timelabel2->setText(time_string2); 313 timelabel2->setText(time_string2);
314 314
315 if(gpppdata.get_show_clock_on_caption() && (seconds == 1)){ 315 if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){
316 // we update the Caption only once per minute not every second 316 // we update the Caption only once per minute not every second
317 // otherwise I get a flickering icon 317 // otherwise I get a flickering icon
318 this->setCaption(caption_string); 318 this->setCaption(caption_string);
319 } 319 }
320 320
321// QToolTip::add(DockWidget::dock_widget, tooltip); 321// QToolTip::add(DockWidget::dock_widget, tooltip);
322} 322}
323 323
324 324
325void ConWindow::closeEvent( QCloseEvent *e ){ 325void ConWindow::closeEvent( QCloseEvent *e ){
326 // we don't want to lose the 326 // we don't want to lose the
327 // conwindow since this is our last connection kppp. 327 // conwindow since this is our last connection kppp.
328 // if we lost it we could only kill the program by hand to get on with life. 328 // if we lost it we could only kill the program by hand to get on with life.
329 e->ignore(); 329 e->ignore();
330 330
331 if(gpppdata.get_dock_into_panel()) 331 if(PPPData::data()->get_dock_into_panel())
332 dock(); 332 dock();
333} 333}
334 334
335 335
336void ConWindow::slotAccounting(QString total, QString session) { 336void ConWindow::slotAccounting(QString total, QString session) {
337 total_bill->setText(total); 337 total_bill->setText(total);
338 session_bill->setText(session); 338 session_bill->setText(session);
339} 339}
340 340
341 341