Falkon Develop
Cross-platform Qt-based web browser
sbi_proxywidget.cpp
Go to the documentation of this file.
1/* ============================================================
2* StatusBarIcons - Extra icons in statusbar for Falkon
3* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "sbi_proxywidget.h"
19#include "sbi_networkproxy.h"
20#include "ui_sbi_proxywidget.h"
21
23 QWidget(parent),
24 ui(new Ui::SBI_ProxyWidget)
25{
26 ui->setupUi(this);
27}
28
30{
31 ui->proxyServer->clear();
32 ui->proxyPort->clear();
33 ui->proxyUsername->clear();
34 ui->proxyPassword->clear();
35
36 ui->proxyType->setCurrentIndex(0);
37 ui->systemProxy->setChecked(true);
38}
39
41{
42 auto* proxy = new SBI_NetworkProxy;
43
44 proxy->setHostName(ui->proxyServer->text());
45 proxy->setPort(ui->proxyPort->text().toInt());
46 proxy->setUserName(ui->proxyUsername->text());
47 proxy->setPassword(ui->proxyPassword->text());
48
49 if (ui->systemProxy->isChecked()) {
50 proxy->setType(QNetworkProxy::NoProxy);
51 } else {
52 proxy->setType(ui->proxyType->currentIndex() == 0 ? QNetworkProxy::HttpProxy : QNetworkProxy::Socks5Proxy);
53 }
54
55 return proxy;
56}
57
59{
60 ui->proxyServer->setText(proxy.hostName());
61 ui->proxyPort->setText(QString::number(proxy.port()));
62 ui->proxyUsername->setText(proxy.userName());
63 ui->proxyPassword->setText(proxy.password());
64 ui->proxyType->setCurrentIndex(0);
65
66 switch (proxy.type()) {
67 case QNetworkProxy::NoProxy:
68 ui->systemProxy->setChecked(true);
69 break;
70
71 case QNetworkProxy::HttpProxy:
72 ui->manualProxy->setChecked(true);
73 ui->proxyType->setCurrentIndex(0);
74 break;
75
76 case QNetworkProxy::Socks5Proxy:
77 ui->manualProxy->setChecked(true);
78 ui->proxyType->setCurrentIndex(1);
79 break;
80
81 default:
82 break;
83 }
84}
85
87{
88 delete ui;
89}
void setHostName(const QString &hostName)
QString hostName() const
quint16 port() const
QNetworkProxy::ProxyType type() const
QString userName() const
QString password() const
void setProxy(const SBI_NetworkProxy &proxy)
SBI_NetworkProxy * getProxy() const
SBI_ProxyWidget(QWidget *parent=nullptr)