kmproxywidget.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 "kmproxywidget.h" 00021 00022 #include <tqlineedit.h> 00023 #include <tqlabel.h> 00024 #include <tqcheckbox.h> 00025 #include <tqlayout.h> 00026 #include <tqvalidator.h> 00027 #include <tdelocale.h> 00028 #include <tdeconfig.h> 00029 #include <kcursor.h> 00030 00031 KMProxyWidget::KMProxyWidget(TQWidget *parent, const char *name) 00032 : TQGroupBox(0, Qt::Vertical, i18n("Proxy Settings"), parent, name) 00033 { 00034 TQLabel *m_hostlabel = new TQLabel(i18n("&Host:"), this); 00035 TQLabel *m_portlabel = new TQLabel(i18n("&Port:"), this); 00036 m_useproxy = new TQCheckBox(i18n("&Use proxy server"), this); 00037 m_useproxy->setCursor(KCursor::handCursor()); 00038 m_proxyhost = new TQLineEdit(this); 00039 m_proxyport = new TQLineEdit(this); 00040 m_proxyport->setValidator(new TQIntValidator(TQT_TQOBJECT(m_proxyport))); 00041 m_hostlabel->setBuddy(m_proxyhost); 00042 m_portlabel->setBuddy(m_proxyport); 00043 00044 connect(m_useproxy,TQT_SIGNAL(toggled(bool)),m_proxyhost,TQT_SLOT(setEnabled(bool))); 00045 connect(m_useproxy,TQT_SIGNAL(toggled(bool)),m_proxyport,TQT_SLOT(setEnabled(bool))); 00046 m_proxyhost->setEnabled(false); 00047 m_proxyport->setEnabled(false); 00048 00049 TQGridLayout *lay0 = new TQGridLayout(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(TDEConfig *conf) 00059 { 00060 conf->setGroup("RLPR"); 00061 m_proxyhost->setText(conf->readEntry("ProxyHost",TQString::null)); 00062 m_proxyport->setText(conf->readEntry("ProxyPort",TQString::null)); 00063 m_useproxy->setChecked(!m_proxyhost->text().isEmpty()); 00064 } 00065 00066 void KMProxyWidget::saveConfig(TDEConfig *conf) 00067 { 00068 conf->setGroup("RLPR"); 00069 conf->writeEntry("ProxyHost",(m_useproxy->isChecked() ? m_proxyhost->text() : TQString::null)); 00070 conf->writeEntry("ProxyPort",(m_useproxy->isChecked() ? m_proxyport->text() : TQString::null)); 00071 }