author | tille <tille> | 2003-05-23 19:43:46 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-23 19:43:46 (UTC) |
commit | 9b6b21112f38181f49b07e973bfe00c0d83a6900 (patch) (unidiff) | |
tree | c2fa45a93ac5c26fe98558f28bb0a166b14ad065 /noncore/settings/networksettings/ppp/modemcmds.cpp | |
parent | 34b9974063032242e5de65fa56d4c2cb5e1ce565 (diff) | |
download | opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.zip opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.tar.gz opie-9b6b21112f38181f49b07e973bfe00c0d83a6900.tar.bz2 |
configure dialog basicly working
more kppp stuff... ;)
Diffstat (limited to 'noncore/settings/networksettings/ppp/modemcmds.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/modemcmds.cpp | 321 |
1 files changed, 321 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp new file mode 100644 index 0000000..766ba0f --- a/dev/null +++ b/noncore/settings/networksettings/ppp/modemcmds.cpp | |||
@@ -0,0 +1,321 @@ | |||
1 | /* | ||
2 | * kPPP: A front end for pppd for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This library is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This library is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Library General Public | ||
23 | * License along with dummyWidget program; if not, write to the Free | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <qlayout.h> | ||
28 | #include <qslider.h> | ||
29 | #include <qbuttongroup.h> | ||
30 | #include <stdlib.h> | ||
31 | //#include <kapplication.h> // for getMiniIcon() | ||
32 | //#include <klocale.h> | ||
33 | #define i18n QObject::tr | ||
34 | #include "modemcmds.h" | ||
35 | #include "pppdata.h" | ||
36 | //#include <kwin.h> | ||
37 | |||
38 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); | ||
39 | |||
40 | // a little trick to make the label look like a disabled lineedit | ||
41 | #define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2); | ||
42 | |||
43 | ModemCommands::ModemCommands(QWidget *parent, const char *name) | ||
44 | : QDialog(parent, name, true ) //, i18n("Edit Modem Commands") , Ok|Cancel) | ||
45 | { | ||
46 | setCaption(i18n("Edit Modem Commands")); | ||
47 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | ||
48 | QWidget *dummyWidget = new QWidget(this); | ||
49 | // setMainWidget(dummyWidget); | ||
50 | |||
51 | const int GRIDROWS = 22; | ||
52 | int row = 0; | ||
53 | |||
54 | // toplevel layout | ||
55 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); | ||
56 | |||
57 | // add grid + frame | ||
58 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); | ||
59 | tl->addLayout(l1); | ||
60 | box = new QGroupBox(this, "box"); | ||
61 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); | ||
62 | |||
63 | // put slider and label into a separate H-Box | ||
64 | QHBoxLayout *l2 = new QHBoxLayout; | ||
65 | l1->addLayout(l2, row, 2); | ||
66 | lpreinitslider = new QLabel("MMMM", this); | ||
67 | FORMATSLIDERLABEL(lpreinitslider); | ||
68 | |||
69 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, | ||
70 | QSlider::Horizontal, this); | ||
71 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); | ||
72 | connect(preinitslider, SIGNAL(valueChanged(int)), | ||
73 | lpreinitslider, SLOT(setNum(int))); | ||
74 | l2->addWidget(lpreinitslider, 0); | ||
75 | l2->addWidget(preinitslider, 1); | ||
76 | |||
77 | lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this); | ||
78 | l1->addWidget(lpreinit, row++, 1); | ||
79 | |||
80 | for(int i = 0; i < PPPData::NumInitStrings; i++) { | ||
81 | initstr[i] = new QLineEdit(this); | ||
82 | QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1), | ||
83 | this); | ||
84 | ADJUSTEDIT(initstr[i]); | ||
85 | l1->addWidget(initLabel, row, 1); | ||
86 | l1->addWidget(initstr[i], row++, 2); | ||
87 | } | ||
88 | |||
89 | QHBoxLayout *l3 = new QHBoxLayout; | ||
90 | l1->addLayout(l3, row, 2); | ||
91 | linitslider = new QLabel("MMMM", this); | ||
92 | FORMATSLIDERLABEL(linitslider); | ||
93 | QSlider *initslider = new QSlider(1, 300, 1, 0, | ||
94 | QSlider::Horizontal, this); | ||
95 | // initslider->setFixedHeight(initslider->sizeHint().height()); | ||
96 | connect(initslider, SIGNAL(valueChanged(int)), | ||
97 | linitslider, SLOT(setNum(int))); | ||
98 | l3->addWidget(linitslider, 0); | ||
99 | l3->addWidget(initslider, 1); | ||
100 | |||
101 | label3 = new QLabel(i18n("Post-init delay (sec/100):"), this); | ||
102 | l1->addWidget(label3, row++, 1); | ||
103 | |||
104 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ | ||
105 | QHBoxLayout *l4 = new QHBoxLayout; | ||
106 | l1->addLayout(l4, row, 2); | ||
107 | ldurationslider = new QLabel("MMMM", this); | ||
108 | FORMATSLIDERLABEL(ldurationslider); | ||
109 | QSlider *durationslider = new QSlider(1, 255, 1, 0, | ||
110 | QSlider::Horizontal, this); | ||
111 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); | ||
112 | connect(durationslider, SIGNAL(valueChanged(int)), | ||
113 | ldurationslider, SLOT(setNum(int))); | ||
114 | l4->addWidget(ldurationslider, 0); | ||
115 | l4->addWidget(durationslider, 1); | ||
116 | |||
117 | lduration = new QLabel(i18n("Dialing speed (sec/100):"), this); | ||
118 | l1->addWidget(lduration, row++, 1); | ||
119 | |||
120 | |||
121 | initresp = new QLineEdit(this); | ||
122 | label2 = new QLabel(i18n("Init response:"), this); | ||
123 | ADJUSTEDIT(initresp); | ||
124 | l1->addWidget(label2, row, 1); | ||
125 | l1->addWidget(initresp, row++, 2); | ||
126 | |||
127 | nodetectdialtone = new QLineEdit(this); | ||
128 | lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this); | ||
129 | ADJUSTEDIT(nodetectdialtone); | ||
130 | l1->addWidget(lnodetectdialtone, row, 1); | ||
131 | l1->addWidget(nodetectdialtone, row++, 2); | ||
132 | |||
133 | dialstr = new QLineEdit(this); | ||
134 | label4 = new QLabel(i18n("Dial string:"),this); | ||
135 | ADJUSTEDIT(dialstr); | ||
136 | l1->addWidget(label4, row, 1); | ||
137 | l1->addWidget(dialstr, row++, 2); | ||
138 | |||
139 | connectresp = new QLineEdit(this); | ||
140 | label5 = new QLabel(i18n("Connect response:"), this); | ||
141 | ADJUSTEDIT(connectresp); | ||
142 | l1->addWidget(label5, row, 1); | ||
143 | l1->addWidget(connectresp, row++, 2); | ||
144 | |||
145 | busyresp = new QLineEdit(this); | ||
146 | label6 = new QLabel(i18n("Busy response:"), this); | ||
147 | ADJUSTEDIT(busyresp); | ||
148 | l1->addWidget(label6, row, 1); | ||
149 | l1->addWidget(busyresp, row++, 2); | ||
150 | |||
151 | nocarrierresp = new QLineEdit(this); | ||
152 | label7 = new QLabel(i18n("No carrier response:"), this); | ||
153 | ADJUSTEDIT(nocarrierresp); | ||
154 | l1->addWidget(label7, row, 1); | ||
155 | l1->addWidget(nocarrierresp, row++, 2); | ||
156 | |||
157 | nodialtoneresp = new QLineEdit(this); | ||
158 | label8 = new QLabel(i18n("No dial tone response:"), this); | ||
159 | ADJUSTEDIT(nodialtoneresp); | ||
160 | l1->addWidget(label8, row, 1); | ||
161 | l1->addWidget(nodialtoneresp, row++, 2); | ||
162 | |||
163 | hangupstr = new QLineEdit(this); | ||
164 | label9 = new QLabel(i18n("Hangup string:"), this); | ||
165 | ADJUSTEDIT(hangupstr); | ||
166 | l1->addWidget(label9, row, 1); | ||
167 | l1->addWidget(hangupstr, row++, 2); | ||
168 | |||
169 | hangupresp = new QLineEdit(this); | ||
170 | label10 = new QLabel(i18n("Hangup response:"), this); | ||
171 | ADJUSTEDIT(hangupresp); | ||
172 | l1->addWidget(label10, row, 1); | ||
173 | l1->addWidget(hangupresp, row++, 2); | ||
174 | |||
175 | answerstr = new QLineEdit(this); | ||
176 | label11 = new QLabel(i18n("Answer string:"), this); | ||
177 | ADJUSTEDIT(answerstr); | ||
178 | l1->addWidget(label11, row, 1); | ||
179 | l1->addWidget(answerstr, row++, 2); | ||
180 | |||
181 | ringresp = new QLineEdit(this); | ||
182 | label12 = new QLabel(i18n("Ring response:"), this); | ||
183 | ADJUSTEDIT(ringresp); | ||
184 | l1->addWidget(label12, row, 1); | ||
185 | l1->addWidget(ringresp, row++, 2); | ||
186 | |||
187 | answerresp = new QLineEdit(this); | ||
188 | label13 = new QLabel(i18n("Answer response:"), this); | ||
189 | ADJUSTEDIT(answerresp); | ||
190 | l1->addWidget(label13, row, 1); | ||
191 | l1->addWidget(answerresp, row++, 2); | ||
192 | |||
193 | escapestr = new QLineEdit(this); | ||
194 | label14 = new QLabel(i18n("Escape string:"), this); | ||
195 | ADJUSTEDIT(escapestr); | ||
196 | l1->addWidget(label14, row, 1); | ||
197 | l1->addWidget(escapestr, row++, 2); | ||
198 | |||
199 | escaperesp = new QLineEdit(this); | ||
200 | label15 = new QLabel(i18n("Escape response:"), this); | ||
201 | ADJUSTEDIT(escaperesp); | ||
202 | l1->addWidget(label15, row, 1); | ||
203 | l1->addWidget(escaperesp, row++, 2); | ||
204 | |||
205 | QHBoxLayout *l5 = new QHBoxLayout; | ||
206 | l1->addLayout(l5, row, 2); | ||
207 | lslider = new QLabel("MMMM", this); | ||
208 | FORMATSLIDERLABEL(lslider); | ||
209 | |||
210 | QSlider *slider = new QSlider(0, 255, 1, 0, | ||
211 | QSlider::Horizontal, this); | ||
212 | // slider->setFixedHeight(slider->sizeHint().height()); | ||
213 | connect(slider, SIGNAL(valueChanged(int)), | ||
214 | lslider, SLOT(setNum(int))); | ||
215 | l5->addWidget(lslider, 0); | ||
216 | l5->addWidget(slider, 1); | ||
217 | |||
218 | label16 = new QLabel(i18n("Guard time (sec/50):"), this); | ||
219 | l1->addWidget(label16, row++, 1); | ||
220 | |||
221 | QLabel *l = new QLabel(i18n("Volume off/low/high:"), this); | ||
222 | l1->addWidget(l, row, 1); | ||
223 | QHBoxLayout *l6 = new QHBoxLayout; | ||
224 | l1->addLayout(l6, row++, 2); | ||
225 | volume_off = new QLineEdit(this); | ||
226 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); | ||
227 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); | ||
228 | volume_medium = new QLineEdit(this); | ||
229 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); | ||
230 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); | ||
231 | volume_high = new QLineEdit(this); | ||
232 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); | ||
233 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); | ||
234 | l6->addWidget(volume_off); | ||
235 | l6->addWidget(volume_medium); | ||
236 | l6->addWidget(volume_high); | ||
237 | |||
238 | initstr[0]->setFocus(); | ||
239 | |||
240 | l1->addColSpacing(0, 10); | ||
241 | l1->addColSpacing(3, 10); | ||
242 | l1->addRowSpacing(0, 5); | ||
243 | l1->addRowSpacing(GRIDROWS, 5); | ||
244 | |||
245 | //set stuff from gpppdata | ||
246 | preinitslider->setValue(gpppdata.modemPreInitDelay()); | ||
247 | lpreinitslider->setNum(gpppdata.modemPreInitDelay()); | ||
248 | for(int i = 0; i < PPPData::NumInitStrings; i++) | ||
249 | initstr[i]->setText(gpppdata.modemInitStr(i)); | ||
250 | initslider->setValue(gpppdata.modemInitDelay()); | ||
251 | linitslider->setNum(gpppdata.modemInitDelay()); | ||
252 | initresp->setText(gpppdata.modemInitResp()); | ||
253 | |||
254 | durationslider->setValue(gpppdata.modemToneDuration()); | ||
255 | ldurationslider->setNum(gpppdata.modemToneDuration()); | ||
256 | |||
257 | nodetectdialtone->setText(gpppdata.modemNoDialToneDetectionStr()); | ||
258 | dialstr->setText(gpppdata.modemDialStr()); | ||
259 | connectresp->setText(gpppdata.modemConnectResp()); | ||
260 | busyresp->setText(gpppdata.modemBusyResp()); | ||
261 | nocarrierresp->setText(gpppdata.modemNoCarrierResp()); | ||
262 | nodialtoneresp->setText(gpppdata.modemNoDialtoneResp()); | ||
263 | |||
264 | escapestr->setText(gpppdata.modemEscapeStr()); | ||
265 | escaperesp->setText(gpppdata.modemEscapeResp()); | ||
266 | |||
267 | hangupstr->setText(gpppdata.modemHangupStr()); | ||
268 | hangupresp->setText(gpppdata.modemHangupResp()); | ||
269 | |||
270 | answerstr->setText(gpppdata.modemAnswerStr()); | ||
271 | ringresp->setText(gpppdata.modemRingResp()); | ||
272 | answerresp->setText(gpppdata.modemAnswerResp()); | ||
273 | |||
274 | slider->setValue(gpppdata.modemEscapeGuardTime()); | ||
275 | lslider->setNum(gpppdata.modemEscapeGuardTime()); | ||
276 | |||
277 | volume_off->setText(gpppdata.volumeOff()); | ||
278 | volume_medium->setText(gpppdata.volumeMedium()); | ||
279 | volume_high->setText(gpppdata.volumeHigh()); | ||
280 | } | ||
281 | |||
282 | |||
283 | void ModemCommands::slotOk() { | ||
284 | gpppdata.setModemPreInitDelay(lpreinitslider->text().toInt()); | ||
285 | for(int i = 0; i < PPPData::NumInitStrings; i++) | ||
286 | gpppdata.setModemInitStr(i, initstr[i]->text()); | ||
287 | gpppdata.setModemInitResp(initresp->text()); | ||
288 | gpppdata.setModemInitDelay(linitslider->text().toInt()); | ||
289 | |||
290 | gpppdata.setModemToneDuration(ldurationslider->text().toInt()); | ||
291 | gpppdata.setModemNoDialToneDetectionStr(nodetectdialtone->text()); | ||
292 | gpppdata.setModemDialStr(dialstr->text()); | ||
293 | gpppdata.setModemConnectResp(connectresp->text()); | ||
294 | gpppdata.setModemBusyResp(busyresp->text()); | ||
295 | gpppdata.setModemNoCarrierResp(nocarrierresp->text()); | ||
296 | gpppdata.setModemNoDialtoneResp(nodialtoneresp->text()); | ||
297 | |||
298 | gpppdata.setModemEscapeStr(escapestr->text()); | ||
299 | gpppdata.setModemEscapeResp(escaperesp->text()); | ||
300 | gpppdata.setModemEscapeGuardTime(lslider->text().toInt()); | ||
301 | gpppdata.setModemHangupStr(hangupstr->text()); | ||
302 | gpppdata.setModemHangupResp(hangupresp->text()); | ||
303 | |||
304 | gpppdata.setModemAnswerStr(answerstr->text()); | ||
305 | gpppdata.setModemRingResp(ringresp->text()); | ||
306 | gpppdata.setModemAnswerResp(answerresp->text()); | ||
307 | |||
308 | gpppdata.setVolumeHigh(volume_high->text()); | ||
309 | gpppdata.setVolumeMedium(volume_medium->text()); | ||
310 | gpppdata.setVolumeOff(volume_off->text()); | ||
311 | |||
312 | gpppdata.save(); | ||
313 | accept(); | ||
314 | } | ||
315 | |||
316 | |||
317 | void ModemCommands::slotCancel() { | ||
318 | reject(); | ||
319 | } | ||
320 | |||
321 | //#include "modemcmds.moc" | ||