summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer/qmlviewer.cpp
diff options
context:
space:
mode:
authorTapani Mikola <tapani.mikola@nokia.com>2009-08-10 19:24:30 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-08-13 05:22:38 (GMT)
commit19c25e46e47cc181fb8a633471a528d78e7d85a6 (patch)
tree5a9e4f3421e5bb0a12c6263f8f51e6c1a888b6a6 /tools/qmlviewer/qmlviewer.cpp
parent6bb860bc0ef7a6457382110a92b8eb4745eeb968 (diff)
downloadQt-19c25e46e47cc181fb8a633471a528d78e7d85a6.zip
Qt-19c25e46e47cc181fb8a633471a528d78e7d85a6.tar.gz
Qt-19c25e46e47cc181fb8a633471a528d78e7d85a6.tar.bz2
Adding the possibility to set the http proxy manually.
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r--tools/qmlviewer/qmlviewer.cpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index c1b9eb1..a1e4911 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -43,6 +43,7 @@
#include <QTimer>
#include <QNetworkProxyFactory>
#include <QKeyEvent>
+#include "proxysettings.h"
QT_BEGIN_NAMESPACE
@@ -355,6 +356,11 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
if (flatmenu) flatmenu->addSeparator();
+ QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings"));
+ QAction *proxyAction = new QAction(tr("Http &proxy..."), parent);
+ connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings()));
+ settingsMenu->addAction(proxyAction);
+
QMenu *helpMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Help"));
QAction *aboutAction = new QAction(tr("&About Qt..."), parent);
connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
@@ -371,6 +377,21 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
}
}
+void QmlViewer::showProxySettings()
+{
+ ProxySettings settingsDlg (this);
+
+ connect (&settingsDlg, SIGNAL (accepted()), this, SLOT (proxySettingsChanged ()));
+
+ settingsDlg.exec();
+}
+
+void QmlViewer::proxySettingsChanged()
+{
+ setupProxy ();
+ reload ();
+}
+
void QmlViewer::setScaleSkin()
{
if (scaleSkin)
@@ -899,13 +920,36 @@ void QmlViewer::setupProxy()
public:
virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query)
{
+ QString protocolTag = query.protocolTag();
+ if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
+ QList<QNetworkProxy> ret;
+ ret << httpProxy;
+ return ret;
+ }
return QNetworkProxyFactory::systemProxyForQuery(query);
}
+ void setHttpProxy (QNetworkProxy proxy)
+ {
+ httpProxy = proxy;
+ httpProxyInUse = true;
+ }
+ void unsetHttpProxy ()
+ {
+ httpProxyInUse = false;
+ }
+ private:
+ bool httpProxyInUse;
+ QNetworkProxy httpProxy;
};
QNetworkAccessManager * nam = canvas->engine()->networkAccessManager();
- nam->setProxyFactory(new SystemProxyFactory);
-}
+ SystemProxyFactory *proxyFactory = new SystemProxyFactory;
+ if (ProxySettings::httpProxyInUse())
+ proxyFactory->setHttpProxy(ProxySettings::httpProxy());
+ else
+ proxyFactory->unsetHttpProxy();
+ nam->setProxyFactory(proxyFactory);
+ }
void QmlViewer::setNetworkCacheSize(int size)
{