20 #include "portdialog.h"
21 #include "cupsdconf.h"
23 #include <tqlineedit.h>
24 #include <tqspinbox.h>
25 #include <tqcheckbox.h>
26 #include <tqpushbutton.h>
29 #include <tqwhatsthis.h>
31 #include <tdelocale.h>
33 PortDialog::PortDialog(TQWidget *parent,
const char *name)
34 : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true)
36 TQWidget *dummy =
new TQWidget(
this);
38 address_ =
new TQLineEdit(dummy);
39 port_ =
new TQSpinBox(0, 9999, 1, dummy);
41 usessl_ =
new TQCheckBox(i18n(
"Use SSL encryption"), dummy);
43 TQLabel *l1 =
new TQLabel(i18n(
"Address:"), dummy);
44 TQLabel *l2 =
new TQLabel(i18n(
"Port:"), dummy);
46 TQVBoxLayout *m1 =
new TQVBoxLayout(dummy, 0, 10);
47 TQGridLayout *m2 =
new TQGridLayout(0, 3, 2, 0, 5);
49 m2->addWidget(l1, 0, 0, TQt::AlignRight);
50 m2->addWidget(l2, 1, 0, TQt::AlignRight);
51 m2->addMultiCellWidget(usessl_, 2, 2, 0, 1);
52 m2->addWidget(address_, 0, 1);
53 m2->addWidget(port_, 1, 1);
55 setCaption(i18n(
"Listen To"));
59 TQString PortDialog::listenString()
62 if (usessl_->isChecked())
63 s.append(
"SSLListen ");
66 if (!address_->text().isEmpty())
67 s.append(address_->text());
70 s.append(
":").append(port_->text());
74 void PortDialog::setInfos(CupsdConf *conf)
76 TQWhatsThis::add(address_, conf->comments_.toolTip(
"address"));
77 TQWhatsThis::add(port_, conf->comments_.toolTip(
"port"));
78 TQWhatsThis::add(usessl_, conf->comments_.toolTip(
"usessl"));
81 TQString PortDialog::newListen(TQWidget *parent, CupsdConf *conf)
83 PortDialog dlg(parent);
87 return dlg.listenString();
89 return TQString::null;
92 TQString PortDialog::editListen(
const TQString& s, TQWidget *parent, CupsdConf *conf)
94 PortDialog dlg(parent);
99 dlg.usessl_->setChecked(s.left(p).startsWith(
"SSL"));
100 TQString addr = s.mid(p+1).stripWhiteSpace();
101 int p1 = addr.find(
':');
104 dlg.address_->setText(addr);
105 dlg.port_->setValue(631);
109 dlg.address_->setText(addr.left(p1));
110 dlg.port_->setValue(addr.mid(p1+1).toInt());
115 return dlg.listenString();
117 return TQString::null;