forked from SaschaWillems/glCapsViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.cpp
48 lines (39 loc) · 1.12 KB
/
settings.cpp
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
#include "settings.h"
#include "QNetworkProxy"
namespace capsViewer {
using namespace std;
settings::settings()
{
}
settings::~settings()
{
}
void settings::restore()
{
QSettings settings("saschawillems", "glcapsviewer");
submitterName = settings.value("global/submitterName", "").toString();
proxyDns = settings.value("proxy/dns", "").toString();
proxyPort = settings.value("proxy/port", "").toString();
proxyUserName = settings.value("proxy/user", "").toString();
proxyUserPassword = settings.value("proxy/password", "").toString();
proxyEnabled = settings.value("proxy/enabled", "").toBool();
// Apply proxy settings
if (proxyEnabled) {
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(proxyDns);
if (!proxyPort.isEmpty()) {
proxy.setPort(proxyPort.toInt());
}
else {
proxy.setPort(80);
}
proxy.setUser(proxyUserName);
proxy.setPassword(proxyUserPassword);
QNetworkProxy::setApplicationProxy(proxy);
}
else {
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
}
}
}