author | tille <tille> | 2003-05-24 17:03:27 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-24 17:03:27 (UTC) |
commit | 58947769d80d49faaccac1703da0e66c90158957 (patch) (side-by-side diff) | |
tree | 4ba8961b94ca5cd74265346bf9b48afdb126c07a | |
parent | ea6b12007f4b5af926f6732637cb159904c4da7a (diff) | |
download | opie-58947769d80d49faaccac1703da0e66c90158957.zip opie-58947769d80d49faaccac1703da0e66c90158957.tar.gz opie-58947769d80d49faaccac1703da0e66c90158957.tar.bz2 |
layout fixes
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 54 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdargs.cpp | 26 |
2 files changed, 42 insertions, 38 deletions
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 6132b80..eee643d 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp @@ -1,170 +1,170 @@ /* * kPPP: A pppd Front End for the KDE project * * $Id$ * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * based on EzPPP: * Copyright (C) 1997 Jay Painter * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <string.h> #include <termios.h> #include <qlayout.h> #include <qmessagebox.h> #include <qwhatsthis.h> #include <qregexp.h> #include <qapplication.h> //#include <kiconloader.h> #include <qbuttongroup.h> //#include <klocale.h> #define i18n QObject::tr #include <qvgroupbox.h> #include <qhbox.h> #include <qdialog.h> //#include <kwin.h> #include "edit.h" #include "pppdata.h" //#include "newwidget.h" #include "iplined.h" #include "auth.h" DialWidget::DialWidget( QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name) { const int GRIDROWS = 6; QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); connect_label = new QLabel(i18n("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 = i18n("Type in a unique name for this connection"); QWhatsThis::add(connect_label,tmp); QWhatsThis::add(connectname_l,tmp); number_label = new QLabel(i18n("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); +// numbers->setMinimumSize(120, 70); lpn->addWidget(numbers); QVBoxLayout *lpn1 = new QVBoxLayout; lpn->addLayout(lpn1); add = new QPushButton(i18n("&Add..."), this); del = new QPushButton(i18n("&Remove"), this); up = new QPushButton(this); //FIXME: QPixmap pm = BarIcon("up"); // up->setPixmap(pm); down = new QPushButton(this); //FIXME: pm = BarIcon("down"); // down->setPixmap(pm); 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 = i18n("<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); auth_l = new QLabel(i18n("Authentication:"), this); tl->addWidget(auth_l, 3, 0); auth = new QComboBox(this); auth->insertItem(i18n("Script-based")); auth->insertItem(i18n("PAP")); auth->insertItem(i18n("Terminal-based")); auth->insertItem(i18n("CHAP")); auth->insertItem(i18n("PAP/CHAP")); tl->addWidget(auth, 3, 1); tmp = i18n("<p>Specifies the method used to identify yourself to\n" "the PPP server. Most universities still use\n" "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" "unsure, contact your ISP.\n" "\n" "If you can choose between PAP and CHAP,\n" "choose CHAP, because it's much safer. If you don't know\n" "whether PAP or CHAP is right, choose PAP/CHAP."); QWhatsThis::add(auth_l,tmp); QWhatsThis::add(auth,tmp); store_password = new QCheckBox(i18n("Store password"), this); store_password->setChecked(true); tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); QWhatsThis::add(store_password, i18n("<p>When this is turned on, your ISP password\n" "will be saved in <i>kppp</i>'s config file, so\n" "you do not need to type it in every time.\n" "\n" "<b><font color=\"red\">Warning:</font> your password will be stored as\n" "plain text in the config file, which is\n" "readable only to you. Make sure nobody\n" "gains access to this file!")); pppdargs = new QPushButton(i18n("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::data()->accname()); // insert the phone numbers into the listbox QString n = PPPData::data()->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++; @@ -733,224 +733,222 @@ void DNSWidget::removedns() { // GatewayWidget // GatewayWidget::GatewayWidget( QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name) { QVBoxLayout *topLayout = new QVBoxLayout(this); topLayout->setSpacing( 2 );//KDialog::spacingHint()); box = new QVGroupBox(i18n("Configuration"), this); // box->setInsideSpacing( 2 );//KDialog::spacingHint()); rb = new QButtonGroup(this); rb->hide(); connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); defaultgateway = new QRadioButton(box); defaultgateway->setText(i18n("Default gateway")); rb->insert(defaultgateway, 0); QWhatsThis::add(defaultgateway, i18n("This makes the PPP peer computer (the computer\n" "you are connected to with your modem) to act as\n" "a gateway. Your computer will send all packets not\n" "going to a computer inside your local net to this\n" "computer, which will route these packets.\n" "\n" "This is the default for most ISPs, so you should\n" "probably leave this option on.")); staticgateway = new QRadioButton(box); staticgateway->setText(i18n("Static gateway")); rb->insert(staticgateway, 1); QWhatsThis::add(staticgateway, i18n("<p>Allows you to specify which computer you want\n" "to use as gateway (see <i>Default Gateway</i> above)")); QHBox *gateBox = new QHBox(box); gate_label = new QLabel(i18n("Gateway IP address:"), gateBox); gatewayaddr = new IPLineEdit(gateBox); defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"), this); QWhatsThis::add(defaultroute, i18n("If this option is enabled, all packets not\n" "going to the local net are routed through\n" "the PPP connection.\n" "\n" "Normally, you should turn this on")); topLayout->addWidget(box); topLayout->addWidget(defaultroute); topLayout->addStretch(); //load info from gpppdata if(!isnewaccount) { if(PPPData::data()->gateway() == "0.0.0.0") { defaultgateway->setChecked(true); hitGatewaySelect(0); } else { gatewayaddr->setText(PPPData::data()->gateway()); staticgateway->setChecked(true); } defaultroute->setChecked(PPPData::data()->defaultroute()); } else { defaultgateway->setChecked(true); hitGatewaySelect(0); defaultroute->setChecked(true); } } void GatewayWidget::save() { PPPData::data()->setGateway(gatewayaddr->text()); PPPData::data()->setDefaultroute(defaultroute->isChecked()); } void GatewayWidget::hitGatewaySelect( int i ) { if(i == 0) { gatewayaddr->setText("0.0.0.0"); gatewayaddr->setEnabled(false); gate_label->setEnabled(false); } else { gatewayaddr->setEnabled(true); gatewayaddr->setText(""); gate_label->setEnabled(true); } } ScriptWidget::ScriptWidget( QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name) { - QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); + + QVBoxLayout *tl = new QVBoxLayout(this, 0 ); se = new ScriptEdit(this); connect(se, SIGNAL(returnPressed()), SLOT(addButton())); tl->addWidget(se); // insert equal-sized buttons - QButtonGroup *bbox = new QButtonGroup(this); - add = new QPushButton( bbox, i18n("Add") ); - bbox->insert(add); + QHBoxLayout *hl = new QHBoxLayout( this ); + tl->addLayout( hl ); + add = new QPushButton( i18n("Add"), this ); + hl->addWidget( add ); connect(add, SIGNAL(clicked()), SLOT(addButton())); -// bbox->addStretch(1); - insert = new QPushButton( bbox, i18n("Insert") ); - bbox->insert(insert); + insert = new QPushButton( i18n("Insert"), this ); + hl->addWidget( insert ); connect(insert, SIGNAL(clicked()), SLOT(insertButton())); -// bbox->addStretch(1); - remove = new QPushButton( bbox, i18n("Remove") ); - bbox->insert(remove); + remove = new QPushButton( i18n("Remove"), this ); + hl->addWidget( remove ); connect(remove, SIGNAL(clicked()), SLOT(removeButton())); - bbox->layout(); - tl->addWidget(bbox); QHBoxLayout *l12 = new QHBoxLayout(0); tl->addLayout(l12); stl = new QListBox(this); - stl->setVScrollBarMode( QScrollView::AlwaysOff ); +// stl->setVScrollBarMode( QScrollView::AlwaysOff ); connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); - stl->setMinimumSize(QSize(70, 140)); +// stl->setMinimumSize(QSize(70, 140)); sl = new QListBox(this); - sl->setVScrollBarMode( QScrollView::AlwaysOff ); +// sl->setVScrollBarMode( QScrollView::AlwaysOff ); connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); - sl->setMinimumSize(QSize(150, 140)); +// sl->setMinimumSize(QSize(150, 140)); slb = new QScrollBar(this); // slb->setFixedWidth(slb->sizeHint().width()); connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); l12->addWidget(stl, 1); l12->addWidget(sl, 3); l12->addWidget(slb, 0); //load data from gpppdata if(!isnewaccount) { QStringList &comlist = PPPData::data()->scriptType(); QStringList &arglist = PPPData::data()->script(); QStringList::Iterator itcom = comlist.begin(); QStringList::Iterator itarg = arglist.begin(); for ( ; itcom != comlist.end() && itarg != arglist.end(); ++itcom, ++itarg ) { stl->insertItem(*itcom); sl->insertItem(*itarg); } } insert->setEnabled(false); remove->setEnabled(false); adjustScrollBar(); tl->activate(); } bool ScriptWidget::check() { uint lstart = 0; uint lend = 0; uint errcnt = 0; if(sl->count() > 0) { for( uint i=0; i <= sl->count()-1; i++) { if(stl->text(i) == "LoopStart") { lstart++; } if (stl->text(i) == "LoopEnd") { lend++; } if ( lend > lstart ) errcnt++; } return ( (errcnt == 0 ) && (lstart == lend) ); } return true; } void ScriptWidget::save() { QStringList typelist, arglist; for(uint i=0; i < sl->count(); i++) { typelist.append(stl->text(i)); arglist.append(sl->text(i)); } PPPData::data()->setScriptType(typelist); PPPData::data()->setScript(arglist); } void ScriptWidget::adjustScrollBar() { if((int)sl->count() <= sl->numItemsVisible()) slb->setRange(0, 0); else slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); } void ScriptWidget::scrolling(int i) { sl->setTopItem(i); stl->setTopItem(i); } void ScriptWidget::slhighlighted(int i) { insert->setEnabled(true); remove->setEnabled(true); stl->setCurrentItem(i); } void ScriptWidget::stlhighlighted(int i) { insert->setEnabled(true); remove->setEnabled(true); sl->setCurrentItem(i); } void ScriptWidget::addButton() { //don't allow more than the maximum script entries if(sl->count() == MAX_SCRIPT_ENTRIES-1) return; @@ -1061,133 +1059,139 @@ void ScriptWidget::insertButton() { stl->insertItem("Send", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::SendNoEcho: stl->insertItem("SendNoEcho", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Pause: stl->insertItem("Pause", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Hangup: stl->insertItem("Hangup", stl->currentItem()); sl->insertItem("", sl->currentItem()); break; case ScriptEdit::Answer: stl->insertItem("Answer", stl->currentItem()); sl->insertItem("", sl->currentItem()); break; case ScriptEdit::Timeout: stl->insertItem("Timeout", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Password: stl->insertItem("Password", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::ID: stl->insertItem("ID", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Prompt: stl->insertItem("Prompt", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::PWPrompt: stl->insertItem("PWPrompt", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::LoopStart: stl->insertItem("LoopStart", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::LoopEnd: stl->insertItem("LoopEnd", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Scan: stl->insertItem("Scan", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Save: stl->insertItem("Save", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; default: break; } adjustScrollBar(); se->setText(""); } void ScriptWidget::removeButton() { if(sl->currentItem() >= 0) { int stlc = stl->currentItem(); sl->removeItem(sl->currentItem()); stl->removeItem(stlc); adjustScrollBar(); insert->setEnabled(sl->currentItem() != -1); remove->setEnabled(sl->currentItem() != -1); } } ///////////////////////////////////////////////////////////////////////////// // // Used to specify a new phone number // ///////////////////////////////////////////////////////////////////////////// PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) - : QDialog(parent,"PhoneNumberDialog",true) { + : QDialog(parent,"PhoneNumberDialog",true) +{ setCaption( i18n("Add Phone Number") ); -// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); - QHBox *hbox = new QHBox(this); + + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setSpacing( 3 ); + layout->setMargin( 3 ); + +// QHBox *hbox = new QHBox(this); // setMainWidget(hbox); - hbox->setSpacing( 2 );//KDialog::spacingHint()); +// hbox->setSpacing( 2 );//KDialog::spacingHint()); - new QLabel(i18n("Enter a phone number:"), hbox); + QLabel *label = new QLabel(this, tr("Enter a phone number:")); + layout->addWidget( label ); - le = new QLineEdit(hbox); -// le->setMinimumWidth(125); + le = new QLineEdit(this, "lineEdit"); + layout->addWidget( le ); connect(le, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &))); le->setFocus(); textChanged(""); -// enableButtonSeparator(true); + } QString PhoneNumberDialog::phoneNumber() { QString s = le->text(); return s; } void PhoneNumberDialog::textChanged(const QString &s) { // enableButtonOK(s.length() > 0); } //#include "edit.moc" diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp index b7fca3f..4039939 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.cpp +++ b/noncore/settings/networksettings/ppp/pppdargs.cpp @@ -1,166 +1,166 @@ /* * kPPP: A pppd front end for the KDE project * * $Id$ * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * based on EzPPP: * Copyright (C) 1997 Jay Painter * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <qlayout.h> #include <qbuttongroup.h> //#include <kwin.h> #include <qapplication.h> #include "pppdargs.h" #include "pppdata.h" //#include <klocale.h> #define i18n QObject::tr PPPdArguments::PPPdArguments(QWidget *parent, const char *name) : QDialog(parent, name, TRUE) { setCaption(i18n("Customize pppd Arguments")); // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); QVBoxLayout *l = new QVBoxLayout(this, 10, 10); QHBoxLayout *tl = new QHBoxLayout(10); l->addLayout(tl); QVBoxLayout *l1 = new QVBoxLayout(); QVBoxLayout *l2 = new QVBoxLayout(); tl->addLayout(l1, 1); tl->addLayout(l2, 0); QHBoxLayout *l11 = new QHBoxLayout(10); l1->addLayout(l11); argument_label = new QLabel(i18n("Argument:"), this); l11->addWidget(argument_label); argument = new QLineEdit(this); connect(argument, SIGNAL(returnPressed()), SLOT(addbutton())); l11->addWidget(argument); connect(argument, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &))); arguments = new QListBox(this); arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); connect(arguments, SIGNAL(highlighted(int)), this, SLOT(itemSelected(int))); l1->addWidget(arguments, 1); add = new QPushButton(i18n("Add"), this); connect(add, SIGNAL(clicked()), SLOT(addbutton())); l2->addWidget(add); l2->addStretch(1); remove = new QPushButton(i18n("Remove"), this); connect(remove, SIGNAL(clicked()), SLOT(removebutton())); l2->addWidget(remove); defaults = new QPushButton(i18n("Defaults"), this); connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); l2->addWidget(defaults); l->addSpacing(5); - QButtonGroup *bbox = new QButtonGroup(this); -// bbox->addStretch(1); - closebtn = new QPushButton( bbox, i18n("OK")); - bbox->insert(closebtn); - connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); - QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); - bbox->insert(cancel); - connect(cancel, SIGNAL(clicked()), - this, SLOT(reject())); - bbox->layout(); - l->addWidget(bbox); - - setFixedSize(sizeHint()); +// QButtonGroup *bbox = new QButtonGroup(this); +// // bbox->addStretch(1); +// closebtn = new QPushButton( bbox, i18n("OK")); +// bbox->insert(closebtn); +// connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); +// QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); +// bbox->insert(cancel); +// connect(cancel, SIGNAL(clicked()), +// this, SLOT(reject())); +// bbox->layout(); +// l->addWidget(bbox); + +// setFixedSize(sizeHint()); //load info from gpppdata init(); add->setEnabled(false); remove->setEnabled(false); argument->setFocus(); } void PPPdArguments::addbutton() { if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { arguments->insertItem(argument->text()); argument->setText(""); } } void PPPdArguments::removebutton() { if(arguments->currentItem() >= 0) arguments->removeItem(arguments->currentItem()); } void PPPdArguments::defaultsbutton() { // all of this is a hack // save current list QStringList arglist(PPPData::data()->pppdArgument()); // get defaults PPPData::data()->setpppdArgumentDefaults(); init(); // restore old list PPPData::data()->setpppdArgument(arglist); } void PPPdArguments::closebutton() { QStringList arglist; for(uint i=0; i < arguments->count(); i++) arglist.append(arguments->text(i)); PPPData::data()->setpppdArgument(arglist); done(0); } void PPPdArguments::init() { while(arguments->count()) arguments->removeItem(0); QStringList &arglist = PPPData::data()->pppdArgument(); for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it ) arguments->insertItem(*it); } void PPPdArguments::textChanged(const QString &s) { add->setEnabled(s.length() > 0); } void PPPdArguments::itemSelected(int idx) { remove->setEnabled(idx != -1); } |