kmproxywidget.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
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 }
 
This file is part of the documentation for kdeprint Library Version 3.2.0.