1 /*******************************************************************
2 Jan Cermak | johniez | aspt.johniez.com
3 Creative Commons 2.5 Attribution-NonCommercial-NoDerivs 2.5 license
4 http://creativecommons.org/licenses/by-nc-nd/2.5/legalcode
5 *******************************************************************/
9 ProxySet::ProxySet(QWidget *parent) : QWidget(parent) {
10 QSettings settings("config/global.ini", QSettings::IniFormat);
11 useProxy = settings.value("Network/proxyUsed", 0).toInt();
12 QString addrS = settings.value("Network/proxyAddr", "").toString();
13 QString portS = settings.value("Network/proxyPort", "").toString();
14 QString nameS = settings.value("Network/proxyName", "").toString();
15 QString passS = settings.value("Network/proxyPass", "").toString();
17 mainLayout = new QVBoxLayout;
18 proxy = new QCheckBox(tr("Use proxy server"));
19 proxy->setCheckState((Qt::CheckState) useProxy);
20 connect(proxy, SIGNAL(stateChanged(int)), this, SLOT(checkChange(int)));
21 addr = new QLabel(tr("proxy address:"));
22 port = new QLabel(tr("proxy port:"));
23 name = new QLabel(tr("proxy username:"));
24 pass = new QLabel(tr("proxy password:"));
25 addrP = new QLineEdit(addrS);
26 portP = new QLineEdit(portS);
27 nameP = new QLineEdit(nameS);
28 passP = new QLineEdit(passS);
29 passP->setEchoMode(QLineEdit::Password);
30 saveButt = new QPushButton(tr("Save changes"));
31 connect(saveButt, SIGNAL(clicked()), this, SLOT(save()));
32 mainLayout->addWidget(proxy);
33 mainLayout->addWidget(addr);
34 mainLayout->addWidget(addrP);
35 mainLayout->addWidget(port);
36 mainLayout->addWidget(portP);
37 mainLayout->addWidget(name);
38 mainLayout->addWidget(nameP);
39 mainLayout->addWidget(pass);
40 mainLayout->addWidget(passP);
41 mainLayout->addWidget(saveButt);
42 setLayout(mainLayout);
46 ProxySet::~ProxySet() {
60 void ProxySet::save() {
61 QSettings settings("config/global.ini", QSettings::IniFormat);
62 settings.setValue("Network/proxyUsed", useProxy);
63 settings.setValue("Network/proxyAddr", addrP->text());
64 settings.setValue("Network/proxyPort", portP->text());
65 settings.setValue("Network/proxyName", nameP->text());
66 settings.setValue("Network/proxyPass", passP->text());
70 void ProxySet::checkChange(int state) {