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>
32 #include <QApplication>
33 #include <kwindowsystem.h>
37 #include <qlineedit.h>
38 #include <qpushbutton.h>
39 #include <q3listbox.h>
41 #include <KStandardGuiItem>
42 #include <kpushbutton.h>
43 #include <kiconloader.h>
45 PPPdArguments::PPPdArguments(QWidget
*parent
, const char *name
)
50 setWindowTitle(i18n("Customize pppd Arguments"));
51 QWidget
*widget
= new QWidget(this);
52 setMainWidget(widget
);
53 KWindowSystem::setIcons(winId(), qApp
->windowIcon().pixmap(IconSize(KIconLoader::Desktop
),IconSize(KIconLoader::Desktop
)), qApp
->windowIcon().pixmap(IconSize(KIconLoader::Small
),IconSize(KIconLoader::Small
)));
54 QVBoxLayout
*l
= new QVBoxLayout(widget
);
57 QHBoxLayout
*tl
= new QHBoxLayout();
60 QVBoxLayout
*l1
= new QVBoxLayout();
61 QVBoxLayout
*l2
= new QVBoxLayout();
65 QHBoxLayout
*l11
= new QHBoxLayout();
66 l11
->setSpacing( 10 );
69 argument_label
= new QLabel(i18n("Arg&ument:"), widget
);
70 l11
->addWidget(argument_label
);
72 argument
= new QLineEdit(widget
);
73 argument_label
->setBuddy(argument
);
74 connect(argument
, SIGNAL(returnPressed()),
76 l11
->addWidget(argument
);
77 connect(argument
, SIGNAL(textChanged(const QString
&)),
78 this, SLOT(textChanged(const QString
&)));
80 arguments
= new Q3ListBox(widget
);
81 arguments
->setMinimumSize(1, fontMetrics().lineSpacing()*10);
82 connect(arguments
, SIGNAL(highlighted(int)),
83 this, SLOT(itemSelected(int)));
84 l1
->addWidget(arguments
, 1);
86 add
= new QPushButton(i18n("&Add"), widget
);
87 connect(add
, SIGNAL(clicked()), SLOT(addbutton()));
91 remove
= new QPushButton(i18n("&Remove"), widget
);
92 connect(remove
, SIGNAL(clicked()), SLOT(removebutton()));
93 l2
->addWidget(remove
);
95 defaults
= new KPushButton(KStandardGuiItem::defaults(), widget
);
96 connect(defaults
, SIGNAL(clicked()), SLOT(defaultsbutton()));
97 l2
->addWidget(defaults
);
101 setButtons(Ok
| Cancel
);
102 connect(this, SIGNAL(okClicked()), SLOT(closebutton()));
104 setFixedSize(sizeHint());
106 //load info from gpppdata
109 add
->setEnabled(false);
110 remove
->setEnabled(false);
111 argument
->setFocus();
115 void PPPdArguments::addbutton() {
116 if(!argument
->text().isEmpty() && arguments
->count() < MAX_PPPD_ARGUMENTS
) {
117 arguments
->insertItem(argument
->text());
118 argument
->setText("");
123 void PPPdArguments::removebutton() {
124 if(arguments
->currentItem() >= 0)
125 arguments
->removeItem(arguments
->currentItem());
129 void PPPdArguments::defaultsbutton() {
130 // all of this is a hack
132 QStringList
arglist(gpppdata
.pppdArgument());
135 gpppdata
.setpppdArgumentDefaults();
139 gpppdata
.setpppdArgument(arglist
);
143 void PPPdArguments::closebutton() {
145 for(uint i
=0; i
< arguments
->count(); i
++)
146 arglist
.append(arguments
->text(i
));
147 gpppdata
.setpppdArgument(arglist
);
153 void PPPdArguments::init() {
154 while(arguments
->count())
155 arguments
->removeItem(0);
157 QStringList
&arglist
= gpppdata
.pppdArgument();
158 for ( QStringList::Iterator it
= arglist
.begin();
161 arguments
->insertItem(*it
);
165 void PPPdArguments::textChanged(const QString
&s
) {
166 add
->setEnabled(s
.length() > 0);
170 void PPPdArguments::itemSelected(int idx
) {
171 remove
->setEnabled(idx
!= -1);
174 #include "pppdargs.moc"