diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-25 22:57:29 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-25 22:57:29 (GMT) |
commit | 314c6ec54e4cb4e2ec936ada7e0a112a60b87832 (patch) | |
tree | a5444e7cae8d40eb549b70dd4473057f6b3cda09 /examples | |
parent | 8e580cebef7128666017ba39d41aa620a1d2eddf (diff) | |
parent | 0094735947164aef8f8e6539c535199b29ed6f4e (diff) | |
download | Qt-314c6ec54e4cb4e2ec936ada7e0a112a60b87832.zip Qt-314c6ec54e4cb4e2ec936ada7e0a112a60b87832.tar.gz Qt-314c6ec54e4cb4e2ec936ada7e0a112a60b87832.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/loader/loader.pro | 2 | ||||
-rw-r--r-- | examples/declarative/loader/main.cpp | 23 | ||||
-rw-r--r-- | examples/declarative/webview/content/SpinSquare.qml | 2 | ||||
-rw-r--r-- | examples/declarative/webview/evalandattach.html | 31 | ||||
-rw-r--r-- | examples/declarative/webview/evalandattach.qml | 55 |
5 files changed, 111 insertions, 2 deletions
diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro index baa5b8c..089eaff 100644 --- a/examples/declarative/loader/loader.pro +++ b/examples/declarative/loader/loader.pro @@ -1,7 +1,7 @@ SOURCES = main.cpp RESOURCES = loader.qrc -QT += script declarative +QT += script declarative network target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp index d018181..68f20d4 100644 --- a/examples/declarative/loader/main.cpp +++ b/examples/declarative/loader/main.cpp @@ -10,8 +10,11 @@ #include <QDebug> #include <QmlContext> #include <QmlComponent> +#include <QmlEngine> #include <qfxview.h> #include <QDebug> +#include <QNetworkDiskCache> +#include <QNetworkAccessManager> QFxView *canvas = 0; @@ -148,6 +151,24 @@ public slots: } }; +class ConfiguredNetworkAccessManager : public QNetworkAccessManager { +public: + ConfiguredNetworkAccessManager() + { + QNetworkDiskCache *cache = new QNetworkDiskCache; + cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-loader-network-cache")); + setCache(cache); + } + + QNetworkReply *createRequest (Operation op, const QNetworkRequest &req, QIODevice * outgoingData) + { + QNetworkRequest request = req; + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + return QNetworkAccessManager::createRequest(op,request,outgoingData); + } +}; + int main(int argc, char *argv[]) { @@ -162,6 +183,8 @@ int main(int argc, char *argv[]) canvas = new QFxView; canvas->setFocusPolicy(Qt::StrongFocus); + canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager); + mw->setCentralWidget(canvas); QMenuBar *mb = mw->menuBar(); diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml index 6d5ada3..95159b6 100644 --- a/examples/declarative/webview/content/SpinSquare.qml +++ b/examples/declarative/webview/content/SpinSquare.qml @@ -2,7 +2,7 @@ import Qt 4.6 Item { property var period : 250 - propert var color : "black" + property var color : "black" id: Root Item { diff --git a/examples/declarative/webview/evalandattach.html b/examples/declarative/webview/evalandattach.html new file mode 100644 index 0000000..c0992bb --- /dev/null +++ b/examples/declarative/webview/evalandattach.html @@ -0,0 +1,31 @@ +<body bgcolor=gray onload="ftext.confirmed.connect (ftext_confirmed); "> + <script> + do_it = function () {var oPressed = document.getElementById('pressed'); + oPressed.innerHTML = 'MouseRegion in QML clicked!';}; + ftext_confirmed = function () { statusText1.text = ftext.text; var oT = document.getElementById('htmlTextInput'); oT.value = ftext.text } + </script> + <table border=1> + <tr> + <td> </td> + <td id='pressed'></td> + </tr> + <tr> + <td><label for='htmlTextInput'>Type something:</label></td> + <td><input type='text' name='htmlTextInput' size='25' id='htmlTextInput' + onfocus="statusText2.text = 'Focus in html text input.'"></td> + </tr> + <tr> + <td><label for='htmlButton'> </label></td> + <td> + <input type='button' id='htmlButton' value='Push' + onclick="var oText = document.getElementById('htmlTextInput'); statusText1.text = oText.value; ftext.text = oText.value" /> + </tr> + </table> + <p> + Below a qml(QFxItem) object inside webkit: + </p> + <object data=content/FieldText.qml TYPE=application/x-qt-plugin id="ftext_id" text="" label="Cool:" width="200" + objectname="ftext"> + </object> +</body> + diff --git a/examples/declarative/webview/evalandattach.qml b/examples/declarative/webview/evalandattach.qml new file mode 100644 index 0000000..bf7f25e --- /dev/null +++ b/examples/declarative/webview/evalandattach.qml @@ -0,0 +1,55 @@ +import Qt 4.6 + +Item { + height: 640 + width: 360 + Text { + id: teksti + text: webView.statusText1 + anchors.top: parent.top + height: 30 + anchors.left: parent.left + width: parent.width/2 + } + + Text { + id: teksti2 + text: webView.statusText2 + anchors.top: parent.top + height: 30 + anchors.left: teksti.right + anchors.right: parent.right + } + + MouseRegion { + anchors.fill: teksti + onClicked: { webView.evaluateJavaScript ("do_it()") } + } + + WebView { + id: webView + property alias statusText1: txt.text + property alias statusText2: txt2.text + anchors.top: teksti.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + focus: true + interactive: true + settings.pluginsEnabled: true + javaScriptWindowObjects: [ + Object { + id: txt + WebView.windowObjectName: "statusText1" + property string text: "Click me!" + }, + Object { + id: txt2 + WebView.windowObjectName: "statusText2" + property string text: "" + } + ] + url: "evalandattach.html" + } + +} |