kmproxywidget.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@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 "kmproxywidget.h"
00021 
00022 #include <qlineedit.h>
00023 #include <qlabel.h>
00024 #include <qcheckbox.h>
00025 #include <qlayout.h>
00026 #include <qvalidator.h>
00027 #include <klocale.h>
00028 #include <kconfig.h>
00029 #include <kcursor.h>
00030 
00031 KMProxyWidget::KMProxyWidget(QWidget *parent, const char *name)
00032 : QGroupBox(0, Qt::Vertical, i18n("Proxy Settings"), parent, name)
00033 {
00034     QLabel  *m_hostlabel = new QLabel(i18n("&Host:"), this);
00035     QLabel  *m_portlabel = new QLabel(i18n("&Port:"), this);
00036     m_useproxy = new QCheckBox(i18n("&Use proxy server"), this);
00037     m_useproxy->setCursor(KCursor::handCursor());
00038     m_proxyhost = new QLineEdit(this);
00039     m_proxyport = new QLineEdit(this);
00040     m_proxyport->setValidator(new QIntValidator(m_proxyport));
00041     m_hostlabel->setBuddy(m_proxyhost);
00042     m_portlabel->setBuddy(m_proxyport);
00043     
00044     connect(m_useproxy,SIGNAL(toggled(bool)),m_proxyhost,SLOT(setEnabled(bool)));
00045     connect(m_useproxy,SIGNAL(toggled(bool)),m_proxyport,SLOT(setEnabled(bool)));
00046     m_proxyhost->setEnabled(false);
00047     m_proxyport->setEnabled(false);
00048 
00049     QGridLayout *lay0 = new QGridLayout(layout(), 3, 2, 10);
00050     lay0->setColStretch(1,1);
00051     lay0->addMultiCellWidget(m_useproxy,0,0,0,1);
00052     lay0->addWidget(m_hostlabel,1,0);
00053     lay0->addWidget(m_portlabel,2,0);
00054     lay0->addWidget(m_proxyhost,1,1);
00055     lay0->addWidget(m_proxyport,2,1);
00056 }
00057 
00058 void KMProxyWidget::loadConfig(KConfig *conf)
00059 {
00060     conf->setGroup("RLPR");
00061     m_proxyhost->setText(conf->readEntry("ProxyHost",QString::null));
00062     m_proxyport->setText(conf->readEntry("ProxyPort",QString::null));
00063     m_useproxy->setChecked(!m_proxyhost->text().isEmpty());
00064 }
00065 
00066 void KMProxyWidget::saveConfig(KConfig *conf)
00067 {
00068     conf->setGroup("RLPR");
00069     conf->writeEntry("ProxyHost",(m_useproxy->isChecked() ? m_proxyhost->text() : QString::null));
00070     conf->writeEntry("ProxyPort",(m_useproxy->isChecked() ? m_proxyport->text() : QString::null));
00071 }
KDE Home | KDE Accessibility Home | Description of Access Keys