summaryrefslogtreecommitdiffstats
path: root/kdeprint/cups/cupsdconf2/portdialog.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeprint/cups/cupsdconf2/portdialog.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeprint/cups/cupsdconf2/portdialog.cpp')
-rw-r--r--kdeprint/cups/cupsdconf2/portdialog.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/kdeprint/cups/cupsdconf2/portdialog.cpp b/kdeprint/cups/cupsdconf2/portdialog.cpp
new file mode 100644
index 000000000..f866450b8
--- /dev/null
+++ b/kdeprint/cups/cupsdconf2/portdialog.cpp
@@ -0,0 +1,118 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#include "portdialog.h"
+#include "cupsdconf.h"
+
+#include <qlineedit.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+
+#include <klocale.h>
+
+PortDialog::PortDialog(QWidget *parent, const char *name)
+ : KDialogBase(parent, name, true, QString::null, Ok|Cancel, Ok, true)
+{
+ QWidget *dummy = new QWidget(this);
+ setMainWidget(dummy);
+ address_ = new QLineEdit(dummy);
+ port_ = new QSpinBox(0, 9999, 1, dummy);
+ port_->setValue(631);
+ usessl_ = new QCheckBox(i18n("Use SSL encryption"), dummy);
+
+ QLabel *l1 = new QLabel(i18n("Address:"), dummy);
+ QLabel *l2 = new QLabel(i18n("Port:"), dummy);
+
+ QVBoxLayout *m1 = new QVBoxLayout(dummy, 0, 10);
+ QGridLayout *m2 = new QGridLayout(0, 3, 2, 0, 5);
+ m1->addLayout(m2);
+ m2->addWidget(l1, 0, 0, Qt::AlignRight);
+ m2->addWidget(l2, 1, 0, Qt::AlignRight);
+ m2->addMultiCellWidget(usessl_, 2, 2, 0, 1);
+ m2->addWidget(address_, 0, 1);
+ m2->addWidget(port_, 1, 1);
+
+ setCaption(i18n("Listen To"));
+ resize(250, 100);
+}
+
+QString PortDialog::listenString()
+{
+ QString s;
+ if (usessl_->isChecked())
+ s.append("SSLListen ");
+ else
+ s.append("Listen ");
+ if (!address_->text().isEmpty())
+ s.append(address_->text());
+ else
+ s.append("*");
+ s.append(":").append(port_->text());
+ return s;
+}
+
+void PortDialog::setInfos(CupsdConf *conf)
+{
+ QWhatsThis::add(address_, conf->comments_.toolTip("address"));
+ QWhatsThis::add(port_, conf->comments_.toolTip("port"));
+ QWhatsThis::add(usessl_, conf->comments_.toolTip("usessl"));
+}
+
+QString PortDialog::newListen(QWidget *parent, CupsdConf *conf)
+{
+ PortDialog dlg(parent);
+ dlg.setInfos(conf);
+ if (dlg.exec())
+ {
+ return dlg.listenString();
+ }
+ return QString::null;
+}
+
+QString PortDialog::editListen(const QString& s, QWidget *parent, CupsdConf *conf)
+{
+ PortDialog dlg(parent);
+ dlg.setInfos(conf);
+ int p = s.find(' ');
+ if (p != -1)
+ {
+ dlg.usessl_->setChecked(s.left(p).startsWith("SSL"));
+ QString addr = s.mid(p+1).stripWhiteSpace();
+ int p1 = addr.find(':');
+ if (p1 == -1)
+ {
+ dlg.address_->setText(addr);
+ dlg.port_->setValue(631);
+ }
+ else
+ {
+ dlg.address_->setText(addr.left(p1));
+ dlg.port_->setValue(addr.mid(p1+1).toInt());
+ }
+ }
+ if (dlg.exec())
+ {
+ return dlg.listenString();
+ }
+ return QString::null;
+}