2 * kPPP: A front end for pppd for the KDE project
6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
10 * Copyright (C) 1997 Jay Painter
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <QVBoxLayout>
31 #include <QHBoxLayout>
32 #include <QGridLayout>
34 #include <kapplication.h> // for getMiniIcon()
36 #include "modemcmds.h"
40 #include <q3groupbox.h>
41 #include <qlineedit.h>
42 #include <qpushbutton.h>
44 #include <kiconloader.h>
47 #define ADJUSTEDIT(e) e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); e->setFixedHeight(e->sizeHint().height()); e->setText(""); e->setMaxLength(MODEMSTR_SIZE);
49 // a little trick to make the label look like a disabled lineedit
50 #define FORMATSLIDERLABEL(l) l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(Qt::AlignCenter); l->setFrameStyle(Q3Frame::WinPanel|Q3Frame::Sunken); l->setLineWidth(2);
52 ModemCommands::ModemCommands(QWidget
*parent
, const char *name
)
56 setCaption( i18n("Edit Modem Commands") );
57 setButtons( Ok
|Cancel
);
58 setDefaultButton( Ok
);
60 KWin::setIcons(winId(), qApp
->windowIcon().pixmap(IconSize(K3Icon::Desktop
),IconSize(K3Icon::Desktop
)), qApp
->windowIcon().pixmap(IconSize(K3Icon::Small
),IconSize(K3Icon::Small
)));
61 QWidget
*dummyWidget
= new QWidget(this);
62 setMainWidget(dummyWidget
);
64 const int GRIDROWS
= 22;
68 QVBoxLayout
*tl
= new QVBoxLayout(dummyWidget
);
73 QGridLayout
*l1
= new QGridLayout();
75 box
= new Q3GroupBox(dummyWidget
, "box");
76 l1
->addMultiCellWidget(box
, row
++, GRIDROWS
, 0, 3);
78 // put slider and label into a separate H-Box
79 QHBoxLayout
*l2
= new QHBoxLayout
;
80 l1
->addLayout(l2
, row
, 2);
81 lpreinitslider
= new QLabel("MMMM", dummyWidget
);
82 FORMATSLIDERLABEL(lpreinitslider
);
84 preinitslider
= new QSlider(Qt::Horizontal
, dummyWidget
);
85 preinitslider
->setMinimum(0);
86 preinitslider
->setMaximum(300);
87 preinitslider
->setPageStep(1);
88 preinitslider
->setValue(0);
90 preinitslider
->setFixedHeight(preinitslider
->sizeHint().height());
91 connect(preinitslider
, SIGNAL(valueChanged(int)),
92 lpreinitslider
, SLOT(setNum(int)));
93 l2
->addWidget(lpreinitslider
, 0);
94 l2
->addWidget(preinitslider
, 1);
96 lpreinit
= new QLabel(i18n("Pre-init delay (sec/100):"), dummyWidget
);
97 l1
->addWidget(lpreinit
, row
++, 1);
99 for(int i
= 0; i
< PPPData::NumInitStrings
; i
++) {
100 initstr
[i
] = new QLineEdit(dummyWidget
);
101 QLabel
*initLabel
= new QLabel(i18n("Initialization string %1:", i
+ 1),
103 ADJUSTEDIT(initstr
[i
]);
104 l1
->addWidget(initLabel
, row
, 1);
105 l1
->addWidget(initstr
[i
], row
++, 2);
108 QHBoxLayout
*l3
= new QHBoxLayout
;
109 l1
->addLayout(l3
, row
, 2);
110 linitslider
= new QLabel("MMMM", dummyWidget
);
111 FORMATSLIDERLABEL(linitslider
);
112 initslider
= new QSlider(Qt::Horizontal
, dummyWidget
);
113 initslider
->setMinimum(1);
114 initslider
->setMaximum(300);
115 initslider
->setPageStep(1);
116 initslider
->setValue(1); // was zero before the Qt4 port.
118 initslider
->setFixedHeight(initslider
->sizeHint().height());
119 connect(initslider
, SIGNAL(valueChanged(int)),
120 linitslider
, SLOT(setNum(int)));
121 l3
->addWidget(linitslider
, 0);
122 l3
->addWidget(initslider
, 1);
124 label3
= new QLabel(i18n("Post-init delay (sec/100):"), dummyWidget
);
125 l1
->addWidget(label3
, row
++, 1);
127 /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */
128 QHBoxLayout
*l4
= new QHBoxLayout
;
129 l1
->addLayout(l4
, row
, 2);
130 ldurationslider
= new QLabel("MMMM", dummyWidget
);
131 FORMATSLIDERLABEL(ldurationslider
);
132 durationslider
= new QSlider(Qt::Horizontal
, dummyWidget
);
133 durationslider
->setMinimum(1);
134 durationslider
->setMaximum(255);
135 durationslider
->setPageStep(1);
136 durationslider
->setValue(1); // was 0 before the Qt4 port
138 durationslider
->setFixedHeight(durationslider
->sizeHint().height());
139 connect(durationslider
, SIGNAL(valueChanged(int)),
140 ldurationslider
, SLOT(setNum(int)));
141 l4
->addWidget(ldurationslider
, 0);
142 l4
->addWidget(durationslider
, 1);
144 lduration
= new QLabel(i18n("Dialing speed (sec/100):"), dummyWidget
);
145 l1
->addWidget(lduration
, row
++, 1);
148 initresp
= new QLineEdit(dummyWidget
);
149 label2
= new QLabel(i18n("Init &response:"), dummyWidget
);
150 label2
->setBuddy(initresp
);
151 ADJUSTEDIT(initresp
);
152 l1
->addWidget(label2
, row
, 1);
153 l1
->addWidget(initresp
, row
++, 2);
155 nodetectdialtone
= new QLineEdit(dummyWidget
);
156 lnodetectdialtone
= new QLabel(i18n("No di&al tone detection:"), dummyWidget
);
157 lnodetectdialtone
->setBuddy(nodetectdialtone
);
158 ADJUSTEDIT(nodetectdialtone
);
159 l1
->addWidget(lnodetectdialtone
, row
, 1);
160 l1
->addWidget(nodetectdialtone
, row
++, 2);
162 dialstr
= new QLineEdit(dummyWidget
);
163 label4
= new QLabel(i18n("Dial &string:"),dummyWidget
);
164 label4
->setBuddy(dialstr
);
166 l1
->addWidget(label4
, row
, 1);
167 l1
->addWidget(dialstr
, row
++, 2);
169 connectresp
= new QLineEdit(dummyWidget
);
170 label5
= new QLabel(i18n("Co&nnect response:"), dummyWidget
);
171 label5
->setBuddy(connectresp
);
172 ADJUSTEDIT(connectresp
);
173 l1
->addWidget(label5
, row
, 1);
174 l1
->addWidget(connectresp
, row
++, 2);
176 busyresp
= new QLineEdit(dummyWidget
);
177 label6
= new QLabel(i18n("Busy response:"), dummyWidget
);
178 ADJUSTEDIT(busyresp
);
179 l1
->addWidget(label6
, row
, 1);
180 l1
->addWidget(busyresp
, row
++, 2);
182 nocarrierresp
= new QLineEdit(dummyWidget
);
183 label7
= new QLabel(i18n("No carr&ier response:"), dummyWidget
);
184 label7
->setBuddy(nocarrierresp
);
185 ADJUSTEDIT(nocarrierresp
);
186 l1
->addWidget(label7
, row
, 1);
187 l1
->addWidget(nocarrierresp
, row
++, 2);
189 nodialtoneresp
= new QLineEdit(dummyWidget
);
190 label8
= new QLabel(i18n("No dial tone response:"), dummyWidget
);
191 ADJUSTEDIT(nodialtoneresp
);
192 l1
->addWidget(label8
, row
, 1);
193 l1
->addWidget(nodialtoneresp
, row
++, 2);
195 hangupstr
= new QLineEdit(dummyWidget
);
196 label9
= new QLabel(i18n("&Hangup string:"), dummyWidget
);
197 label9
->setBuddy(hangupstr
);
198 ADJUSTEDIT(hangupstr
);
199 l1
->addWidget(label9
, row
, 1);
200 l1
->addWidget(hangupstr
, row
++, 2);
202 hangupresp
= new QLineEdit(dummyWidget
);
203 label10
= new QLabel(i18n("Hangup response:"), dummyWidget
);
204 ADJUSTEDIT(hangupresp
);
205 l1
->addWidget(label10
, row
, 1);
206 l1
->addWidget(hangupresp
, row
++, 2);
208 answerstr
= new QLineEdit(dummyWidget
);
209 label11
= new QLabel(i18n("Answ&er string:"), dummyWidget
);
210 label11
->setBuddy(answerstr
);
211 ADJUSTEDIT(answerstr
);
212 l1
->addWidget(label11
, row
, 1);
213 l1
->addWidget(answerstr
, row
++, 2);
215 ringresp
= new QLineEdit(dummyWidget
);
216 label12
= new QLabel(i18n("Ring response:"), dummyWidget
);
217 ADJUSTEDIT(ringresp
);
218 l1
->addWidget(label12
, row
, 1);
219 l1
->addWidget(ringresp
, row
++, 2);
221 answerresp
= new QLineEdit(dummyWidget
);
222 label13
= new QLabel(i18n("Ans&wer response:"), dummyWidget
);
223 label13
->setBuddy(answerresp
);
224 ADJUSTEDIT(answerresp
);
225 l1
->addWidget(label13
, row
, 1);
226 l1
->addWidget(answerresp
, row
++, 2);
228 dlpresp
= new QLineEdit(dummyWidget
);
229 label17
= new QLabel(i18n("DLP response:"), dummyWidget
);
231 l1
->addWidget(label17
, row
, 1);
232 l1
->addWidget(dlpresp
, row
++, 2);
234 escapestr
= new QLineEdit(dummyWidget
);
235 label14
= new QLabel(i18n("Escape strin&g:"), dummyWidget
);
236 label14
->setBuddy(escapestr
);
237 ADJUSTEDIT(escapestr
);
238 l1
->addWidget(label14
, row
, 1);
239 l1
->addWidget(escapestr
, row
++, 2);
241 escaperesp
= new QLineEdit(dummyWidget
);
242 label15
= new QLabel(i18n("Escape response:"), dummyWidget
);
243 ADJUSTEDIT(escaperesp
);
244 l1
->addWidget(label15
, row
, 1);
245 l1
->addWidget(escaperesp
, row
++, 2);
247 QHBoxLayout
*l5
= new QHBoxLayout
;
248 l1
->addLayout(l5
, row
, 2);
249 lslider
= new QLabel("MMMM", dummyWidget
);
250 FORMATSLIDERLABEL(lslider
);
252 slider
= new QSlider(Qt::Horizontal
, dummyWidget
);
253 slider
->setMinimum(0);
254 slider
->setMaximum(255);
255 slider
->setPageStep(1);
258 slider
->setFixedHeight(slider
->sizeHint().height());
259 connect(slider
, SIGNAL(valueChanged(int)),
260 lslider
, SLOT(setNum(int)));
261 l5
->addWidget(lslider
, 0);
262 l5
->addWidget(slider
, 1);
264 label16
= new QLabel(i18n("Guard time (sec/50):"), dummyWidget
);
265 l1
->addWidget(label16
, row
++, 1);
267 QLabel
*l
= new QLabel(i18n("Volume off/low/high:"), dummyWidget
);
268 l1
->addWidget(l
, row
, 1);
269 QHBoxLayout
*l6
= new QHBoxLayout
;
270 l1
->addLayout(l6
, row
++, 2);
271 volume_off
= new QLineEdit(dummyWidget
);
272 volume_off
->setFixedHeight(volume_off
->sizeHint().height());
273 volume_off
->setMinimumWidth((int)(volume_off
->sizeHint().width() / 2));
274 volume_medium
= new QLineEdit(dummyWidget
);
275 volume_medium
->setFixedHeight(volume_medium
->sizeHint().height());
276 volume_medium
->setMinimumWidth((int)(volume_medium
->sizeHint().width() / 2));
277 volume_high
= new QLineEdit(dummyWidget
);
278 volume_high
->setFixedHeight(volume_high
->sizeHint().height());
279 volume_high
->setMinimumWidth((int)(volume_high
->sizeHint().width() / 2));
280 l6
->addWidget(volume_off
);
281 l6
->addWidget(volume_medium
);
282 l6
->addWidget(volume_high
);
284 initstr
[0]->setFocus();
286 l1
->addItem(new QSpacerItem(10,0), 0, 0);
287 l1
->addItem(new QSpacerItem(10,0), 0, 3);
288 l1
->addItem(new QSpacerItem(0, 5), 0, 0);
289 l1
->addItem(new QSpacerItem(0, 5), GRIDROWS
, 0);
291 //set stuff from gpppdata
292 preinitslider
->setValue(gpppdata
.modemPreInitDelay());
293 lpreinitslider
->setNum(gpppdata
.modemPreInitDelay());
294 for(int i
= 0; i
< PPPData::NumInitStrings
; i
++)
295 initstr
[i
]->setText(gpppdata
.modemInitStr(i
));
296 initslider
->setValue(gpppdata
.modemInitDelay());
297 linitslider
->setNum(gpppdata
.modemInitDelay());
298 initresp
->setText(gpppdata
.modemInitResp());
300 durationslider
->setValue(gpppdata
.modemToneDuration());
301 ldurationslider
->setNum(gpppdata
.modemToneDuration());
303 nodetectdialtone
->setText(gpppdata
.modemNoDialToneDetectionStr());
304 dialstr
->setText(gpppdata
.modemDialStr());
305 dlpresp
->setText(gpppdata
.modemDLPResp());
307 connectresp
->setText(gpppdata
.modemConnectResp());
308 busyresp
->setText(gpppdata
.modemBusyResp());
309 nocarrierresp
->setText(gpppdata
.modemNoCarrierResp());
310 nodialtoneresp
->setText(gpppdata
.modemNoDialtoneResp());
312 escapestr
->setText(gpppdata
.modemEscapeStr());
313 escaperesp
->setText(gpppdata
.modemEscapeResp());
315 hangupstr
->setText(gpppdata
.modemHangupStr());
316 hangupresp
->setText(gpppdata
.modemHangupResp());
318 answerstr
->setText(gpppdata
.modemAnswerStr());
319 ringresp
->setText(gpppdata
.modemRingResp());
320 answerresp
->setText(gpppdata
.modemAnswerResp());
322 slider
->setValue(gpppdata
.modemEscapeGuardTime());
323 lslider
->setNum(gpppdata
.modemEscapeGuardTime());
325 volume_off
->setText(gpppdata
.volumeOff());
326 volume_medium
->setText(gpppdata
.volumeMedium());
327 volume_high
->setText(gpppdata
.volumeHigh());
329 // Save the data, so if it not exist we save the default
331 connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
332 connect(this,SIGNAL(cancelClicked()),this,SLOT(slotCancel()));
336 void ModemCommands::slotOk() {
337 gpppdata
.setModemPreInitDelay(lpreinitslider
->text().toInt());
338 for(int i
= 0; i
< PPPData::NumInitStrings
; i
++)
339 gpppdata
.setModemInitStr(i
, initstr
[i
]->text());
340 gpppdata
.setModemInitResp(initresp
->text());
341 gpppdata
.setModemInitDelay(linitslider
->text().toInt());
343 gpppdata
.setModemToneDuration(ldurationslider
->text().toInt());
344 gpppdata
.setModemNoDialToneDetectionStr(nodetectdialtone
->text());
345 gpppdata
.setModemDialStr(dialstr
->text());
346 gpppdata
.setModemDLPResp(dlpresp
->text());
348 gpppdata
.setModemConnectResp(connectresp
->text());
349 gpppdata
.setModemBusyResp(busyresp
->text());
350 gpppdata
.setModemNoCarrierResp(nocarrierresp
->text());
351 gpppdata
.setModemNoDialtoneResp(nodialtoneresp
->text());
353 gpppdata
.setModemEscapeStr(escapestr
->text());
354 gpppdata
.setModemEscapeResp(escaperesp
->text());
355 gpppdata
.setModemEscapeGuardTime(lslider
->text().toInt());
356 gpppdata
.setModemHangupStr(hangupstr
->text());
357 gpppdata
.setModemHangupResp(hangupresp
->text());
359 gpppdata
.setModemAnswerStr(answerstr
->text());
360 gpppdata
.setModemRingResp(ringresp
->text());
361 gpppdata
.setModemAnswerResp(answerresp
->text());
363 gpppdata
.setVolumeHigh(volume_high
->text());
364 gpppdata
.setVolumeMedium(volume_medium
->text());
365 gpppdata
.setVolumeOff(volume_off
->text());
372 void ModemCommands::slotCancel() {
373 //set stuff from gpppdata
374 preinitslider
->setValue(gpppdata
.modemPreInitDelay());
375 lpreinitslider
->setNum(gpppdata
.modemPreInitDelay());
376 for(int i
= 0; i
< PPPData::NumInitStrings
; i
++)
377 initstr
[i
]->setText(gpppdata
.modemInitStr(i
));
378 initslider
->setValue(gpppdata
.modemInitDelay());
379 linitslider
->setNum(gpppdata
.modemInitDelay());
380 initresp
->setText(gpppdata
.modemInitResp());
382 durationslider
->setValue(gpppdata
.modemToneDuration());
383 ldurationslider
->setNum(gpppdata
.modemToneDuration());
385 nodetectdialtone
->setText(gpppdata
.modemNoDialToneDetectionStr());
386 dialstr
->setText(gpppdata
.modemDialStr());
387 dlpresp
->setText(gpppdata
.modemDLPResp());
389 connectresp
->setText(gpppdata
.modemConnectResp());
390 busyresp
->setText(gpppdata
.modemBusyResp());
391 nocarrierresp
->setText(gpppdata
.modemNoCarrierResp());
392 nodialtoneresp
->setText(gpppdata
.modemNoDialtoneResp());
394 escapestr
->setText(gpppdata
.modemEscapeStr());
395 escaperesp
->setText(gpppdata
.modemEscapeResp());
397 hangupstr
->setText(gpppdata
.modemHangupStr());
398 hangupresp
->setText(gpppdata
.modemHangupResp());
400 answerstr
->setText(gpppdata
.modemAnswerStr());
401 ringresp
->setText(gpppdata
.modemRingResp());
402 answerresp
->setText(gpppdata
.modemAnswerResp());
404 slider
->setValue(gpppdata
.modemEscapeGuardTime());
405 lslider
->setNum(gpppdata
.modemEscapeGuardTime());
407 volume_off
->setText(gpppdata
.volumeOff());
408 volume_medium
->setText(gpppdata
.volumeMedium());
409 volume_high
->setText(gpppdata
.volumeHigh());
413 #include "modemcmds.moc"