Allow using system proxy settings
authorunc0rr
Sat, 22 Sep 2012 19:01:39 +0400
changeset 7702 c8906c3a2aeb
parent 7701 2b9017ffc72f
child 7703 78d2ac987f41
Allow using system proxy settings
QTfrontend/gameuiconfig.cpp
QTfrontend/ui/page/pageoptions.cpp
share/hedgewars/Data/Locale/hedgewars_ar.ts
share/hedgewars/Data/Locale/hedgewars_bg.ts
share/hedgewars/Data/Locale/hedgewars_cs.ts
share/hedgewars/Data/Locale/hedgewars_de.ts
share/hedgewars/Data/Locale/hedgewars_en.ts
share/hedgewars/Data/Locale/hedgewars_es.ts
share/hedgewars/Data/Locale/hedgewars_fi.ts
share/hedgewars/Data/Locale/hedgewars_fr.ts
share/hedgewars/Data/Locale/hedgewars_hu.ts
share/hedgewars/Data/Locale/hedgewars_it.ts
share/hedgewars/Data/Locale/hedgewars_ja.ts
share/hedgewars/Data/Locale/hedgewars_ko.ts
share/hedgewars/Data/Locale/hedgewars_lt.ts
share/hedgewars/Data/Locale/hedgewars_nl.ts
share/hedgewars/Data/Locale/hedgewars_pl.ts
share/hedgewars/Data/Locale/hedgewars_pt_BR.ts
share/hedgewars/Data/Locale/hedgewars_pt_PT.ts
share/hedgewars/Data/Locale/hedgewars_ru.ts
share/hedgewars/Data/Locale/hedgewars_sk.ts
share/hedgewars/Data/Locale/hedgewars_sv.ts
share/hedgewars/Data/Locale/hedgewars_tr_TR.ts
share/hedgewars/Data/Locale/hedgewars_uk.ts
share/hedgewars/Data/Locale/hedgewars_zh_CN.ts
share/hedgewars/Data/Locale/hedgewars_zh_TW.ts
--- a/QTfrontend/gameuiconfig.cpp	Fri Sep 21 23:33:34 2012 +0400
+++ b/QTfrontend/gameuiconfig.cpp	Sat Sep 22 19:01:39 2012 +0400
@@ -24,6 +24,7 @@
 #include <QCryptographicHash>
 #include <QStandardItemModel>
 #include <QNetworkProxy>
+#include <QNetworkProxyFactory>
 
 #include "gameuiconfig.h"
 #include "hwform.h"
@@ -224,30 +225,41 @@
     setValue("misc/autoUpdate", isAutoUpdateEnabled());
 #endif
 
