Settings (dialog): add HTTP+SOCKS5 radio buttons and use them
authorgregor herrmann <gregor@toastfreeware.priv.at>
Thu, 5 Oct 2017 12:13:38 +0000 (14:13 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Thu, 5 Oct 2017 16:31:15 +0000 (18:31 +0200)
Hopefully fixes: #59

src/gui/settingsdialog.cpp
src/gui/settingsdialog.ui

index dfaff36..3e29c78 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "appsettings.h"
 #include <QDebug>
-#include <QNetworkProxy>
 
 SettingsDialog::SettingsDialog(QWidget *aParent)
     : QDialog(aParent)
@@ -36,6 +35,9 @@ void SettingsDialog::loadDialogData()
     // deserialize dialog data
     address->setText(AppSettings::proxyAddress());
     port->setValue(AppSettings::proxyPort());
+    const int proxyType = AppSettings::proxyType(); // QNetworkProxy::ProxyType
+    proxyTypeHTTP->setChecked(proxyType != 1); // HTTP=3, but we enable it by default, i.e. unless SOCKS5=1
+    proxyTypeSOCKS5->setChecked(proxyType == 1);
     directConnection->setChecked(AppSettings::isDirectConnection());
     proxyWidget->setDisabled(directConnection->isChecked());
 }
@@ -46,7 +48,7 @@ void SettingsDialog::saveDialogData()
     // serialize dialog data
     AppSettings::setProxyAddress(address->text());
     AppSettings::setProxyPort(port->value());
-    AppSettings::setProxyType(QNetworkProxy::HttpProxy); // TODO!!
+    AppSettings::setProxyType(proxyTypeHTTP->isChecked() ? 3 : proxyTypeSOCKS5->isChecked() ? 1 : 0);
     AppSettings::setDirectConnection(directConnection->isChecked());
 }
 
index 89c78db..579ffd6 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>500</width>
-    <height>152</height>
+    <height>168</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -29,7 +29,7 @@
    <item>
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
-      <string>HTTP proxy settings</string>
+      <string>Proxy settings</string>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout_2">
       <item>
       </item>
       <item>
        <widget class="QFrame" name="proxyWidget">
-        <layout class="QHBoxLayout" name="horizontalLayout_3">
+        <layout class="QVBoxLayout" name="verticalLayout_3">
          <item>
-          <widget class="QLabel" name="label">
-           <property name="text">
-            <string>Address: </string>
-           </property>
-          </widget>
+          <layout class="QHBoxLayout" name="horizontalLayout">
+           <item>
+            <widget class="QLabel" name="label">
+             <property name="text">
+              <string>Address: </string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLineEdit" name="address"/>
+           </item>
+           <item>
+            <widget class="QLabel" name="label_2">
+             <property name="text">
+              <string>Port:</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QSpinBox" name="port">
+             <property name="alignment">
+              <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+             </property>
+             <property name="minimum">
+              <number>1</number>
+             </property>
+             <property name="maximum">
+              <number>65535</number>
+             </property>
+             <property name="value">
+              <number>8080</number>
+             </property>
+            </widget>
+           </item>
+          </layout>
          </item>
          <item>
-          <widget class="QLineEdit" name="address"/>
-         </item>
-         <item>
-          <widget class="QLabel" name="label_2">
-           <property name="text">
-            <string>Port:</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QSpinBox" name="port">
-           <property name="alignment">
-            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-           </property>
-           <property name="minimum">
-            <number>1</number>
-           </property>
-           <property name="maximum">
-            <number>65535</number>
-           </property>
-           <property name="value">
-            <number>8080</number>
-           </property>
-          </widget>
+          <layout class="QHBoxLayout" name="horizontalLayout_2">
+           <item>
+            <widget class="QLabel" name="label_3">
+             <property name="text">
+              <string>Proxy type:</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QRadioButton" name="proxyTypeHTTP">
+             <property name="text">
+              <string>HTTP proxy</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QRadioButton" name="proxyTypeSOCKS5">
+             <property name="text">
+              <string>SOCKS5 proxy</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
          </item>
         </layout>
        </widget>