Diffstat (limited to 'noncore/settings/networksettings/ppp/conwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/conwindow.cpp | 245 |
1 files changed, 121 insertions, 124 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 @@ -30,21 +30,18 @@ // #include <klocale.h> #define i18n QObject::tr // #include <kglobal.h> -extern PPPData gpppdata; -ConWindow::ConWindow(QWidget *parent, const char *name, QDialog *mainwidget ) -// PPPStats *st) +ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, + QDialog *mainwidget ) : QWidget(parent, name, 0), minutes(0), seconds(0), hours(0), days(0), tl1(0), -// stats(st), - accountingEnabled(false), - volumeAccountingEnabled(false) + _pppdata(pd) { info1 = new QLabel(i18n("Connected at:"), this); info2 = new QLabel("", this); @@ -114,135 +111,135 @@ QString ConWindow::prettyPrintVolume(unsigned int n) { s += " " + quant[idx]; return s; } -void ConWindow::accounting(bool on) { - // cache accounting settings - accountingEnabled = on; - volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); - - // delete old layout - if(tl1 != 0) - delete tl1; - - // add layout now - tl1 = new QVBoxLayout(this, 10, 10); - tl1->addSpacing(5); - QHBoxLayout *tl = new QHBoxLayout; - tl1->addLayout(tl); - tl->addSpacing(20); - QGridLayout *l1; - - int vol_lines = 0; - if(PPPData::data()->VolAcctEnabled()) - vol_lines = 1; - - if(accountingEnabled) - l1 = new QGridLayout(4 + vol_lines, 2, 5); - else - l1 = new QGridLayout(2 + vol_lines, 2, 5); - tl->addLayout(l1); - l1->setColStretch(0, 0); - l1->setColStretch(1, 1); - - info2->setAlignment(AlignRight|AlignVCenter); - timelabel2->setAlignment(AlignRight|AlignVCenter); - session_bill->setAlignment(AlignRight|AlignVCenter); - total_bill->setAlignment(AlignRight|AlignVCenter); - volinfo->setAlignment(AlignRight|AlignVCenter); - // make sure that there's enough space for the bills - QString s1 = session_bill->text(); - QString s2 = total_bill->text(); - QString s3 = volinfo->text(); - - session_bill->setText("888888.88 XXX"); - total_bill->setText("888888.88 XXX"); - volinfo->setText("8888.8 MB"); - session_bill->setFixedSize(session_bill->sizeHint()); - total_bill->setFixedSize(total_bill->sizeHint()); - volinfo->setFixedSize(volinfo->sizeHint()); - session_bill->setText(s1); - total_bill->setText(s2); - volinfo->setText(s3); - - l1->addWidget(info1, 0, 0); - l1->addWidget(info2, 0, 1); - l1->addWidget(timelabel1, 1, 0); - l1->addWidget(timelabel2, 1, 1); - if(accountingEnabled) { - session_bill_l->show(); - session_bill->show(); - total_bill_l->show(); - total_bill->show(); - l1->addWidget(session_bill_l, 2, 0); - l1->addWidget(session_bill, 2, 1); - l1->addWidget(total_bill_l, 3, 0); - l1->addWidget(total_bill, 3, 1); - - if(volumeAccountingEnabled) { - vollabel->show(); - volinfo->show(); - l1->addWidget(vollabel, 4, 0); - l1->addWidget(volinfo, 4, 1); - } else { - vollabel->hide(); - volinfo->hide(); - } - - } else { - session_bill_l->hide(); - session_bill->hide(); - total_bill_l->hide(); - total_bill->hide(); - - if(volumeAccountingEnabled) { - vollabel->show(); - volinfo->show(); - l1->addWidget(vollabel, 2, 0); - l1->addWidget(volinfo, 2, 1); - } else { - vollabel->hide(); - volinfo->hide(); - } - } +// void ConWindow::accounting(bool on) { +// // cache accounting settings +// accountingEnabled = on; +// // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); - tl->addSpacing(10); - QVBoxLayout *l2 = new QVBoxLayout(5); - tl->addLayout(l2); - l2->addStretch(1); -// l2->addWidget(statsbutton); - l2->addWidget(cancelbutton); +// // delete old layout +// if(tl1 != 0) +// delete tl1; - l2->addStretch(1); +// // add layout now +// tl1 = new QVBoxLayout(this, 10, 10); +// tl1->addSpacing(5); +// QHBoxLayout *tl = new QHBoxLayout; +// tl1->addLayout(tl); +// tl->addSpacing(20); +// QGridLayout *l1; - tl1->addSpacing(5); +// int vol_lines = 0; +// // if(_pppdata->VolAcctEnabled()) +// // vol_lines = 1; - setFixedSize(sizeHint()); -/* - do not overwrite position read from config - setGeometry((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height())/2, - width(), - height()); -*/ -} +// if(accountingEnabled) +// l1 = new QGridLayout(4 + vol_lines, 2, 5); +// else +// l1 = new QGridLayout(2 + vol_lines, 2, 5); +// tl->addLayout(l1); +// l1->setColStretch(0, 0); +// l1->setColStretch(1, 1); + +// info2->setAlignment(AlignRight|AlignVCenter); +// timelabel2->setAlignment(AlignRight|AlignVCenter); +// session_bill->setAlignment(AlignRight|AlignVCenter); +// total_bill->setAlignment(AlignRight|AlignVCenter); +// volinfo->setAlignment(AlignRight|AlignVCenter); +// // make sure that there's enough space for the bills +// QString s1 = session_bill->text(); +// QString s2 = total_bill->text(); +// QString s3 = volinfo->text(); + +// session_bill->setText("888888.88 XXX"); +// total_bill->setText("888888.88 XXX"); +// volinfo->setText("8888.8 MB"); +// session_bill->setFixedSize(session_bill->sizeHint()); +// total_bill->setFixedSize(total_bill->sizeHint()); +// volinfo->setFixedSize(volinfo->sizeHint()); +// session_bill->setText(s1); +// total_bill->setText(s2); +// volinfo->setText(s3); + +// l1->addWidget(info1, 0, 0); +// l1->addWidget(info2, 0, 1); +// l1->addWidget(timelabel1, 1, 0); +// l1->addWidget(timelabel2, 1, 1); +// if(accountingEnabled) { +// session_bill_l->show(); +// session_bill->show(); +// total_bill_l->show(); +// total_bill->show(); +// l1->addWidget(session_bill_l, 2, 0); +// l1->addWidget(session_bill, 2, 1); +// l1->addWidget(total_bill_l, 3, 0); +// l1->addWidget(total_bill, 3, 1); + +// if(volumeAccountingEnabled) { +// vollabel->show(); +// volinfo->show(); +// l1->addWidget(vollabel, 4, 0); +// l1->addWidget(volinfo, 4, 1); +// } else { +// vollabel->hide(); +// volinfo->hide(); +// } + +// } else { +// session_bill_l->hide(); +// session_bill->hide(); +// total_bill_l->hide(); +// total_bill->hide(); + +// if(volumeAccountingEnabled) { +// vollabel->show(); +// volinfo->show(); +// l1->addWidget(vollabel, 2, 0); +// l1->addWidget(volinfo, 2, 1); +// } else { +// vollabel->hide(); +// volinfo->hide(); +// } +// } +// tl->addSpacing(10); +// QVBoxLayout *l2 = new QVBoxLayout(5); +// tl->addLayout(l2); +// l2->addStretch(1); +// // l2->addWidget(statsbutton); +// l2->addWidget(cancelbutton); -void ConWindow::dock() { -// DockWidget::dock_widget->show(); - this->hide(); -} +// l2->addStretch(1); + +// tl1->addSpacing(5); + +// setFixedSize(sizeHint()); +// /* +// do not overwrite position read from config +// setGeometry((QApplication::desktop()->width() - width()) / 2, +// (QApplication::desktop()->height() - height())/2, +// width(), +// height()); +// */ +// } + + +// void ConWindow::dock() { +// // DockWidget::dock_widget->show(); +// this->hide(); +// } void ConWindow::startClock() { minutes = 0; seconds = 0; hours = 0; QString title ; - title = PPPData::data()->accname(); + title = _pppdata->accname(); - if(PPPData::data()->get_show_clock_on_caption()){ + if(_pppdata->get_show_clock_on_caption()){ title += " 00:00" ; } this->setCaption(title); @@ -264,9 +261,9 @@ void ConWindow::stopClock() { void ConWindow::timeclick() { // QString tooltip = i18n("Connection: %1\n" // "Connected at: %2\n" // "Time connected: %3") -// .arg(PPPData::data()->accname()).arg(info2->text()) +// .arg(_pppdata->accname()).arg(info2->text()) // .arg(time_string2); // if(accountingEnabled) // tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") @@ -274,9 +271,9 @@ void ConWindow::timeclick() { // // volume accounting // if(volumeAccountingEnabled) { // volinfo->setEnabled(TRUE); -// int bytes = PPPData::data()->totalBytes(); +// int bytes = _pppdata->totalBytes(); // volinfo->setText(prettyPrintVolume(bytes)); // } // seconds++; @@ -304,16 +301,16 @@ void ConWindow::timeclick() { // else // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); -// caption_string = PPPData::data()->accname(); +// caption_string = _pppdata->accname(); // caption_string += " "; // caption_string += time_string; // timelabel2->setText(time_string2); -// if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){ +// if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){ // // we update the Caption only once per minute not every second // // otherwise I get a flickering icon // this->setCaption(caption_string); // } @@ -327,10 +324,10 @@ void ConWindow::closeEvent( QCloseEvent *e ){ // conwindow since this is our last connection kppp. // if we lost it we could only kill the program by hand to get on with life. e->ignore(); - if(PPPData::data()->get_dock_into_panel()) - dock(); +// if(_pppdata->get_dock_into_panel()) +// dock(); } void ConWindow::slotAccounting(QString total, QString session) { |