author | tille <tille> | 2003-05-23 19:43:46 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-23 19:43:46 (UTC) |
commit | 9b6b21112f38181f49b07e973bfe00c0d83a6900 (patch) (unidiff) | |
tree | c2fa45a93ac5c26fe98558f28bb0a166b14ad065 /noncore/settings/networksettings/ppp/pppdargs.cpp | |
parent | 34b9974063032242e5de65fa56d4c2cb5e1ce565 (diff) | |
download | opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.zip opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.tar.gz opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.tar.bz2 |
configure dialog basicly working
more kppp stuff... ;)
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppdargs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdargs.cpp | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp new file mode 100644 index 0000000..04d0dd0 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/pppdargs.cpp | |||
@@ -0,0 +1,166 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * | ||
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. | ||
17 | * | ||
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. | ||
22 | * | ||
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., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | */ | ||
27 | |||
28 | #include <qlayout.h> | ||
29 | #include <qbuttongroup.h> | ||
30 | //#include <kwin.h> | ||
31 | #include <qapplication.h> | ||
32 | #include "pppdargs.h" | ||
33 | #include "pppdata.h" | ||
34 | //#include <klocale.h> | ||
35 | #define i18n QObject::tr | ||
36 | |||
37 | PPPdArguments::PPPdArguments(QWidget *parent, const char *name) | ||
38 | : QDialog(parent, name, TRUE) | ||
39 | { | ||
40 | setCaption(i18n("Customize pppd Arguments")); | ||
41 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | ||
42 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); | ||
43 | QHBoxLayout *tl = new QHBoxLayout(10); | ||
44 | l->addLayout(tl); | ||
45 | QVBoxLayout *l1 = new QVBoxLayout(); | ||
46 | QVBoxLayout *l2 = new QVBoxLayout(); | ||
47 | tl->addLayout(l1, 1); | ||
48 | tl->addLayout(l2, 0); | ||
49 | |||
50 | QHBoxLayout *l11 = new QHBoxLayout(10); | ||
51 | l1->addLayout(l11); | ||
52 | |||
53 | argument_label = new QLabel(i18n("Argument:"), this); | ||
54 | l11->addWidget(argument_label); | ||
55 | |||
56 | argument = new QLineEdit(this); | ||
57 | connect(argument, SIGNAL(returnPressed()), | ||
58 | SLOT(addbutton())); | ||
59 | l11->addWidget(argument); | ||
60 | connect(argument, SIGNAL(textChanged(const QString &)), | ||
61 | this, SLOT(textChanged(const QString &))); | ||
62 | |||
63 | arguments = new QListBox(this); | ||
64 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); | ||
65 | connect(arguments, SIGNAL(highlighted(int)), | ||
66 | this, SLOT(itemSelected(int))); | ||
67 | l1->addWidget(arguments, 1); | ||
68 | |||
69 | add = new QPushButton(i18n("Add"), this); | ||
70 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); | ||
71 | l2->addWidget(add); | ||
72 | l2->addStretch(1); | ||
73 | |||
74 | remove = new QPushButton(i18n("Remove"), this); | ||
75 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); | ||
76 | l2->addWidget(remove); | ||
77 | |||
78 | defaults = new QPushButton(i18n("Defaults"), this); | ||
79 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); | ||
80 | l2->addWidget(defaults); | ||
81 | |||
82 | l->addSpacing(5); | ||
83 | |||
84 | QButtonGroup *bbox = new QButtonGroup(this); | ||
85 | // bbox->addStretch(1); | ||
86 | closebtn = new QPushButton( bbox, i18n("OK")); | ||
87 | bbox->insert(closebtn); | ||
88 | connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); | ||
89 | QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); | ||
90 | bbox->insert(cancel); | ||
91 | connect(cancel, SIGNAL(clicked()), | ||
92 | this, SLOT(reject())); | ||
93 | bbox->layout(); | ||
94 | l->addWidget(bbox); | ||
95 | |||
96 | setFixedSize(sizeHint()); | ||
97 | |||
98 | //load info from gpppdata | ||
99 | init(); | ||
100 | |||
101 | add->setEnabled(false); | ||
102 | remove->setEnabled(false); | ||
103 | argument->setFocus(); | ||
104 | } | ||
105 | |||
106 | |||
107 | void PPPdArguments::addbutton() { | ||
108 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { | ||
109 | arguments->insertItem(argument->text()); | ||
110 | argument->setText(""); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | |||
115 | void PPPdArguments::removebutton() { | ||
116 | if(arguments->currentItem() >= 0) | ||
117 | arguments->removeItem(arguments->currentItem()); | ||
118 | } | ||
119 | |||
120 | |||
121 | void PPPdArguments::defaultsbutton() { | ||
122 | // all of this is a hack | ||
123 | // save current list | ||
124 | QStringList arglist(gpppdata.pppdArgument()); | ||
125 | |||
126 | // get defaults | ||
127 | gpppdata.setpppdArgumentDefaults(); | ||
128 | init(); | ||
129 | |||
130 | // restore old list | ||
131 | gpppdata.setpppdArgument(arglist); | ||
132 | } | ||
133 | |||
134 | |||
135 | void PPPdArguments::closebutton() { | ||
136 | QStringList arglist; | ||
137 | for(uint i=0; i < arguments->count(); i++) | ||
138 | arglist.append(arguments->text(i)); | ||
139 | gpppdata.setpppdArgument(arglist); | ||
140 | |||
141 | done(0); | ||
142 | } | ||
143 | |||
144 | |||
145 | void PPPdArguments::init() { | ||
146 | while(arguments->count()) | ||
147 | arguments->removeItem(0); | ||
148 | |||
149 | QStringList &arglist = gpppdata.pppdArgument(); | ||
150 | for ( QStringList::Iterator it = arglist.begin(); | ||
151 | it != arglist.end(); | ||
152 | ++it ) | ||
153 | arguments->insertItem(*it); | ||
154 | } | ||
155 | |||
156 | |||
157 | void PPPdArguments::textChanged(const QString &s) { | ||
158 | add->setEnabled(s.length() > 0); | ||
159 | } | ||
160 | |||
161 | |||
162 | void PPPdArguments::itemSelected(int idx) { | ||
163 | remove->setEnabled(idx != -1); | ||
164 | } | ||
165 | |||
166 | |||