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 *******************************************************************/
10 * \brief Proxy settings widget constructor.
12 ProxySet::ProxySet(QWidget *parent) : QWidget(parent) {
13 QSettings settings("config/global.ini", QSettings::IniFormat);
14 useProxy = settings.value("Network/proxyUsed", 0).toInt();
15 QString addrS = settings.value("Network/proxyAddr", "").toString();
16 QString portS = settings.value("Network/proxyPort", "").toString();
17 QString nameS = settings.value("Network/proxyName", "").toString();
18 QString passS = settings.value("Network/proxyPass", "").toString();
20 mainLayout = new QVBoxLayout;
21 proxy = new QCheckBox(tr("Use proxy server"));
22 proxy->setCheckState((Qt::CheckState) useProxy);
23 connect(proxy, SIGNAL(stateChanged(int)), this, SLOT(checkChange(int)));
24 addr = new QLabel(tr("proxy address:"));
25 port = new QLabel(tr("proxy port:"));
26 name = new QLabel(tr("proxy username:"));
27 pass = new QLabel(tr("proxy password:"));
28 addrP = new QLineEdit(addrS);
29 portP = new QLineEdit(portS);
30 nameP = new QLineEdit(nameS);
31 passP = new QLineEdit(passS);
32 passP->setEchoMode(QLineEdit::Password);
33 saveButt = new QPushButton(tr("Save changes"));
34 connect(saveButt, SIGNAL(clicked()), this, SLOT(save()));
35 mainLayout->addWidget(proxy);
36 mainLayout->addWidget(addr);
37 mainLayout->addWidget(addrP);
38 mainLayout->addWidget(port);
39 mainLayout->addWidget(portP);
40 mainLayout->addWidget(name);
41 mainLayout->addWidget(nameP);
42 mainLayout->addWidget(pass);
43 mainLayout->addWidget(passP);
44 mainLayout->addWidget(saveButt);
45 setLayout(mainLayout);
50 * \brief Proxy settings destructor.
52 ProxySet::~ProxySet() {
67 * \brief Slot assigned to save button click.
69 void ProxySet::save() {
70 QSettings settings("config/global.ini", QSettings::IniFormat);
71 settings.setValue("Network/proxyUsed", useProxy);
72 settings.setValue("Network/proxyAddr", addrP->text());
73 settings.setValue("Network/proxyPort", portP->text());
74 settings.setValue("Network/proxyName", nameP->text());
75 settings.setValue("Network/proxyPass", passP->text());
80 * \brief Slot assigned to check box changes.
82 void ProxySet::checkChange(int state) {