Mercurial > hg > octave-nkf
changeset 13607:fd31226d4c3a
Proxy settings can now be configured.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Wed, 17 Aug 2011 00:36:10 +0200 |
parents | ac9ef5a29460 |
children | d3527a9dfe27 |
files | gui/src/MainWindow.cpp gui/src/OctaveGUI.cpp gui/src/ResourceManager.cpp gui/src/ResourceManager.h gui/src/SettingsDialog.cpp |
diffstat | 5 files changed, 61 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -180,6 +180,7 @@ SettingsDialog settingsDialog (this); settingsDialog.exec (); emit settingsChanged (); + ResourceManager::instance ()->updateNetworkSettings (); } void
--- a/gui/src/OctaveGUI.cpp +++ b/gui/src/OctaveGUI.cpp @@ -39,6 +39,7 @@ translator.load (translatorFile); application.installTranslator (&translator); + ResourceManager::instance ()->updateNetworkSettings (); MainWindow w; w.show (); return application.exec ();
--- a/gui/src/ResourceManager.cpp +++ b/gui/src/ResourceManager.cpp @@ -18,6 +18,7 @@ #include "ResourceManager.h" #include <QFile> +#include <QNetworkProxy> ResourceManager ResourceManager::m_singleton; @@ -63,3 +64,43 @@ // TODO: Quick hack to be able to test language files. return QString("../languages/%1.qm").arg(language); } + +void +ResourceManager::updateNetworkSettings () +{ + QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy; + if (m_settings->value ("useProxyServer").toBool ()) + { + QString proxyTypeString = m_settings->value ("proxyType").toString (); + if (proxyTypeString == "NoProxy") + { + proxyType = QNetworkProxy::NoProxy; + } + else if (proxyTypeString == "DefaultProxy") + { + proxyType = QNetworkProxy::DefaultProxy; + } + else if (proxyTypeString == "Socks5Proxy") + { + proxyType = QNetworkProxy::Socks5Proxy; + } + else if (proxyTypeString == "HttpProxy") + { + proxyType = QNetworkProxy::HttpProxy; + } + else if (proxyTypeString == "HttpCachingProxy") + { + proxyType = QNetworkProxy::HttpCachingProxy; + } + else if (proxyTypeString == "FtpCachingProxy") + { + proxyType = QNetworkProxy::FtpCachingProxy; + } + } + + QNetworkProxy proxy; + proxy.setType (proxyType); + proxy.setHostName (m_settings->value ("proxyHostName").toString ()); + proxy.setPort (m_settings->value ("proxyPort").toInt ()); + QNetworkProxy::setApplicationProxy (proxy); +}
--- a/gui/src/ResourceManager.h +++ b/gui/src/ResourceManager.h @@ -37,6 +37,8 @@ QString homePath (); void setSettings (QString file); QString findTranslatorFile (QString language); + void updateNetworkSettings (); + private: ResourceManager ();
--- a/gui/src/SettingsDialog.cpp +++ b/gui/src/SettingsDialog.cpp @@ -22,6 +22,18 @@ ui->showLastModified->setChecked (settings->value ("showLastModified").toBool()); ui->showHiddenFiles->setChecked (settings->value ("showHiddenFiles").toBool()); ui->useAlternatingRowColors->setChecked (settings->value ("useAlternatingRowColors").toBool()); + ui->useProxyServer->setChecked (settings->value ("useProxyServer").toBool ()); + ui->proxyHostName->setText (settings->value ("proxyHostName").toString ()); + + int currentIndex = 0; + QString proxyTypeString = settings->value ("proxyType").toString (); + while ( (currentIndex < ui->proxyType->count ()) && (ui->proxyType->currentText () != proxyTypeString)) + { + currentIndex++; + ui->proxyType->setCurrentIndex (currentIndex); + } + + ui->proxyPort->setText (settings->value ("proxyPort").toString ()); } SettingsDialog::~SettingsDialog () @@ -40,5 +52,9 @@ settings->setValue ("showLastModified", ui->showLastModified->isChecked ()); settings->setValue ("showHiddenFiles", ui->showHiddenFiles->isChecked ()); settings->setValue ("useAlternatingRowColors", ui->useAlternatingRowColors->isChecked ()); + settings->setValue ("useProxyServer", ui->useProxyServer->isChecked ()); + settings->setValue ("proxyType", ui->proxyType->currentText ()); + settings->setValue ("proxyHostName", ui->proxyHostName->text ()); + settings->setValue ("proxyPort", ui->proxyPort->text ()); delete ui; }