summaryrefslogtreecommitdiffstats
path: root/kdeprint/rlpr/kmproxywidget.cpp
blob: 49e6f29eefb149cc7871522ae70f6bbaf36b83ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *  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 "kmproxywidget.h"

#include <tqlineedit.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqvalidator.h>
#include <klocale.h>
#include <kconfig.h>
#include <kcursor.h>

KMProxyWidget::KMProxyWidget(TQWidget *parent, const char *name)
: TQGroupBox(0, Qt::Vertical, i18n("Proxy Settings"), parent, name)
{
	QLabel	*m_hostlabel = new TQLabel(i18n("&Host:"), this);
	QLabel	*m_portlabel = new TQLabel(i18n("&Port:"), this);
	m_useproxy = new TQCheckBox(i18n("&Use proxy server"), this);
	m_useproxy->setCursor(KCursor::handCursor());
	m_proxyhost = new TQLineEdit(this);
	m_proxyport = new TQLineEdit(this);
	m_proxyport->setValidator(new TQIntValidator(m_proxyport));
	m_hostlabel->setBuddy(m_proxyhost);
	m_portlabel->setBuddy(m_proxyport);
	
	connect(m_useproxy,TQT_SIGNAL(toggled(bool)),m_proxyhost,TQT_SLOT(setEnabled(bool)));
	connect(m_useproxy,TQT_SIGNAL(toggled(bool)),m_proxyport,TQT_SLOT(setEnabled(bool)));
	m_proxyhost->setEnabled(false);
	m_proxyport->setEnabled(false);

	QGridLayout	*lay0 = new TQGridLayout(tqlayout(), 3, 2, 10);
	lay0->setColStretch(1,1);
	lay0->addMultiCellWidget(m_useproxy,0,0,0,1);
	lay0->addWidget(m_hostlabel,1,0);
	lay0->addWidget(m_portlabel,2,0);
	lay0->addWidget(m_proxyhost,1,1);
	lay0->addWidget(m_proxyport,2,1);
}

void KMProxyWidget::loadConfig(KConfig *conf)
{
	conf->setGroup("RLPR");
	m_proxyhost->setText(conf->readEntry("ProxyHost",TQString::null));
	m_proxyport->setText(conf->readEntry("ProxyPort",TQString::null));
	m_useproxy->setChecked(!m_proxyhost->text().isEmpty());
}

void KMProxyWidget::saveConfig(KConfig *conf)
{
	conf->setGroup("RLPR");
	conf->writeEntry("ProxyHost",(m_useproxy->isChecked() ? m_proxyhost->text() : TQString::null));
	conf->writeEntry("ProxyPort",(m_useproxy->isChecked() ? m_proxyport->text() : TQString::null));
}