summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-06-10 13:46:02 (UTC)
committer harlekin <harlekin>2003-06-10 13:46:02 (UTC)
commit8ffea5d37080bd173d55a458296c1fc461a54d13 (patch) (side-by-side diff)
tree0c7f4a1129ed35d00742e55527ee4e4af59b562b
parent6189cb95c39acdd5b27e09f9d0798d91fa182e5a (diff)
downloadopie-8ffea5d37080bd173d55a458296c1fc461a54d13.zip
opie-8ffea5d37080bd173d55a458296c1fc461a54d13.tar.gz
opie-8ffea5d37080bd173d55a458296c1fc461a54d13.tar.bz2
layout fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 7760d5e..04905e8 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -56,300 +56,300 @@ AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
connect(accountlist_l, SIGNAL(selected(int)),
this, SLOT(editaccount()));
l1->addWidget(accountlist_l, 10);
edit_b = new QPushButton(tr("&Edit..."), this);
connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
l1->addWidget(edit_b);
new_b = new QPushButton(tr("&New..."), this);
connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
l1->addWidget(new_b);
QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
"to the Internet"));
copy_b = new QPushButton(tr("Co&py"), this);
connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
l1->addWidget(copy_b);
QWhatsThis::add(copy_b,
tr("Makes a copy of the selected account. All\n"
"settings of the selected account are copied\n"
"to a new account, that you can modify to fit your\n"
"needs"));
delete_b = new QPushButton(tr("De&lete"), this);
connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
l1->addWidget(delete_b);
QWhatsThis::add(delete_b,
tr("<p>Deletes the selected account\n\n"
"<font color=\"red\"><b>Use with care!</b></font>"));
QHBoxLayout *l12 = new QHBoxLayout;
l1->addStretch(1);
l1->addLayout(l12);
int currAccId = _pppdata->currentAccountID();
qDebug("currentAccountID %i", currAccId);
//load up account list from gppdata to the list box
if(_pppdata->count() > 0) {
for(int i=0; i <= _pppdata->count()-1; i++) {
_pppdata->setAccountbyIndex(i);
accountlist_l->insertItem(_pppdata->accname());
}
}
_pppdata->setAccountbyIndex( currAccId );
qDebug("setting listview index to %i",_pppdata->currentAccountID() );
accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
slotListBoxSelect( _pppdata->currentAccountID() );
l1->activate();
}
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) {
qDebug("setting account to %i", idx);
QString account = _pppdata->accname();
_pppdata->setAccountbyIndex(accountlist_l->currentItem());
}
}
void AccountWidget::editaccount() {
_pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem()));
int result = doTab();
if(result == QDialog::Accepted) {
accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem());
// emit resetaccounts();
_pppdata->save();
}
}
void AccountWidget::newaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
QMessageBox::information(this, "sorry",
tr("Maximum number of accounts reached."));
return;
}
int result;
if (_pppdata->newaccount() == -1){
qDebug("_pppdata->newaccount() == -1");
return;
}
result = doTab();
if(result == QDialog::Accepted) {
accountlist_l->insertItem(_pppdata->accname());
accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true);
_pppdata->save();
} else
_pppdata->deleteAccount();
}
void AccountWidget::copyaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
return;
}
if(accountlist_l->currentItem()<0) {
QMessageBox::information(this, "sorry", tr("No account selected."));
return;
}
_pppdata->copyaccount(accountlist_l->currentItem());
accountlist_l->insertItem(_pppdata->accname());
// emit resetaccounts();
_pppdata->save();
}
void AccountWidget::deleteaccount() {
QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
.arg(accountlist_l->text(accountlist_l->currentItem()));
if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes)
return;
if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
accountlist_l->removeItem(accountlist_l->currentItem());
emit resetaccounts();
_pppdata->save();
slotListBoxSelect(accountlist_l->currentItem());
}
int AccountWidget::doTab(){
QDialog *dlg = new QDialog( 0, "newAccount", true );
QVBoxLayout *layout = new QVBoxLayout( dlg );
layout->setSpacing( 0 );
layout->setMargin( 1 );
tabWindow = new QTabWidget( dlg, "tabWindow" );
layout->addWidget( tabWindow );
bool isnewaccount;
if(_pppdata->accname().isEmpty()) {
dlg->setCaption(tr("New Account"));
isnewaccount = true;
} else {
QString tit = tr("Edit Account: ");
tit += _pppdata->accname();
dlg->setCaption(tit);
isnewaccount = false;
}
// // DIAL WIDGET
dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
tabWindow->addTab( dial_w, tr("Dial") );
// // AUTH WIDGET
auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
tabWindow->addTab( auth_w, tr("Authentication") );
// // IP WIDGET
ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
tabWindow->addTab( ip_w, tr("IP") );
// // GATEWAY WIDGET
gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
tabWindow->addTab( gateway_w, tr("Gateway") );
// // DNS WIDGET
dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
tabWindow->addTab( dns_w, tr("DNS") );
// // EXECUTE WIDGET
ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
tabWindow->addTab( exec_w, tr("Execute") );
int result = 0;
bool ok = false;
while (!ok){
- // dlg->showMinimized();
+ dlg->showMaximized();
result = dlg->exec();
ok = true;
if(result == QDialog::Accepted) {
if (!auth_w->check()){
ok = false;
} else if(!dial_w->save()) {
QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
ok = false;
}else{
ip_w->save();
dns_w->save();
gateway_w->save();
auth_w->save();
exec_w->save();
}
}
}
delete dlg;
return result;
}
QString AccountWidget::prettyPrintVolume(unsigned int n) {
int idx = 0;
const QString quant[] = {tr("Byte"), tr("KB"),
tr("MB"), tr("GB"), QString::null};
float n1 = n;
while(n >= 1024 && quant[idx] != QString::null) {
idx++;
n /= 1024;
}
int i = idx;
while(i--)
n1 = n1 / 1024.0;
QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
s += " " + quant[idx];
return s;
}
/////////////////////////////////////////////////////////////////////////////
//
// Queries the user what to reset: costs, volume or both
//
/////////////////////////////////////////////////////////////////////////////
// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
// setCaption(tr("Reset Accounting"));
// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this);
// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f);
// // costs->setChecked(true);
// // l1->addWidget(costs);
// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n"
// // "to zero. Typically you'll want to\n"
// // "do this once a month."));
// // volume = new QCheckBox(tr("Reset volume accounting"), f);
// // volume->setChecked(true);
// // l1->addWidget(volume);
// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n"
// // "to zero. Typically you'll want to do this\n"
// // "once a month."));
// l1->activate();
// // this activates the f-layout and sets minimumSize()
// f->show();
// tl->addWidget(f);
// QButtonGroup *bbox = new QButtonGroup(this);
// // bbox->addStretch(1);
// QPushButton *ok = new QPushButton( bbox, tr("OK") );
// bbox->insert(ok);
// ok->setDefault(true);
// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") );
// bbox->insert(cancel);
// connect(ok, SIGNAL(clicked()),
// this, SLOT(accepted()));
// connect(cancel, SIGNAL(clicked()),
// this, SLOT(reject()));
// bbox->layout();
// tl->addWidget(bbox);
// }
// void QueryReset::accepted() {
// int result = costs->isChecked() ? COSTS : 0;
// result += volume->isChecked() ? VOLUME : 0;
// done(result);
// }
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index b880978..0c96253 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -26,384 +26,385 @@
#include <string.h>
#include <termios.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qwhatsthis.h>
#include <qregexp.h>
#include <qapplication.h>
#include <qbuttongroup.h>
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
#include <qpe/resource.h>
#include "edit.h"
#include "pppdata.h"
#include "iplined.h"
#include "auth.h"
DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
const int GRIDROWS = 6;
QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );
connect_label = new QLabel(tr("Connection name:"), this);
tl->addWidget(connect_label, 0, 0);
connectname_l = new QLineEdit(this);
// connectname_l->setMaxLength(ACCNAME_SIZE);
tl->addWidget(connectname_l, 0, 1);
QString tmp = tr("Type in a unique name for this connection");
QWhatsThis::add(connect_label,tmp);
QWhatsThis::add(connectname_l,tmp);
number_label = new QLabel(tr("Phone number:"), this);
number_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(number_label, 1, 0);
QHBoxLayout *lpn = new QHBoxLayout(5);
tl->addLayout(lpn, 1, 1);
numbers = new QListBox(this);
// numbers->setMinimumSize(120, 70);
lpn->addWidget(numbers);
QVBoxLayout *lpn1 = new QVBoxLayout;
lpn->addLayout(lpn1);
add = new QPushButton(tr("&Add..."), this);
del = new QPushButton(tr("&Remove"), this);
up = new QPushButton(this);
up->setPixmap( Resource::loadPixmap("inline/up") );
down = new QPushButton(this);
down->setPixmap( Resource::loadPixmap("inline/down") );
lpn1->addWidget(add);
lpn1->addWidget(del);
lpn1->addStretch(1);
lpn1->addWidget(up);
lpn1->addWidget(down);
connect(add, SIGNAL(clicked()),
this, SLOT(addNumber()));
connect(del, SIGNAL(clicked()),
this, SLOT(delNumber()));
connect(up, SIGNAL(clicked()),
this, SLOT(upNumber()));
connect(down, SIGNAL(clicked()),
this, SLOT(downNumber()));
connect(numbers, SIGNAL(highlighted(int)),
this, SLOT(selectionChanged(int)));
numbersChanged();
tmp = tr("<p>Specifies the phone numbers to dial. You\n"
"can supply multiple numbers here, simply\n"
"click on \"Add\". You can arrange the\n"
"order the numbers are tried by using the\n"
"arrow buttons.\n\n"
"When a number is busy or fails, <i>kppp</i> will \n"
"try the next number and so on");
QWhatsThis::add(number_label,tmp);
QWhatsThis::add(numbers,tmp);
pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this);
connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
// Set defaults if editing an existing connection
if(!isnewaccount) {
connectname_l->setText(_pppdata->accname());
// insert the phone numbers into the listbox
QString n = _pppdata->phonenumber();
QString tmp = "";
uint idx = 0;
while(idx != n.length()) {
if(n[idx] == ':') {
if(tmp.length() > 0)
numbers->insertItem(tmp);
tmp = "";
} else
tmp += n[idx];
idx++;
}
if(tmp.length() > 0)
numbers->insertItem(tmp);
}
numbersChanged();
tl->activate();
}
bool DialWidget::save() {
//first check to make sure that the account name is unique!
if(connectname_l->text().isEmpty() ||
!_pppdata->isUniqueAccname(connectname_l->text())) {
return false;
} else {
_pppdata->setAccname(connectname_l->text());
QString number = "";
for(uint i = 0; i < numbers->count(); i++) {
if(i != 0)
number += ":";
number += numbers->text(i);
}
_pppdata->setPhonenumber(number);
return true;
}
}
void DialWidget::numbersChanged() {
int sel = numbers->currentItem();
del->setEnabled(sel != -1);
up->setEnabled(sel != -1 && sel != 0);
down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
}
void DialWidget::selectionChanged(int) {
numbersChanged();
}
void DialWidget::addNumber() {
PhoneNumberDialog dlg(this);
if(dlg.exec()) {
numbers->insertItem(dlg.phoneNumber());
numbersChanged();
}
}
void DialWidget::delNumber() {
if(numbers->currentItem() != -1) {
numbers->removeItem(numbers->currentItem());
numbersChanged();
}
}
void DialWidget::upNumber() {
int idx = numbers->currentItem();
if(idx != -1) {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx-1);
numbers->setCurrentItem(idx-1);
numbersChanged();
}
}
void DialWidget::downNumber() {
int idx = numbers->currentItem();
if(idx != -1) {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx+1);
numbers->setCurrentItem(idx+1);
numbersChanged();
}
}
void DialWidget::pppdargsbutton() {
PPPdArguments pa(_pppdata, this);
+ pa.showMaximized();
pa.exec();
}
/////////////////////////////////////////////////////////////////////////////
// ExecWidget
/////////////////////////////////////////////////////////////////////////////
ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) :
QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this);
tl->addWidget(l);
tl->addStretch(1);
QGridLayout *l1 = new QGridLayout(4, 2, 10);
tl->addLayout(l1);
l1->setColStretch(0, 0);
l1->setColStretch(1, 1);
before_connect_l = new QLabel(tr("Before connect:"), this);
before_connect_l->setAlignment(AlignVCenter);
l1->addWidget(before_connect_l, 0, 0);
before_connect = new QLineEdit(this);
// before_connect->setMaxLength(COMMAND_SIZE);
l1->addWidget(before_connect, 0, 1);
QString tmp = tr("Allows you to run a program <b>before</b> a connection\n"
"is established. It is called immediately before\n"
"dialing has begun.\n\n"
"This might be useful, e.g. to stop HylaFAX blocking the\n"
"modem.");
QWhatsThis::add(before_connect_l,tmp);
QWhatsThis::add(before_connect,tmp);
command_label = new QLabel(tr("Upon connect:"), this);
command_label->setAlignment(AlignVCenter);
l1->addWidget(command_label, 1, 0);
command = new QLineEdit(this);
// command->setMaxLength(COMMAND_SIZE);
l1->addWidget(command, 1, 1);
tmp = tr("Allows you to run a program <b>after</b> a connection\n"
"is established. When your program is called, all\n"
"preparations for an Internet connection are finished.\n"
"\n"
"Very useful for fetching mail and news");
QWhatsThis::add(command_label,tmp);
QWhatsThis::add(command,tmp);
predisconnect_label = new QLabel(tr("Before disconnect:"),
this);
predisconnect_label->setAlignment(AlignVCenter);
l1->addWidget(predisconnect_label, 2, 0);
predisconnect = new QLineEdit(this);
// predisconnect->setMaxLength(COMMAND_SIZE);
l1->addWidget(predisconnect, 2, 1);
tmp = tr("Allows you to run a program <b>before</b> a connection\n"
"is closed. The connection will stay open until\n"
"the program exits.");
QWhatsThis::add(predisconnect_label,tmp);
QWhatsThis::add(predisconnect,tmp);
discommand_label = new QLabel(tr("Upon disconnect:"),
this);
discommand_label->setAlignment(AlignVCenter);
l1->addWidget(discommand_label, 3, 0);
discommand = new QLineEdit(this);
// discommand->setMaxLength(COMMAND_SIZE);
l1->addWidget(discommand, 3, 1);
tmp = tr("Allows you to run a program <b>after</b> a connection\n"
"has been closed.");
QWhatsThis::add(discommand_label,tmp);
QWhatsThis::add(discommand,tmp);
// extra space between entries
l1->addRowSpacing(1, 5);
l1->addRowSpacing(3, 5);
tl->addStretch(1);
tl->activate();
// Set defaults if editing an existing connection
if(!isnewaccount) {
before_connect->setText(_pppdata->command_before_connect());
command->setText(_pppdata->command_on_connect());
discommand->setText(_pppdata->command_on_disconnect());
predisconnect->setText(_pppdata->command_before_disconnect());
}
}
bool ExecWidget::save() {
_pppdata->setCommand_before_connect(before_connect->text());
_pppdata->setCommand_on_connect(command->text());
_pppdata->setCommand_before_disconnect(predisconnect->text());
_pppdata->setCommand_on_disconnect(discommand->text());
return true;
}
/////////////////////////////////////////////////////////////////////////////
//
// IPWidget
//
/////////////////////////////////////////////////////////////////////////////
IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 3 );//KDialog::spacingHint());
box = new QVGroupBox(tr("Configuration"), this);
// box->setInsideSpacing( 1 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)),
SLOT(hitIPSelect(int)));
dynamicadd_rb = new QRadioButton(box);
dynamicadd_rb->setText(tr("Dynamic IP address"));
QWhatsThis::add(dynamicadd_rb,
tr("Select this option when your computer gets an\n"
"internet address (IP) every time a\n"
"connection is made.\n"
"\n"
"Almost every Internet Service Provider uses\n"
"this method, so this should be turned on."));
staticadd_rb = new QRadioButton(box);
staticadd_rb->setText(tr("Static IP address"));
rb->insert(dynamicadd_rb, 0);
rb->insert(staticadd_rb, 1);
QWhatsThis::add(staticadd_rb,
tr("Select this option when your computer has a\n"
"fixed internet address (IP). Most computers\n"
"don't have this, so you should probably select\n"
"dynamic IP addressing unless you know what you\n"
"are doing."));
QWidget *ipWidget = new QWidget(box);
QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
ipLayout->setSpacing( 2 );//KDialog::spacingHint());
ipaddress_label = new QLabel(tr("IP address:"), ipWidget);
QString tmp = tr("If your computer has a permanent internet\n"
"address, you must supply your IP address here.");
ipLayout->addWidget(ipaddress_label, 0, 0);
ipaddress_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(ipaddress_l, 0, 1);
QWhatsThis::add(ipaddress_label,tmp);
QWhatsThis::add(ipaddress_l,tmp);
sub_label = new QLabel(tr("Subnet mask:"), ipWidget);
tmp = tr("<p>If your computer has a static Internet address,\n"
"you must supply a network mask here. In almost\n"
"all cases this netmask will be <b>255.255.255.0</b>,\n"
"but your mileage may vary.\n"
"\n"
"If unsure, contact your Internet Service Provider");
ipLayout->addWidget(sub_label, 1, 0);
subnetmask_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(subnetmask_l, 1, 1);
QWhatsThis::add(sub_label,tmp);
QWhatsThis::add(subnetmask_l,tmp);
autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this);
autoname->setChecked(_pppdata->autoname());
connect(autoname,SIGNAL(toggled(bool)),
this,SLOT(autoname_t(bool)));
QWhatsThis::add(autoname,
tr("<p>Whenever you connect, this reconfigures\n"
"your hostname to match the IP address you\n"
"got from the PPP server. This may be useful\n"
"if you need to use a protocol which depends\n"
"on this information, but it can also cause several\n"
"<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
"\n"
"Don't enable this unless you really need it."));