00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "cupsdnetworkpage.h"
00021
#include "cupsdconf.h"
00022
#include "editlist.h"
00023
#include "portdialog.h"
00024
#include "sizewidget.h"
00025
00026
#include <qlabel.h>
00027
#include <qcheckbox.h>
00028
#include <qcombobox.h>
00029
#include <qlayout.h>
00030
#include <qwhatsthis.h>
00031
00032
#include <klocale.h>
00033
#include <knuminput.h>
00034
00035 CupsdNetworkPage::CupsdNetworkPage(
QWidget *parent,
const char *name)
00036 : CupsdPage(parent, name)
00037 {
00038 setPageLabel(i18n(
"Network"));
00039 setHeader(i18n(
"Network Settings"));
00040 setPixmap(
"network");
00041
00042 keepalive_ =
new QCheckBox(i18n(
"Keep alive"),
this);
00043 keepalivetimeout_ =
new KIntNumInput(
this);
00044 maxclients_ =
new KIntNumInput(
this);
00045 maxrequestsize_ =
new SizeWidget(
this);
00046 clienttimeout_ =
new KIntNumInput(
this);
00047 hostnamelookup_ =
new QComboBox(
this);
00048 listen_ =
new EditList(
this);
00049
00050 keepalivetimeout_->setRange(0, 10000, 1,
true);
00051 keepalivetimeout_->setSteps(1, 10);
00052 keepalivetimeout_->setSpecialValueText(i18n(
"Unlimited"));
00053 keepalivetimeout_->setSuffix(i18n(
" sec"));
00054
00055 maxclients_->setRange(1, 1000, 1,
true);
00056 maxclients_->setSteps(1, 10);
00057
00058 clienttimeout_->setRange(0, 10000, 1,
true);
00059 clienttimeout_->setSteps(1, 10);
00060 clienttimeout_->setSpecialValueText(i18n(
"Unlimited"));
00061 clienttimeout_->setSuffix(i18n(
" sec"));
00062
00063 hostnamelookup_->insertItem(i18n(
"Off"));
00064 hostnamelookup_->insertItem(i18n(
"On"));
00065 hostnamelookup_->insertItem(i18n(
"Double"));
00066
00067
QLabel *l1 =
new QLabel(i18n(
"Hostname lookups:"),
this);
00068 QLabel *l2 =
new QLabel(i18n(
"Keep-alive timeout:"),
this);
00069 QLabel *l3 =
new QLabel(i18n(
"Max clients:"),
this);
00070 QLabel *l4 =
new QLabel(i18n(
"Max request size:"),
this);
00071 QLabel *l5 =
new QLabel(i18n(
"Client timeout:"),
this);
00072 QLabel *l6 =
new QLabel(i18n(
"Listen to:"),
this);
00073
00074
QGridLayout *m1 =
new QGridLayout(
this, 8, 2, 10, 7);
00075 m1->setRowStretch(7, 1);
00076 m1->setColStretch(1, 1);
00077 m1->addWidget(l1, 0, 0, Qt::AlignRight);
00078 m1->addWidget(l2, 2, 0, Qt::AlignRight);
00079 m1->addWidget(l3, 3, 0, Qt::AlignRight);
00080 m1->addWidget(l4, 4, 0, Qt::AlignRight);
00081 m1->addWidget(l5, 5, 0, Qt::AlignRight);
00082 m1->addWidget(l6, 6, 0, Qt::AlignTop|Qt::AlignRight);
00083 m1->addWidget(keepalive_, 1, 1);
00084 m1->addWidget(hostnamelookup_, 0, 1);
00085 m1->addWidget(keepalivetimeout_, 2, 1);
00086 m1->addWidget(maxclients_, 3, 1);
00087 m1->addWidget(maxrequestsize_, 4, 1);
00088 m1->addWidget(clienttimeout_, 5, 1);
00089 m1->addWidget(listen_, 6, 1);
00090
00091 connect(listen_, SIGNAL(add()), SLOT(slotAdd()));
00092 connect(listen_, SIGNAL(edit(
int)), SLOT(slotEdit(
int)));
00093 connect(listen_, SIGNAL(defaultList()), SLOT(slotDefaultList()));
00094 connect(keepalive_, SIGNAL(toggled(
bool)), keepalivetimeout_, SLOT(setEnabled(
bool)));
00095 keepalive_->setChecked(
true);
00096 }
00097
00098
bool CupsdNetworkPage::loadConfig(CupsdConf *conf,
QString&)
00099 {
00100 conf_ = conf;
00101 hostnamelookup_->setCurrentItem(conf_->hostnamelookup_);
00102 keepalive_->setChecked(conf_->keepalive_);
00103 keepalivetimeout_->setValue(conf_->keepalivetimeout_);
00104 maxclients_->setValue(conf_->maxclients_);
00105 maxrequestsize_->setSizeString(conf_->maxrequestsize_);
00106 clienttimeout_->setValue(conf_->clienttimeout_);
00107 listen_->insertItems(conf_->listenaddresses_);
00108
00109
return true;
00110 }
00111
00112
bool CupsdNetworkPage::saveConfig(CupsdConf *conf,
QString&)
00113 {
00114 conf->hostnamelookup_ = hostnamelookup_->currentItem();
00115 conf->keepalive_ = keepalive_->isChecked();
00116 conf->keepalivetimeout_ = keepalivetimeout_->value();
00117 conf->maxclients_ = maxclients_->value();
00118 conf->maxrequestsize_ = maxrequestsize_->sizeString();
00119 conf->clienttimeout_ = clienttimeout_->value();
00120 conf->listenaddresses_ = listen_->items();
00121
00122
return true;
00123 }
00124
00125
void CupsdNetworkPage::setInfos(CupsdConf *conf)
00126 {
00127 QWhatsThis::add(hostnamelookup_, conf->comments_.toolTip(
"hostnamelookups"));
00128 QWhatsThis::add(keepalive_, conf->comments_.toolTip(
"keepalive"));
00129 QWhatsThis::add(keepalivetimeout_, conf->comments_.toolTip(
"keepalivetimeout"));
00130 QWhatsThis::add(maxclients_, conf->comments_.toolTip(
"maxclients"));
00131 QWhatsThis::add(maxrequestsize_, conf->comments_.toolTip(
"maxrequestsize"));
00132 QWhatsThis::add(clienttimeout_, conf->comments_.toolTip(
"timeout"));
00133 QWhatsThis::add(listen_, conf->comments_.toolTip(
"listen"));
00134 }
00135
00136
void CupsdNetworkPage::slotAdd()
00137 {
00138
QString s = PortDialog::newListen(
this, conf_);
00139
if (!s.isEmpty())
00140 listen_->insertItem(s);
00141 }
00142
00143
void CupsdNetworkPage::slotEdit(
int index)
00144 {
00145
QString s = listen_->text(index);
00146 s = PortDialog::editListen(s,
this, conf_);
00147
if (!s.isEmpty())
00148 listen_->setText(index, s);
00149 }
00150
00151
void CupsdNetworkPage::slotDefaultList()
00152 {
00153 listen_->clear();
00154
QStringList l;
00155 l <<
"Listen *:631";
00156 listen_->insertItems(l);
00157 }
00158
00159
#include "cupsdnetworkpage.moc"