summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-06-10 13:46:02 (UTC)
committer harlekin <harlekin>2003-06-10 13:46:02 (UTC)
commit8ffea5d37080bd173d55a458296c1fc461a54d13 (patch) (unidiff)
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
@@ -1,355 +1,355 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <qdir.h> 27#include <qdir.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qtabdialog.h> 31#include <qtabdialog.h>
32#include <qwhatsthis.h> 32#include <qwhatsthis.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34 34
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qbuttongroup.h> 36#include <qbuttongroup.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <qvgroupbox.h> 38#include <qvgroupbox.h>
39 39
40#include "accounts.h" 40#include "accounts.h"
41#include "authwidget.h" 41#include "authwidget.h"
42#include "pppdata.h" 42#include "pppdata.h"
43#include "edit.h" 43#include "edit.h"
44 44
45void parseargs(char* buf, char** args); 45void parseargs(char* buf, char** args);
46 46
47AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) 47AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
48 : QWidget( parent, name )//, _pppdata(pd) 48 : QWidget( parent, name )//, _pppdata(pd)
49{ 49{
50 _pppdata = pd; 50 _pppdata = pd;
51 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 51 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
52 accountlist_l = new QListBox(this); 52 accountlist_l = new QListBox(this);
53 53
54 connect(accountlist_l, SIGNAL(highlighted(int)), 54 connect(accountlist_l, SIGNAL(highlighted(int)),
55 this, SLOT(slotListBoxSelect(int))); 55 this, SLOT(slotListBoxSelect(int)));
56 connect(accountlist_l, SIGNAL(selected(int)), 56 connect(accountlist_l, SIGNAL(selected(int)),
57 this, SLOT(editaccount())); 57 this, SLOT(editaccount()));
58 l1->addWidget(accountlist_l, 10); 58 l1->addWidget(accountlist_l, 10);
59 59
60 edit_b = new QPushButton(tr("&Edit..."), this); 60 edit_b = new QPushButton(tr("&Edit..."), this);
61 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 61 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
62 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); 62 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
63 l1->addWidget(edit_b); 63 l1->addWidget(edit_b);
64 64
65 new_b = new QPushButton(tr("&New..."), this); 65 new_b = new QPushButton(tr("&New..."), this);
66 connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); 66 connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
67 l1->addWidget(new_b); 67 l1->addWidget(new_b);
68 QWhatsThis::add(new_b, tr("Create a new dialup connection\n" 68 QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
69 "to the Internet")); 69 "to the Internet"));
70 70
71 copy_b = new QPushButton(tr("Co&py"), this); 71 copy_b = new QPushButton(tr("Co&py"), this);
72 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); 72 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
73 l1->addWidget(copy_b); 73 l1->addWidget(copy_b);
74 QWhatsThis::add(copy_b, 74 QWhatsThis::add(copy_b,
75 tr("Makes a copy of the selected account. All\n" 75 tr("Makes a copy of the selected account. All\n"
76 "settings of the selected account are copied\n" 76 "settings of the selected account are copied\n"
77 "to a new account, that you can modify to fit your\n" 77 "to a new account, that you can modify to fit your\n"
78 "needs")); 78 "needs"));
79 79
80 delete_b = new QPushButton(tr("De&lete"), this); 80 delete_b = new QPushButton(tr("De&lete"), this);
81 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); 81 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
82 l1->addWidget(delete_b); 82 l1->addWidget(delete_b);
83 QWhatsThis::add(delete_b, 83 QWhatsThis::add(delete_b,
84 tr("<p>Deletes the selected account\n\n" 84 tr("<p>Deletes the selected account\n\n"
85 "<font color=\"red\"><b>Use with care!</b></font>")); 85 "<font color=\"red\"><b>Use with care!</b></font>"));
86 86
87 QHBoxLayout *l12 = new QHBoxLayout; 87 QHBoxLayout *l12 = new QHBoxLayout;
88 l1->addStretch(1); 88 l1->addStretch(1);
89 l1->addLayout(l12); 89 l1->addLayout(l12);
90 90
91 int currAccId = _pppdata->currentAccountID(); 91 int currAccId = _pppdata->currentAccountID();
92 qDebug("currentAccountID %i", currAccId); 92 qDebug("currentAccountID %i", currAccId);
93 93
94 //load up account list from gppdata to the list box 94 //load up account list from gppdata to the list box
95 if(_pppdata->count() > 0) { 95 if(_pppdata->count() > 0) {
96 for(int i=0; i <= _pppdata->count()-1; i++) { 96 for(int i=0; i <= _pppdata->count()-1; i++) {
97 _pppdata->setAccountbyIndex(i); 97 _pppdata->setAccountbyIndex(i);
98 accountlist_l->insertItem(_pppdata->accname()); 98 accountlist_l->insertItem(_pppdata->accname());
99 } 99 }
100 } 100 }
101 _pppdata->setAccountbyIndex( currAccId ); 101 _pppdata->setAccountbyIndex( currAccId );
102 102
103 qDebug("setting listview index to %i",_pppdata->currentAccountID() ); 103 qDebug("setting listview index to %i",_pppdata->currentAccountID() );
104 accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); 104 accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
105 slotListBoxSelect( _pppdata->currentAccountID() ); 105 slotListBoxSelect( _pppdata->currentAccountID() );
106 106
107 l1->activate(); 107 l1->activate();
108} 108}
109 109
110 110
111 111
112void AccountWidget::slotListBoxSelect(int idx) { 112void AccountWidget::slotListBoxSelect(int idx) {
113 delete_b->setEnabled((bool)(idx != -1)); 113 delete_b->setEnabled((bool)(idx != -1));
114 edit_b->setEnabled((bool)(idx != -1)); 114 edit_b->setEnabled((bool)(idx != -1));
115 copy_b->setEnabled((bool)(idx != -1)); 115 copy_b->setEnabled((bool)(idx != -1));
116 if(idx!=-1) { 116 if(idx!=-1) {
117 qDebug("setting account to %i", idx); 117 qDebug("setting account to %i", idx);
118 QString account = _pppdata->accname(); 118 QString account = _pppdata->accname();
119 _pppdata->setAccountbyIndex(accountlist_l->currentItem()); 119 _pppdata->setAccountbyIndex(accountlist_l->currentItem());
120 } 120 }
121} 121}
122 122
123void AccountWidget::editaccount() { 123void AccountWidget::editaccount() {
124 _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); 124 _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem()));
125 125
126 int result = doTab(); 126 int result = doTab();
127 127
128 if(result == QDialog::Accepted) { 128 if(result == QDialog::Accepted) {
129 accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); 129 accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem());
130// emit resetaccounts(); 130// emit resetaccounts();
131 _pppdata->save(); 131 _pppdata->save();
132 } 132 }
133} 133}
134 134
135 135
136void AccountWidget::newaccount() { 136void AccountWidget::newaccount() {
137 137
138 if(accountlist_l->count() == MAX_ACCOUNTS) { 138 if(accountlist_l->count() == MAX_ACCOUNTS) {
139 QMessageBox::information(this, "sorry", 139 QMessageBox::information(this, "sorry",
140 tr("Maximum number of accounts reached.")); 140 tr("Maximum number of accounts reached."));
141 return; 141 return;
142 } 142 }
143 143
144 int result; 144 int result;
145 if (_pppdata->newaccount() == -1){ 145 if (_pppdata->newaccount() == -1){
146 qDebug("_pppdata->newaccount() == -1"); 146 qDebug("_pppdata->newaccount() == -1");
147 return; 147 return;
148 } 148 }
149 result = doTab(); 149 result = doTab();
150 150
151 if(result == QDialog::Accepted) { 151 if(result == QDialog::Accepted) {
152 accountlist_l->insertItem(_pppdata->accname()); 152 accountlist_l->insertItem(_pppdata->accname());
153 accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); 153 accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true);
154 154
155 _pppdata->save(); 155 _pppdata->save();
156 } else 156 } else
157 _pppdata->deleteAccount(); 157 _pppdata->deleteAccount();
158} 158}
159 159
160 160
161void AccountWidget::copyaccount() { 161void AccountWidget::copyaccount() {
162 if(accountlist_l->count() == MAX_ACCOUNTS) { 162 if(accountlist_l->count() == MAX_ACCOUNTS) {
163 QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); 163 QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
164 return; 164 return;
165 } 165 }
166 166
167 if(accountlist_l->currentItem()<0) { 167 if(accountlist_l->currentItem()<0) {
168 QMessageBox::information(this, "sorry", tr("No account selected.")); 168 QMessageBox::information(this, "sorry", tr("No account selected."));
169 return; 169 return;
170 } 170 }
171 171
172 _pppdata->copyaccount(accountlist_l->currentItem()); 172 _pppdata->copyaccount(accountlist_l->currentItem());
173 173
174 accountlist_l->insertItem(_pppdata->accname()); 174 accountlist_l->insertItem(_pppdata->accname());
175// emit resetaccounts(); 175// emit resetaccounts();
176 _pppdata->save(); 176 _pppdata->save();
177} 177}
178 178
179 179
180void AccountWidget::deleteaccount() { 180void AccountWidget::deleteaccount() {
181 181
182 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") 182 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
183 .arg(accountlist_l->text(accountlist_l->currentItem())); 183 .arg(accountlist_l->text(accountlist_l->currentItem()));
184 184
185 if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes) 185 if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes)
186 return; 186 return;
187 187
188 if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) 188 if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
189 accountlist_l->removeItem(accountlist_l->currentItem()); 189 accountlist_l->removeItem(accountlist_l->currentItem());
190 190
191 emit resetaccounts(); 191 emit resetaccounts();
192 _pppdata->save(); 192 _pppdata->save();
193 193
194 slotListBoxSelect(accountlist_l->currentItem()); 194 slotListBoxSelect(accountlist_l->currentItem());
195 195
196} 196}
197 197
198 198
199int AccountWidget::doTab(){ 199int AccountWidget::doTab(){
200 QDialog *dlg = new QDialog( 0, "newAccount", true ); 200 QDialog *dlg = new QDialog( 0, "newAccount", true );
201 QVBoxLayout *layout = new QVBoxLayout( dlg ); 201 QVBoxLayout *layout = new QVBoxLayout( dlg );
202 layout->setSpacing( 0 ); 202 layout->setSpacing( 0 );
203 layout->setMargin( 1 ); 203 layout->setMargin( 1 );
204 204
205 tabWindow = new QTabWidget( dlg, "tabWindow" ); 205 tabWindow = new QTabWidget( dlg, "tabWindow" );
206 layout->addWidget( tabWindow ); 206 layout->addWidget( tabWindow );
207 207
208 bool isnewaccount; 208 bool isnewaccount;
209 209
210 if(_pppdata->accname().isEmpty()) { 210 if(_pppdata->accname().isEmpty()) {
211 dlg->setCaption(tr("New Account")); 211 dlg->setCaption(tr("New Account"));
212 isnewaccount = true; 212 isnewaccount = true;
213 } else { 213 } else {
214 QString tit = tr("Edit Account: "); 214 QString tit = tr("Edit Account: ");
215 tit += _pppdata->accname(); 215 tit += _pppdata->accname();
216 dlg->setCaption(tit); 216 dlg->setCaption(tit);
217 isnewaccount = false; 217 isnewaccount = false;
218 } 218 }
219 219
220// // DIAL WIDGET 220// // DIAL WIDGET
221 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); 221 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
222 tabWindow->addTab( dial_w, tr("Dial") ); 222 tabWindow->addTab( dial_w, tr("Dial") );
223 223
224// // AUTH WIDGET 224// // AUTH WIDGET
225 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); 225 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
226 tabWindow->addTab( auth_w, tr("Authentication") ); 226 tabWindow->addTab( auth_w, tr("Authentication") );
227 227
228// // IP WIDGET 228// // IP WIDGET
229 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); 229 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
230 tabWindow->addTab( ip_w, tr("IP") ); 230 tabWindow->addTab( ip_w, tr("IP") );
231 231
232// // GATEWAY WIDGET 232// // GATEWAY WIDGET
233 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); 233 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
234 tabWindow->addTab( gateway_w, tr("Gateway") ); 234 tabWindow->addTab( gateway_w, tr("Gateway") );
235 235
236// // DNS WIDGET 236// // DNS WIDGET
237 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); 237 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
238 tabWindow->addTab( dns_w, tr("DNS") ); 238 tabWindow->addTab( dns_w, tr("DNS") );
239 239
240// // EXECUTE WIDGET 240// // EXECUTE WIDGET
241 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); 241 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
242 tabWindow->addTab( exec_w, tr("Execute") ); 242 tabWindow->addTab( exec_w, tr("Execute") );
243 243
244 int result = 0; 244 int result = 0;
245 bool ok = false; 245 bool ok = false;
246 246
247 while (!ok){ 247 while (!ok){
248 // dlg->showMinimized(); 248 dlg->showMaximized();
249 result = dlg->exec(); 249 result = dlg->exec();
250 ok = true; 250 ok = true;
251 251
252 if(result == QDialog::Accepted) { 252 if(result == QDialog::Accepted) {
253 if (!auth_w->check()){ 253 if (!auth_w->check()){
254 ok = false; 254 ok = false;
255 } else if(!dial_w->save()) { 255 } else if(!dial_w->save()) {
256 QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); 256 QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
257 ok = false; 257 ok = false;
258 }else{ 258 }else{
259 ip_w->save(); 259 ip_w->save();
260 dns_w->save(); 260 dns_w->save();
261 gateway_w->save(); 261 gateway_w->save();
262 auth_w->save(); 262 auth_w->save();
263 exec_w->save(); 263 exec_w->save();
264 } 264 }
265 } 265 }
266 } 266 }
267 267
268 delete dlg; 268 delete dlg;
269 269
270 return result; 270 return result;
271} 271}
272 272
273 273
274QString AccountWidget::prettyPrintVolume(unsigned int n) { 274QString AccountWidget::prettyPrintVolume(unsigned int n) {
275 int idx = 0; 275 int idx = 0;
276 const QString quant[] = {tr("Byte"), tr("KB"), 276 const QString quant[] = {tr("Byte"), tr("KB"),
277 tr("MB"), tr("GB"), QString::null}; 277 tr("MB"), tr("GB"), QString::null};
278 278
279 float n1 = n; 279 float n1 = n;
280 while(n >= 1024 && quant[idx] != QString::null) { 280 while(n >= 1024 && quant[idx] != QString::null) {
281 idx++; 281 idx++;
282 n /= 1024; 282 n /= 1024;
283 } 283 }
284 284
285 int i = idx; 285 int i = idx;
286 while(i--) 286 while(i--)
287 n1 = n1 / 1024.0; 287 n1 = n1 / 1024.0;
288 288
289 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); 289 QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
290 s += " " + quant[idx]; 290 s += " " + quant[idx];
291 return s; 291 return s;
292} 292}
293 293
294 294
295///////////////////////////////////////////////////////////////////////////// 295/////////////////////////////////////////////////////////////////////////////
296// 296//
297// Queries the user what to reset: costs, volume or both 297// Queries the user what to reset: costs, volume or both
298// 298//
299///////////////////////////////////////////////////////////////////////////// 299/////////////////////////////////////////////////////////////////////////////
300// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { 300// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
301// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 301// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
302// setCaption(tr("Reset Accounting")); 302// setCaption(tr("Reset Accounting"));
303 303
304// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 304// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
305// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); 305// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this);
306 306
307// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 307// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
308// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); 308// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f);
309// // costs->setChecked(true); 309// // costs->setChecked(true);
310// // l1->addWidget(costs); 310// // l1->addWidget(costs);
311// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" 311// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n"
312 // // "to zero. Typically you'll want to\n" 312 // // "to zero. Typically you'll want to\n"
313 // // "do this once a month.")); 313 // // "do this once a month."));
314 314
315// // volume = new QCheckBox(tr("Reset volume accounting"), f); 315// // volume = new QCheckBox(tr("Reset volume accounting"), f);
316// // volume->setChecked(true); 316// // volume->setChecked(true);
317// // l1->addWidget(volume); 317// // l1->addWidget(volume);
318// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" 318// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n"
319 // // "to zero. Typically you'll want to do this\n" 319 // // "to zero. Typically you'll want to do this\n"
320 // // "once a month.")); 320 // // "once a month."));
321 321
322// l1->activate(); 322// l1->activate();
323 323
324// // this activates the f-layout and sets minimumSize() 324// // this activates the f-layout and sets minimumSize()
325// f->show(); 325// f->show();
326 326
327// tl->addWidget(f); 327// tl->addWidget(f);
328 328
329// QButtonGroup *bbox = new QButtonGroup(this); 329// QButtonGroup *bbox = new QButtonGroup(this);
330// // bbox->addStretch(1); 330// // bbox->addStretch(1);
331// QPushButton *ok = new QPushButton( bbox, tr("OK") ); 331// QPushButton *ok = new QPushButton( bbox, tr("OK") );
332// bbox->insert(ok); 332// bbox->insert(ok);
333// ok->setDefault(true); 333// ok->setDefault(true);
334// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); 334// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") );
335// bbox->insert(cancel); 335// bbox->insert(cancel);
336 336
337// connect(ok, SIGNAL(clicked()), 337// connect(ok, SIGNAL(clicked()),
338 // this, SLOT(accepted())); 338 // this, SLOT(accepted()));
339// connect(cancel, SIGNAL(clicked()), 339// connect(cancel, SIGNAL(clicked()),
340 // this, SLOT(reject())); 340 // this, SLOT(reject()));
341 341
342// bbox->layout(); 342// bbox->layout();
343// tl->addWidget(bbox); 343// tl->addWidget(bbox);
344 344
345// } 345// }
346 346
347 347
348// void QueryReset::accepted() { 348// void QueryReset::accepted() {
349// int result = costs->isChecked() ? COSTS : 0; 349// int result = costs->isChecked() ? COSTS : 0;
350// result += volume->isChecked() ? VOLUME : 0; 350// result += volume->isChecked() ? VOLUME : 0;
351 351
352// done(result); 352// done(result);
353// } 353// }
354 354
355 355
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
@@ -1,1133 +1,1134 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * Copyright (C) 1997 Bernd Johannes Wuebben 5 * Copyright (C) 1997 Bernd Johannes Wuebben
6 * wuebben@math.cornell.edu 6 * wuebben@math.cornell.edu
7 * 7 *
8 * based on EzPPP: 8 * based on EzPPP:
9 * Copyright (C) 1997 Jay Painter 9 * Copyright (C) 1997 Jay Painter
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public 21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free 22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#include <string.h> 26#include <string.h>
27#include <termios.h> 27#include <termios.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qbuttongroup.h> 33#include <qbuttongroup.h>
34#include <qvgroupbox.h> 34#include <qvgroupbox.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qdialog.h> 36#include <qdialog.h>
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38 38
39#include "edit.h" 39#include "edit.h"
40#include "pppdata.h" 40#include "pppdata.h"
41#include "iplined.h" 41#include "iplined.h"
42#include "auth.h" 42#include "auth.h"
43 43
44DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount 44DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
45 , const char *name ) 45 , const char *name )
46 : QWidget(parent, name), _pppdata(pd) 46 : QWidget(parent, name), _pppdata(pd)
47{ 47{
48 const int GRIDROWS = 6; 48 const int GRIDROWS = 6;
49 49
50 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); 50 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );
51 51
52 connect_label = new QLabel(tr("Connection name:"), this); 52 connect_label = new QLabel(tr("Connection name:"), this);
53 tl->addWidget(connect_label, 0, 0); 53 tl->addWidget(connect_label, 0, 0);
54 54
55 connectname_l = new QLineEdit(this); 55 connectname_l = new QLineEdit(this);
56// connectname_l->setMaxLength(ACCNAME_SIZE); 56// connectname_l->setMaxLength(ACCNAME_SIZE);
57 tl->addWidget(connectname_l, 0, 1); 57 tl->addWidget(connectname_l, 0, 1);
58 QString tmp = tr("Type in a unique name for this connection"); 58 QString tmp = tr("Type in a unique name for this connection");
59 59
60 QWhatsThis::add(connect_label,tmp); 60 QWhatsThis::add(connect_label,tmp);
61 QWhatsThis::add(connectname_l,tmp); 61 QWhatsThis::add(connectname_l,tmp);
62 62
63 63
64 number_label = new QLabel(tr("Phone number:"), this); 64 number_label = new QLabel(tr("Phone number:"), this);
65 number_label->setAlignment(AlignTop|AlignLeft); 65 number_label->setAlignment(AlignTop|AlignLeft);
66 tl->addWidget(number_label, 1, 0); 66 tl->addWidget(number_label, 1, 0);
67 67
68 QHBoxLayout *lpn = new QHBoxLayout(5); 68 QHBoxLayout *lpn = new QHBoxLayout(5);
69 tl->addLayout(lpn, 1, 1); 69 tl->addLayout(lpn, 1, 1);
70 numbers = new QListBox(this); 70 numbers = new QListBox(this);
71// numbers->setMinimumSize(120, 70); 71// numbers->setMinimumSize(120, 70);
72 lpn->addWidget(numbers); 72 lpn->addWidget(numbers);
73 QVBoxLayout *lpn1 = new QVBoxLayout; 73 QVBoxLayout *lpn1 = new QVBoxLayout;
74 lpn->addLayout(lpn1); 74 lpn->addLayout(lpn1);
75 add = new QPushButton(tr("&Add..."), this); 75 add = new QPushButton(tr("&Add..."), this);
76 del = new QPushButton(tr("&Remove"), this); 76 del = new QPushButton(tr("&Remove"), this);
77 77
78 up = new QPushButton(this); 78 up = new QPushButton(this);
79 up->setPixmap( Resource::loadPixmap("inline/up") ); 79 up->setPixmap( Resource::loadPixmap("inline/up") );
80 down = new QPushButton(this); 80 down = new QPushButton(this);
81 down->setPixmap( Resource::loadPixmap("inline/down") ); 81 down->setPixmap( Resource::loadPixmap("inline/down") );
82 lpn1->addWidget(add); 82 lpn1->addWidget(add);
83 lpn1->addWidget(del); 83 lpn1->addWidget(del);
84 lpn1->addStretch(1); 84 lpn1->addStretch(1);
85 lpn1->addWidget(up); 85 lpn1->addWidget(up);
86 lpn1->addWidget(down); 86 lpn1->addWidget(down);
87 connect(add, SIGNAL(clicked()), 87 connect(add, SIGNAL(clicked()),
88 this, SLOT(addNumber())); 88 this, SLOT(addNumber()));
89 connect(del, SIGNAL(clicked()), 89 connect(del, SIGNAL(clicked()),
90 this, SLOT(delNumber())); 90 this, SLOT(delNumber()));
91 connect(up, SIGNAL(clicked()), 91 connect(up, SIGNAL(clicked()),
92 this, SLOT(upNumber())); 92 this, SLOT(upNumber()));
93 connect(down, SIGNAL(clicked()), 93 connect(down, SIGNAL(clicked()),
94 this, SLOT(downNumber())); 94 this, SLOT(downNumber()));
95 connect(numbers, SIGNAL(highlighted(int)), 95 connect(numbers, SIGNAL(highlighted(int)),
96 this, SLOT(selectionChanged(int))); 96 this, SLOT(selectionChanged(int)));
97 numbersChanged(); 97 numbersChanged();
98 98
99 tmp = tr("<p>Specifies the phone numbers to dial. You\n" 99 tmp = tr("<p>Specifies the phone numbers to dial. You\n"
100 "can supply multiple numbers here, simply\n" 100 "can supply multiple numbers here, simply\n"
101 "click on \"Add\". You can arrange the\n" 101 "click on \"Add\". You can arrange the\n"
102 "order the numbers are tried by using the\n" 102 "order the numbers are tried by using the\n"
103 "arrow buttons.\n\n" 103 "arrow buttons.\n\n"
104 "When a number is busy or fails, <i>kppp</i> will \n" 104 "When a number is busy or fails, <i>kppp</i> will \n"
105 "try the next number and so on"); 105 "try the next number and so on");
106 106
107 QWhatsThis::add(number_label,tmp); 107 QWhatsThis::add(number_label,tmp);
108 QWhatsThis::add(numbers,tmp); 108 QWhatsThis::add(numbers,tmp);
109 109
110 pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); 110 pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this);
111 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); 111 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
112 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); 112 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
113 113
114 // Set defaults if editing an existing connection 114 // Set defaults if editing an existing connection
115 if(!isnewaccount) { 115 if(!isnewaccount) {
116 connectname_l->setText(_pppdata->accname()); 116 connectname_l->setText(_pppdata->accname());
117 117
118 // insert the phone numbers into the listbox 118 // insert the phone numbers into the listbox
119 QString n = _pppdata->phonenumber(); 119 QString n = _pppdata->phonenumber();
120 QString tmp = ""; 120 QString tmp = "";
121 uint idx = 0; 121 uint idx = 0;
122 while(idx != n.length()) { 122 while(idx != n.length()) {
123 if(n[idx] == ':') { 123 if(n[idx] == ':') {
124 if(tmp.length() > 0) 124 if(tmp.length() > 0)
125 numbers->insertItem(tmp); 125 numbers->insertItem(tmp);
126 tmp = ""; 126 tmp = "";
127 } else 127 } else
128 tmp += n[idx]; 128 tmp += n[idx];
129 idx++; 129 idx++;
130 } 130 }
131 if(tmp.length() > 0) 131 if(tmp.length() > 0)
132 numbers->insertItem(tmp); 132 numbers->insertItem(tmp);
133 133
134 } 134 }
135 135
136 numbersChanged(); 136 numbersChanged();
137 tl->activate(); 137 tl->activate();
138} 138}
139 139
140bool DialWidget::save() { 140bool DialWidget::save() {
141 //first check to make sure that the account name is unique! 141 //first check to make sure that the account name is unique!
142 if(connectname_l->text().isEmpty() || 142 if(connectname_l->text().isEmpty() ||
143 !_pppdata->isUniqueAccname(connectname_l->text())) { 143 !_pppdata->isUniqueAccname(connectname_l->text())) {
144 return false; 144 return false;
145 } else { 145 } else {
146 _pppdata->setAccname(connectname_l->text()); 146 _pppdata->setAccname(connectname_l->text());
147 147
148 QString number = ""; 148 QString number = "";
149 for(uint i = 0; i < numbers->count(); i++) { 149 for(uint i = 0; i < numbers->count(); i++) {
150 if(i != 0) 150 if(i != 0)
151 number += ":"; 151 number += ":";
152 number += numbers->text(i); 152 number += numbers->text(i);
153 } 153 }
154 154
155 _pppdata->setPhonenumber(number); 155 _pppdata->setPhonenumber(number);
156 return true; 156 return true;
157 } 157 }
158} 158}
159 159
160 160
161void DialWidget::numbersChanged() { 161void DialWidget::numbersChanged() {
162 int sel = numbers->currentItem(); 162 int sel = numbers->currentItem();
163 163
164 del->setEnabled(sel != -1); 164 del->setEnabled(sel != -1);
165 up->setEnabled(sel != -1 && sel != 0); 165 up->setEnabled(sel != -1 && sel != 0);
166 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); 166 down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
167} 167}
168 168
169 169
170void DialWidget::selectionChanged(int) { 170void DialWidget::selectionChanged(int) {
171 numbersChanged(); 171 numbersChanged();
172} 172}
173 173
174 174
175void DialWidget::addNumber() { 175void DialWidget::addNumber() {
176 PhoneNumberDialog dlg(this); 176 PhoneNumberDialog dlg(this);
177 if(dlg.exec()) { 177 if(dlg.exec()) {
178 numbers->insertItem(dlg.phoneNumber()); 178 numbers->insertItem(dlg.phoneNumber());
179 numbersChanged(); 179 numbersChanged();
180 } 180 }
181} 181}
182 182
183 183
184void DialWidget::delNumber() { 184void DialWidget::delNumber() {
185 if(numbers->currentItem() != -1) { 185 if(numbers->currentItem() != -1) {
186 numbers->removeItem(numbers->currentItem()); 186 numbers->removeItem(numbers->currentItem());
187 numbersChanged(); 187 numbersChanged();
188 } 188 }
189} 189}
190 190
191 191
192void DialWidget::upNumber() { 192void DialWidget::upNumber() {
193 int idx = numbers->currentItem(); 193 int idx = numbers->currentItem();
194 if(idx != -1) { 194 if(idx != -1) {
195 QString item = numbers->text(idx); 195 QString item = numbers->text(idx);
196 numbers->removeItem(idx); 196 numbers->removeItem(idx);
197 numbers->insertItem(item, idx-1); 197 numbers->insertItem(item, idx-1);
198 numbers->setCurrentItem(idx-1); 198 numbers->setCurrentItem(idx-1);
199 numbersChanged(); 199 numbersChanged();
200 } 200 }
201} 201}
202 202
203 203
204void DialWidget::downNumber() { 204void DialWidget::downNumber() {
205 int idx = numbers->currentItem(); 205 int idx = numbers->currentItem();
206 if(idx != -1) { 206 if(idx != -1) {
207 QString item = numbers->text(idx); 207 QString item = numbers->text(idx);
208 numbers->removeItem(idx); 208 numbers->removeItem(idx);
209 numbers->insertItem(item, idx+1); 209 numbers->insertItem(item, idx+1);
210 numbers->setCurrentItem(idx+1); 210 numbers->setCurrentItem(idx+1);
211 numbersChanged(); 211 numbersChanged();
212 } 212 }
213} 213}
214 214
215 215
216void DialWidget::pppdargsbutton() { 216void DialWidget::pppdargsbutton() {
217 PPPdArguments pa(_pppdata, this); 217 PPPdArguments pa(_pppdata, this);
218 pa.showMaximized();
218 pa.exec(); 219 pa.exec();
219} 220}
220 221
221 222
222 223
223///////////////////////////////////////////////////////////////////////////// 224/////////////////////////////////////////////////////////////////////////////
224// ExecWidget 225// ExecWidget
225///////////////////////////////////////////////////////////////////////////// 226/////////////////////////////////////////////////////////////////////////////
226ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : 227ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) :
227 QWidget(parent, name), _pppdata(pd) 228 QWidget(parent, name), _pppdata(pd)
228{ 229{
229 QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); 230 QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
230 231
231 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); 232 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);
232 233
233 tl->addWidget(l); 234 tl->addWidget(l);
234 tl->addStretch(1); 235 tl->addStretch(1);
235 236
236 QGridLayout *l1 = new QGridLayout(4, 2, 10); 237 QGridLayout *l1 = new QGridLayout(4, 2, 10);
237 tl->addLayout(l1); 238 tl->addLayout(l1);
238 l1->setColStretch(0, 0); 239 l1->setColStretch(0, 0);
239 l1->setColStretch(1, 1); 240 l1->setColStretch(1, 1);
240 241
241 before_connect_l = new QLabel(tr("Before connect:"), this); 242 before_connect_l = new QLabel(tr("Before connect:"), this);
242 before_connect_l->setAlignment(AlignVCenter); 243 before_connect_l->setAlignment(AlignVCenter);
243 l1->addWidget(before_connect_l, 0, 0); 244 l1->addWidget(before_connect_l, 0, 0);
244 before_connect = new QLineEdit(this); 245 before_connect = new QLineEdit(this);
245// before_connect->setMaxLength(COMMAND_SIZE); 246// before_connect->setMaxLength(COMMAND_SIZE);
246 l1->addWidget(before_connect, 0, 1); 247 l1->addWidget(before_connect, 0, 1);
247 QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" 248 QString tmp = tr("Allows you to run a program <b>before</b> a connection\n"
248 "is established. It is called immediately before\n" 249 "is established. It is called immediately before\n"
249 "dialing has begun.\n\n" 250 "dialing has begun.\n\n"
250 "This might be useful, e.g. to stop HylaFAX blocking the\n" 251 "This might be useful, e.g. to stop HylaFAX blocking the\n"
251 "modem."); 252 "modem.");
252 253
253 QWhatsThis::add(before_connect_l,tmp); 254 QWhatsThis::add(before_connect_l,tmp);
254 QWhatsThis::add(before_connect,tmp); 255 QWhatsThis::add(before_connect,tmp);
255 256
256 command_label = new QLabel(tr("Upon connect:"), this); 257 command_label = new QLabel(tr("Upon connect:"), this);
257 command_label->setAlignment(AlignVCenter); 258 command_label->setAlignment(AlignVCenter);
258 l1->addWidget(command_label, 1, 0); 259 l1->addWidget(command_label, 1, 0);
259 command = new QLineEdit(this); 260 command = new QLineEdit(this);
260// command->setMaxLength(COMMAND_SIZE); 261// command->setMaxLength(COMMAND_SIZE);
261 l1->addWidget(command, 1, 1); 262 l1->addWidget(command, 1, 1);
262 tmp = tr("Allows you to run a program <b>after</b> a connection\n" 263 tmp = tr("Allows you to run a program <b>after</b> a connection\n"
263 "is established. When your program is called, all\n" 264 "is established. When your program is called, all\n"
264 "preparations for an Internet connection are finished.\n" 265 "preparations for an Internet connection are finished.\n"
265 "\n" 266 "\n"
266 "Very useful for fetching mail and news"); 267 "Very useful for fetching mail and news");
267 268
268 QWhatsThis::add(command_label,tmp); 269 QWhatsThis::add(command_label,tmp);
269 QWhatsThis::add(command,tmp); 270 QWhatsThis::add(command,tmp);
270 271
271 predisconnect_label = new QLabel(tr("Before disconnect:"), 272 predisconnect_label = new QLabel(tr("Before disconnect:"),
272 this); 273 this);
273 predisconnect_label->setAlignment(AlignVCenter); 274 predisconnect_label->setAlignment(AlignVCenter);
274 l1->addWidget(predisconnect_label, 2, 0); 275 l1->addWidget(predisconnect_label, 2, 0);
275 predisconnect = new QLineEdit(this); 276 predisconnect = new QLineEdit(this);
276// predisconnect->setMaxLength(COMMAND_SIZE); 277// predisconnect->setMaxLength(COMMAND_SIZE);
277 l1->addWidget(predisconnect, 2, 1); 278 l1->addWidget(predisconnect, 2, 1);
278 tmp = tr("Allows you to run a program <b>before</b> a connection\n" 279 tmp = tr("Allows you to run a program <b>before</b> a connection\n"
279 "is closed. The connection will stay open until\n" 280 "is closed. The connection will stay open until\n"
280 "the program exits."); 281 "the program exits.");
281 282
282 QWhatsThis::add(predisconnect_label,tmp); 283 QWhatsThis::add(predisconnect_label,tmp);
283 QWhatsThis::add(predisconnect,tmp); 284 QWhatsThis::add(predisconnect,tmp);
284 285
285 discommand_label = new QLabel(tr("Upon disconnect:"), 286 discommand_label = new QLabel(tr("Upon disconnect:"),
286 this); 287 this);
287 discommand_label->setAlignment(AlignVCenter); 288 discommand_label->setAlignment(AlignVCenter);
288 l1->addWidget(discommand_label, 3, 0); 289 l1->addWidget(discommand_label, 3, 0);
289 290
290 discommand = new QLineEdit(this); 291 discommand = new QLineEdit(this);
291// discommand->setMaxLength(COMMAND_SIZE); 292// discommand->setMaxLength(COMMAND_SIZE);
292 l1->addWidget(discommand, 3, 1); 293 l1->addWidget(discommand, 3, 1);
293 tmp = tr("Allows you to run a program <b>after</b> a connection\n" 294 tmp = tr("Allows you to run a program <b>after</b> a connection\n"
294 "has been closed."); 295 "has been closed.");
295 296
296 QWhatsThis::add(discommand_label,tmp); 297 QWhatsThis::add(discommand_label,tmp);
297 QWhatsThis::add(discommand,tmp); 298 QWhatsThis::add(discommand,tmp);
298 299
299 // extra space between entries 300 // extra space between entries
300 l1->addRowSpacing(1, 5); 301 l1->addRowSpacing(1, 5);
301 l1->addRowSpacing(3, 5); 302 l1->addRowSpacing(3, 5);
302 303
303 tl->addStretch(1); 304 tl->addStretch(1);
304 tl->activate(); 305 tl->activate();
305 306
306 // Set defaults if editing an existing connection 307 // Set defaults if editing an existing connection
307 if(!isnewaccount) { 308 if(!isnewaccount) {
308 before_connect->setText(_pppdata->command_before_connect()); 309 before_connect->setText(_pppdata->command_before_connect());
309 command->setText(_pppdata->command_on_connect()); 310 command->setText(_pppdata->command_on_connect());
310 discommand->setText(_pppdata->command_on_disconnect()); 311 discommand->setText(_pppdata->command_on_disconnect());
311 predisconnect->setText(_pppdata->command_before_disconnect()); 312 predisconnect->setText(_pppdata->command_before_disconnect());
312 } 313 }
313} 314}
314 315
315 316
316bool ExecWidget::save() { 317bool ExecWidget::save() {
317 _pppdata->setCommand_before_connect(before_connect->text()); 318 _pppdata->setCommand_before_connect(before_connect->text());
318 _pppdata->setCommand_on_connect(command->text()); 319 _pppdata->setCommand_on_connect(command->text());
319 _pppdata->setCommand_before_disconnect(predisconnect->text()); 320 _pppdata->setCommand_before_disconnect(predisconnect->text());
320 _pppdata->setCommand_on_disconnect(discommand->text()); 321 _pppdata->setCommand_on_disconnect(discommand->text());
321 return true; 322 return true;
322} 323}
323 324
324 325
325 326
326///////////////////////////////////////////////////////////////////////////// 327/////////////////////////////////////////////////////////////////////////////
327// 328//
328// IPWidget 329// IPWidget
329// 330//
330///////////////////////////////////////////////////////////////////////////// 331/////////////////////////////////////////////////////////////////////////////
331IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 332IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
332 : QWidget(parent, name), _pppdata(pd) 333 : QWidget(parent, name), _pppdata(pd)
333{ 334{
334 QVBoxLayout *topLayout = new QVBoxLayout(this); 335 QVBoxLayout *topLayout = new QVBoxLayout(this);
335 topLayout->setSpacing( 3 );//KDialog::spacingHint()); 336 topLayout->setSpacing( 3 );//KDialog::spacingHint());
336 337
337 box = new QVGroupBox(tr("Configuration"), this); 338 box = new QVGroupBox(tr("Configuration"), this);
338// box->setInsideSpacing( 1 );//KDialog::spacingHint()); 339// box->setInsideSpacing( 1 );//KDialog::spacingHint());
339 340
340 rb = new QButtonGroup(this); 341 rb = new QButtonGroup(this);
341 rb->hide(); 342 rb->hide();
342 connect(rb, SIGNAL(clicked(int)), 343 connect(rb, SIGNAL(clicked(int)),
343 SLOT(hitIPSelect(int))); 344 SLOT(hitIPSelect(int)));
344 345
345 dynamicadd_rb = new QRadioButton(box); 346 dynamicadd_rb = new QRadioButton(box);
346 dynamicadd_rb->setText(tr("Dynamic IP address")); 347 dynamicadd_rb->setText(tr("Dynamic IP address"));
347 QWhatsThis::add(dynamicadd_rb, 348 QWhatsThis::add(dynamicadd_rb,
348 tr("Select this option when your computer gets an\n" 349 tr("Select this option when your computer gets an\n"
349 "internet address (IP) every time a\n" 350 "internet address (IP) every time a\n"
350 "connection is made.\n" 351 "connection is made.\n"
351 "\n" 352 "\n"
352 "Almost every Internet Service Provider uses\n" 353 "Almost every Internet Service Provider uses\n"
353 "this method, so this should be turned on.")); 354 "this method, so this should be turned on."));
354 355
355 staticadd_rb = new QRadioButton(box); 356 staticadd_rb = new QRadioButton(box);
356 staticadd_rb->setText(tr("Static IP address")); 357 staticadd_rb->setText(tr("Static IP address"));
357 rb->insert(dynamicadd_rb, 0); 358 rb->insert(dynamicadd_rb, 0);
358 rb->insert(staticadd_rb, 1); 359 rb->insert(staticadd_rb, 1);
359 QWhatsThis::add(staticadd_rb, 360 QWhatsThis::add(staticadd_rb,
360 tr("Select this option when your computer has a\n" 361 tr("Select this option when your computer has a\n"
361 "fixed internet address (IP). Most computers\n" 362 "fixed internet address (IP). Most computers\n"
362 "don't have this, so you should probably select\n" 363 "don't have this, so you should probably select\n"
363 "dynamic IP addressing unless you know what you\n" 364 "dynamic IP addressing unless you know what you\n"
364 "are doing.")); 365 "are doing."));
365 366
366 QWidget *ipWidget = new QWidget(box); 367 QWidget *ipWidget = new QWidget(box);
367 QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); 368 QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
368 ipLayout->setSpacing( 2 );//KDialog::spacingHint()); 369 ipLayout->setSpacing( 2 );//KDialog::spacingHint());
369 370
370 ipaddress_label = new QLabel(tr("IP address:"), ipWidget); 371 ipaddress_label = new QLabel(tr("IP address:"), ipWidget);
371 QString tmp = tr("If your computer has a permanent internet\n" 372 QString tmp = tr("If your computer has a permanent internet\n"
372 "address, you must supply your IP address here."); 373 "address, you must supply your IP address here.");
373 ipLayout->addWidget(ipaddress_label, 0, 0); 374 ipLayout->addWidget(ipaddress_label, 0, 0);
374 375
375 ipaddress_l = new IPLineEdit(ipWidget); 376 ipaddress_l = new IPLineEdit(ipWidget);
376 ipLayout->addWidget(ipaddress_l, 0, 1); 377 ipLayout->addWidget(ipaddress_l, 0, 1);
377 378
378 QWhatsThis::add(ipaddress_label,tmp); 379 QWhatsThis::add(ipaddress_label,tmp);
379 QWhatsThis::add(ipaddress_l,tmp); 380 QWhatsThis::add(ipaddress_l,tmp);
380 381
381 sub_label = new QLabel(tr("Subnet mask:"), ipWidget); 382 sub_label = new QLabel(tr("Subnet mask:"), ipWidget);
382 tmp = tr("<p>If your computer has a static Internet address,\n" 383 tmp = tr("<p>If your computer has a static Internet address,\n"
383 "you must supply a network mask here. In almost\n" 384 "you must supply a network mask here. In almost\n"
384 "all cases this netmask will be <b>255.255.255.0</b>,\n" 385 "all cases this netmask will be <b>255.255.255.0</b>,\n"
385 "but your mileage may vary.\n" 386 "but your mileage may vary.\n"
386 "\n" 387 "\n"
387 "If unsure, contact your Internet Service Provider"); 388 "If unsure, contact your Internet Service Provider");
388 ipLayout->addWidget(sub_label, 1, 0); 389 ipLayout->addWidget(sub_label, 1, 0);
389 390
390 subnetmask_l = new IPLineEdit(ipWidget); 391 subnetmask_l = new IPLineEdit(ipWidget);
391 ipLayout->addWidget(subnetmask_l, 1, 1); 392 ipLayout->addWidget(subnetmask_l, 1, 1);
392 393
393 QWhatsThis::add(sub_label,tmp); 394 QWhatsThis::add(sub_label,tmp);
394 QWhatsThis::add(subnetmask_l,tmp); 395 QWhatsThis::add(subnetmask_l,tmp);
395 396
396 autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); 397 autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this);
397 autoname->setChecked(_pppdata->autoname()); 398 autoname->setChecked(_pppdata->autoname());
398 connect(autoname,SIGNAL(toggled(bool)), 399 connect(autoname,SIGNAL(toggled(bool)),
399 this,SLOT(autoname_t(bool))); 400 this,SLOT(autoname_t(bool)));
400 401
401 QWhatsThis::add(autoname, 402 QWhatsThis::add(autoname,
402 tr("<p>Whenever you connect, this reconfigures\n" 403 tr("<p>Whenever you connect, this reconfigures\n"
403 "your hostname to match the IP address you\n" 404 "your hostname to match the IP address you\n"
404 "got from the PPP server. This may be useful\n" 405 "got from the PPP server. This may be useful\n"
405 "if you need to use a protocol which depends\n" 406 "if you need to use a protocol which depends\n"
406 "on this information, but it can also cause several\n" 407 "on this information, but it can also cause several\n"
407 "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" 408 "<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
408 "\n" 409 "\n"
409 "Don't enable this unless you really need it.")); 410 "Don't enable this unless you really need it."));
410 411
411 topLayout->addWidget(box); 412 topLayout->addWidget(box);
412 topLayout->addWidget(autoname); 413 topLayout->addWidget(autoname);
413 topLayout->addStretch(); 414 topLayout->addStretch();
414 415
415 //load info from gpppdata 416 //load info from gpppdata
416 if(!isnewaccount) { 417 if(!isnewaccount) {
417 if(_pppdata->ipaddr() == "0.0.0.0" && 418 if(_pppdata->ipaddr() == "0.0.0.0" &&
418 _pppdata->subnetmask() == "0.0.0.0") { 419 _pppdata->subnetmask() == "0.0.0.0") {
419 dynamicadd_rb->setChecked(true); 420 dynamicadd_rb->setChecked(true);
420 hitIPSelect(0); 421 hitIPSelect(0);
421 autoname->setChecked(_pppdata->autoname()); 422 autoname->setChecked(_pppdata->autoname());
422 } 423 }
423 else { 424 else {
424 ipaddress_l->setText(_pppdata->ipaddr()); 425 ipaddress_l->setText(_pppdata->ipaddr());
425 subnetmask_l->setText(_pppdata->subnetmask()); 426 subnetmask_l->setText(_pppdata->subnetmask());
426 staticadd_rb->setChecked(true); 427 staticadd_rb->setChecked(true);
427 autoname->setChecked(false); 428 autoname->setChecked(false);
428 } 429 }
429 } 430 }
430 else { 431 else {
431 dynamicadd_rb->setChecked(true); 432 dynamicadd_rb->setChecked(true);
432 hitIPSelect(0); 433 hitIPSelect(0);
433 } 434 }
434 435
435} 436}
436 437
437void IPWidget::autoname_t(bool on) { 438void IPWidget::autoname_t(bool on) {
438 static bool was_warned = false; 439 static bool was_warned = false;
439 440
440 // big-fat warning when selecting the auto configure hostname option 441 // big-fat warning when selecting the auto configure hostname option
441 if(on && !was_warned) { 442 if(on && !was_warned) {
442 QMessageBox::information(this, 443 QMessageBox::information(this,
443 tr("Selecting this option might cause some weird " 444 tr("Selecting this option might cause some weird "
444 "problems with the X-server and applications " 445 "problems with the X-server and applications "
445 "while kppp is connected. Don't use it until " 446 "while kppp is connected. Don't use it until "
446 "you know what you are doing!\n" 447 "you know what you are doing!\n"
447 "For more information take a look at the " 448 "For more information take a look at the "
448 "handbook (or help) in the section \"Frequently " 449 "handbook (or help) in the section \"Frequently "
449 "asked questions\"."), 450 "asked questions\"."),
450 tr("Warning")); 451 tr("Warning"));
451 was_warned = true; 452 was_warned = true;
452 } 453 }
453} 454}
454 455
455 456
456void IPWidget::save() { 457void IPWidget::save() {
457 if(dynamicadd_rb->isChecked()) { 458 if(dynamicadd_rb->isChecked()) {
458 _pppdata->setIpaddr("0.0.0.0"); 459 _pppdata->setIpaddr("0.0.0.0");
459 _pppdata->setSubnetmask("0.0.0.0"); 460 _pppdata->setSubnetmask("0.0.0.0");
460 } else { 461 } else {
461 _pppdata->setIpaddr(ipaddress_l->text()); 462 _pppdata->setIpaddr(ipaddress_l->text());
462 _pppdata->setSubnetmask(subnetmask_l->text()); 463 _pppdata->setSubnetmask(subnetmask_l->text());
463 } 464 }
464 _pppdata->setAutoname(autoname->isChecked()); 465 _pppdata->setAutoname(autoname->isChecked());
465} 466}
466 467
467 468
468void IPWidget::hitIPSelect( int i ) { 469void IPWidget::hitIPSelect( int i ) {
469 if(i == 0) { 470 if(i == 0) {
470 ipaddress_label->setEnabled(false); 471 ipaddress_label->setEnabled(false);
471 sub_label->setEnabled(false); 472 sub_label->setEnabled(false);
472 ipaddress_l->setEnabled(false); 473 ipaddress_l->setEnabled(false);
473 subnetmask_l->setEnabled(false); 474 subnetmask_l->setEnabled(false);
474 } 475 }
475 else { 476 else {
476 ipaddress_label->setEnabled(true); 477 ipaddress_label->setEnabled(true);
477 sub_label->setEnabled(true); 478 sub_label->setEnabled(true);
478 ipaddress_l->setEnabled(true); 479 ipaddress_l->setEnabled(true);
479 subnetmask_l->setEnabled(true); 480 subnetmask_l->setEnabled(true);
480 } 481 }
481} 482}
482 483
483 484
484 485
485DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 486DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
486 : QWidget(parent, name), _pppdata(pd) 487 : QWidget(parent, name), _pppdata(pd)
487{ 488{
488 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); 489 QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );
489 490
490 dnsdomain_label = new QLabel(tr("Domain name:"), this); 491 dnsdomain_label = new QLabel(tr("Domain name:"), this);
491 tl->addWidget(dnsdomain_label, 0, 0); 492 tl->addWidget(dnsdomain_label, 0, 0);
492 493
493 dnsdomain = new QLineEdit(this); 494 dnsdomain = new QLineEdit(this);
494 495
495 tl->addWidget(dnsdomain, 0, 1); 496 tl->addWidget(dnsdomain, 0, 1);
496 QString tmp = tr("If you enter a domain name here, this domain\n" 497 QString tmp = tr("If you enter a domain name here, this domain\n"
497 "name is used for your computer while you are\n" 498 "name is used for your computer while you are\n"
498 "connected. When the connection is closed, the\n" 499 "connected. When the connection is closed, the\n"
499 "original domain name of your computer is\n" 500 "original domain name of your computer is\n"
500 "restored.\n" 501 "restored.\n"
501 "\n" 502 "\n"
502 "If you leave this field blank, no changes are\n" 503 "If you leave this field blank, no changes are\n"
503 "made to the domain name."); 504 "made to the domain name.");
504 505
505 QWhatsThis::add(dnsdomain_label,tmp); 506 QWhatsThis::add(dnsdomain_label,tmp);
506 QWhatsThis::add(dnsdomain,tmp); 507 QWhatsThis::add(dnsdomain,tmp);
507 508
508 conf_label = new QLabel(tr("Configuration:"), this); 509 conf_label = new QLabel(tr("Configuration:"), this);
509 tl->addWidget(conf_label, 1, 0); 510 tl->addWidget(conf_label, 1, 0);
510 511
511 bg = new QButtonGroup("Group", this); 512 bg = new QButtonGroup("Group", this);
512 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); 513 connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
513 bg->hide(); 514 bg->hide();
514 515
515 autodns = new QRadioButton(tr("Automatic"), this); 516 autodns = new QRadioButton(tr("Automatic"), this);
516 bg->insert(autodns, 0); 517 bg->insert(autodns, 0);
517 tl->addWidget(autodns, 1, 1); 518 tl->addWidget(autodns, 1, 1);
518 if(!_pppdata->pppdVersionMin(2, 3, 7)) 519 if(!_pppdata->pppdVersionMin(2, 3, 7))
519 autodns->setEnabled(false); 520 autodns->setEnabled(false);
520 521
521 mandns = new QRadioButton(tr("Manual"), this); 522 mandns = new QRadioButton(tr("Manual"), this);
522 bg->insert(mandns, 1); 523 bg->insert(mandns, 1);
523 tl->addWidget(mandns, 2, 1); 524 tl->addWidget(mandns, 2, 1);
524 525
525 dns_label = new QLabel(tr("DNS IP address:"), this); 526 dns_label = new QLabel(tr("DNS IP address:"), this);
526 tl->addWidget(dns_label, 3, 0); 527 tl->addWidget(dns_label, 3, 0);
527 528
528 QHBoxLayout *l2 = new QHBoxLayout; 529 QHBoxLayout *l2 = new QHBoxLayout;
529 tl->addLayout(l2, 3, 1); 530 tl->addLayout(l2, 3, 1);
530 dnsipaddr = new IPLineEdit(this); 531 dnsipaddr = new IPLineEdit(this);
531 connect(dnsipaddr, SIGNAL(returnPressed()), 532 connect(dnsipaddr, SIGNAL(returnPressed()),
532 SLOT(adddns())); 533 SLOT(adddns()));
533 connect(dnsipaddr, SIGNAL(textChanged(const QString &)), 534 connect(dnsipaddr, SIGNAL(textChanged(const QString &)),
534 SLOT(DNS_Edit_Changed(const QString &))); 535 SLOT(DNS_Edit_Changed(const QString &)));
535 l2->addWidget(dnsipaddr, 1); 536 l2->addWidget(dnsipaddr, 1);
536 l2->addStretch(1); 537 l2->addStretch(1);
537 tmp = tr("<p>Allows you to specify a new DNS server to be\n" 538 tmp = tr("<p>Allows you to specify a new DNS server to be\n"
538 "used while you are connected. When the\n" 539 "used while you are connected. When the\n"
539 "connection is closed, this DNS entry will be\n" 540 "connection is closed, this DNS entry will be\n"
540 "removed again.\n" 541 "removed again.\n"
541 "\n" 542 "\n"
542 "To add a DNS server, type in the IP address of\n" 543 "To add a DNS server, type in the IP address of\n"
543 "the DNS server here and click on <b>Add</b>"); 544 "the DNS server here and click on <b>Add</b>");
544 545
545 QWhatsThis::add(dns_label, tmp); 546 QWhatsThis::add(dns_label, tmp);
546 QWhatsThis::add(dnsipaddr, tmp); 547 QWhatsThis::add(dnsipaddr, tmp);
547 548
548 QHBoxLayout *l1 = new QHBoxLayout; 549 QHBoxLayout *l1 = new QHBoxLayout;
549 tl->addLayout(l1, 4, 1); 550 tl->addLayout(l1, 4, 1);
550 add = new QPushButton(tr("Add"), this); 551 add = new QPushButton(tr("Add"), this);
551 connect(add, SIGNAL(clicked()), SLOT(adddns())); 552 connect(add, SIGNAL(clicked()), SLOT(adddns()));
552 l1->addWidget(add); 553 l1->addWidget(add);
553// l1->addStretch(1); 554// l1->addStretch(1);
554 QWhatsThis::add(add, 555 QWhatsThis::add(add,
555 tr("Click this button to add the DNS server\n" 556 tr("Click this button to add the DNS server\n"
556 "specified in the field above. The entry\n" 557 "specified in the field above. The entry\n"
557 "will then be added to the list below")); 558 "will then be added to the list below"));
558 559
559 remove = new QPushButton(tr("Remove"), this); 560 remove = new QPushButton(tr("Remove"), this);
560 connect(remove, SIGNAL(clicked()), SLOT(removedns())); 561 connect(remove, SIGNAL(clicked()), SLOT(removedns()));
561 l1->addWidget(remove); 562 l1->addWidget(remove);
562 QWhatsThis::add(remove, 563 QWhatsThis::add(remove,
563 tr("Click this button to remove the selected DNS\n" 564 tr("Click this button to remove the selected DNS\n"
564 "server entry from the list below")); 565 "server entry from the list below"));
565 566
566 servers_label = new QLabel(tr("DNS address list:"), this); 567 servers_label = new QLabel(tr("DNS address list:"), this);
567 servers_label->setAlignment(AlignTop|AlignLeft); 568 servers_label->setAlignment(AlignTop|AlignLeft);
568 tl->addWidget(servers_label, 5, 0); 569 tl->addWidget(servers_label, 5, 0);
569 570
570 dnsservers = new QListBox(this); 571 dnsservers = new QListBox(this);
571 dnsservers->setMinimumSize(150, 80); 572 dnsservers->setMinimumSize(150, 80);
572 connect(dnsservers, SIGNAL(highlighted(int)), 573 connect(dnsservers, SIGNAL(highlighted(int)),
573 SLOT(DNS_Entry_Selected(int))); 574 SLOT(DNS_Entry_Selected(int)));
574 tl->addWidget(dnsservers, 5, 1); 575 tl->addWidget(dnsservers, 5, 1);
575 tmp = tr("<p>This shows all defined DNS servers to use\n" 576 tmp = tr("<p>This shows all defined DNS servers to use\n"
576 "while you are connected. Use the <b>Add</b> and\n" 577 "while you are connected. Use the <b>Add</b> and\n"
577 "<b>Remove</b> buttons to modify the list"); 578 "<b>Remove</b> buttons to modify the list");
578 579
579 QWhatsThis::add(servers_label,tmp); 580 QWhatsThis::add(servers_label,tmp);
580 QWhatsThis::add(dnsservers,tmp); 581 QWhatsThis::add(dnsservers,tmp);
581 582
582 exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); 583 exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this);
583 // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); 584 // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this);
584 exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); 585 exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
585 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); 586 tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
586 QWhatsThis::add(exdnsdisabled_toggle, 587 QWhatsThis::add(exdnsdisabled_toggle,
587 tr("<p>When this option is selected, all DNS\n" 588 tr("<p>When this option is selected, all DNS\n"
588 "servers specified in <tt>/etc/resolv.conf</tt> are\n" 589 "servers specified in <tt>/etc/resolv.conf</tt> are\n"
589 "temporary disabled while the dialup connection\n" 590 "temporary disabled while the dialup connection\n"
590 "is established. After the connection is\n" 591 "is established. After the connection is\n"
591 "closed, the servers will be re-enabled\n" 592 "closed, the servers will be re-enabled\n"
592 "\n" 593 "\n"
593 "Typically, there is no reason to use this\n" 594 "Typically, there is no reason to use this\n"
594 "option, but it may become useful under \n" 595 "option, but it may become useful under \n"
595 "some circumstances.")); 596 "some circumstances."));
596 597
597 598
598 // restore data if editing 599 // restore data if editing
599 if(!isnewaccount) { 600 if(!isnewaccount) {
600 dnsservers->insertStringList(_pppdata->dns()); 601 dnsservers->insertStringList(_pppdata->dns());
601 dnsdomain->setText(_pppdata->domain()); 602 dnsdomain->setText(_pppdata->domain());
602 } 603 }
603 604
604 int mode = _pppdata->autoDNS() ? 0 : 1; 605 int mode = _pppdata->autoDNS() ? 0 : 1;
605 bg->setButton(mode); 606 bg->setButton(mode);
606 DNS_Mode_Selected(mode); 607 DNS_Mode_Selected(mode);
607 608
608 tl->activate(); 609 tl->activate();
609} 610}
610 611
611void DNSWidget::DNS_Edit_Changed(const QString &text) { 612void DNSWidget::DNS_Edit_Changed(const QString &text) {
612 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); 613 QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
613 add->setEnabled(text.find(r) != -1); 614 add->setEnabled(text.find(r) != -1);
614} 615}
615 616
616void DNSWidget::DNS_Entry_Selected(int) { 617void DNSWidget::DNS_Entry_Selected(int) {
617 remove->setEnabled(true); 618 remove->setEnabled(true);
618} 619}
619 620
620void DNSWidget::DNS_Mode_Selected(int mode) { 621void DNSWidget::DNS_Mode_Selected(int mode) {
621 bool on = (mode == 1); 622 bool on = (mode == 1);
622 dns_label->setEnabled(on); 623 dns_label->setEnabled(on);
623 servers_label->setEnabled(on); 624 servers_label->setEnabled(on);
624 dnsipaddr->setText(""); 625 dnsipaddr->setText("");
625 dnsipaddr->setEnabled(on); 626 dnsipaddr->setEnabled(on);
626 add->setEnabled(false); 627 add->setEnabled(false);
627 remove->setEnabled(dnsservers->count()>0 && on); 628 remove->setEnabled(dnsservers->count()>0 && on);
628 dnsservers->clearSelection(); 629 dnsservers->clearSelection();
629 dnsservers->setEnabled(on); 630 dnsservers->setEnabled(on);
630 dnsservers->triggerUpdate(false); 631 dnsservers->triggerUpdate(false);
631} 632}
632 633
633void DNSWidget::save() { 634void DNSWidget::save() {
634 _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); 635 _pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
635 QStringList serverlist; 636 QStringList serverlist;
636 for(uint i=0; i < dnsservers->count(); i++) 637 for(uint i=0; i < dnsservers->count(); i++)
637 serverlist.append(dnsservers->text(i)); 638 serverlist.append(dnsservers->text(i));
638 _pppdata->setDns(serverlist); 639 _pppdata->setDns(serverlist);
639 640
640 // strip leading dot 641 // strip leading dot
641 QString s(dnsdomain->text()); 642 QString s(dnsdomain->text());
642 if(s.left(1) == ".") 643 if(s.left(1) == ".")
643 _pppdata->setDomain(s.mid(1)); 644 _pppdata->setDomain(s.mid(1));
644 else 645 else
645 _pppdata->setDomain(dnsdomain->text()); 646 _pppdata->setDomain(dnsdomain->text());
646 647
647 _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); 648 _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
648} 649}
649 650
650 651
651void DNSWidget::adddns() { 652void DNSWidget::adddns() {
652 if(dnsservers->count() < MAX_DNS_ENTRIES) { 653 if(dnsservers->count() < MAX_DNS_ENTRIES) {
653 dnsservers->insertItem(dnsipaddr->text()); 654 dnsservers->insertItem(dnsipaddr->text());
654 dnsipaddr->setText(""); 655 dnsipaddr->setText("");
655 } 656 }
656} 657}
657 658
658 659
659void DNSWidget::removedns() { 660void DNSWidget::removedns() {
660 int i; 661 int i;
661 i = dnsservers->currentItem(); 662 i = dnsservers->currentItem();
662 if(i != -1) 663 if(i != -1)
663 dnsservers->removeItem(i); 664 dnsservers->removeItem(i);
664 remove->setEnabled(dnsservers->count()>0); 665 remove->setEnabled(dnsservers->count()>0);
665} 666}
666 667
667 668
668// 669//
669// GatewayWidget 670// GatewayWidget
670// 671//
671GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 672GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
672 : QWidget(parent, name), _pppdata(pd) 673 : QWidget(parent, name), _pppdata(pd)
673{ 674{
674 QVBoxLayout *topLayout = new QVBoxLayout(this); 675 QVBoxLayout *topLayout = new QVBoxLayout(this);
675 topLayout->setSpacing( 2 ); 676 topLayout->setSpacing( 2 );
676 topLayout->setMargin( 0 ); 677 topLayout->setMargin( 0 );
677 678
678 box = new QVGroupBox(tr("Configuration"), this); 679 box = new QVGroupBox(tr("Configuration"), this);
679 680
680 rb = new QButtonGroup(this); 681 rb = new QButtonGroup(this);
681 rb->hide(); 682 rb->hide();
682 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); 683 connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
683 684
684 defaultgateway = new QRadioButton(box); 685 defaultgateway = new QRadioButton(box);
685 defaultgateway->setText(tr("Default gateway")); 686 defaultgateway->setText(tr("Default gateway"));
686 rb->insert(defaultgateway, 0); 687 rb->insert(defaultgateway, 0);
687 QWhatsThis::add(defaultgateway, 688 QWhatsThis::add(defaultgateway,
688 tr("This makes the PPP peer computer (the computer\n" 689 tr("This makes the PPP peer computer (the computer\n"
689 "you are connected to with your modem) to act as\n" 690 "you are connected to with your modem) to act as\n"
690 "a gateway. Your computer will send all packets not\n" 691 "a gateway. Your computer will send all packets not\n"
691 "going to a computer inside your local net to this\n" 692 "going to a computer inside your local net to this\n"
692 "computer, which will route these packets.\n" 693 "computer, which will route these packets.\n"
693 "\n" 694 "\n"
694 "This is the default for most ISPs, so you should\n" 695 "This is the default for most ISPs, so you should\n"
695 "probably leave this option on.")); 696 "probably leave this option on."));
696 697
697 698
698 staticgateway = new QRadioButton(box); 699 staticgateway = new QRadioButton(box);
699 staticgateway->setText(tr("Static gateway")); 700 staticgateway->setText(tr("Static gateway"));
700 rb->insert(staticgateway, 1); 701 rb->insert(staticgateway, 1);
701 QWhatsThis::add(staticgateway, 702 QWhatsThis::add(staticgateway,
702 tr("<p>Allows you to specify which computer you want\n" 703 tr("<p>Allows you to specify which computer you want\n"
703 "to use as gateway (see <i>Default Gateway</i> above)")); 704 "to use as gateway (see <i>Default Gateway</i> above)"));
704 705
705 QHBox *gateBox = new QHBox(box); 706 QHBox *gateBox = new QHBox(box);
706 gate_label = new QLabel(tr("Gateway IP address:"), gateBox); 707 gate_label = new QLabel(tr("Gateway IP address:"), gateBox);
707 gatewayaddr = new IPLineEdit(gateBox); 708 gatewayaddr = new IPLineEdit(gateBox);
708 709
709 defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), 710 defaultroute = new QCheckBox(tr("Assign the default route to this gateway"),
710 this); 711 this);
711 QWhatsThis::add(defaultroute, 712 QWhatsThis::add(defaultroute,
712 tr("If this option is enabled, all packets not\n" 713 tr("If this option is enabled, all packets not\n"
713 "going to the local net are routed through\n" 714 "going to the local net are routed through\n"
714 "the PPP connection.\n" 715 "the PPP connection.\n"
715 "\n" 716 "\n"
716 "Normally, you should turn this on")); 717 "Normally, you should turn this on"));
717 718
718 topLayout->addWidget(box); 719 topLayout->addWidget(box);
719 topLayout->addWidget(defaultroute); 720 topLayout->addWidget(defaultroute);
720 topLayout->addStretch(); 721 topLayout->addStretch();
721 722
722 //load info from gpppdata 723 //load info from gpppdata
723 if(!isnewaccount) { 724 if(!isnewaccount) {
724 if(_pppdata->gateway() == "0.0.0.0") { 725 if(_pppdata->gateway() == "0.0.0.0") {
725 defaultgateway->setChecked(true); 726 defaultgateway->setChecked(true);
726 hitGatewaySelect(0); 727 hitGatewaySelect(0);
727 } 728 }
728 else { 729 else {
729 gatewayaddr->setText(_pppdata->gateway()); 730 gatewayaddr->setText(_pppdata->gateway());
730 staticgateway->setChecked(true); 731 staticgateway->setChecked(true);
731 } 732 }
732 defaultroute->setChecked(_pppdata->defaultroute()); 733 defaultroute->setChecked(_pppdata->defaultroute());
733 } 734 }
734 else { 735 else {
735 defaultgateway->setChecked(true); 736 defaultgateway->setChecked(true);
736 hitGatewaySelect(0); 737 hitGatewaySelect(0);
737 defaultroute->setChecked(true); 738 defaultroute->setChecked(true);
738 } 739 }
739} 740}
740 741
741void GatewayWidget::save() { 742void GatewayWidget::save() {
742 _pppdata->setGateway(gatewayaddr->text()); 743 _pppdata->setGateway(gatewayaddr->text());
743 _pppdata->setDefaultroute(defaultroute->isChecked()); 744 _pppdata->setDefaultroute(defaultroute->isChecked());
744} 745}
745 746
746 747
747void GatewayWidget::hitGatewaySelect( int i ) { 748void GatewayWidget::hitGatewaySelect( int i ) {
748 if(i == 0) { 749 if(i == 0) {
749 gatewayaddr->setText("0.0.0.0"); 750 gatewayaddr->setText("0.0.0.0");
750 gatewayaddr->setEnabled(false); 751 gatewayaddr->setEnabled(false);
751 gate_label->setEnabled(false); 752 gate_label->setEnabled(false);
752 } 753 }
753 else { 754 else {
754 gatewayaddr->setEnabled(true); 755 gatewayaddr->setEnabled(true);
755 gatewayaddr->setText(""); 756 gatewayaddr->setText("");
756 gate_label->setEnabled(true); 757 gate_label->setEnabled(true);
757 } 758 }
758} 759}
759 760
760 761
761 762
762ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) 763ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
763 : QWidget(parent, name),_pppdata(pd) 764 : QWidget(parent, name),_pppdata(pd)
764{ 765{
765 766
766 QVBoxLayout *tl = new QVBoxLayout(this, 0 ); 767 QVBoxLayout *tl = new QVBoxLayout(this, 0 );
767 se = new ScriptEdit(this); 768 se = new ScriptEdit(this);
768 connect(se, SIGNAL(returnPressed()), SLOT(addButton())); 769 connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
769 tl->addWidget(se); 770 tl->addWidget(se);
770 771
771 // insert equal-sized buttons 772 // insert equal-sized buttons
772 QHBoxLayout *hl = new QHBoxLayout( this ); 773 QHBoxLayout *hl = new QHBoxLayout( this );
773 tl->addLayout( hl ); 774 tl->addLayout( hl );
774 add = new QPushButton( tr("Add"), this ); 775 add = new QPushButton( tr("Add"), this );
775 hl->addWidget( add ); 776 hl->addWidget( add );
776 connect(add, SIGNAL(clicked()), SLOT(addButton())); 777 connect(add, SIGNAL(clicked()), SLOT(addButton()));
777 insert = new QPushButton( tr("Insert"), this ); 778 insert = new QPushButton( tr("Insert"), this );
778 hl->addWidget( insert ); 779 hl->addWidget( insert );
779 connect(insert, SIGNAL(clicked()), SLOT(insertButton())); 780 connect(insert, SIGNAL(clicked()), SLOT(insertButton()));
780 remove = new QPushButton( tr("Remove"), this ); 781 remove = new QPushButton( tr("Remove"), this );
781 hl->addWidget( remove ); 782 hl->addWidget( remove );
782 connect(remove, SIGNAL(clicked()), SLOT(removeButton())); 783 connect(remove, SIGNAL(clicked()), SLOT(removeButton()));
783 784
784 QHBoxLayout *l12 = new QHBoxLayout(0); 785 QHBoxLayout *l12 = new QHBoxLayout(0);
785 tl->addLayout(l12); 786 tl->addLayout(l12);
786 stl = new QListBox(this); 787 stl = new QListBox(this);
787// stl->setVScrollBarMode( QScrollView::AlwaysOff ); 788// stl->setVScrollBarMode( QScrollView::AlwaysOff );
788 connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); 789 connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
789// stl->setMinimumSize(QSize(70, 140)); 790// stl->setMinimumSize(QSize(70, 140));
790 791
791 sl = new QListBox(this); 792 sl = new QListBox(this);
792// sl->setVScrollBarMode( QScrollView::AlwaysOff ); 793// sl->setVScrollBarMode( QScrollView::AlwaysOff );
793 connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); 794 connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int)));
794// sl->setMinimumSize(QSize(150, 140)); 795// sl->setMinimumSize(QSize(150, 140));
795 796
796 slb = new QScrollBar(this); 797 slb = new QScrollBar(this);
797// slb->setFixedWidth(slb->sizeHint().width()); 798// slb->setFixedWidth(slb->sizeHint().width());
798 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); 799 connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
799 800
800 l12->addWidget(stl, 1); 801 l12->addWidget(stl, 1);
801 l12->addWidget(sl, 3); 802 l12->addWidget(sl, 3);
802 l12->addWidget(slb, 0); 803 l12->addWidget(slb, 0);
803 804
804 //load data from gpppdata 805 //load data from gpppdata
805 if(!isnewaccount) { 806 if(!isnewaccount) {
806 QStringList &comlist = _pppdata->scriptType(); 807 QStringList &comlist = _pppdata->scriptType();
807 QStringList &arglist = _pppdata->script(); 808 QStringList &arglist = _pppdata->script();
808 QStringList::Iterator itcom = comlist.begin(); 809 QStringList::Iterator itcom = comlist.begin();
809 QStringList::Iterator itarg = arglist.begin(); 810 QStringList::Iterator itarg = arglist.begin();
810 811
811 for ( ; 812 for ( ;
812 itcom != comlist.end() && itarg != arglist.end(); 813 itcom != comlist.end() && itarg != arglist.end();
813 ++itcom, ++itarg ) 814 ++itcom, ++itarg )
814 { 815 {
815 stl->insertItem(*itcom); 816 stl->insertItem(*itcom);
816 sl->insertItem(*itarg); 817 sl->insertItem(*itarg);
817 } 818 }
818 } 819 }
819 820
820 insert->setEnabled(false); 821 insert->setEnabled(false);
821 remove->setEnabled(false); 822 remove->setEnabled(false);
822 adjustScrollBar(); 823 adjustScrollBar();
823 tl->activate(); 824 tl->activate();
824} 825}
825 826
826bool ScriptWidget::check() { 827bool ScriptWidget::check() {
827 uint lstart = 0; 828 uint lstart = 0;
828 uint lend = 0; 829 uint lend = 0;
829 uint errcnt = 0; 830 uint errcnt = 0;
830 831
831 if(sl->count() > 0) { 832 if(sl->count() > 0) {
832 for( uint i=0; i <= sl->count()-1; i++) { 833 for( uint i=0; i <= sl->count()-1; i++) {
833 if(stl->text(i) == "LoopStart") { 834 if(stl->text(i) == "LoopStart") {
834 lstart++; 835 lstart++;
835 } 836 }
836 if (stl->text(i) == "LoopEnd") { 837 if (stl->text(i) == "LoopEnd") {
837 lend++; 838 lend++;
838 } 839 }
839 if ( lend > lstart ) errcnt++; 840 if ( lend > lstart ) errcnt++;
840 } 841 }
841 return ( (errcnt == 0 ) && (lstart == lend) ); 842 return ( (errcnt == 0 ) && (lstart == lend) );
842 } 843 }
843 return true; 844 return true;
844} 845}
845 846
846 847
847void ScriptWidget::save() { 848void ScriptWidget::save() {
848 QStringList typelist, arglist; 849 QStringList typelist, arglist;
849 for(uint i=0; i < sl->count(); i++) { 850 for(uint i=0; i < sl->count(); i++) {
850 typelist.append(stl->text(i)); 851 typelist.append(stl->text(i));
851 arglist.append(sl->text(i)); 852 arglist.append(sl->text(i));
852 } 853 }
853 _pppdata->setScriptType(typelist); 854 _pppdata->setScriptType(typelist);
854 _pppdata->setScript(arglist); 855 _pppdata->setScript(arglist);
855} 856}
856 857
857 858
858 859
859void ScriptWidget::adjustScrollBar() { 860void ScriptWidget::adjustScrollBar() {
860 if((int)sl->count() <= sl->numItemsVisible()) 861 if((int)sl->count() <= sl->numItemsVisible())
861 slb->setRange(0, 0); 862 slb->setRange(0, 0);
862 else 863 else
863 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); 864 slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
864} 865}
865 866
866 867
867void ScriptWidget::scrolling(int i) { 868void ScriptWidget::scrolling(int i) {
868 sl->setTopItem(i); 869 sl->setTopItem(i);
869 stl->setTopItem(i); 870 stl->setTopItem(i);
870} 871}
871 872
872 873
873void ScriptWidget::slhighlighted(int i) { 874void ScriptWidget::slhighlighted(int i) {
874 insert->setEnabled(true); 875 insert->setEnabled(true);
875 remove->setEnabled(true); 876 remove->setEnabled(true);
876 stl->setCurrentItem(i); 877 stl->setCurrentItem(i);
877} 878}
878 879
879 880
880void ScriptWidget::stlhighlighted(int i) { 881void ScriptWidget::stlhighlighted(int i) {
881 insert->setEnabled(true); 882 insert->setEnabled(true);
882 remove->setEnabled(true); 883 remove->setEnabled(true);
883 sl->setCurrentItem(i); 884 sl->setCurrentItem(i);
884} 885}
885 886
886 887
887void ScriptWidget::addButton() { 888void ScriptWidget::addButton() {
888 //don't allow more than the maximum script entries 889 //don't allow more than the maximum script entries
889 if(sl->count() == MAX_SCRIPT_ENTRIES-1) 890 if(sl->count() == MAX_SCRIPT_ENTRIES-1)
890 return; 891 return;
891 892
892 switch(se->type()) { 893 switch(se->type()) {
893 case ScriptEdit::Expect: 894 case ScriptEdit::Expect:
894 stl->insertItem("Expect"); 895 stl->insertItem("Expect");
895 sl->insertItem(se->text()); 896 sl->insertItem(se->text());
896 break; 897 break;
897 898
898 case ScriptEdit::Send: 899 case ScriptEdit::Send:
899 stl->insertItem("Send"); 900 stl->insertItem("Send");
900 sl->insertItem(se->text()); 901 sl->insertItem(se->text());
901 break; 902 break;
902 903
903 case ScriptEdit::SendNoEcho: 904 case ScriptEdit::SendNoEcho:
904 stl->insertItem("SendNoEcho"); 905 stl->insertItem("SendNoEcho");
905 sl->insertItem(se->text()); 906 sl->insertItem(se->text());
906 break; 907 break;
907 908
908 case ScriptEdit::Pause: 909 case ScriptEdit::Pause:
909 stl->insertItem("Pause"); 910 stl->insertItem("Pause");
910 sl->insertItem(se->text()); 911 sl->insertItem(se->text());
911 break; 912 break;
912 913
913 case ScriptEdit::Hangup: 914 case ScriptEdit::Hangup:
914 stl->insertItem("Hangup"); 915 stl->insertItem("Hangup");
915 sl->insertItem(""); 916 sl->insertItem("");
916 break; 917 break;
917 918
918 case ScriptEdit::Answer: 919 case ScriptEdit::Answer:
919 stl->insertItem("Answer"); 920 stl->insertItem("Answer");
920 sl->insertItem(""); 921 sl->insertItem("");
921 break; 922 break;
922 923
923 case ScriptEdit::Timeout: 924 case ScriptEdit::Timeout:
924 stl->insertItem("Timeout"); 925 stl->insertItem("Timeout");
925 sl->insertItem(se->text()); 926 sl->insertItem(se->text());
926 break; 927 break;
927 928
928 case ScriptEdit::Password: 929 case ScriptEdit::Password:
929 stl->insertItem("Password"); 930 stl->insertItem("Password");
930 sl->insertItem(se->text()); 931 sl->insertItem(se->text());
931 break; 932 break;
932 933
933 case ScriptEdit::ID: 934 case ScriptEdit::ID:
934 stl->insertItem("ID"); 935 stl->insertItem("ID");
935 sl->insertItem(se->text()); 936 sl->insertItem(se->text());
936 break; 937 break;
937 938
938 case ScriptEdit::Prompt: 939 case ScriptEdit::Prompt:
939 stl->insertItem("Prompt"); 940 stl->insertItem("Prompt");
940 sl->insertItem(se->text()); 941 sl->insertItem(se->text());
941 break; 942 break;
942 943
943 case ScriptEdit::PWPrompt: 944 case ScriptEdit::PWPrompt:
944 stl->insertItem("PWPrompt"); 945 stl->insertItem("PWPrompt");
945 sl->insertItem(se->text()); 946 sl->insertItem(se->text());
946 break; 947 break;
947 948
948 case ScriptEdit::LoopStart: 949 case ScriptEdit::LoopStart:
949 stl->insertItem("LoopStart"); 950 stl->insertItem("LoopStart");
950 sl->insertItem(se->text()); 951 sl->insertItem(se->text());
951 break; 952 break;
952 953
953 case ScriptEdit::LoopEnd: 954 case ScriptEdit::LoopEnd:
954 stl->insertItem("LoopEnd"); 955 stl->insertItem("LoopEnd");
955 sl->insertItem(se->text()); 956 sl->insertItem(se->text());
956 break; 957 break;
957 958
958 case ScriptEdit::Scan: 959 case ScriptEdit::Scan:
959 stl->insertItem("Scan"); 960 stl->insertItem("Scan");
960 sl->insertItem(se->text()); 961 sl->insertItem(se->text());
961 break; 962 break;
962 963
963 case ScriptEdit::Save: 964 case ScriptEdit::Save:
964 stl->insertItem("Save"); 965 stl->insertItem("Save");
965 sl->insertItem(se->text()); 966 sl->insertItem(se->text());
966 break; 967 break;
967 968
968 default: 969 default:
969 break; 970 break;
970 } 971 }
971 972
972 //get the scrollbar adjusted, and scroll the list so we can see what 973 //get the scrollbar adjusted, and scroll the list so we can see what
973 //we're adding to 974 //we're adding to
974 adjustScrollBar(); 975 adjustScrollBar();
975 slb->setValue(slb->maxValue()); 976 slb->setValue(slb->maxValue());
976 977
977 //clear the text in the entry box 978 //clear the text in the entry box
978 se->setText(""); 979 se->setText("");
979} 980}
980 981
981 982
982void ScriptWidget::insertButton() { 983void ScriptWidget::insertButton() {
983 //exit if there is no highlighted item, or we've reached the 984 //exit if there is no highlighted item, or we've reached the
984 //maximum entries in the script list 985 //maximum entries in the script list
985 if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) 986 if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1))
986 return; 987 return;
987 988
988 switch(se->type()) { 989 switch(se->type()) {
989 case ScriptEdit::Expect: 990 case ScriptEdit::Expect:
990 stl->insertItem("Expect", stl->currentItem()); 991 stl->insertItem("Expect", stl->currentItem());
991 sl->insertItem(se->text(), sl->currentItem()); 992 sl->insertItem(se->text(), sl->currentItem());
992 break; 993 break;
993 994
994 case ScriptEdit::Send: 995 case ScriptEdit::Send:
995 stl->insertItem("Send", stl->currentItem()); 996 stl->insertItem("Send", stl->currentItem());
996 sl->insertItem(se->text(), sl->currentItem()); 997 sl->insertItem(se->text(), sl->currentItem());
997 break; 998 break;
998 999
999 case ScriptEdit::SendNoEcho: 1000 case ScriptEdit::SendNoEcho:
1000 stl->insertItem("SendNoEcho", stl->currentItem()); 1001 stl->insertItem("SendNoEcho", stl->currentItem());
1001 sl->insertItem(se->text(), sl->currentItem()); 1002 sl->insertItem(se->text(), sl->currentItem());
1002 break; 1003 break;
1003 1004
1004 case ScriptEdit::Pause: 1005 case ScriptEdit::Pause:
1005 stl->insertItem("Pause", stl->currentItem()); 1006 stl->insertItem("Pause", stl->currentItem());
1006 sl->insertItem(se->text(), sl->currentItem()); 1007 sl->insertItem(se->text(), sl->currentItem());
1007 break; 1008 break;
1008 1009
1009 case ScriptEdit::Hangup: 1010 case ScriptEdit::Hangup:
1010 stl->insertItem("Hangup", stl->currentItem()); 1011 stl->insertItem("Hangup", stl->currentItem());
1011 sl->insertItem("", sl->currentItem()); 1012 sl->insertItem("", sl->currentItem());
1012 break; 1013 break;
1013 1014
1014 case ScriptEdit::Answer: 1015 case ScriptEdit::Answer:
1015 stl->insertItem("Answer", stl->currentItem()); 1016 stl->insertItem("Answer", stl->currentItem());
1016 sl->insertItem("", sl->currentItem()); 1017 sl->insertItem("", sl->currentItem());
1017 break; 1018 break;
1018 1019
1019 case ScriptEdit::Timeout: 1020 case ScriptEdit::Timeout:
1020 stl->insertItem("Timeout", stl->currentItem()); 1021 stl->insertItem("Timeout", stl->currentItem());
1021 sl->insertItem(se->text(), sl->currentItem()); 1022 sl->insertItem(se->text(), sl->currentItem());
1022 break; 1023 break;
1023 1024
1024 case ScriptEdit::Password: 1025 case ScriptEdit::Password:
1025 stl->insertItem("Password", stl->currentItem()); 1026 stl->insertItem("Password", stl->currentItem());
1026 sl->insertItem(se->text(), sl->currentItem()); 1027 sl->insertItem(se->text(), sl->currentItem());
1027 break; 1028 break;
1028 1029
1029 case ScriptEdit::ID: 1030 case ScriptEdit::ID:
1030 stl->insertItem("ID", stl->currentItem()); 1031 stl->insertItem("ID", stl->currentItem());
1031 sl->insertItem(se->text(), sl->currentItem()); 1032 sl->insertItem(se->text(), sl->currentItem());
1032 break; 1033 break;
1033 1034
1034 case ScriptEdit::Prompt: 1035 case ScriptEdit::Prompt:
1035 stl->insertItem("Prompt", stl->currentItem()); 1036 stl->insertItem("Prompt", stl->currentItem());
1036 sl->insertItem(se->text(), sl->currentItem()); 1037 sl->insertItem(se->text(), sl->currentItem());
1037 break; 1038 break;
1038 1039
1039 case ScriptEdit::PWPrompt: 1040 case ScriptEdit::PWPrompt:
1040 stl->insertItem("PWPrompt", stl->currentItem()); 1041 stl->insertItem("PWPrompt", stl->currentItem());
1041 sl->insertItem(se->text(), sl->currentItem()); 1042 sl->insertItem(se->text(), sl->currentItem());
1042 break; 1043 break;
1043 1044
1044 case ScriptEdit::LoopStart: 1045 case ScriptEdit::LoopStart:
1045 stl->insertItem("LoopStart", stl->currentItem()); 1046 stl->insertItem("LoopStart", stl->currentItem());
1046 sl->insertItem(se->text(), sl->currentItem()); 1047 sl->insertItem(se->text(), sl->currentItem());
1047 break; 1048 break;
1048 1049
1049 case ScriptEdit::LoopEnd: 1050 case ScriptEdit::LoopEnd:
1050 stl->insertItem("LoopEnd", stl->currentItem()); 1051 stl->insertItem("LoopEnd", stl->currentItem());
1051 sl->insertItem(se->text(), sl->currentItem()); 1052 sl->insertItem(se->text(), sl->currentItem());
1052 break; 1053 break;
1053 1054
1054 case ScriptEdit::Scan: 1055 case ScriptEdit::Scan:
1055 stl->insertItem("Scan", stl->currentItem()); 1056 stl->insertItem("Scan", stl->currentItem());
1056 sl->insertItem(se->text(), sl->currentItem()); 1057 sl->insertItem(se->text(), sl->currentItem());
1057 break; 1058 break;
1058 1059
1059 case ScriptEdit::Save: 1060 case ScriptEdit::Save:
1060 stl->insertItem("Save", stl->currentItem()); 1061 stl->insertItem("Save", stl->currentItem());
1061 sl->insertItem(se->text(), sl->currentItem()); 1062 sl->insertItem(se->text(), sl->currentItem());
1062 break; 1063 break;
1063 1064
1064 default: 1065 default:
1065 break; 1066 break;
1066 } 1067 }
1067 adjustScrollBar(); 1068 adjustScrollBar();
1068 se->setText(""); 1069 se->setText("");
1069} 1070}
1070 1071
1071 1072
1072void ScriptWidget::removeButton() { 1073void ScriptWidget::removeButton() {
1073 if(sl->currentItem() >= 0) { 1074 if(sl->currentItem() >= 0) {
1074 int stlc = stl->currentItem(); 1075 int stlc = stl->currentItem();
1075 sl->removeItem(sl->currentItem()); 1076 sl->removeItem(sl->currentItem());
1076 stl->removeItem(stlc); 1077 stl->removeItem(stlc);
1077 adjustScrollBar(); 1078 adjustScrollBar();
1078 insert->setEnabled(sl->currentItem() != -1); 1079 insert->setEnabled(sl->currentItem() != -1);
1079 remove->setEnabled(sl->currentItem() != -1); 1080 remove->setEnabled(sl->currentItem() != -1);
1080 } 1081 }
1081} 1082}
1082 1083
1083 1084
1084 1085
1085///////////////////////////////////////////////////////////////////////////// 1086/////////////////////////////////////////////////////////////////////////////
1086// 1087//
1087// Used to specify a new phone number 1088// Used to specify a new phone number
1088// 1089//
1089///////////////////////////////////////////////////////////////////////////// 1090/////////////////////////////////////////////////////////////////////////////
1090PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) 1091PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
1091 : QDialog(parent,"PhoneNumberDialog",true) 1092 : QDialog(parent,"PhoneNumberDialog",true)
1092{ 1093{
1093 setCaption( tr("Add Phone Number") ); 1094 setCaption( tr("Add Phone Number") );
1094 1095
1095 1096
1096 QVBoxLayout *layout = new QVBoxLayout( this ); 1097 QVBoxLayout *layout = new QVBoxLayout( this );
1097 layout->setSpacing( 3 ); 1098 layout->setSpacing( 3 );
1098 layout->setMargin( 3 ); 1099 layout->setMargin( 3 );
1099 1100
1100// QHBox *hbox = new QHBox(this); 1101// QHBox *hbox = new QHBox(this);
1101// setMainWidget(hbox); 1102// setMainWidget(hbox);
1102 1103
1103// hbox->setSpacing( 2 );//KDialog::spacingHint()); 1104// hbox->setSpacing( 2 );//KDialog::spacingHint());
1104 1105
1105 QLabel *label = new QLabel(this, tr("Enter a phone number:")); 1106 QLabel *label = new QLabel(this, tr("Enter a phone number:"));
1106 layout->addWidget( label ); 1107 layout->addWidget( label );
1107 1108
1108 le = new QLineEdit(this, "lineEdit"); 1109 le = new QLineEdit(this, "lineEdit");
1109 layout->addWidget( le ); 1110 layout->addWidget( le );
1110 1111
1111 connect(le, SIGNAL(textChanged(const QString &)), 1112 connect(le, SIGNAL(textChanged(const QString &)),
1112 this, SLOT(textChanged(const QString &))); 1113 this, SLOT(textChanged(const QString &)));
1113 1114
1114 le->setFocus(); 1115 le->setFocus();
1115 textChanged(""); 1116 textChanged("");
1116 1117
1117 1118
1118} 1119}
1119 1120
1120 1121
1121QString PhoneNumberDialog::phoneNumber() { 1122QString PhoneNumberDialog::phoneNumber() {
1122 QString s = le->text(); 1123 QString s = le->text();
1123 1124
1124 return s; 1125 return s;
1125} 1126}
1126 1127
1127 1128
1128void PhoneNumberDialog::textChanged(const QString &s) { 1129void PhoneNumberDialog::textChanged(const QString &s) {
1129// enableButtonOK(s.length() > 0); 1130// enableButtonOK(s.length() > 0);
1130} 1131}
1131 1132
1132 1133
1133//#include "edit.moc" 1134//#include "edit.moc"