summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/configure.cpp40
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp32
2 files changed, 64 insertions, 8 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index eaa68a2a1c..967e0111e9 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -25,6 +25,13 @@
25#include "browsedirtree.h" 25#include "browsedirtree.h"
26 26
27#include <stdio.h> 27#include <stdio.h>
28#if defined(Q_OS_WIN32)
29#if defined(UNICODE)
30#define _UNICODE
31#endif
32#include <tchar.h>
33#include <windows.h>
34#endif
28 35
29#define DEFAULT_LANG "English (C)" 36#define DEFAULT_LANG "English (C)"
30 37
@@ -37,8 +44,8 @@ Config::Config(QWidget *parent) : QDialog(parent)
37 QRegExp validate("[0-9]*"); 44 QRegExp validate("[0-9]*");
38 proxyValidator->setRegExp(validate); 45 proxyValidator->setRegExp(validate);
39 ui.proxyPort->setValidator(proxyValidator); 46 ui.proxyPort->setValidator(proxyValidator);
40#ifndef __linux 47#if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
41 ui.radioSystemProxy->setEnabled(false); // only on linux for now 48 ui.radioSystemProxy->setEnabled(false); // not on macox for now
42#endif 49#endif
43 // build language list and sort alphabetically 50 // build language list and sort alphabetically
44 QStringList langs = findLanguageFiles(); 51 QStringList langs = findLanguageFiles();
@@ -160,7 +167,7 @@ void Config::setUserSettings(QSettings *user)
160 ui.proxyUser->setText(proxy.userName()); 167 ui.proxyUser->setText(proxy.userName());
161 ui.proxyPass->setText(proxy.password()); 168 ui.proxyPass->setText(proxy.password());
162 169
163 QString proxyType = userSettings->value("proxytype").toString(); 170 QString proxyType = userSettings->value("proxytype", "system").toString();
164 if(proxyType == "manual") ui.radioManualProxy->setChecked(true); 171 if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
165 else if(proxyType == "system") ui.radioSystemProxy->setChecked(true); 172 else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
166 else ui.radioNoProxy->setChecked(true); 173 else ui.radioNoProxy->setChecked(true);
@@ -419,13 +426,36 @@ void Config::setSystemProxy(bool checked)
419 proxy.setHost(ui.proxyHost->text()); 426 proxy.setHost(ui.proxyHost->text());
420 proxy.setPort(ui.proxyPort->text().toInt()); 427 proxy.setPort(ui.proxyPort->text().toInt());
421 // show system values in input box 428 // show system values in input box
422#ifdef __linux 429 QUrl envproxy;
423 QUrl envproxy = QUrl(getenv("http_proxy")); 430#if defined(Q_OS_LINUX)
431 envproxy = QUrl(getenv("http_proxy"));
432#endif
433#if defined(Q_OS_WIN32)
434 HKEY hk;
435 wchar_t proxyval[80];
436 DWORD buflen = 80;
437 long ret;
438
439 ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
440 0, KEY_QUERY_VALUE, &hk);
441 if(ret != ERROR_SUCCESS) return;
442
443 ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
444 if(ret != ERROR_SUCCESS) return;
445
446 RegCloseKey(hk);
447 envproxy = QUrl("http://" + QString::fromWCharArray(proxyval));
448 qDebug() << envproxy;
424 ui.proxyHost->setText(envproxy.host()); 449 ui.proxyHost->setText(envproxy.host());
425 ui.proxyPort->setText(QString("%1").arg(envproxy.port())); 450 ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
426 ui.proxyUser->setText(envproxy.userName()); 451 ui.proxyUser->setText(envproxy.userName());
427 ui.proxyPass->setText(envproxy.password()); 452 ui.proxyPass->setText(envproxy.password());
428#endif 453#endif
454 ui.proxyHost->setText(envproxy.host());
455 ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
456 ui.proxyUser->setText(envproxy.userName());
457 ui.proxyPass->setText(envproxy.password());
458
429 } 459 }
430 else { 460 else {
431 ui.proxyHost->setText(proxy.host()); 461 ui.proxyHost->setText(proxy.host());
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 37ae90323f..00c409fb7b 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -32,9 +32,17 @@
32#include "uninstallwindow.h" 32#include "uninstallwindow.h"
33#include "browseof.h" 33#include "browseof.h"
34 34
35#ifdef __linux 35#if defined(Q_OS_LINUX)
36#include <stdio.h> 36#include <stdio.h>
37#endif 37#endif
38#if defined(Q_OS_WIN32)
39#if defined(UNICODE)
40#define _UNICODE
41#endif
42#include <stdio.h>
43#include <tchar.h>
44#include <windows.h>
45#endif
38 46
39RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) 47RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
40{ 48{
@@ -935,12 +943,30 @@ void RbUtilQt::updateInfo()
935 943
936QUrl RbUtilQt::proxy() 944QUrl RbUtilQt::proxy()
937{ 945{
938 if(userSettings->value("proxytype") == "manual") 946 if(userSettings->value("proxytype", "system").toString() == "manual")
939 return QUrl(userSettings->value("proxy").toString()); 947 return QUrl(userSettings->value("proxy").toString());
940#ifdef __linux 948#if defined(Q_OS_LINUX)
941 else if(userSettings->value("proxytype") == "system") 949 else if(userSettings->value("proxytype") == "system")
942 return QUrl(getenv("http_proxy")); 950 return QUrl(getenv("http_proxy"));
943#endif 951#endif
952#if defined(Q_OS_WIN32)
953 HKEY hk;
954 wchar_t proxyval[80];
955 DWORD buflen = 80;
956 long ret;
957
958 ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
959 0, KEY_QUERY_VALUE, &hk);
960 if(ret != ERROR_SUCCESS) return QUrl("");
961
962 ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
963 if(ret != ERROR_SUCCESS) return QUrl("");
964
965 RegCloseKey(hk);
966 qDebug() << QString::fromWCharArray(proxyval);
967 return QUrl("http://" + QString::fromWCharArray(proxyval));
968
969#endif
944 return QUrl(""); 970 return QUrl("");
945} 971}
946 972