summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer
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
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')
-rw-r--r--tools/qmlviewer/main.cpp2
-rw-r--r--tools/qmlviewer/proxysettings.cpp78
-rw-r--r--tools/qmlviewer/proxysettings.h40
-rw-r--r--tools/qmlviewer/proxysettings.ui176
-rw-r--r--tools/qmlviewer/qmlviewer.cpp48
-rw-r--r--tools/qmlviewer/qmlviewer.h2
-rw-r--r--tools/qmlviewer/qmlviewer.pro27
7 files changed, 360 insertions, 13 deletions
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index e5f5e05..b2593a5 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -60,6 +60,8 @@ int main(int argc, char ** argv)
QApplication app(argc, argv);
app.setApplicationName("viewer");
+ app.setOrganizationName("Nokia");
+ app.setOrganizationDomain("nokia.com");
bool frameless = false;
QString fileName;
diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qmlviewer/proxysettings.cpp
new file mode 100644
index 0000000..f232fd1
--- /dev/null
+++ b/tools/qmlviewer/proxysettings.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+
+#include <QIntValidator>
+#include <QSettings>
+
+#include "proxysettings.h"
+
+ProxySettings::ProxySettings (QWidget * parent)
+ : QDialog (parent), Ui::ProxySettings()
+{
+ setupUi (this);
+
+ proxyServerEdit->setInputMask ("000.000.000.000;_");
+ QIntValidator *validator = new QIntValidator (0, 9999, this);
+ proxyPortEdit->setValidator (validator);
+
+ QSettings settings;
+ proxyCheckBox->setChecked (settings.value ("http_proxy/use", 0).toBool ());
+ proxyServerEdit->insert (settings.value ("http_proxy/hostname", "").toString ());
+ proxyPortEdit->insert (settings.value ("http_proxy/port", "80").toString ());
+ usernameEdit->insert (settings.value ("http_proxy/username", "").toString ());
+ passwordEdit->insert (settings.value ("http_proxy/password", "").toString ());
+}
+
+ProxySettings::~ProxySettings()
+{
+}
+
+void ProxySettings::accept ()
+{
+ QSettings settings;
+
+ settings.setValue ("http_proxy/use", proxyCheckBox->isChecked ());
+ settings.setValue ("http_proxy/hostname", proxyServerEdit->text ());
+ settings.setValue ("http_proxy/port", proxyPortEdit->text ());
+ settings.setValue ("http_proxy/username", usernameEdit->text ());
+ settings.setValue ("http_proxy/password", passwordEdit->text ());
+
+ QDialog::accept ();
+}
+
+QNetworkProxy ProxySettings::httpProxy ()
+{
+ QSettings settings;
+ QNetworkProxy proxy;
+
+ bool proxyInUse = settings.value ("http_proxy/use", 0).toBool ();
+ if (proxyInUse) {
+ proxy.setType (QNetworkProxy::HttpProxy);
+ proxy.setHostName (settings.value ("http_proxy/hostname", "").toString ());// "192.168.220.5"
+ proxy.setPort (settings.value ("http_proxy/port", 80).toInt ()); // 8080
+ proxy.setUser (settings.value ("http_proxy/username", "").toString ());
+ proxy.setPassword (settings.value ("http_proxy/password", "").toString ());
+ //QNetworkProxy::setApplicationProxy (proxy);
+ }
+ else {
+ proxy.setType (QNetworkProxy::NoProxy);
+ }
+ return proxy;
+}
+
+bool ProxySettings::httpProxyInUse()
+{
+ QSettings settings;
+ return settings.value ("http_proxy/use", 0).toBool ();
+}
diff --git a/tools/qmlviewer/proxysettings.h b/tools/qmlviewer/proxysettings.h
new file mode 100644
index 0000000..1d4d577
--- /dev/null
+++ b/tools/qmlviewer/proxysettings.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#ifndef PROXYSETTINGS_H
+#define PROXYSETTINGS_H
+
+#include <QDialog>
+#include <QNetworkProxy>
+#include "ui_proxysettings.h"
+
+/**
+*/
+class ProxySettings : public QDialog, public Ui::ProxySettings
+{
+
+Q_OBJECT
+
+public:
+ ProxySettings(QWidget * parent = 0);
+
+ ~ProxySettings();
+
+ static QNetworkProxy httpProxy ();
+ static bool httpProxyInUse ();
+
+public slots:
+ virtual void accept ();
+};
+
+#endif // PROXYSETTINGS_H
diff --git a/tools/qmlviewer/proxysettings.ui b/tools/qmlviewer/proxysettings.ui
new file mode 100644
index 0000000..75fad16
--- /dev/null
+++ b/tools/qmlviewer/proxysettings.ui
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProxySettings</class>
+ <widget class="QDialog" name="ProxySettings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>522</width>
+ <height>280</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>230</y>
+ <width>491</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="proxyPortEdit">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>96</y>
+ <width>363</width>
+ <height>30</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="usernameEdit">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>138</y>
+ <width>363</width>
+ <height>30</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="passwordEdit">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>180</y>
+ <width>363</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ <widget class="QLabel" name="usernameLabel">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>138</y>
+ <width>126</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="proxyServerEdit">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>54</y>
+ <width>363</width>
+ <height>30</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="proxyCheckBox">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>19</y>
+ <width>493</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Use http proxy</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>96</y>
+ <width>126</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Port:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="passwordLabel">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>180</y>
+ <width>126</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="serverAddressLabel">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>54</y>
+ <width>126</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Server Address:</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ProxySettings</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ProxySettings</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
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)
{
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index 914f77d..5b875d7 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -56,6 +56,8 @@ public slots:
void toggleRecordingWithSelection();
void ffmpegFinished(int code);
void setSkin(const QString& skinDirectory);
+ void showProxySettings ();
+ void proxySettingsChanged ();
protected:
virtual void keyPressEvent(QKeyEvent *);
diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro
index a8ccd91..8b9a768 100644
--- a/tools/qmlviewer/qmlviewer.pro
+++ b/tools/qmlviewer/qmlviewer.pro
@@ -1,15 +1,20 @@
-TEMPLATE = app
-CONFIG += qt uic
+TEMPLATE = app
+CONFIG += qt \
+ uic
DESTDIR = ../../bin
-QT += declarative script network sql
-# Input
-HEADERS += qmlviewer.h
-SOURCES += main.cpp qmlviewer.cpp
-
-FORMS = recopts.ui
+QT += declarative \
+ script \
+ network \
+ sql
+# Input
+HEADERS += qmlviewer.h \
+ proxysettings.h
+SOURCES += main.cpp \
+ qmlviewer.cpp \
+ proxysettings.cpp
+FORMS = recopts.ui \
+ proxysettings.ui
include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri)
-
-target.path=$$[QT_INSTALL_BINS]
+target.path = $$[QT_INSTALL_BINS]
INSTALLS += target
-