summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/conwindow.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/conwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index 9136ca0..7641bbe 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -3,120 +3,115 @@
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 17 * Library General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Library General Public 19 * You should have received a copy of the GNU Library General Public
20 * License along with this program; if not, write to the Free 20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qdialog.h> 25#include <qdialog.h>
26#include "conwindow.h" 26#include "conwindow.h"
27//#include "docking.h"
28#include "pppdata.h" 27#include "pppdata.h"
29// #include "pppstats.h"
30// #include <klocale.h>
31#define i18n QObject::tr
32// #include <kglobal.h>
33 28
34 29
35ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, 30ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name,
36 QDialog *mainwidget ) 31 QDialog *mainwidget )
37 : QWidget(parent, name, 0), 32 : QWidget(parent, name, 0),
38 minutes(0), 33 minutes(0),
39 seconds(0), 34 seconds(0),
40 hours(0), 35 hours(0),
41 days(0), 36 days(0),
42 tl1(0), 37 tl1(0),
43 _pppdata(pd) 38 _pppdata(pd)
44{ 39{
45 info1 = new QLabel(i18n("Connected at:"), this); 40 info1 = new QLabel(QObject::tr("Connected at:"), this);
46 info2 = new QLabel("", this); 41 info2 = new QLabel("", this);
47 42
48 timelabel1 = new QLabel(i18n("Time connected:"), this); 43 timelabel1 = new QLabel(QObject::tr("Time connected:"), this);
49 timelabel2 = new QLabel("000:00:00", this); 44 timelabel2 = new QLabel("000:00:00", this);
50 45
51 vollabel = new QLabel(i18n("Volume:"), this); 46 vollabel = new QLabel(QObject::tr("Volume:"), this);
52 volinfo = new QLabel("", this); 47 volinfo = new QLabel("", this);
53 48
54 // now the stuff for accounting 49 // now the stuff for accounting
55 session_bill_l = new QLabel(i18n("Session Bill:"), this); 50 session_bill_l = new QLabel(QObject::tr("Session Bill:"), this);
56 session_bill = new QLabel("", this); 51 session_bill = new QLabel("", this);
57 total_bill_l = new QLabel(i18n("Total Bill:"), this); 52 total_bill_l = new QLabel(QObject::tr("Total Bill:"), this);
58 total_bill = new QLabel("", this); 53 total_bill = new QLabel("", this);
59 54
60 this->setCaption("kppp"); 55 this->setCaption("kppp");
61 56
62 cancelbutton = new QPushButton(this); 57 cancelbutton = new QPushButton(this);
63 cancelbutton->setText(i18n("Disconnect")); 58 cancelbutton->setText(QObject::tr("Disconnect"));
64 connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); 59 connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect()));
65 60
66 // statsbutton = new QPushButton(this); 61 // statsbutton = new QPushButton(this);
67// statsbutton->setText(i18n("Details")); 62// statsbutton->setText(QObject::tr("Details"));
68// statsbutton->setFocus(); 63// statsbutton->setFocus();
69// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); 64// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats()));
70 65
71 clocktimer = new QTimer(this); 66 clocktimer = new QTimer(this);
72 connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); 67 connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick()));
73 68
74 // read window position from config file 69 // read window position from config file
75// int p_x, p_y; 70// int p_x, p_y;
76// PPPData::data()->winPosConWin(p_x, p_y); 71// PPPData::data()->winPosConWin(p_x, p_y);
77// setGeometry(p_x, p_y, 320, 110); 72// setGeometry(p_x, p_y, 320, 110);
78} 73}
79 74
80ConWindow::~ConWindow() { 75ConWindow::~ConWindow() {
81 stopClock(); 76 stopClock();
82} 77}
83 78
84// save window position when window was closed 79// save window position when window was closed
85bool ConWindow::event(QEvent *e) { 80bool ConWindow::event(QEvent *e) {
86 if (e->type() == QEvent::Hide) 81 if (e->type() == QEvent::Hide)
87 { 82 {
88// PPPData::data()->setWinPosConWin(x(), y()); 83// PPPData::data()->setWinPosConWin(x(), y());
89 return true; 84 return true;
90 } 85 }
91 else 86 else
92 return QWidget::event(e); 87 return QWidget::event(e);
93} 88}
94 89
95QString ConWindow::prettyPrintVolume(unsigned int n) { 90QString ConWindow::prettyPrintVolume(unsigned int n) {
96 int idx = 0; 91 int idx = 0;
97 const QString quant[] = {i18n("Byte"), i18n("KB"), 92 const QString quant[] = {QObject::tr("Byte"), QObject::tr("KB"),
98 i18n("MB"), i18n("GB"), QString::null}; 93 QObject::tr("MB"), QObject::tr("GB"), QString::null};
99 94
100 float n1 = n; 95 float n1 = n;
101 while(n >= 1024 && quant[idx] != QString::null) { 96 while(n >= 1024 && quant[idx] != QString::null) {
102 idx++; 97 idx++;
103 n /= 1024; 98 n /= 1024;
104 } 99 }
105 100
106 int i = idx; 101 int i = idx;
107 while(i--) 102 while(i--)
108 n1 = n1 / 1024.0; 103 n1 = n1 / 1024.0;
109 104
110 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); 105 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
111 s += " " + quant[idx]; 106 s += " " + quant[idx];
112 return s; 107 return s;
113} 108}
114 109
115// void ConWindow::accounting(bool on) { 110// void ConWindow::accounting(bool on) {
116// // cache accounting settings 111// // cache accounting settings
117// accountingEnabled = on; 112// accountingEnabled = on;
118// // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); 113// // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
119 114
120// // delete old layout 115// // delete old layout
121// if(tl1 != 0) 116// if(tl1 != 0)
122// delete tl1; 117// delete tl1;
@@ -238,56 +233,56 @@ void ConWindow::startClock() {
238 233
239 title = _pppdata->accname(); 234 title = _pppdata->accname();
240 235
241 if(_pppdata->get_show_clock_on_caption()){ 236 if(_pppdata->get_show_clock_on_caption()){
242 title += " 00:00" ; 237 title += " 00:00" ;
243 } 238 }
244 this->setCaption(title); 239 this->setCaption(title);
245 240
246 timelabel2->setText("00:00:00"); 241 timelabel2->setText("00:00:00");
247 clocktimer->start(1000); 242 clocktimer->start(1000);
248} 243}
249 244
250 245
251void ConWindow::setConnectionSpeed(const QString &speed) { 246void ConWindow::setConnectionSpeed(const QString &speed) {
252 info2->setText(speed); 247 info2->setText(speed);
253} 248}
254 249
255 250
256void ConWindow::stopClock() { 251void ConWindow::stopClock() {
257 clocktimer->stop(); 252 clocktimer->stop();
258} 253}
259 254
260 255
261void ConWindow::timeclick() { 256void ConWindow::timeclick() {
262// QString tooltip = i18n("Connection: %1\n" 257// QString tooltip = QObject::tr("Connection: %1\n"
263 // "Connected at: %2\n" 258 // "Connected at: %2\n"
264 // "Time connected: %3") 259 // "Time connected: %3")
265 // .arg(_pppdata->accname()).arg(info2->text()) 260 // .arg(_pppdata->accname()).arg(info2->text())
266 // .arg(time_string2); 261 // .arg(time_string2);
267 262
268// if(accountingEnabled) 263// if(accountingEnabled)
269// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") 264// tooltip += QObject::tr("\nSession Bill: %1\nTotal Bill: %2")
270 // .arg(session_bill->text()).arg(total_bill->text()); 265 // .arg(session_bill->text()).arg(total_bill->text());
271// // volume accounting 266// // volume accounting
272// if(volumeAccountingEnabled) { 267// if(volumeAccountingEnabled) {
273 268
274// volinfo->setEnabled(TRUE); 269// volinfo->setEnabled(TRUE);
275// int bytes = _pppdata->totalBytes(); 270// int bytes = _pppdata->totalBytes();
276// volinfo->setText(prettyPrintVolume(bytes)); 271// volinfo->setText(prettyPrintVolume(bytes));
277// } 272// }
278 273
279// seconds++; 274// seconds++;
280 275
281// if(seconds >= 60 ) { 276// if(seconds >= 60 ) {
282// minutes ++; 277// minutes ++;
283// seconds = 0; 278// seconds = 0;
284// } 279// }
285 280
286// if (minutes >= 60){ 281// if (minutes >= 60){
287// minutes = 0; 282// minutes = 0;
288// hours ++; 283// hours ++;
289// } 284// }
290 285
291// if( hours >= 24){ 286// if( hours >= 24){
292// days ++; 287// days ++;
293// hours = 0; 288// hours = 0;