-    int proxyType = Form->ui.pageOptions->cbProxyType->currentIndex();
-    setValue("proxy/type", proxyType);
+    { // setup proxy
+        int proxyType = Form->ui.pageOptions->cbProxyType->currentIndex();
+        setValue("proxy/type", proxyType);
 
-    if(proxyType > 0)
-    {
-        setValue("proxy/host", Form->ui.pageOptions->leProxy->text());
-        setValue("proxy/port", Form->ui.pageOptions->sbProxyPort->value());
-        setValue("proxy/login", Form->ui.pageOptions->leProxyLogin->text());
-        setValue("proxy/password", Form->ui.pageOptions->leProxyPassword->text());
-    }
+        if(proxyType > 1)
+        {
+            setValue("proxy/host", Form->ui.pageOptions->leProxy->text());
+            setValue("proxy/port", Form->ui.pageOptions->sbProxyPort->value());
+            setValue("proxy/login", Form->ui.pageOptions->leProxyLogin->text());
+            setValue("proxy/password", Form->ui.pageOptions->leProxyPassword->text());
+        }
+
+        QNetworkProxy proxy;
 
-    const QNetworkProxy::ProxyType proxyTypesMap[] = {
-        QNetworkProxy::NoProxy
-        , QNetworkProxy::Socks5Proxy
-        , QNetworkProxy::HttpProxy};
+        if(proxyType == 1)
+        {
+            // use system proxy settings
+            proxy = QNetworkProxyFactory::systemProxyForQuery().at(0);
+        } else
+        {
+            const QNetworkProxy::ProxyType proxyTypesMap[] = {
+                QNetworkProxy::NoProxy
+                , QNetworkProxy::NoProxy // dummy value
+                , QNetworkProxy::Socks5Proxy
+                , QNetworkProxy::HttpProxy};
 
-    QNetworkProxy proxy;
-    proxy.setType(proxyTypesMap[proxyType]);
-    proxy.setHostName(Form->ui.pageOptions->leProxy->text());
-    proxy.setPort(Form->ui.pageOptions->sbProxyPort->value());
-    proxy.setUser(Form->ui.pageOptions->leProxyLogin->text());
-    proxy.setPassword(Form->ui.pageOptions->leProxyPassword->text());
-    QNetworkProxy::setApplicationProxy(proxy);
+            proxy.setType(proxyTypesMap[proxyType]);
+            proxy.setHostName(Form->ui.pageOptions->leProxy->text());
+            proxy.setPort(Form->ui.pageOptions->sbProxyPort->value());
+            proxy.setUser(Form->ui.pageOptions->leProxyLogin->text());
+            proxy.setPassword(Form->ui.pageOptions->leProxyPassword->text());
+        }
 
+        QNetworkProxy::setApplicationProxy(proxy);
+    }
 
     { // save colors
         QStandardItemModel * model = DataManager::instance().colorsModel();
--- a/QTfrontend/ui/page/pageoptions.cpp	Fri Sep 21 23:33:34 2012 +0400
+++ b/QTfrontend/ui/page/pageoptions.cpp	Sat Sep 22 19:01:39 2012 +0400
@@ -466,6 +466,7 @@
             cbProxyType = new QComboBox(gbProxy);
             cbProxyType->addItems(QStringList()
                                   << tr("No proxy")
+                                  << tr("System proxy settings")
                                   << tr("Socks5 proxy")
                                   << tr("HTTP proxy"));
             gbLayout->addWidget(cbProxyType, 0, 1);
@@ -626,7 +627,7 @@
 
 void PageOptions::onProxyTypeChanged()
 {
-    bool b = cbProxyType->currentIndex() > 0;
+    bool b = cbProxyType->currentIndex() > 1;
 
     sbProxyPort->setEnabled(b);
     leProxy->setEnabled(b);
--- a/share/hedgewars/Data/Locale/hedgewars_ar.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_ar.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1091,6 +1091,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_bg.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_bg.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1067,6 +1067,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_cs.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_cs.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1079,6 +1079,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_de.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_de.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1161,6 +1161,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_en.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_en.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1107,6 +1107,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_es.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_es.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1161,6 +1161,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_fi.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_fi.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1136,6 +1136,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_fr.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_fr.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1119,6 +1119,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_hu.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_hu.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1085,6 +1085,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_it.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_it.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1137,6 +1137,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_ja.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_ja.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1054,6 +1054,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_ko.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_ko.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -995,6 +995,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_lt.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_lt.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1220,11 +1220,16 @@
     </message>
     <message>
         <location filename="../../../../QTfrontend/ui/page/pageoptions.cpp" line="469"/>
-        <source>Socks5 proxy</source>
+        <source>System proxy settings</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <location filename="../../../../QTfrontend/ui/page/pageoptions.cpp" line="470"/>
+        <source>Socks5 proxy</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../../../../QTfrontend/ui/page/pageoptions.cpp" line="471"/>
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
--- a/share/hedgewars/Data/Locale/hedgewars_nl.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_nl.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1012,6 +1012,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_pl.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_pl.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1189,6 +1189,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_pt_BR.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_pt_BR.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1199,6 +1199,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_pt_PT.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_pt_PT.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1126,6 +1126,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_ru.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_ru.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1137,6 +1137,10 @@
         <source>HTTP proxy</source>
         <translation>HTTP прокси</translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation>Системные настройки</translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
@@ -1914,7 +1918,7 @@
     </message>
     <message>
         <source>Proxy settings</source>
-        <translation type="unfinished"></translation>
+        <translation>Настройки прокси</translation>
     </message>
 </context>
 <context>
@@ -2171,7 +2175,7 @@
     </message>
     <message>
         <source>Format</source>
-        <translation type="unfinished"></translation>
+        <translation>Формат</translation>
     </message>
     <message>
         <source>Audio codec</source>
--- a/share/hedgewars/Data/Locale/hedgewars_sk.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_sk.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1184,6 +1184,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_sv.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_sv.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1153,6 +1153,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_tr_TR.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_tr_TR.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1031,6 +1031,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_uk.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_uk.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1133,6 +1133,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>
--- a/share/hedgewars/Data/Locale/hedgewars_zh_CN.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_zh_CN.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1403,11 +1403,16 @@
     </message>
     <message>
         <location filename="../../../../QTfrontend/ui/page/pageoptions.cpp" line="469"/>
-        <source>Socks5 proxy</source>
+        <source>System proxy settings</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <location filename="../../../../QTfrontend/ui/page/pageoptions.cpp" line="470"/>
+        <source>Socks5 proxy</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../../../../QTfrontend/ui/page/pageoptions.cpp" line="471"/>
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
--- a/share/hedgewars/Data/Locale/hedgewars_zh_TW.ts	Fri Sep 21 23:33:34 2012 +0400
+++ b/share/hedgewars/Data/Locale/hedgewars_zh_TW.ts	Sat Sep 22 19:01:39 2012 +0400
@@ -1057,6 +1057,10 @@
         <source>HTTP proxy</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>System proxy settings</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>PagePlayDemo</name>