• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

portdialog.cpp
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "portdialog.h"
00021 #include "cupsdconf.h"
00022 
00023 #include <tqlineedit.h>
00024 #include <tqspinbox.h>
00025 #include <tqcheckbox.h>
00026 #include <tqpushbutton.h>
00027 #include <tqlabel.h>
00028 #include <tqlayout.h>
00029 #include <tqwhatsthis.h>
00030 
00031 #include <tdelocale.h>
00032 
00033 PortDialog::PortDialog(TQWidget *parent, const char *name)
00034     : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true)
00035 {
00036     TQWidget    *dummy = new TQWidget(this);
00037     setMainWidget(dummy);
00038     address_ = new TQLineEdit(dummy);
00039     port_ = new TQSpinBox(0, 9999, 1, dummy);
00040     port_->setValue(631);
00041     usessl_ = new TQCheckBox(i18n("Use SSL encryption"), dummy);
00042 
00043     TQLabel *l1 = new TQLabel(i18n("Address:"), dummy);
00044     TQLabel *l2 = new TQLabel(i18n("Port:"), dummy);
00045 
00046     TQVBoxLayout    *m1 = new TQVBoxLayout(dummy, 0, 10);
00047     TQGridLayout    *m2 = new TQGridLayout(0, 3, 2, 0, 5);
00048     m1->addLayout(TQT_TQLAYOUT(m2));
00049     m2->addWidget(l1, 0, 0, Qt::AlignRight);
00050     m2->addWidget(l2, 1, 0, Qt::AlignRight);
00051     m2->addMultiCellWidget(usessl_, 2, 2, 0, 1);
00052     m2->addWidget(address_, 0, 1);
00053     m2->addWidget(port_, 1, 1);
00054 
00055     setCaption(i18n("Listen To"));
00056     resize(250, 100);
00057 }
00058 
00059 TQString PortDialog::listenString()
00060 {
00061     TQString s;
00062     if (usessl_->isChecked())
00063         s.append("SSLListen ");
00064     else
00065         s.append("Listen ");
00066     if (!address_->text().isEmpty())
00067         s.append(address_->text());
00068     else
00069         s.append("*");
00070     s.append(":").append(port_->text());
00071     return s;
00072 }
00073 
00074 void PortDialog::setInfos(CupsdConf *conf)
00075 {
00076     TQWhatsThis::add(address_, conf->comments_.toolTip("address"));
00077     TQWhatsThis::add(port_, conf->comments_.toolTip("port"));
00078     TQWhatsThis::add(usessl_, conf->comments_.toolTip("usessl"));
00079 }
00080 
00081 TQString PortDialog::newListen(TQWidget *parent, CupsdConf *conf)
00082 {
00083     PortDialog  dlg(parent);
00084     dlg.setInfos(conf);
00085     if (dlg.exec())
00086     {
00087         return dlg.listenString();
00088     }
00089     return TQString::null;
00090 }
00091 
00092 TQString PortDialog::editListen(const TQString& s, TQWidget *parent, CupsdConf *conf)
00093 {
00094     PortDialog  dlg(parent);
00095     dlg.setInfos(conf);
00096     int p = s.find(' ');
00097     if (p != -1)
00098     {
00099         dlg.usessl_->setChecked(s.left(p).startsWith("SSL"));
00100         TQString    addr = s.mid(p+1).stripWhiteSpace();
00101         int p1 = addr.find(':');
00102         if (p1 == -1)
00103         {
00104             dlg.address_->setText(addr);
00105             dlg.port_->setValue(631);
00106         }
00107         else
00108         {
00109             dlg.address_->setText(addr.left(p1));
00110             dlg.port_->setValue(addr.mid(p1+1).toInt());
00111         }
00112     }
00113     if (dlg.exec())
00114     {
00115         return dlg.listenString();
00116     }
00117     return TQString::null;
00118 }

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.