1/*
2 * kPPP: A pppd front end for the KDE project
3 *
4 * $Id$
5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu
8 *
9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter
11 *
12 * This program 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 program 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 this program; if not, write to the Free
24 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 */
26
27#include <termios.h>
28#include <string.h>
29
30//Added by qt3to4:
31#include <QLabel>
32#include <QVBoxLayout>
33#include <QFrame>
34#include <QHBoxLayout>
35#include <QGridLayout>
36
37#include <knuminput.h>
38#include <qslider.h>
39#include "general.h"
40#include "version.h"
41#include "miniterm.h"
42#include "modeminfo.h"
43#include "modemcmds.h"
44#include "devices.h"
45#include "pppdata.h"
46#include <klocale.h>
47#include <qlayout.h>
48#include <q3grid.h>
49
50/////////////////////////////////////////////////////////////////////////////
51//
52// Widget containing misc. configuration options
53//
54/////////////////////////////////////////////////////////////////////////////
55GeneralWidget::GeneralWidget( QWidget *parent, const char *name)
56 : QWidget(parent)
57{
58 setObjectName(name);
59
60 QVBoxLayout *tl = new QVBoxLayout(parent);
61 tl->setSpacing(KDialog::spacingHint());
62 tl->setMargin(0);
63
64 QHBoxLayout *hbox = new QHBoxLayout();
65 tl->addItem(hbox);
66 QLabel *label;
67 label = new QLabel(i18n("pppd version:"), parent);
68 hbox->addWidget(label);
69 QString version = gpppdata.pppdVersion();
70 if(version == "0.0.0")
71 version = "unknown";
72 label = new QLabel(version, parent);
73 label->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
74 hbox->addWidget(label);
75
76 KIntNumInput *pppdTimeout = new KIntNumInput(gpppdata.pppdTimeout(), parent);
77 pppdTimeout->setLabel(i18n("pppd &timeout:"));
78 pppdTimeout->setRange(1, TIMEOUT_SIZE, 5);
79 pppdTimeout->setSliderEnabled(true);
80 pppdTimeout->setSuffix(i18n(" sec"));
81 connect(pppdTimeout, SIGNAL(valueChanged(int)),
82 SLOT(pppdtimeoutchanged(int)));
83 tl->addWidget(pppdTimeout);
84 QString tmp = i18n("<i>kppp</i> will wait this number of seconds\n"
85 "to see if a PPP connection is established.\n"
86 "If no connection is made in this time frame,\n"
87 "<i>kppp</i> will give up and kill pppd.");
88 pppdTimeout->setWhatsThis(tmp);
89
90 tl->addSpacing(10);
91
92 QCheckBox *chkBox;
93 chkBox = new QCheckBox(i18n("Doc&k into panel on connect"), parent);
94 chkBox->setWhatsThis(
95 i18n("<p>After a connection is established, the\n"
96 "window is minimized and a small icon\n"
97 "in the KDE panel represents this window.\n"
98 "\n"
99 "Clicking on this icon will restore the\n"
100 "window to its original location and\n"
101 "size."));
102
103 chkBox->setChecked(gpppdata.get_dock_into_panel());
104 connect(chkBox,SIGNAL(toggled(bool)),
105 this, SLOT(docking_toggled(bool)));
106 tl->addWidget(chkBox);
107
108 chkBox = new QCheckBox(i18n("A&utomatic redial on disconnect"), parent);
109 chkBox->setChecked(gpppdata.automatic_redial());
110 connect(chkBox,SIGNAL(toggled(bool)),
111 this, SLOT(redial_toggled(bool)));
112 tl->addWidget(chkBox);
113 chkBox->setWhatsThis(
114 i18n("<p>When a connection is established and\n"
115 "it somehow gets disconnected, <i>kppp</i>\n"
116 "will try to reconnect to the same account.\n"
117 "\n"
118 "See <a href=\"#redial\">here</a> for more on this topic."));
119
120 chkBox = new QCheckBox(i18n("Automatic redial on NO &CARRIER"), parent);
121 chkBox->setChecked(gpppdata.get_redial_on_nocarrier());
122 connect(chkBox,SIGNAL(toggled(bool)),
123 this, SLOT(nocarrier_toggled(bool)));
124 tl->addWidget(chkBox);
125 chkBox->setWhatsThis(
126 i18n("<p>When dialing if modem returns NO CARRIER\n"
127 "the program will make a new attempt to redial\n"
128 "instead of waiting for user to click <CANCEL>\n"
129 "button."));
130
131 chkBox = new QCheckBox(i18n("&Show clock on caption"), parent);
132 chkBox->setChecked(gpppdata.get_show_clock_on_caption());
133 connect(chkBox, SIGNAL(toggled(bool)),
134 this, SLOT(caption_toggled(bool)));
135 tl->addWidget(chkBox);
136 chkBox->setWhatsThis(
137 i18n("When this option is checked, the window\n"
138 "title shows the time since a connection\n"
139 "was established. Very useful, so you \n"
140 "should turn this on"));
141
142 chkBox = new QCheckBox(i18n("Disco&nnect on X server shutdown"), parent);
143 chkBox->setChecked(gpppdata.get_xserver_exit_disconnect());
144 connect(chkBox, SIGNAL(toggled(bool)),
145 this, SLOT(xserver_toggled(bool)));
146 tl->addWidget(chkBox);
147 chkBox->setWhatsThis(
148 i18n("<p>Checking this option will close any\n"
149 "open connection when the X-server is\n"
150 "shut down. You should enable this option\n"
151 "unless you know what you are doing.\n"
152 "\n"
153 "See <a href=\"#disxserver\">here</a> for more on this."));
154
155 chkBox = new QCheckBox(i18n("&Quit on disconnect"), parent);
156 chkBox->setChecked(gpppdata.quit_on_disconnect());
157 connect(chkBox, SIGNAL(toggled(bool)),
158 this, SLOT(quit_toggled(bool)));
159 tl->addWidget(chkBox);
160 chkBox->setWhatsThis(
161 i18n("When this option is turned on, <i>kppp</i>\n"
162 "will be closed when you disconnect"));
163
164 chkBox = new QCheckBox(i18n("Minimi&ze window on connect"), parent);
165 chkBox->setChecked(gpppdata.get_iconify_on_connect());
166 connect(chkBox,SIGNAL(toggled(bool)),
167 this,SLOT(iconify_toggled(bool)));
168 tl->addWidget(chkBox);
169 chkBox->setWhatsThis(
170 i18n("Iconifies <i>kppp</i>'s window when a\n"
171 "connection is established"));
172
173 tl->addStretch();
174
175}
176
177
178void GeneralWidget::docking_toggled(bool on){
179 gpppdata.set_dock_into_panel(on);
180}
181
182
183void GeneralWidget::iconify_toggled(bool on){
184 gpppdata.set_iconify_on_connect(on);
185}
186
187
188void GeneralWidget::caption_toggled(bool on){
189 gpppdata.set_show_clock_on_caption(on);
190}
191
192
193void GeneralWidget::redial_toggled(bool on){
194 gpppdata.set_automatic_redial(on);
195}
196
197void GeneralWidget::nocarrier_toggled(bool on){
198 gpppdata.set_redial_on_nocarrier(on);
199}
200
201void GeneralWidget::xserver_toggled(bool on){
202 gpppdata.set_xserver_exit_disconnect(on);
203}
204
205
206void GeneralWidget::quit_toggled(bool on){
207 gpppdata.set_quit_on_disconnect(on);
208}
209
210
211void GeneralWidget::pppdtimeoutchanged(int n) {
212 gpppdata.setpppdTimeout(n);
213
214}
215
216
217ModemWidget::ModemWidget(QWidget *parent, bool isnewmodem)
218 : QWidget(parent)
219{
220 QVBoxLayout *topLayout = new QVBoxLayout(parent);
221 topLayout->setSpacing(KDialog::spacingHint());
222 topLayout->setMargin(0);
223 topLayout->addWidget(this);
224
225 QGridLayout *tl = new QGridLayout(this );
226 tl->setSpacing( KDialog::spacingHint() );
227
228 connect_label = new QLabel(i18n("Modem &name:"), this);
229 tl->addWidget(connect_label, 0, 0);
230
231 connectname_l = new QLineEdit(this);
232 connectname_l->setMaxLength(ACCNAME_SIZE);
233 connect_label->setBuddy(connectname_l);
234
235 tl->addWidget(connectname_l, 0, 1);
236 QString tmp = i18n("Type in a unique name for this modem");
237
238 connect_label->setWhatsThis(tmp);
239 connectname_l->setWhatsThis(tmp);
240
241 label1 = new QLabel(i18n("Modem de&vice:"), this);
242 tl->addWidget(label1, 1, 0);
243
244 modemdevice = new QComboBox(this);
245 modemdevice->setEditable( false );
246 label1->setBuddy(modemdevice);
247 // ### deviceExist mechanism not functional right now
248 bool deviceExist = false;
249 for(int k = 0; devices[k]; k++)
250 {
251 if ( devices[k] == gpppdata.modemDevice())
252 deviceExist = true;
253 modemdevice->addItem(devices[k]);
254 }
255 if ( !deviceExist )
256 modemdevice->addItem(gpppdata.modemDevice());
257
258 tl->addWidget(modemdevice, 1, 1);
259/* connect(modemdevice, SIGNAL(activated(int)),
260 SLOT(setmodemdc(int)));*/
261 tmp = i18n("This specifies the serial port your modem is attached \n"
262 "to. On Linux/x86, typically this is either /dev/ttyS0 \n"
263 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
264 "\n"
265 "If you have an internal ISDN card with AT command\n"
266 "emulation (most cards under Linux support this), you\n"
267 "should select one of the /dev/ttyIx devices.");
268
269 label1->setWhatsThis(tmp);
270 modemdevice->setWhatsThis(tmp);
271
272
273 label2 = new QLabel(i18n("&Flow control:"), this);
274 tl->addWidget(label2, 2, 0);
275
276 flowcontrol = new QComboBox(this);
277 flowcontrol->setEditable( false );
278 label2->setBuddy(flowcontrol);
279 flowcontrol->addItem(i18n("Hardware [CRTSCTS]")); // sync with pppdata.cpp
280 flowcontrol->addItem(i18n("Software [XON/XOFF]"));
281 flowcontrol->addItem(i18n("None"));
282
283 flowListItem << "Hardware [CRTSCTS]";
284 flowListItem << "Software [XON/XOFF]";
285 flowListItem << "None";
286
287 tl->addWidget(flowcontrol, 2, 1);
288 /*connect(flowcontrol, SIGNAL(activated(int)),
289 SLOT(setflowcontrol(int)));*/
290
291 tmp = i18n("<p>Specifies how the serial port and modem\n"
292 "communicate. You should not change this unless\n"
293 "you know what you are doing.\n"
294 "\n"
295 "<b>Default</b>: CRTSCTS");
296
297 label2->setWhatsThis(tmp);
298 flowcontrol->setWhatsThis(tmp);
299
300 labelenter = new QLabel(i18n("&Line termination:"), this);
301 tl->addWidget(labelenter, 3, 0);
302
303 enter = new QComboBox(this);
304 enter->setEditable( false );
305 labelenter->setBuddy(enter);
306 enter->addItem("CR");
307 enter->addItem("LF");
308 enter->addItem("CR/LF");
309 tl->addWidget(enter, 3, 1);
310 /* connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));*/
311 tmp = i18n("<p>Specifies how AT commands are sent to your\n"
312 "modem. Most modems will work fine with the\n"
313 "default <i>CR/LF</i>. If your modem does not react\n"
314 "to the init string, you should try different\n"
315 "settings here\n"
316 "\n"
317 "<b>Default</b>: CR/LF");
318
319 labelenter->setWhatsThis(tmp);
320 enter->setWhatsThis( tmp);
321
322 baud_label = new QLabel(i18n("Co&nnection speed:"), this);
323 tl->addWidget(baud_label, 4, 0);
324 baud_c = new QComboBox(this);
325 baud_label->setBuddy(baud_c);
326
327 static const char *baudrates[] = {
328
329#ifdef B460800
330 "460800",
331#endif
332
333#ifdef B230400
334 "230400",
335#endif
336
337#ifdef B115200
338 "115200",
339#endif
340
341#ifdef B57600
342 "57600",
343#endif
344
345 "38400",
346 "19200",
347 "9600",
348 "4800",
349 "2400",
350 "1200",
351 0};
352
353 for(int k = 0; baudrates[k]; k++)
354 baud_c->addItem(baudrates[k]);
355
356 baud_c->setCurrentIndex(3);
357 /*connect(baud_c, SIGNAL(activated(int)),
358 this, SLOT(speed_selection(int)));*/
359 tl->addWidget(baud_c, 4, 1);
360
361 tmp = i18n("Specifies the speed your modem and the serial\n"
362 "port talk to each other. You should begin with\n"
363 "at least 115200 bits/sec (or more if you know\n"
364 "that your serial port supports higher speeds).\n"
365 "If you have connection problems, try to reduce\n"
366 "this value.");
367
368 baud_label->setWhatsThis(tmp);
369 baud_c->setWhatsThis(tmp);
370
371 for(int i=0; i <= enter->count()-1; i++) {
372 if(gpppdata.enter() == enter->itemText(i))
373 enter->setCurrentIndex(i);
374 }
375
376 tl->addItem(new QSpacerItem(0, 10), 4, 0);
377
378 //Modem Lock File
379 modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
380
381 modemlockfile->setChecked(gpppdata.modemLockFile());
382/* connect(modemlockfile, SIGNAL(toggled(bool)),
383 SLOT(modemlockfilechanged(bool)));*/
384 tl->addWidget(modemlockfile, 5, 0, 1, 2);
385 // l12->addStretch(1);
386 modemlockfile->setWhatsThis(
387 i18n("<p>To prevent other programs from accessing the\n"
388 "modem while a connection is established, a\n"
389 "file can be created to indicate that the modem\n"
390 "is in use. On Linux an example file would be\n"
391 "<tt>/var/lock/LCK..ttyS1</tt>\n"
392 "Here you can select whether this locking will\n"
393 "be done.\n"
394 "\n"
395 "<b>Default</b>: On"));
396
397 // Modem Timeout Line Edit Box
398
399 modemtimeout = new KIntNumInput(gpppdata.modemTimeout(), this);
400 modemtimeout->setLabel(i18n("Modem &timeout:"));
401 modemtimeout->setRange(1, 120, 1);
402 modemtimeout->setSuffix(i18n(" sec"));
403/* connect(modemtimeout, SIGNAL(valueChanged(int)),
404 SLOT(modemtimeoutchanged(int)));*/
405 tl->addWidget(modemtimeout, 6, 0, 1, 2);
406
407 modemtimeout->setWhatsThis(
408 i18n("This specifies how long <i>kppp</i> waits for a\n"
409 "<i>CONNECT</i> response from your modem. The\n"
410 "recommended value is 30 seconds."));
411
412// Set defaults if editing an existing connection
413 if(!isnewmodem) {
414 connectname_l->setText(gpppdata.modname());
415
416 //set stuff from gpppdata
417 for(int i=0; i <= enter->count()-1; i++) {
418 if(gpppdata.enter() == enter->itemText(i))
419 enter->setCurrentIndex(i);
420 }
421
422 for(int i=0; i <= modemdevice->count()-1; i++) {
423 if(gpppdata.modemDevice() == modemdevice->itemText(i))
424 modemdevice->setCurrentIndex(i);
425 }
426
427 for(int i=0; i <= flowcontrol->count()-1; i++)
428 if(gpppdata.flowcontrol() == flowListItem[i])
429 flowcontrol->setCurrentIndex(i);
430
431 //set the modem speed
432 for(int i=0; i < baud_c->count(); i++)
433 if(baud_c->itemText(i) == gpppdata.speed())
434 baud_c->setCurrentIndex(i);
435
436 } else {
437 //Set the standard Items
438 enter->setCurrentIndex(0);
439 modemdevice->setCurrentIndex(0);
440 flowcontrol->setCurrentIndex(0);
441 baud_c->setCurrentIndex(0);
442 }
443
444 tl->setRowStretch(7, 1);
445}
446
447bool ModemWidget::save()
448{
449 //first check to make sure that the modem name is unique!
450 if(connectname_l->text().isEmpty() ||
451 !gpppdata.isUniqueModname(connectname_l->text())) {
452 return false;
453 } else {
454 gpppdata.setModname(connectname_l->text());
455 gpppdata.setSpeed(baud_c->itemText(baud_c->currentIndex()));
456 gpppdata.setEnter(enter->itemText(enter->currentIndex()));
457 gpppdata.setModemDevice(modemdevice->itemText(modemdevice->currentIndex()));
458 gpppdata.setFlowcontrol(flowListItem[flowcontrol->currentIndex()]);
459 gpppdata.setModemLockFile(modemlockfile->isChecked());
460 gpppdata.setModemTimeout(modemtimeout->value());
461 return true;
462 }
463}
464
465
466ModemWidget2::ModemWidget2(QWidget *parent, const char *name)
467 : QWidget(parent)
468{
469 setObjectName(name);
470
471 QVBoxLayout *topLayout = new QVBoxLayout(parent);
472 topLayout->setSpacing(KDialog::spacingHint());
473 topLayout->setMargin(0);
474 topLayout->addWidget(this);
475
476 QVBoxLayout *l1 = new QVBoxLayout(this);
477 l1->setSpacing(KDialog::spacingHint());
478 l1->setMargin(0);
479
480
481 waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
482 waitfordt->setChecked(gpppdata.waitForDialTone());
483 // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
484 l1->addWidget(waitfordt);
485 waitfordt->setWhatsThis(
486 i18n("<p>Normally the modem waits for a dial tone\n"
487 "from your phone line, indicating that it can\n"
488 "start to dial a number. If your modem does not\n"
489 "recognize this sound, or your local phone system\n"
490 "does not emit such a tone, uncheck this option\n"
491 "\n"
492 "<b>Default:</b>: On"));
493
494 busywait = new KIntNumInput(gpppdata.busyWait(), this);
495 busywait->setLabel(i18n("B&usy wait:"));
496 busywait->setRange(0, 300, 5);
497 busywait->setSliderEnabled(true);
498 busywait->setSuffix(i18n(" sec"));
499 // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
500 l1->addWidget(busywait);
501
502 busywait->setWhatsThis(
503 i18n("Specifies the number of seconds to wait before\n"
504 "redial if all dialed numbers are busy. This is\n"
505 "necessary because some modems get stuck if the\n"
506 "same number is busy too often.\n"
507 "\n"
508 "The default is 0 seconds, you should not change\n"
509 "this unless you need to."));
510
511 l1->addSpacing(10);
512
513 QHBoxLayout *hbl = new QHBoxLayout;
514 hbl->setSpacing(KDialog::spacingHint());
515
516 QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
517 hbl->addWidget(volumeLabel);
518 volume = new QSlider(Qt::Horizontal, this);
519 volume->setMinimum(0);
520 volume->setMaximum(2);
521 volume->setPageStep(1);
522 volume->setValue(gpppdata.volume());
523 volumeLabel->setBuddy(volume);
524 volume->setTickPosition(QSlider::TicksBelow);
525 hbl->addWidget(volume);
526
527 l1->addLayout(hbl);
528
529 /* connect(volume, SIGNAL(valueChanged(int)),
530 this, SLOT(volumeChanged(int)));*/
531 QString tmp = i18n("Most modems have a speaker which makes\n"
532 "a lot of noise when dialing. Here you can\n"
533 "either turn this completely off or select a\n"
534 "lower volume.\n"
535 "\n"
536 "If this does not work for your modem,\n"
537 "you must modify the modem volume command.");
538
539 volumeLabel->setWhatsThis(tmp);
540 volume->setWhatsThis( tmp);
541
542 l1->addSpacing(20);
543
544#if 0
545 chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
546 chkbox1->setChecked(gpppdata.UseCDLine());
547 connect(chkbox1,SIGNAL(toggled(bool)),
548 this,SLOT(use_cdline_toggled(bool)));
549 l12->addWidget(chkbox1);
550 l12->addStretch(1);
551 l1->addStretch(1);
552 chkbox1->setWhatsThis(
553 i18n("This controls how <i>kppp</i> detects that the modem\n"
554 "is not responding. Unless you are having\n"
555 "problems with this, do not modify this setting.\n"
556 "\n"
557 "<b>Default</b>: Off"));
558#endif
559
560 modemcmds = new QPushButton(i18n("Mod&em Commands..."), this);
561 modemcmds->setWhatsThis(
562 i18n("Allows you to change the AT command for\n"
563 "your modem."));
564
565 modeminfo_button = new QPushButton(i18n("&Query Modem..."), this);
566 modeminfo_button->setWhatsThis(
567 i18n("Most modems support the ATI command set to\n"
568 "find out vendor and revision of your modem.\n"
569 "\n"
570 "Press this button to query your modem for\n"
571 "this information. It can be useful to help\n"
572 "you set up the modem"));
573
574 terminal_button = new QPushButton(i18n("&Terminal..."), this);
575 terminal_button->setWhatsThis(
576 i18n("Opens the built-in terminal program. You\n"
577 "can use this if you want to play around\n"
578 "with your modem's AT command set"));
579
580 QHBoxLayout *hbox = new QHBoxLayout();
581 l1->addLayout(hbox);
582 hbox->addStretch(1);
583 QVBoxLayout *vbox = new QVBoxLayout();
584 hbox->addLayout(vbox);
585
586 vbox->addWidget(modemcmds);
587 vbox->addWidget(modeminfo_button);
588 vbox->addWidget(terminal_button);
589
590 hbox->addStretch(1);
591 l1->addStretch(1);
592
593 connect(modemcmds, SIGNAL(clicked()),
594 SLOT(modemcmdsbutton()));
595 connect(modeminfo_button, SIGNAL(clicked()),
596 SLOT(query_modem()));
597 connect(terminal_button, SIGNAL(clicked()),
598 SLOT(terminal()));
599
600 // Create the Modem Command so if the window is not opened they are autosaved anyway
601 mc = new ModemCommands(this);
602}
603
604
605void ModemWidget2::modemcmdsbutton() {
606 mc->exec();
607}
608
609
610void ModemWidget2::query_modem() {
611 ModemTransfer mt(this);
612 mt.exec();
613}
614
615
616void ModemWidget2::terminal() {
617 MiniTerm terminal(NULL,NULL);
618 terminal.exec();
619}
620
621
622#if 0
623void ModemWidget2::use_cdline_toggled(bool on) {
624 gpppdata.setUseCDLine(on);
625}
626#endif
627
628bool ModemWidget2::save()
629{
630 gpppdata.setWaitForDialTone(waitfordt->isChecked());
631 gpppdata.setbusyWait(busywait->value());
632 gpppdata.setVolume(volume->value());
633 return true;
634}
635
636
637/////////////////////////////////////////////////////////////////////////////
638//
639// Setup widget for the graph
640//
641/////////////////////////////////////////////////////////////////////////////
642GraphSetup::GraphSetup(QWidget *parent) :
643 QWidget(parent)
644{
645 QVBoxLayout *tl = new QVBoxLayout(this);
646
647 bool enable;
648 QColor bg, text, in, out;
649 gpppdata.graphingOptions(enable, bg, text, in, out);
650
651 enable_check = new QCheckBox(i18n("&Enable throughput graph"), this);
652 tl->addWidget(enable_check);
653
654 grpColor = new Q3GroupBox(2, Qt::Horizontal,
655 i18n("Graph Colors"), this);
656 tl->addWidget(grpColor);
657
658 QLabel *label;
659
660 label = new QLabel(i18n("Bac&kground:"), grpColor);
661 bg_color = new KColorButton( bg, grpColor );
662 bg_color->setFixedSize(80, 24);
663 label->setBuddy(bg_color);
664
665 label = new QLabel(i18n("&Text:"), grpColor);
666 text_color = new KColorButton( text,grpColor );
667 text_color->setFixedSize(80, 24);
668 label->setBuddy(text_color);
669
670 label = new QLabel(i18n("I&nput bytes:"), grpColor);
671 in_color = new KColorButton( in,grpColor );
672 in_color->setFixedSize(80, 24);
673 label->setBuddy(in_color);
674
675 label = new QLabel(i18n("O&utput bytes:"), grpColor);
676 out_color = new KColorButton( out, grpColor );
677 out_color->setFixedSize(80, 24);
678 label->setBuddy(out_color);
679
680 tl->addStretch();
681
682 connect(enable_check, SIGNAL(toggled(bool)), this, SLOT(enableToggled(bool)));
683 connect(bg_color, SIGNAL(changed(QColor)),
684 SLOT(colorChanged(QColor)));
685 connect(text_color, SIGNAL(changed(QColor)),
686 SLOT(colorChanged(QColor)));
687 connect(in_color, SIGNAL(changed(QColor)),
688 SLOT(colorChanged(QColor)));
689 connect(out_color, SIGNAL(changed(QColor)),
690 SLOT(colorChanged(QColor)));
691
692 tl->activate();
693
694 enable_check->setChecked(enable);
695 enableToggled(enable);
696}
697
698void GraphSetup::enableToggled(bool b) {
699 grpColor->setEnabled(b);
700 save();
701}
702
703
704void GraphSetup::colorChanged(const QColor &) {
705 save();
706}
707
708void GraphSetup::save() {
709 gpppdata.setGraphingOptions(enable_check->isChecked(),
710 bg_color->color(),
711 text_color->color(),
712 in_color->color(),
713 out_color->color());
714}
715
716#include "general.moc"
717