2 * kPPP: A pppd front end for the KDE project
6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
10 * Copyright (C) 1997 Jay Painter
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details.
23 * You should have received a copy of the GNU Library General Public
24 * License along with this program; if not, write to the Free
25 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <QVBoxLayout>
31 #include <QHBoxLayout>
33 #include <kapplication.h>
37 #include <qlineedit.h>
38 #include <qpushbutton.h>
39 #include <q3listbox.h>
41 #include <KStandardGuiItem>
42 #include <kpushbutton.h>
43 #include <KStandardGuiItem>
44 #include <kiconloader.h>
46 PPPdArguments::PPPdArguments(QWidget
*parent
, const char *name
)
51 setWindowTitle(i18n("Customize pppd Arguments"));
52 KWin::setIcons(winId(), qApp
->windowIcon().pixmap(IconSize(K3Icon::Desktop
),IconSize(K3Icon::Desktop
)), qApp
->windowIcon().pixmap(IconSize(K3Icon::Small
),IconSize(K3Icon::Small
)));
53 QVBoxLayout
*l
= new QVBoxLayout(this);
56 QHBoxLayout
*tl
= new QHBoxLayout();
59 QVBoxLayout
*l1
= new QVBoxLayout();
60 QVBoxLayout
*l2
= new QVBoxLayout();
64 QHBoxLayout
*l11
= new QHBoxLayout();
65 l11
->setSpacing( 10 );
68 argument_label
= new QLabel(i18n("Arg&ument:"), this);
69 l11
->addWidget(argument_label
);
71 argument
= new QLineEdit(this);
72 argument_label
->setBuddy(argument
);
73 connect(argument
, SIGNAL(returnPressed()),
75 l11
->addWidget(argument
);
76 connect(argument
, SIGNAL(textChanged(const QString
&)),
77 this, SLOT(textChanged(const QString
&)));
79 arguments
= new Q3ListBox(this);
80 arguments
->setMinimumSize(1, fontMetrics().lineSpacing()*10);
81 connect(arguments
, SIGNAL(highlighted(int)),
82 this, SLOT(itemSelected(int)));
83 l1
->addWidget(arguments
, 1);
85 add
= new QPushButton(i18n("&Add"), this);
86 connect(add
, SIGNAL(clicked()), SLOT(addbutton()));
90 remove
= new QPushButton(i18n("&Remove"), this);
91 connect(remove
, SIGNAL(clicked()), SLOT(removebutton()));
92 l2
->addWidget(remove
);
94 defaults
= new KPushButton(KStandardGuiItem::defaults(), this);
95 connect(defaults
, SIGNAL(clicked()), SLOT(defaultsbutton()));
96 l2
->addWidget(defaults
);
100 setButtons(Ok
| Cancel
);
101 connect(this, SIGNAL(okClicked()), SLOT(closebutton()));
103 setFixedSize(sizeHint());
105 //load info from gpppdata
108 add
->setEnabled(false);
109 remove
->setEnabled(false);
110 argument
->setFocus();
114 void PPPdArguments::addbutton() {
115 if(!argument
->text().isEmpty() && arguments
->count() < MAX_PPPD_ARGUMENTS
) {
116 arguments
->insertItem(argument
->text());
117 argument
->setText("");
122 void PPPdArguments::removebutton() {
123 if(arguments
->currentItem() >= 0)
124 arguments
->removeItem(arguments
->currentItem());
128 void PPPdArguments::defaultsbutton() {
129 // all of this is a hack
131 QStringList
arglist(gpppdata
.pppdArgument());
134 gpppdata
.setpppdArgumentDefaults();
138 gpppdata
.setpppdArgument(arglist
);
142 void PPPdArguments::closebutton() {
144 for(uint i
=0; i
< arguments
->count(); i
++)
145 arglist
.append(arguments
->text(i
));
146 gpppdata
.setpppdArgument(arglist
);
152 void PPPdArguments::init() {
153 while(arguments
->count())
154 arguments
->removeItem(0);
156 QStringList
&arglist
= gpppdata
.pppdArgument();
157 for ( QStringList::Iterator it
= arglist
.begin();
160 arguments
->insertItem(*it
);
164 void PPPdArguments::textChanged(const QString
&s
) {
165 add
->setEnabled(s
.length() > 0);
169 void PPPdArguments::itemSelected(int idx
) {
170 remove
->setEnabled(idx
!= -1);
173 #include "pppdargs.moc"