summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-08-28 09:26:38 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-11 10:35:00 (GMT)
commita840cbffba476205eba81f56f40ec32cea6097cc (patch)
tree1c8f0b294884aaedc03e5eb49a4918c0a7d8326f /examples
parente3af89e2630bba68d3f10a33bccdd19bbc46664d (diff)
downloadqtsensors-a840cbffba476205eba81f56f40ec32cea6097cc.tar.gz
Doc: Update Sensor Explorer example
Following changes are made to the example - Use of Qt Quick Controls / TableView to present the sensor information, reducing the example to a single QML file - Updated launcher main.cpp for the QML example - Remove separate example doc for the import subproject - Various fixes to example doc, add a screenshot - Ensure import module + qmldir are built/deployed to correct location Task-number: QTBUG-32881 Task-number: QTBUG-33875 Change-Id: I0ed7c7ebc916fcad6da5e3c66d81be8f348a93e1 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/sensors/sensor_explorer/PropertyList.qml127
-rw-r--r--examples/sensors/sensor_explorer/SensorList.qml146
-rw-r--r--examples/sensors/sensor_explorer/components/ApplicationWindow.qml51
-rw-r--r--examples/sensors/sensor_explorer/components/Button.qml75
-rw-r--r--examples/sensors/sensor_explorer/components/TextField.qml109
-rw-r--r--examples/sensors/sensor_explorer/components/images/button_background_disabled.pngbin579 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/components/images/button_background_normal.pngbin901 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/components/images/button_background_pressed.pngbin334 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/components/images/textfield_background_disabled.pngbin936 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/components/images/textfield_background_normal.pngbin767 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/content/listitem_select.pngbin156 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/doc/images/qtsensors-examples-explorer.pngbin0 -> 39873 bytes
-rw-r--r--examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc71
-rw-r--r--examples/sensors/sensor_explorer/import/import.pro32
-rw-r--r--examples/sensors/sensor_explorer/import/main.cpp3
-rw-r--r--examples/sensors/sensor_explorer/main.cpp26
-rw-r--r--examples/sensors/sensor_explorer/qml.pro16
-rw-r--r--examples/sensors/sensor_explorer/qml.qrc11
-rw-r--r--examples/sensors/sensor_explorer/sensor_explorer.qml282
19 files changed, 251 insertions, 698 deletions
diff --git a/examples/sensors/sensor_explorer/PropertyList.qml b/examples/sensors/sensor_explorer/PropertyList.qml
deleted file mode 100644
index 639acf1..0000000
--- a/examples/sensors/sensor_explorer/PropertyList.qml
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//Import the declarative plugins
-import QtQuick 2.0
-import Explorer 1.0
-
-Rectangle {
- id: controlrect
- anchors.margins: 5
- color: "transparent"
-
- property PropertyInfo selectedItem: null;
- property alias listmodel: itemList.model
-
- onListmodelChanged: {
- itemList.currentIndex = -1;
- selectedItem = null;
- }
-
- Rectangle {
- id: itemListRect
- anchors.fill: parent
- color: "transparent"
-
- ListView {
- id: itemList
- anchors.fill: itemListRect
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- focus: true
- currentIndex: -1
- delegate: itemListDelegate
- clip: true
-
- Rectangle {
- id: scrollbar
- anchors.right: itemList.right
- y: itemList.visibleArea.yPosition * itemList.height
- width: 2
- height: itemList.visibleArea.heightRatio * itemList.height
- color: "black"
- }
- }
-
- Component {
- id: itemListDelegate
-
- Rectangle {
- width: itemList.width
- height: itemNameText.font.pixelSize + 3
- color: "transparent"
-
- Image {
- id: backgroundImage
- anchors.fill: parent
- source: "content/listitem_select.png"
- visible: itemList.currentIndex === index
- }
-
- Text {
- id: itemNameText
- text: model.modelData.name
- font.pixelSize: 15
- color: (itemList.currentIndex === index ? "#1c94ff" : "black")
- }
-
- Text {
- id: itemValueText
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.rightMargin: 5
- font.pixelSize: 15
- horizontalAlignment: Text.AlignRight
- text: model.modelData.value
- color: (itemList.currentIndex === index ? "#1c94ff" : "black")
- }
-
- MouseArea {
- anchors.fill: parent
-
- onClicked: {
- itemList.currentIndex = index;
- selectedItem = model.modelData;
- }
- }
- }
- }
- }
-}
diff --git a/examples/sensors/sensor_explorer/SensorList.qml b/examples/sensors/sensor_explorer/SensorList.qml
deleted file mode 100644
index 9152e42..0000000
--- a/examples/sensors/sensor_explorer/SensorList.qml
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//Import the declarative plugins
-import QtQuick 2.0
-import Explorer 1.0
-
-Rectangle {
- id: controlrect
- anchors.margins: 5
- color: "transparent"
-
- property SensorItem selectedItem: null;
- property alias title: labelTitle.text
- property alias listmodel: itemList.model
-
- onListmodelChanged: {
- itemList.currentIndex = -1;
- selectedItem = null;
- }
-
- Text {
- id: labelTitle
- anchors.top: controlrect.top
- anchors.left: controlrect.left
- anchors.right: controlrect.right
- horizontalAlignment: Text.AlignHCenter
- font.pixelSize: 30
- font.bold: true
- text: ""
- }
-
- Rectangle {
- id: titleLine
- anchors.top: labelTitle.bottom
- anchors.left: controlrect.left
- anchors.right: controlrect.right
- height: 1
- border.width: 1
- border.color: "#999999"
- }
-
- Rectangle {
- id: itemListRect
- anchors.top: titleLine.bottom
- anchors.left: controlrect.left
- anchors.right: controlrect.right
- anchors.bottom: controlrect.bottom
- color: "transparent"
-
- ListView {
- id: itemList
- anchors.fill: itemListRect
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- focus: true
- currentIndex: -1
- delegate: itemListDelegate
- clip: true
-
- Rectangle {
- id: scrollbar
- anchors.right: itemList.right
- y: itemList.visibleArea.yPosition * itemList.height
- width: 2
- height: itemList.visibleArea.heightRatio * itemList.height
- color: "black"
- }
- }
-
- Component {
- id: itemListDelegate
-
- Rectangle {
- width: itemList.width
- height: 30
- color: "transparent"
-
- Image {
- id: backgroundImage
- anchors.fill: parent
- source: "content/listitem_select.png"
- visible: itemList.currentIndex === index
- }
-
- Text {
- id: itemText
- height: 30
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.leftMargin: 5
- text: model.modelData.id
- color: (itemList.currentIndex === index ? "#1c94ff" : "black")
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: 15
- }
-
- MouseArea {
- anchors.fill: parent
-
- onClicked: {
- itemList.currentIndex = index;
- selectedItem = model.modelData;
- }
- }
- }
- }
- }
-}
diff --git a/examples/sensors/sensor_explorer/components/ApplicationWindow.qml b/examples/sensors/sensor_explorer/components/ApplicationWindow.qml
deleted file mode 100644
index 06654e4..0000000
--- a/examples/sensors/sensor_explorer/components/ApplicationWindow.qml
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//Import the declarative plugins
-import QtQuick 2.0
-
-Rectangle {
- id: appWnd
- x: 0
- y: 0
- width: 320
- height: 480
- color: "#ececec"
-}
diff --git a/examples/sensors/sensor_explorer/components/Button.qml b/examples/sensors/sensor_explorer/components/Button.qml
deleted file mode 100644
index 7c1d498..0000000
--- a/examples/sensors/sensor_explorer/components/Button.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//Import the declarative plugins
-import QtQuick 2.0
-
-//Implementation of the Button control.
-Item {
- id: button
- width: 30
- height: 100
- property alias text: innerText.text
- signal clicked
-
- Image {
- id: backgroundImage
- anchors.fill: parent
- source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
- }
-
- Text {
- id: innerText
- anchors.centerIn: parent
- color: "white"
- font.bold: true
- }
-
- //Mouse area to react on click events
- MouseArea {
- anchors.fill: button
- onClicked: { button.clicked();}
- onPressed: {
- backgroundImage.source = "images/button_background_pressed.png" }
- onReleased: {
- backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
- }
- }
-}
diff --git a/examples/sensors/sensor_explorer/components/TextField.qml b/examples/sensors/sensor_explorer/components/TextField.qml
deleted file mode 100644
index 43cf953..0000000
--- a/examples/sensors/sensor_explorer/components/TextField.qml
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//Import the declarative plugins
-import QtQuick 2.0
-
-Item {
- id: textInputFrame
- property alias text: textInput.text
- signal accepted
-
- resources: [
- Component{
- id: cursorA
- Rectangle {
- id: cursor_rect
- width: 2
- height: 20
- color: "#1c94ff"
- visible: textInput.cursorVisible
-
- PropertyAnimation on opacity {
- easing.type: Easing.OutSine
- loops: Animation.Infinite
- from: 0
- to: 1.0
- duration: 750
- }
- }
- }
- ]
-
- Image {
- id: backgroundImage
- anchors.fill: parent
- source: (textInputFrame.enabled ? "images/textfield_background_normal.png" : "images/textfield_background_disabled.png")
- }
-
- TextInput {
- id: textInput
- anchors.fill: parent
- anchors.topMargin: 5
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- activeFocusOnPress: false
-
- cursorDelegate: cursorA
-
- onEnabledChanged: {
- textInput.focus = false;
- }
-
- onAccepted: {
- textInputFrame.accepted();
- }
-
- MouseArea {
- anchors.fill: parent
-
- onClicked: {
- if (!textInput.activeFocus) {
- textInput.forceActiveFocus()
- textInput.openSoftwareInputPanel();
- } else {
- textInput.focus = false;
- }
- }
-
- onPressAndHold: textInput.closeSoftwareInputPanel();
- }
- }
-}
diff --git a/examples/sensors/sensor_explorer/components/images/button_background_disabled.png b/examples/sensors/sensor_explorer/components/images/button_background_disabled.png
deleted file mode 100644
index 62a00b9..0000000
--- a/examples/sensors/sensor_explorer/components/images/button_background_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/components/images/button_background_normal.png b/examples/sensors/sensor_explorer/components/images/button_background_normal.png
deleted file mode 100644
index 1fecad5..0000000
--- a/examples/sensors/sensor_explorer/components/images/button_background_normal.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/components/images/button_background_pressed.png b/examples/sensors/sensor_explorer/components/images/button_background_pressed.png
deleted file mode 100644
index 149529e..0000000
--- a/examples/sensors/sensor_explorer/components/images/button_background_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/components/images/textfield_background_disabled.png b/examples/sensors/sensor_explorer/components/images/textfield_background_disabled.png
deleted file mode 100644
index 98bc601..0000000
--- a/examples/sensors/sensor_explorer/components/images/textfield_background_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/components/images/textfield_background_normal.png b/examples/sensors/sensor_explorer/components/images/textfield_background_normal.png
deleted file mode 100644
index b90b50c..0000000
--- a/examples/sensors/sensor_explorer/components/images/textfield_background_normal.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/content/listitem_select.png b/examples/sensors/sensor_explorer/content/listitem_select.png
deleted file mode 100644
index def234f..0000000
--- a/examples/sensors/sensor_explorer/content/listitem_select.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-explorer.png b/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-explorer.png
new file mode 100644
index 0000000..0976b9f
--- /dev/null
+++ b/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-explorer.png
Binary files differ
diff --git a/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc b/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc
index be04215..b40bf39 100644
--- a/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc
+++ b/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc
@@ -27,30 +27,45 @@
/*!
\example sensor_explorer
- \title Qt Sensors - Explorer QML example
+ \title Qt Sensors - Explorer QML Example
\ingroup qtsensors-examples
+ \brief Demonstrates how to read the meta-data of available sensors.
- \section2 Sensor Explorer in QML
- \brief The Sensor Explorer example demonstrates how to read the meta-data of available sensors.
-
+ \image qtsensors-examples-explorer.png
This example is divided into two parts:
\list
- \li A \l{Sensor Explorer QML Import}{C++ plug-in} that provides QML alternatives for QSensorExplorer, QPropertyInfo and the QSensorItem classes.
- \li A QML Application that uses the QML alternatives to read the sensors meta-data and present it.
+ \li A \l{Sensor Explorer QML Import}{C++ plugin} that provides QML
+ alternatives for \c QSensorExplorer, \c QPropertyInfo and
+ \c QSensorItem C++ classes.
+ \li A \l{Sensor Explorer QML Application}{QML Application} that uses
+ the QML types to read the sensor meta-data and present it.
\endlist
-
- This is a pure QML application that can be run from Qt Creator or directly using the
- \c qmlscene binary. You should install the other C++ plug-in before trying to run
- this example, otherwise it will not find its dependencies.
+ This example is built as an executable with C++ code that runs the QML,
+ but it can also be launched directly using the \c qmlscene tool. You
+ should build the top-level \e sensor_explorer project before trying to
+ run this example or it will not be able to find its dependencies.
\code
- qmlscene main.qml
+ qmlscene -I . sensor_explorer.qml
\endcode
- To write a QML application that will use the Explorer QML type you need to do the following steps:
+ Above, the -I . parameter adds the current directory as a module import
+ path to locate the Explorer QML module.
+
+ \section1 Sensor Explorer QML Import
+
+ The Sensor Explorer QML import defines the \e Explorer QML module,
+ exporting \c QSensorExplorer, \c QPropertyInfo and \c QSensorItem C++
+ classes as QML types. The source code is available in the
+ \c sensor_explorer/import subdirectory.
+
+ \section1 Sensor Explorer QML Application
+
+ To write a QML application that will use the QML types exposed by the
+ Explorer module, following steps are needed:
Import the Explorer 1.0 declarative plugin:
@@ -60,32 +75,30 @@
\snippet sensor_explorer/sensor_explorer.qml 1
- You can retrieve a list of all available sensors using the SensorExplorer:
+ You can retrieve a list of all available sensors using
+ \c SensorExplorer.availableSensors:
\snippet sensor_explorer/sensor_explorer.qml 2
- To retrieve the properties of a SensorItem use:
+ The example uses the returned list as a model to populate a view of
+ available sensors.
+
+ To retrieve the properties of a sensor, use \c SensorItem.properties:
\snippet sensor_explorer/sensor_explorer.qml 3
- Changing a property value can be done like:
+ The property list is used as a model for another view that displays the
+ property names and values.
+
+ It is possible to edit the values of certain sensor properties. Selecting
+ a writable property value will open an editor. \c SensorExplorer QML
+ type allows you to pass a new value for a sensor property value as
+ follows:
\snippet sensor_explorer/sensor_explorer.qml 4
- Starting and stopping a sensor can be done like:
+ Starting and stopping a sensor can be done by setting the
+ \c SensorItem.start property:
\snippet sensor_explorer/sensor_explorer.qml 5
*/
-
-/*!
- \example sensor_explorer/import
- \title Sensor Explorer QML Import
-
- \section2 Sensor Explorer Declarative Plugin
- \brief The Sensor Explorer QML import exports the QSensorExplorer, QPropertyInfo and the QSensorItem class as a QML type.
-
- This example creates the \e {Explorer 1.0} import.
-
- \sa {Qt Sensors - Explorer QML example}
-*/
-
diff --git a/examples/sensors/sensor_explorer/import/import.pro b/examples/sensors/sensor_explorer/import/import.pro
index 85f471c..196c373 100644
--- a/examples/sensors/sensor_explorer/import/import.pro
+++ b/examples/sensors/sensor_explorer/import/import.pro
@@ -2,21 +2,39 @@ TEMPLATE = lib
CONFIG += plugin
TARGET = $$qtLibraryTarget(declarative_explorer)
-TARGETPATH = Explorer
+DESTDIR = ../Explorer
QT += qml sensors
-SOURCES = main.cpp explorer.cpp sensoritem.cpp propertyinfo.cpp
-HEADERS = explorer.h sensoritem.h propertyinfo.h
+SOURCES = \
+ main.cpp \
+ explorer.cpp \
+ sensoritem.cpp \
+ propertyinfo.cpp
-DESTPATH=$$[QT_INSTALL_EXAMPLES]/qtsensors/sensor_explorer/Explorer
+HEADERS = \
+ explorer.h \
+ sensoritem.h \
+ propertyinfo.h
-target.path=$$DESTPATH
-INSTALLS += target
+DESTPATH=$$[QT_INSTALL_EXAMPLES]/sensors/sensor_explorer/Explorer
+target.path=$$DESTPATH
qmldir.files=$$PWD/qmldir
qmldir.path=$$DESTPATH
-INSTALLS += qmldir
+INSTALLS += target qmldir
OTHER_FILES += \
plugin.json qmldir
+
+copyfile = $$PWD/qmldir
+copydest = $$DESTDIR
+
+# On Windows, use backslashes as directory separators
+win32: {
+ copyfile ~= s,/,\\,g
+ copydest ~= s,/,\\,g
+}
+
+# Copy the qmldir file to the same folder as the plugin binary
+QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$copyfile) $$quote($$copydest) $$escape_expand(\\n\\t)
diff --git a/examples/sensors/sensor_explorer/import/main.cpp b/examples/sensors/sensor_explorer/import/main.cpp
index f040fa1..36025e0 100644
--- a/examples/sensors/sensor_explorer/import/main.cpp
+++ b/examples/sensors/sensor_explorer/import/main.cpp
@@ -52,9 +52,8 @@ class SensorExplorerDeclarativeModule : public QQmlExtensionPlugin
public:
virtual void registerTypes(const char *uri)
{
- qDebug() << "SensorExplorerDeclarativeModule::registerTypes(const char *uri)";
-
Q_ASSERT(QLatin1String(uri) == QLatin1String("Explorer"));
+ // @uri Explorer
qmlRegisterType<QSensorExplorer>(uri, 1, 0, "SensorExplorer");
qmlRegisterType<QSensorItem>(uri, 1, 0, "SensorItem");
qmlRegisterType<QPropertyInfo>(uri, 1, 0, "PropertyInfo");
diff --git a/examples/sensors/sensor_explorer/main.cpp b/examples/sensors/sensor_explorer/main.cpp
index 34f5ba3..066f559 100644
--- a/examples/sensors/sensor_explorer/main.cpp
+++ b/examples/sensors/sensor_explorer/main.cpp
@@ -38,5 +38,27 @@
**
****************************************************************************/
-#include "../stub.h"
-SENSORS_EXAMPLE_MAIN(sensor_explorer)
+#include <QtQml>
+#include <QtQuick/QQuickWindow>
+
+#ifndef QT_NO_WIDGETS
+#include <QtWidgets/QApplication>
+#define Application QApplication
+#else
+#include <QtGui/QGuiApplication>
+#define Application QGuiApplication
+#endif
+
+int main(int argc, char *argv[])
+{
+ Application app(argc, argv);
+ QQmlApplicationEngine engine(QUrl("qrc:///sensor_explorer.qml"));
+ QObject *topLevel = engine.rootObjects().value(0);
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
+ if (!window) {
+ qWarning("Error: Your root item has to be a Window.");
+ return -1;
+ }
+ window->show();
+ return app.exec();
+}
diff --git a/examples/sensors/sensor_explorer/qml.pro b/examples/sensors/sensor_explorer/qml.pro
index e9fe0bf..e018830 100644
--- a/examples/sensors/sensor_explorer/qml.pro
+++ b/examples/sensors/sensor_explorer/qml.pro
@@ -1,16 +1,18 @@
TEMPLATE = app
TARGET = sensor_explorer
-QT += quick
+QT += qml quick
+
+qtHaveModule(widgets) {
+ QT += widgets
+}
SOURCES = main.cpp
app.files = \
- $$files(*.qml) \
- icon.png \
- components \
- content
+ sensor_explorer.qml \
+ icon.png
-target.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/sensor_explorer
-app.path = $$[QT_INSTALL_EXAMPLES]/qtsensors/sensor_explorer
+target.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensor_explorer
+app.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensor_explorer
INSTALLS += target app
RESOURCES += \
diff --git a/examples/sensors/sensor_explorer/qml.qrc b/examples/sensors/sensor_explorer/qml.qrc
index 3f11f3e..df6160a 100644
--- a/examples/sensors/sensor_explorer/qml.qrc
+++ b/examples/sensors/sensor_explorer/qml.qrc
@@ -1,16 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>PropertyList.qml</file>
- <file>SensorList.qml</file>
<file>sensor_explorer.qml</file>
- <file>components/ApplicationWindow.qml</file>
- <file>components/TextField.qml</file>
- <file>components/Button.qml</file>
- <file>components/images/button_background_disabled.png</file>
- <file>components/images/textfield_background_normal.png</file>
- <file>components/images/textfield_background_disabled.png</file>
- <file>components/images/button_background_pressed.png</file>
- <file>components/images/button_background_normal.png</file>
- <file>content/listitem_select.png</file>
</qresource>
</RCC>
diff --git a/examples/sensors/sensor_explorer/sensor_explorer.qml b/examples/sensors/sensor_explorer/sensor_explorer.qml
index d396d98..d7f8b8e 100644
--- a/examples/sensors/sensor_explorer/sensor_explorer.qml
+++ b/examples/sensors/sensor_explorer/sensor_explorer.qml
@@ -38,159 +38,177 @@
**
****************************************************************************/
-//Import the declarative plugins
-import QtQuick 2.0
-import "components"
+import QtQuick 2.1
+import QtQuick.Window 2.1
+import QtQuick.Controls 1.0
//! [0]
import Explorer 1.0
//! [0]
-ApplicationWindow {
- id: mainWnd
+Window {
+ id: window
+ width: 320
+ height: 480
+ minimumWidth: 320
+ minimumHeight: 480
-//! [1]
+ //! [1]
SensorExplorer {
id: explorer
}
-//! [1]
-
- SensorList {
- id: sensorList
- anchors.top: parent.top
- anchors.topMargin: 0
- anchors.left: parent.left
- anchors.right: parent.right
- height: 170
- title: "sensor explorer"
-
-//! [2]
- listmodel: explorer.availableSensors
-//! [2]
-
- onSelectedItemChanged: {
- explorer.selectedSensorItem = sensorList.selectedItem;
- startstopButton.text=(explorer.selectedSensorItem !== null ?
- (explorer.selectedSensorItem.start === true ? "Stop" : "Start") : "Start")
- if (sensorList.selectedItem !== null)
-
-//! [3]
- propertyList.listmodel = sensorList.selectedItem.properties;
-//! [3]
- }
- }
+ //! [1]
+
+ Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+
+ GroupBox {
+ title: qsTr("Available Sensors")
+ width: parent.width
+ height: window.height * 0.4
+
+ TableView {
+ id: sensorList
+ anchors.fill: parent
+ //! [2]
+ model: explorer.availableSensors
+ //! [2]
+
+ TableViewColumn { role: "id"; title: qsTr("ID"); width: sensorList.width * 0.7 }
+ TableViewColumn { role: "start"; title: qsTr("Running"); width: sensorList.width * 0.3 - 5 }
+
+ onClicked: {
+ explorer.selectedSensorItem = explorer.availableSensors[row]
+ //! [3]
+ propertyList.model = explorer.selectedSensorItem.properties
+ //! [3]
+ button.update()
+ }
+ }
- Rectangle {
- id: listSplitLine
- anchors.top: sensorList.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- height: 1
- border.width: 1
- border.color: "#999999"
- }
+ Button {
+ id: button
+ anchors.margins: 4
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: sensorList.bottom
+ text: qsTr("Start")
+ enabled: explorer.selectedSensorItem !== null
+
+ function update() {
+ text = (explorer.selectedSensorItem !== null ?
+ (explorer.selectedSensorItem.start === true ?
+ qsTr("Stop") : qsTr("Start")) : qsTr("Start"))
+ }
+
+ onClicked: {
+ if (explorer.selectedSensorItem !== null) {
+ //! [5]
+ if (text === "Start") {
+ explorer.selectedSensorItem.start = true;
+ text = "Stop";
+ }
+ else {
+ explorer.selectedSensorItem.start = false;
+ text = "Start";
+ }
+ //! [5]
+ }
+ }
+ }
- PropertyList {
- id: propertyList
- anchors.top: listSplitLine.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: listPropertyEndLine.top
- anchors.bottomMargin: 5
-
- onSelectedItemChanged: {
- textfield.enabled = (propertyList.selectedItem === null ?
- false : propertyList.selectedItem.isWriteable);
}
- }
- Rectangle {
- id: listPropertyEndLine
- anchors.bottom: startstopButton.top
- anchors.bottomMargin: 5
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- height: 1
- border.width: 1
- border.color: "#999999"
- }
+ GroupBox {
+ title: qsTr("Properties")
+ width: parent.width
+ height: window.height * 0.55
+ enabled: explorer.selectedSensorItem != null
- Button {
- id: startstopButton
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.margins: 5
- text: (explorer.selectedSensorItem !== null ?
- (explorer.selectedSensorItem.start === true ? "Stop" : "Start") : "Start")
- enabled: true
- height: 30
- width: 80
-
- onClicked: {
- if (explorer.selectedSensorItem !== null) {
-//! [5]
- if (text === "Start") {
- explorer.selectedSensorItem.start = true;
- text = "Stop";
- }
- else {
- explorer.selectedSensorItem.start = false;
- text = "Start";
- }
-//! [5]
- }
+ TableView {
+ id: propertyList
+ property PropertyInfo selectedItem: null
- textfield.text = "";
- }
- }
+ anchors.fill: parent
+ TableViewColumn { role: "name"; title: qsTr("Name"); width: propertyList.width * 0.5 }
+ TableViewColumn { role: "value"; title: qsTr("Value"); width: propertyList.width * 0.5 - 5 }
- TextField {
- id: textfield
- anchors.top: parent.bottom
- anchors.topMargin: -35
- anchors.left: startstopButton.right
- anchors.right: parent.right
- anchors.margins: 5
- height: 30
- enabled: false
-
- onEnabledChanged: {
- if (!textfield.enabled) {
- textfield.closeSoftwareInputPanel();
- textfield.anchors.top= parent.bottom;
- textfield.anchors.topMargin= -35;
- textfield.text = "";
- }
- }
+ onClicked: {
+ selectedItem = model[row]
+ }
- onFocusChanged: {
- if (textfield.focus) {
- textfield.anchors.top= sensorList.bottom
- textfield.anchors.topMargin= -15
- }
- else {
- textfield.closeSoftwareInputPanel();
- textfield.anchors.top= parent.bottom;
- textfield.anchors.topMargin= -35;
- }
- }
+ itemDelegate: {
+ if (selectedItem && selectedItem.isWriteable)
+ return editableDelegate;
+ return readOnlyDelegate;
+ }
- onAccepted: {
+ Component {
+ id: readOnlyDelegate
+ Item {
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: styleData.elideMode
+ text: styleData.value
+ color: propertyList.model[styleData.row].isWriteable ?
+ styleData.textColor : Qt.lighter(styleData.textColor)
+ }
+ }
+ }
- if (explorer.selectedSensorItem !== null
- && propertyList.selectedItem !== null) {
-//! [4]
- explorer.selectedSensorItem.changePropertyValue(propertyList.selectedItem, textfield.text);
-//! [4]
- propertyList.focus=true;
+ Component {
+ id: editableDelegate
+ Item {
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: styleData.elideMode
+ text: styleData.value
+ color: styleData.textColor
+ visible: !styleData.selected || styleData.column === 0
+ }
+ Loader { // Initialize text editor lazily to improve performance
+ id: loaderEditor
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ Connections {
+ target: loaderEditor.item
+ onAccepted: {
+ //! [4]
+ explorer.selectedSensorItem.changePropertyValue(propertyList.selectedItem, loaderEditor.item.text);
+ //! [4]
+ }
+ }
+
+ // Load the editor for selected 'Value' cell
+ sourceComponent: (styleData.selected && styleData.column === 1) ? editor : null
+
+ Component {
+ id: editor
+ TextInput {
+ id: textinput
+ color: styleData.textColor
+ text: styleData.value
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: textinput.forceActiveFocus()
+ }
+ }
+ }
+ }
+ }
+ }
}
- textfield.text = "";
}
}
}
-