summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-08-09 22:39:08 +0200
committerSergio Ahumada <sergio.ahumada@digia.com>2013-08-09 22:39:08 +0200
commit6dd954f2b9ce1f241d968d201183f8a80d729e57 (patch)
treeb75782e5137f4c147f721401daa2df30d0a9f1b6
parent4afdb9965bf4a12e657be202c46cc19c65c8f49d (diff)
parent1484cb76315984d4833b510bf9b4e65af4ca696e (diff)
downloadqtsensors-6dd954f2b9ce1f241d968d201183f8a80d729e57.tar.gz
qtsensors-6dd954f2b9ce1f241d968d201183f8a80d729e57.tar.bz2
qtsensors-6dd954f2b9ce1f241d968d201183f8a80d729e57.zip
Merge remote-tracking branch 'origin/release' into stable
Change-Id: Ie0fd1cdeb9cc4eba373852bf2087fcf229a7339c
-rw-r--r--examples/sensors/accelbubble/accelbubble.pro2
-rw-r--r--examples/sensors/accelbubble/accelbubble.qml49
-rw-r--r--examples/sensors/accelbubble/accelbubble.qrc2
-rw-r--r--examples/sensors/accelbubble/content/Bluebubble.svg10
-rw-r--r--examples/sensors/accelbubble/content/Bluebubble2.pngbin12815 -> 0 bytes
-rwxr-xr-xexamples/sensors/accelbubble/doc/images/accelbubble.pngbin0 -> 5181 bytes
-rw-r--r--examples/sensors/accelbubble/doc/src/accelbubble.qdoc8
-rw-r--r--examples/sensors/accelbubble/main.cpp13
-rw-r--r--examples/sensors/sensors.pro4
9 files changed, 58 insertions, 30 deletions
diff --git a/examples/sensors/accelbubble/accelbubble.pro b/examples/sensors/accelbubble/accelbubble.pro
index 3986e4a..d0378bb 100644
--- a/examples/sensors/accelbubble/accelbubble.pro
+++ b/examples/sensors/accelbubble/accelbubble.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = accelbubble
-QT += quick
+QT += quick sensors svg xml
SOURCES = main.cpp
RESOURCES += \
diff --git a/examples/sensors/accelbubble/accelbubble.qml b/examples/sensors/accelbubble/accelbubble.qml
index 726fb6f..8f676dc 100644
--- a/examples/sensors/accelbubble/accelbubble.qml
+++ b/examples/sensors/accelbubble/accelbubble.qml
@@ -38,16 +38,22 @@
**
****************************************************************************/
-import QtQuick 2.0
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+
//! [0]
import QtSensors 5.0
//! [0]
-Rectangle {
- id: mainPage
+ApplicationWindow {
+ title: "Accelerate Bubble"
+ id: mainWindow
width: 320
height: 480
+ visible: true
+
//! [1]
Accelerometer {
@@ -60,45 +66,44 @@ Rectangle {
//! [3]
onReadingChanged: {
- var newx = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .1)
- var newy = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .1)
+ var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .1)
+ var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .1)
- if (newx < 0)
- newx = 0
+ if (newX < 0)
+ newX = 0
- if (newx > mainPage.width - bubble.width)
- newx = mainPage.width - bubble.width
+ if (newX > mainWindow.width - bubble.width)
+ newX = mainWindow.width - bubble.width
- if (newy < 18)
- newy = 18
+ if (newY < 18)
+ newY = 18
- if (newy > mainPage.height - bubble.height)
- newy = mainPage.height - bubble.height
+ if (newY > mainWindow.height - bubble.height)
+ newY = mainWindow.height - bubble.height
- bubble.x = newx
- bubble.y = newy
+ bubble.x = newX
+ bubble.y = newY
}
//! [3]
}
function calcPitch(x,y,z) {
- return Math.atan(y / Math.sqrt(x*x + z*z)) * 57.2957795;
+ return -(Math.atan(y / Math.sqrt(x * x + z * z)) * 57.2957795);
}
function calcRoll(x,y,z) {
- return Math.atan(x / Math.sqrt(y*y + z*z)) * 57.2957795;
+ return -(Math.atan(x / Math.sqrt(y * y + z * z)) * 57.2957795);
}
Image {
id: bubble
- source: "content/Bluebubble2.png"
- property real centerX: parent.width / 2
- property real centerY: parent.height / 2;
+ source: "content/Bluebubble.svg"
+ smooth: true
+ property real centerX: mainWindow.width / 2
+ property real centerY: mainWindow.height / 2
property real bubbleCenter: bubble.width / 2
x: centerX - bubbleCenter
y: centerY - bubbleCenter
- smooth: true
-
Behavior on y {
SmoothedAnimation {
easing.type: Easing.Linear
diff --git a/examples/sensors/accelbubble/accelbubble.qrc b/examples/sensors/accelbubble/accelbubble.qrc
index f3ca2f0..5cb6945 100644
--- a/examples/sensors/accelbubble/accelbubble.qrc
+++ b/examples/sensors/accelbubble/accelbubble.qrc
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>accelbubble.qml</file>
- <file>content/Bluebubble2.png</file>
+ <file>content/Bluebubble.svg</file>
</qresource>
</RCC>
diff --git a/examples/sensors/accelbubble/content/Bluebubble.svg b/examples/sensors/accelbubble/content/Bluebubble.svg
new file mode 100644
index 0000000..d9c406c
--- /dev/null
+++ b/examples/sensors/accelbubble/content/Bluebubble.svg
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny">
+ <defs>
+ <radialGradient id="grad1" cx="0.5" cy="0.7" r="0.7" fx="0.5" fy="0.4">
+ <stop offset="0" style="stop-color:rgb(255,255,255)" />
+ <stop offset="1.5" style="stop-color:rgb(0,102,153)" />
+ </radialGradient>
+ </defs>
+ <circle cx="100" cy="80" r="42" fill="url(#grad1)"/>
+</svg>
diff --git a/examples/sensors/accelbubble/content/Bluebubble2.png b/examples/sensors/accelbubble/content/Bluebubble2.png
deleted file mode 100644
index f96126e..0000000
--- a/examples/sensors/accelbubble/content/Bluebubble2.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/accelbubble/doc/images/accelbubble.png b/examples/sensors/accelbubble/doc/images/accelbubble.png
new file mode 100755
index 0000000..84e876d
--- /dev/null
+++ b/examples/sensors/accelbubble/doc/images/accelbubble.png
Binary files differ
diff --git a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc b/examples/sensors/accelbubble/doc/src/accelbubble.qdoc
index 83c5d3d..0249dd4 100644
--- a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc
+++ b/examples/sensors/accelbubble/doc/src/accelbubble.qdoc
@@ -28,13 +28,15 @@
/*!
\example accelbubble
\title Qt Sensors - Accel Bubble
- \brief The AccelBubble example demonstrates the Legacy Accelerometer QML type.
+ \brief The AccelBubble example demonstrates the Accelerometer QML type.
\ingroup qtsensors-examples
+ \image accelbubble.png
+
\section1 Overview
- Writing a QML application that uses the Legacy Accelerometer QML sensors type requires the following steps:
+ Writing a QML application that uses the Accelerometer QML sensors type requires the following steps:
- Import the Legacy Sensors Declarative module.
+ Import the Sensors Declarative module.
\snippet accelbubble/accelbubble.qml 0
diff --git a/examples/sensors/accelbubble/main.cpp b/examples/sensors/accelbubble/main.cpp
index bc55763..222c896 100644
--- a/examples/sensors/accelbubble/main.cpp
+++ b/examples/sensors/accelbubble/main.cpp
@@ -38,5 +38,14 @@
**
****************************************************************************/
-#include "../stub.h"
-SENSORS_EXAMPLE_MAIN(accelbubble)
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc,argv);
+ QQmlApplicationEngine engine(QUrl("qrc:///accelbubble.qml"));
+
+ return app.exec();
+}
diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro
index 1c3f8d0..6b994b8 100644
--- a/examples/sensors/sensors.pro
+++ b/examples/sensors/sensors.pro
@@ -4,11 +4,13 @@ SUBDIRS += grue
qtHaveModule(quick) {
SUBDIRS += \
- accelbubble \
qmlsensorgestures \
qmlqtsensors \
sensor_explorer \
shakeit
+
+ qtHaveModule(svg): SUBDIRS += \
+ accelbubble
}
qtHaveModule(widgets): SUBDIRS += \