Falkon Develop
Cross-platform Qt-based web browser
sbi_networkproxy.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_networkproxy.h"
19
20#include <QSettings>
21
23 : m_port(0)
24 , m_type(QNetworkProxy::NoProxy)
25{
26}
27
29{
30 return m_port == other.m_port && m_hostname == other.m_hostname &&
31 m_username == other.m_username && m_password == other.m_password &&
32 m_type == other.m_type;
33}
34
36{
37 return m_port;
38}
39
40void SBI_NetworkProxy::setPort(quint16 port)
41{
42 m_port = port;
43}
44
46{
47 return m_hostname;
48}
49
50void SBI_NetworkProxy::setHostName(const QString &hostName)
51{
52 m_hostname = hostName;
53}
54
56{
57 return m_username;
58}
59
60void SBI_NetworkProxy::setUserName(const QString &userName)
61{
62 m_username = userName;
63}
64
66{
67 return m_password;
68}
69
70void SBI_NetworkProxy::setPassword(const QString &password)
71{
72 m_password = password;
73}
74
75QNetworkProxy::ProxyType SBI_NetworkProxy::type() const
76{
77 return m_type;
78}
79
80void SBI_NetworkProxy::setType(QNetworkProxy::ProxyType type)
81{
82 m_type = type;
83}
84
85void SBI_NetworkProxy::loadFromSettings(const QSettings &settings)
86{
87 m_hostname = settings.value("HostName", QString()).toString();
88 m_port = settings.value("Port", 0).toInt();
89 m_username = settings.value("Username", QString()).toString();
90 m_password = settings.value("Password", QString()).toString();
91
92 m_type = QNetworkProxy::ProxyType(settings.value("ProxyType", QNetworkProxy::NoProxy).toInt());
93}
94
95void SBI_NetworkProxy::saveToSettings(QSettings &settings) const
96{
97 settings.setValue("HostName", m_hostname);
98 settings.setValue("Port", m_port);
99 settings.setValue("Username", m_username);
100 settings.setValue("Password", m_password);
101
102 settings.setValue("ProxyType", m_type);
103}
104
106{
107 QNetworkProxy proxy;
108 proxy.setHostName(m_hostname);
109 proxy.setPort(m_port);
110 proxy.setUser(m_username);
111 proxy.setPassword(m_password);
112 proxy.setType(m_type);
113
114 QNetworkProxy::setApplicationProxy(proxy);
115}
void setHostName(const QString &hostName)
void setPort(quint16 port)
void saveToSettings(QSettings &settings) const
QString hostName() const
void setPassword(const QString &password)
quint16 port() const
QNetworkProxy::ProxyType type() const
void setUserName(const QString &userName)
QString userName() const
bool operator==(const SBI_NetworkProxy &other) const
void loadFromSettings(const QSettings &settings)
QString password() const
void setType(QNetworkProxy::ProxyType type)