summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/accounts.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/accounts.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp110
1 files changed, 57 insertions, 53 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index d902517..19db9ef 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -50,36 +50,36 @@
void parseargs(char* buf, char** args);
AccountWidget::AccountWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
- int min = 0;
+// int min = 0;
QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
// add a hbox
// QHBoxLayout *l11 = new QHBoxLayout;
// l1->addLayout(l11);
accountlist_l = new QListBox(this);
- accountlist_l->setMinimumSize(160, 128);
+// accountlist_l->setMinimumSize(160, 128);
connect(accountlist_l, SIGNAL(highlighted(int)),
this, SLOT(slotListBoxSelect(int)));
connect(accountlist_l, SIGNAL(selected(int)),
this, SLOT(editaccount()));
l1->addWidget(accountlist_l, 10);
// QVBoxLayout *l111 = new QVBoxLayout(this);
// l11->addLayout(l111, 1);
edit_b = new QPushButton(i18n("&Edit..."), this);
connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
- min = edit_b->sizeHint().width();
- min = QMAX(70,min);
- edit_b->setMinimumWidth(min);
+// min = edit_b->sizeHint().width();
+// min = QMAX(70,min);
+// edit_b->setMinimumWidth(min);
l1->addWidget(edit_b);
new_b = new QPushButton(i18n("&New..."), this);
connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
l1->addWidget(new_b);
@@ -162,16 +162,16 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
// connect(log, SIGNAL(clicked()),
// this, SLOT(viewLogClicked()));
// l122->addWidget(log);
// l122->addStretch(1);
//load up account list from gppdata to the list box
- if(gpppdata.count() > 0) {
- for(int i=0; i <= gpppdata.count()-1; i++) {
- gpppdata.setAccountbyIndex(i);
- accountlist_l->insertItem(gpppdata.accname());
+ if(PPPData::data()->count() > 0) {
+ for(int i=0; i <= PPPData::data()->count()-1; i++) {
+ PPPData::data()->setAccountbyIndex(i);
+ accountlist_l->insertItem(PPPData::data()->accname());
}
}
slotListBoxSelect(accountlist_l->currentItem());
l1->activate();
@@ -181,24 +181,24 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
void AccountWidget::slotListBoxSelect(int idx) {
delete_b->setEnabled((bool)(idx != -1));
edit_b->setEnabled((bool)(idx != -1));
copy_b->setEnabled((bool)(idx != -1));
if(idx!=-1) {
- QString account = gpppdata.accname();
- gpppdata.setAccountbyIndex(accountlist_l->currentItem());
+ QString account = PPPData::data()->accname();
+ PPPData::data()->setAccountbyIndex(accountlist_l->currentItem());
// reset->setEnabled(TRUE);
// costlabel->setEnabled(TRUE);
// costedit->setEnabled(TRUE);
// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem())));
// vollabel->setEnabled(TRUE);
// voledit->setEnabled(TRUE);
- int bytes = gpppdata.totalBytes();
+// int bytes = PPPData::data()->totalBytes();
// voledit->setText(prettyPrintVolume(bytes));
- gpppdata.setAccount(account);
+ PPPData::data()->setAccount(account);
} else{
// reset->setEnabled(FALSE);
// costlabel->setEnabled(FALSE);
// costedit->setText("");
// costedit->setEnabled(FALSE);
// vollabel->setEnabled(FALSE);
@@ -237,20 +237,20 @@ void AccountWidget::slotListBoxSelect(int idx) {
// // voledit->setText(prettyPrintVolume(0));
// // }
// }
void AccountWidget::editaccount() {
- gpppdata.setAccount(accountlist_l->text(accountlist_l->currentItem()));
+ PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem()));
int result = doTab();
if(result == QDialog::Accepted) {
- accountlist_l->changeItem(gpppdata.accname(),accountlist_l->currentItem());
+ accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem());
// emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->save();
}
}
void AccountWidget::newaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
@@ -268,37 +268,37 @@ void AccountWidget::newaccount() {
// i18n("Create New Account"),
// i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
// switch(query) {
// case QMessageBox::Yes:
// {
-// if (gpppdata.newaccount() == -1)
+// if (PPPData::data()->newaccount() == -1)
// return;
// // ProviderDB pdb(this);
// // result = pdb.exec();
// break;
// }
// case QMessageBox::No:
- if (gpppdata.newaccount() == -1){
- qDebug("gpppdata.newaccount() == -1");
+ if (PPPData::data()->newaccount() == -1){
+ qDebug("PPPData::data()->newaccount() == -1");
return;
}
result = doTab();
// break;
// default:
// return;
// }
if(result == QDialog::Accepted) {
- accountlist_l->insertItem(gpppdata.accname());
- accountlist_l->setSelected(accountlist_l->findItem(gpppdata.accname()),
+ accountlist_l->insertItem(PPPData::data()->accname());
+ accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()),
true);
// emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->save();
} else
- gpppdata.deleteAccount();
+ PPPData::data()->deleteAccount();
}
void AccountWidget::copyaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
@@ -307,75 +307,79 @@ void AccountWidget::copyaccount() {
if(accountlist_l->currentItem()<0) {
QMessageBox::information(this, "sorry", i18n("No account selected."));
return;
}
- gpppdata.copyaccount(accountlist_l->currentItem());
+ PPPData::data()->copyaccount(accountlist_l->currentItem());
- accountlist_l->insertItem(gpppdata.accname());
+ accountlist_l->insertItem(PPPData::data()->accname());
// emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->save();
}
void AccountWidget::deleteaccount() {
QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
.arg(accountlist_l->text(accountlist_l->currentItem()));
if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
return;
- if(gpppdata.deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
+ if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
accountlist_l->removeItem(accountlist_l->currentItem());
emit resetaccounts();
- gpppdata.save();
+ PPPData::data()->save();
slotListBoxSelect(accountlist_l->currentItem());
}
int AccountWidget::doTab(){
- QDialog *dlg = new QDialog( this );
- tabWindow = new QTabWidget( dlg );
- // tabWindow = new KDialogBase( KDialogBase::Tabbed, QString::null,
-// KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok,
-// 0, 0, true);
-// KWin::setIcons(tabWindow->winId(), kapp->icon(), kapp->miniIcon());
+ QDialog *dlg = new QDialog( this, "newAccount", true );
+ QVBoxLayout *layout = new QVBoxLayout( dlg );
+ layout->setSpacing( 0 );
+ layout->setMargin( 1 );
+
+ tabWindow = new QTabWidget( dlg, "tabWindow" );
+ layout->addWidget( tabWindow );
+
bool isnewaccount;
- if(gpppdata.accname().isEmpty()) {
- tabWindow->setCaption(i18n("New Account"));
- isnewaccount = true;
+ if(PPPData::data()->accname().isEmpty()) {
+ dlg->setCaption(i18n("New Account"));
+ isnewaccount = true;
} else {
- QString tit = i18n("Edit Account: ");
- tit += gpppdata.accname();
- tabWindow->setCaption(tit);
- isnewaccount = false;
+ QString tit = i18n("Edit Account: ");
+ tit += PPPData::data()->accname();
+ dlg->setCaption(tit);
+ isnewaccount = false;
}
- dial_w = new DialWidget( tabWindow );
- tabWindow->addTab( dial_w, i18n("Dial") );//, i18n("Dial Setup")), isnewaccount);
- ip_w = new IPWidget( tabWindow );
- tabWindow->addTab( ip_w, i18n("IP") );//, i18n("IP Setup")), isnewaccount);
- gateway_w = new GatewayWidget( tabWindow );
- tabWindow->addTab( gateway_w, i18n("Gateway") );//, i18n("Gateway Setup")), isnewaccount);
- dns_w = new DNSWidget( tabWindow );
- tabWindow->addTab( dns_w, i18n("DNS") );//, i18n("DNS Servers")), isnewaccount);
- script_w = new ScriptWidget( tabWindow );
- tabWindow->addTab( script_w, i18n("Login Script") ); //, i18n("Edit Login Script")), isnewaccount);
- ExecWidget *exec_w = new ExecWidget( tabWindow );
- tabWindow->addTab( exec_w, i18n("Execute") );//, i18n("Execute Programs")), isnewaccount);
+ dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup");
+ tabWindow->addTab( dial_w, i18n("Dial") );
+ ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup"));
+ tabWindow->addTab( ip_w, i18n("IP") );
+ gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup"));
+ tabWindow->addTab( gateway_w, i18n("Gateway") );
+ dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") );
+ tabWindow->addTab( dns_w, i18n("DNS") );
+ script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script"));
+ tabWindow->addTab( script_w, i18n("Login Script") );
+ ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs"));
+ tabWindow->addTab( exec_w, i18n("Execute") );
// acct = new AccountingSelector( tabWindow, isnewaccount );
// tabWindow->addTab( acct, i18n("Accounting"));
int result = 0;
bool ok = false;
+ qDebug("AccountWidget::doTab dlg->showMinimized");
+ dlg->showMinimized();
while (!ok){
result = dlg->exec();
ok = true;
if(result == QDialog::Accepted) {