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