20 #include "cupsdbrowsingpage.h"
21 #include "cupsdconf.h"
23 #include "browsedialog.h"
27 #include <tqcheckbox.h>
28 #include <tqcombobox.h>
29 #include <tqwhatsthis.h>
31 #include <tdelocale.h>
32 #include <knuminput.h>
34 CupsdBrowsingPage::CupsdBrowsingPage(TQWidget *parent,
const char *name)
35 : CupsdPage(parent, name)
37 setPageLabel(i18n(
"Browsing"));
38 setHeader(i18n(
"Browsing Settings"));
39 setPixmap(
"tdeprint_printer_remote");
41 browseinterval_ =
new KIntNumInput(
this);
42 browseport_ =
new KIntNumInput(
this);
43 browsetimeout_ =
new KIntNumInput(
this);
44 browsing_ =
new TQCheckBox(i18n(
"Use browsing"),
this);
45 cups_ =
new TQCheckBox(
"CUPS",
this);
46 slp_ =
new TQCheckBox(
"SLP",
this);
47 browseaddresses_ =
new EditList(
this);
48 browseorder_ =
new TQComboBox(
this);
49 useimplicitclasses_ =
new TQCheckBox(i18n(
"Implicit classes"),
this);
50 hideimplicitmembers_ =
new TQCheckBox(i18n(
"Hide implicit members"),
this);
51 useshortnames_ =
new TQCheckBox(i18n(
"Use short names"),
this);
52 useanyclasses_ =
new TQCheckBox(i18n(
"Use \"any\" classes"),
this);
54 browseorder_->insertItem(i18n(
"Allow, Deny"));
55 browseorder_->insertItem(i18n(
"Deny, Allow"));
57 browseport_->setRange(0, 9999, 1,
true);
58 browseport_->setSteps(1, 5);
59 browseinterval_->setRange(0, 10000, 1,
true);
60 browseinterval_->setSteps(1, 10);
61 browseinterval_->setSuffix(i18n(
" sec"));
62 browsetimeout_->setRange(0, 10000, 1,
true);
63 browsetimeout_->setSteps(1, 10);
64 browsetimeout_->setSuffix(i18n(
" sec"));
66 TQLabel *l1 =
new TQLabel(i18n(
"Browse port:"),
this);
67 TQLabel *l2 =
new TQLabel(i18n(
"Browse interval:"),
this);
68 TQLabel *l3 =
new TQLabel(i18n(
"Browse timeout:"),
this);
69 TQLabel *l4 =
new TQLabel(i18n(
"Browse addresses:"),
this);
70 TQLabel *l5 =
new TQLabel(i18n(
"Browse order:"),
this);
71 TQLabel *l6 =
new TQLabel(i18n(
"Browse options:"),
this);
73 TQGridLayout *m1 =
new TQGridLayout(
this, 8, 2, 10, 7);
74 m1->setRowStretch(7, 1);
75 m1->setColStretch(1, 1);
76 TQHBoxLayout *m2 =
new TQHBoxLayout(0, 0, 10);
77 m1->addMultiCellLayout(m2, 0, 0, 0, 1);
78 m2->addWidget(browsing_);
82 m1->addWidget(l1, 1, 0, TQt::AlignRight);
83 m1->addWidget(l2, 2, 0, TQt::AlignRight);
84 m1->addWidget(l3, 3, 0, TQt::AlignRight);
85 m1->addWidget(l4, 4, 0, TQt::AlignRight|TQt::AlignTop);
86 m1->addWidget(l5, 5, 0, TQt::AlignRight);
87 m1->addWidget(l6, 6, 0, TQt::AlignRight|TQt::AlignTop);
88 m1->addWidget(browseport_, 1, 1);
89 m1->addWidget(browseinterval_, 2, 1);
90 m1->addWidget(browsetimeout_, 3, 1);
91 m1->addWidget(browseaddresses_, 4, 1);
92 m1->addWidget(browseorder_, 5, 1);
93 TQGridLayout *m3 =
new TQGridLayout(0, 2, 2, 0, 5);
94 m1->addLayout(m3, 6, 1);
95 m3->addWidget(useimplicitclasses_, 0, 0);
96 m3->addWidget(useanyclasses_, 0, 1);
97 m3->addWidget(hideimplicitmembers_, 1, 0);
98 m3->addWidget(useshortnames_, 1, 1);
100 connect(browsing_, TQ_SIGNAL(toggled(
bool)), cups_, TQ_SLOT(setEnabled(
bool)));
101 connect(browsing_, TQ_SIGNAL(toggled(
bool)), slp_, TQ_SLOT(setEnabled(
bool)));
102 connect(browsing_, TQ_SIGNAL(toggled(
bool)), browseport_, TQ_SLOT(setEnabled(
bool)));
103 connect(browsing_, TQ_SIGNAL(toggled(
bool)), browseinterval_, TQ_SLOT(setEnabled(
bool)));
104 connect(browsing_, TQ_SIGNAL(toggled(
bool)), browsetimeout_, TQ_SLOT(setEnabled(
bool)));
105 connect(browsing_, TQ_SIGNAL(toggled(
bool)), browseaddresses_, TQ_SLOT(setEnabled(
bool)));
106 connect(browsing_, TQ_SIGNAL(toggled(
bool)), browseorder_, TQ_SLOT(setEnabled(
bool)));
107 connect(browsing_, TQ_SIGNAL(toggled(
bool)), useimplicitclasses_, TQ_SLOT(setEnabled(
bool)));
108 connect(browsing_, TQ_SIGNAL(toggled(
bool)), useanyclasses_, TQ_SLOT(setEnabled(
bool)));
109 connect(browsing_, TQ_SIGNAL(toggled(
bool)), hideimplicitmembers_, TQ_SLOT(setEnabled(
bool)));
110 connect(browsing_, TQ_SIGNAL(toggled(
bool)), useshortnames_, TQ_SLOT(setEnabled(
bool)));
112 connect(browsing_, TQ_SIGNAL(toggled(
bool)), l1, TQ_SLOT(setEnabled(
bool)));
113 connect(browsing_, TQ_SIGNAL(toggled(
bool)), l2, TQ_SLOT(setEnabled(
bool)));
114 connect(browsing_, TQ_SIGNAL(toggled(
bool)), l3, TQ_SLOT(setEnabled(
bool)));
115 connect(browsing_, TQ_SIGNAL(toggled(
bool)), l4, TQ_SLOT(setEnabled(
bool)));
116 connect(browsing_, TQ_SIGNAL(toggled(
bool)), l5, TQ_SLOT(setEnabled(
bool)));
117 connect(browsing_, TQ_SIGNAL(toggled(
bool)), l6, TQ_SLOT(setEnabled(
bool)));
119 connect(browseaddresses_, TQ_SIGNAL(add()), TQ_SLOT(slotAdd()));
120 connect(browseaddresses_, TQ_SIGNAL(edit(
int)), TQ_SLOT(slotEdit(
int)));
121 connect(browseaddresses_, TQ_SIGNAL(defaultList()), TQ_SLOT(slotDefaultList()));
122 connect(browseinterval_, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(intervalChanged(
int)));
123 browsing_->setChecked(
true);
126 bool CupsdBrowsingPage::loadConfig(CupsdConf *conf, TQString&)
129 browsing_->setChecked(conf_->browsing_);
130 cups_->setChecked(conf_->browseprotocols_.findIndex(
"CUPS") != -1);
131 slp_->setChecked(conf_->browseprotocols_.findIndex(
"SLP") != -1);
132 browseport_->setValue(conf_->browseport_);
133 browseinterval_->setValue(conf_->browseinterval_);
134 browsetimeout_->setValue(conf_->browsetimeout_);
135 browseaddresses_->insertItems(conf_->browseaddresses_);
136 browseorder_->setCurrentItem(conf_->browseorder_);
137 useimplicitclasses_->setChecked(conf_->useimplicitclasses_);
138 useanyclasses_->setChecked(conf_->useanyclasses_);
139 hideimplicitmembers_->setChecked(conf_->hideimplicitmembers_);
140 useshortnames_->setChecked(conf_->useshortnames_);
145 bool CupsdBrowsingPage::saveConfig(CupsdConf *conf, TQString&)
147 conf->browsing_ = browsing_->isChecked();
149 if (cups_->isChecked()) l <<
"CUPS";
150 if (slp_->isChecked()) l <<
"SLP";
151 conf->browseprotocols_ = l;
152 conf->browseport_ = browseport_->value();
153 conf->browseinterval_ = browseinterval_->value();
154 conf->browsetimeout_ = browsetimeout_->value();
155 conf->browseaddresses_ = browseaddresses_->items();
156 conf->browseorder_ = browseorder_->currentItem();
157 conf->useimplicitclasses_ = useimplicitclasses_->isChecked();
158 conf->useanyclasses_ = useanyclasses_->isChecked();
159 conf->hideimplicitmembers_ = hideimplicitmembers_->isChecked();
160 conf->useshortnames_ = useshortnames_->isChecked();
165 void CupsdBrowsingPage::setInfos(CupsdConf *conf)
167 TQWhatsThis::add(browsing_, conf->comments_.toolTip(
"browsing"));
168 TQWhatsThis::add(cups_, conf->comments_.toolTip(
"browseprotocols"));
169 TQWhatsThis::add(slp_, conf->comments_.toolTip(
"browseprotocols"));
170 TQWhatsThis::add(browseinterval_, conf->comments_.toolTip(
"browseinterval"));
171 TQWhatsThis::add(browseport_, conf->comments_.toolTip(
"browseport"));
172 TQWhatsThis::add(browsetimeout_, conf->comments_.toolTip(
"browsetimeout"));
173 TQWhatsThis::add(browseaddresses_, conf->comments_.toolTip(
"browseaddresses"));
174 TQWhatsThis::add(browseorder_, conf->comments_.toolTip(
"browseorder"));
175 TQWhatsThis::add(useimplicitclasses_, conf->comments_.toolTip(
"implicitclasses"));
176 TQWhatsThis::add(useanyclasses_, conf->comments_.toolTip(
"implicitanyclasses"));
177 TQWhatsThis::add(hideimplicitmembers_, conf->comments_.toolTip(
"hideimplicitmembers"));
178 TQWhatsThis::add(useshortnames_, conf->comments_.toolTip(
"browseshortnames"));
181 void CupsdBrowsingPage::slotAdd()
183 TQString s = BrowseDialog::newAddress(
this, conf_);
185 browseaddresses_->insertItem(s);
188 void CupsdBrowsingPage::slotEdit(
int index)
190 TQString s = browseaddresses_->text(index);
191 s = BrowseDialog::editAddress(s,
this, conf_);
193 browseaddresses_->setText(index, s);
196 void CupsdBrowsingPage::slotDefaultList()
198 browseaddresses_->clear();
200 l <<
"Send 255.255.255.255";
201 browseaddresses_->insertItems(l);
204 void CupsdBrowsingPage::intervalChanged(
int val)
206 browsetimeout_->setRange(val, 10000, 1,
true);
207 browsetimeout_->setSteps(1, 10);
210 #include "cupsdbrowsingpage.moc"