20 #include "cupsdnetworkpage.h"
21 #include "cupsdconf.h"
23 #include "portdialog.h"
24 #include "sizewidget.h"
27 #include <tqcheckbox.h>
28 #include <tqcombobox.h>
30 #include <tqwhatsthis.h>
32 #include <tdelocale.h>
33 #include <knuminput.h>
35 CupsdNetworkPage::CupsdNetworkPage(TQWidget *parent,
const char *name)
36 : CupsdPage(parent, name)
38 setPageLabel(i18n(
"Network"));
39 setHeader(i18n(
"Network Settings"));
42 keepalive_ =
new TQCheckBox(i18n(
"Keep alive"),
this);
43 keepalivetimeout_ =
new KIntNumInput(
this);
44 maxclients_ =
new KIntNumInput(
this);
45 maxrequestsize_ =
new SizeWidget(
this);
46 clienttimeout_ =
new KIntNumInput(
this);
47 hostnamelookup_ =
new TQComboBox(
this);
48 listen_ =
new EditList(
this);
50 keepalivetimeout_->setRange(0, 10000, 1,
true);
51 keepalivetimeout_->setSteps(1, 10);
52 keepalivetimeout_->setSpecialValueText(i18n(
"Unlimited"));
53 keepalivetimeout_->setSuffix(i18n(
" sec"));
55 maxclients_->setRange(1, 1000, 1,
true);
56 maxclients_->setSteps(1, 10);
58 clienttimeout_->setRange(0, 10000, 1,
true);
59 clienttimeout_->setSteps(1, 10);
60 clienttimeout_->setSpecialValueText(i18n(
"Unlimited"));
61 clienttimeout_->setSuffix(i18n(
" sec"));
63 hostnamelookup_->insertItem(i18n(
"Off"));
64 hostnamelookup_->insertItem(i18n(
"On"));
65 hostnamelookup_->insertItem(i18n(
"Double"));
67 TQLabel *l1 =
new TQLabel(i18n(
"Hostname lookups:"),
this);
68 TQLabel *l2 =
new TQLabel(i18n(
"Keep-alive timeout:"),
this);
69 TQLabel *l3 =
new TQLabel(i18n(
"Max clients:"),
this);
70 TQLabel *l4 =
new TQLabel(i18n(
"Max request size:"),
this);
71 TQLabel *l5 =
new TQLabel(i18n(
"Client timeout:"),
this);
72 TQLabel *l6 =
new TQLabel(i18n(
"Listen to:"),
this);
74 TQGridLayout *m1 =
new TQGridLayout(
this, 8, 2, 10, 7);
75 m1->setRowStretch(7, 1);
76 m1->setColStretch(1, 1);
77 m1->addWidget(l1, 0, 0, TQt::AlignRight);
78 m1->addWidget(l2, 2, 0, TQt::AlignRight);
79 m1->addWidget(l3, 3, 0, TQt::AlignRight);
80 m1->addWidget(l4, 4, 0, TQt::AlignRight);
81 m1->addWidget(l5, 5, 0, TQt::AlignRight);
82 m1->addWidget(l6, 6, 0, TQt::AlignTop|TQt::AlignRight);
83 m1->addWidget(keepalive_, 1, 1);
84 m1->addWidget(hostnamelookup_, 0, 1);
85 m1->addWidget(keepalivetimeout_, 2, 1);
86 m1->addWidget(maxclients_, 3, 1);
87 m1->addWidget(maxrequestsize_, 4, 1);
88 m1->addWidget(clienttimeout_, 5, 1);
89 m1->addWidget(listen_, 6, 1);
91 connect(listen_, TQ_SIGNAL(add()), TQ_SLOT(slotAdd()));
92 connect(listen_, TQ_SIGNAL(edit(
int)), TQ_SLOT(slotEdit(
int)));
93 connect(listen_, TQ_SIGNAL(defaultList()), TQ_SLOT(slotDefaultList()));
94 connect(keepalive_, TQ_SIGNAL(toggled(
bool)), keepalivetimeout_, TQ_SLOT(setEnabled(
bool)));
95 keepalive_->setChecked(
true);
98 bool CupsdNetworkPage::loadConfig(CupsdConf *conf, TQString&)
101 hostnamelookup_->setCurrentItem(conf_->hostnamelookup_);
102 keepalive_->setChecked(conf_->keepalive_);
103 keepalivetimeout_->setValue(conf_->keepalivetimeout_);
104 maxclients_->setValue(conf_->maxclients_);
105 maxrequestsize_->setSizeString(conf_->maxrequestsize_);
106 clienttimeout_->setValue(conf_->clienttimeout_);
107 listen_->insertItems(conf_->listenaddresses_);
112 bool CupsdNetworkPage::saveConfig(CupsdConf *conf, TQString&)
114 conf->hostnamelookup_ = hostnamelookup_->currentItem();
115 conf->keepalive_ = keepalive_->isChecked();
116 conf->keepalivetimeout_ = keepalivetimeout_->value();
117 conf->maxclients_ = maxclients_->value();
118 conf->maxrequestsize_ = maxrequestsize_->sizeString();
119 conf->clienttimeout_ = clienttimeout_->value();
120 conf->listenaddresses_ = listen_->items();
125 void CupsdNetworkPage::setInfos(CupsdConf *conf)
127 TQWhatsThis::add(hostnamelookup_, conf->comments_.toolTip(
"hostnamelookups"));
128 TQWhatsThis::add(keepalive_, conf->comments_.toolTip(
"keepalive"));
129 TQWhatsThis::add(keepalivetimeout_, conf->comments_.toolTip(
"keepalivetimeout"));
130 TQWhatsThis::add(maxclients_, conf->comments_.toolTip(
"maxclients"));
131 TQWhatsThis::add(maxrequestsize_, conf->comments_.toolTip(
"maxrequestsize"));
132 TQWhatsThis::add(clienttimeout_, conf->comments_.toolTip(
"timeout"));
133 TQWhatsThis::add(listen_, conf->comments_.toolTip(
"listen"));
136 void CupsdNetworkPage::slotAdd()
138 TQString s = PortDialog::newListen(
this, conf_);
140 listen_->insertItem(s);
143 void CupsdNetworkPage::slotEdit(
int index)
145 TQString s = listen_->text(index);
146 s = PortDialog::editListen(s,
this, conf_);
148 listen_->setText(index, s);
151 void CupsdNetworkPage::slotDefaultList()
156 listen_->insertItems(l);
159 #include "cupsdnetworkpage.moc"