changeset 771:7982f8a04f73

[fix] Bug ID 2916163: The proxy settings a properly used and applied now. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1048 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Sat, 23 Apr 2011 15:42:56 +0000
parents 01f01ab124a1
children e7a901dd454d
files src/UpdateCheckDialog.cpp src/UpdateCheckDialog.h
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/UpdateCheckDialog.cpp	Sat Apr 23 10:43:42 2011 +0000
+++ b/src/UpdateCheckDialog.cpp	Sat Apr 23 15:42:56 2011 +0000
@@ -32,6 +32,7 @@
 #include <QRegExpValidator>
 #include <QNetworkRequest>
 #include <QNetworkReply>
+#include <QNetworkProxy>
 
 /*!
     \class UpdateCheckDialog
@@ -64,14 +65,16 @@
     // Connect the dialogs buttonbox with a button click handler.
     connect( _updateCheckDialogForm->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(handleUpdateCheckDialogButtonClicked(QAbstractButton*)) );
 
-    settings->registerObjectSlot(this, "onProxySettingsChanged()", "ProxyEnabled");
-    settings->registerObjectSlot(this, "onProxySettingsChanged()", "ProxyHostName");
-    settings->registerObjectSlot(this, "onProxySettingsChanged()", "ProxyPort");
-    settings->registerObjectSlot(this, "onProxySettingsChanged()", "ProxyUserName");
-    settings->registerObjectSlot(this, "onProxySettingsChanged()", "ProxyPassword");
+    settings->registerObjectSlot(this, "initProxySettings()", "ProxyEnabled");
+    settings->registerObjectSlot(this, "initProxySettings()", "ProxyHostName");
+    settings->registerObjectSlot(this, "initProxySettings()", "ProxyPort");
+    settings->registerObjectSlot(this, "initProxySettings()", "ProxyUserName");
+    settings->registerObjectSlot(this, "initProxySettings()", "ProxyPassword");
 
     _settings = settings;
 
+	initProxySettings();
+
     // This dialog is always modal.
     setModal(true);
 }
@@ -175,6 +178,7 @@
     // If there was some error while trying to retrieve the update info from server and not cancel was pressed.
     else if ( _roleOfClickedButton != QDialogButtonBox::RejectRole ) {
         QMessageBox::warning(this, tr("Update check error"), tr("There was an error while trying to check for an update! Error was : %1").arg(networkReply->errorString()) );
+		hide();
     }
     _manualUpdateRequested = false;
     networkReply->deleteLater();
@@ -303,12 +307,16 @@
     return versionInteger;
 }
 
-void UpdateCheckDialog::onProxySettingsChanged()
+void UpdateCheckDialog::initProxySettings()
 {
     if ( _settings->getValueByName("ProxyEnabled") == true ) {
-
+		QString proxyHostName = _settings->getValueByName("ProxyHostName").toString();
+		int proxyPort = _settings->getValueByName("ProxyPort").toInt();
+		QString proxyUserName = _settings->getValueByName("ProxyUserName").toString();
+		QString proxyPassword = _settings->getValueByName("ProxyPassword").toString();
+		_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyHostName, proxyPort, proxyUserName, proxyPassword));
     }
     else {
-
+		_networkAccessManager->setProxy(QNetworkProxy());
     }
 }
--- a/src/UpdateCheckDialog.h	Sat Apr 23 10:43:42 2011 +0000
+++ b/src/UpdateCheckDialog.h	Sat Apr 23 15:42:56 2011 +0000
@@ -50,7 +50,7 @@
     void checkResultsOfFetchedPadXMLFile(QNetworkReply *networkReply);
     void handleUpdateCheckDialogButtonClicked(QAbstractButton *clickedButton);
     void updateUpdateCheckProgressBar();
-    void onProxySettingsChanged();
+    void initProxySettings();
 
 private:
 	Ui::UpdateCheckDialog *_updateCheckDialogForm;