summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/examples.pro4
-rw-r--r--examples/qmllegend/doc/src/qmllegend.qdoc67
-rw-r--r--examples/qmllegend/main.cpp49
-rw-r--r--examples/qmllegend/qml/qmllegend/data.qml79
-rw-r--r--examples/qmllegend/qml/qmllegend/legenditem.qml118
-rw-r--r--examples/qmllegend/qml/qmllegend/main.qml238
-rw-r--r--examples/qmllegend/qml/qmllegend/newbutton.qml52
-rw-r--r--examples/qmllegend/qmllegend.desktop11
-rw-r--r--examples/qmllegend/qmllegend.pro25
-rw-r--r--examples/qmllegend/qmllegend.qrc8
-rw-r--r--examples/qmllegend/qmllegend64.pngbin0 -> 3400 bytes
-rw-r--r--examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp81
-rw-r--r--examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h33
-rw-r--r--examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri180
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp5
-rw-r--r--src/datavisualization/theme/q3dtheme.h2
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp8
17 files changed, 958 insertions, 2 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index d126b26d..73db54c0 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -2,7 +2,9 @@ TEMPLATE = subdirs
SUBDIRS += qmlbars \
qmlscatter \
qmlsurface \
- qmlcustominput
+ qmlcustominput \
+ qmllegend
+
!android: {
SUBDIRS += bars \
custominput \
diff --git a/examples/qmllegend/doc/src/qmllegend.qdoc b/examples/qmllegend/doc/src/qmllegend.qdoc
new file mode 100644
index 00000000..6d210ffb
--- /dev/null
+++ b/examples/qmllegend/doc/src/qmllegend.qdoc
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+/*!
+ \example qmllegend
+ \title Qt Quick 2 Legend Example
+ \ingroup qtdatavisualization_examples
+ \brief Showing graph legend in a QML application.
+
+ The Qt Quick 2 legend example shows how to make an interactive legend for a graph.
+
+ \image qmllegend-example.png
+
+ The interesting thing about this example is displaying the legend. We'll concentrate on
+ thate and skip explaining the basic functionality - for
+ more detailed QML example documentation, see \l{Qt Quick 2 Scatter Example}.
+
+ \section1 Legend
+
+ The legend is simply a column of custom \c LegendItem items inside a transparent rectangle.
+ Each item is supplied with a series and the graph theme:
+
+ \snippet ../examples/qmllegend/qml/qmllegend/main.qml 0
+
+ The legend items consist of a marker rectangle, which indicates the color of the series,
+ and a text field, which shows the name of the series. The colors we get from the series and
+ the theme supplied at legend item initialization:
+
+ \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 0
+ \dots 4
+ \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 1
+
+ We want the legend to be interactive, so we add additional logic to enable selection of a
+ series by clicking on a legend item, as well as highlighting the legend item corresponding
+ to the selected series.
+
+ The highlight depends on the selection state of the series, so we define two states, which
+ follow the Bar3DSeries::selectedBar property and adjust the \c legendItem color appropriately:
+
+ \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 3
+
+ To make the legend item interactive, we define a MouseArea to detect clicks on it and adjust
+ the series selection accordingly:
+
+ \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 2
+
+ The \c previousSelection used above is another custom property of \c LegendItem, which we update
+ whenever selection changes on the series. This way we remember the last selected bar of
+ each series:
+
+ \snippet ../examples/qmllegend/qml/qmllegend/legenditem.qml 4
+*/
diff --git a/examples/qmllegend/main.cpp b/examples/qmllegend/main.cpp
new file mode 100644
index 00000000..9a07695a
--- /dev/null
+++ b/examples/qmllegend/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include <QtDataVisualization/qutils.h>
+#include <QtGui/QGuiApplication>
+#include "qtquick2applicationviewer.h"
+#ifdef Q_OS_ANDROID
+#include <QDir>
+#include <QQmlEngine>
+#endif
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QtQuick2ApplicationViewer viewer;
+
+ // Enable antialiasing
+ viewer.setFormat(QtDataVisualization::qDefaultSurfaceFormat());
+
+#ifdef Q_OS_ANDROID
+ viewer.addImportPath(QString::fromLatin1("assets:/qml"));
+ viewer.engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(),
+ QString::fromLatin1("lib")));
+#endif
+ viewer.setTitle(QStringLiteral("Legend example"));
+
+ viewer.setSource(QUrl("qrc:/qml/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/qmllegend/qml/qmllegend/data.qml b/examples/qmllegend/qml/qmllegend/data.qml
new file mode 100644
index 00000000..3f15b8cd
--- /dev/null
+++ b/examples/qmllegend/qml/qmllegend/data.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtDataVisualization 1.0
+
+Item {
+ property alias model: dataModel
+
+ ListModel {
+ id: dataModel
+ ListElement{ year: "2010"; month: "Jan"; s1: "-14"; s2: "-15"; s3: "-15" }
+ ListElement{ year: "2010"; month: "Feb"; s1: "-15"; s2: "-16"; s3: "-9" }
+ ListElement{ year: "2010"; month: "Mar"; s1: "-7"; s2: "-4"; s3: "-2" }
+ ListElement{ year: "2010"; month: "Apr"; s1: "3"; s2: "2"; s3: "2" }
+ ListElement{ year: "2010"; month: "May"; s1: "7"; s2: "9"; s3: "10" }
+ ListElement{ year: "2010"; month: "Jun"; s1: "12"; s2: "13"; s3: "22" }
+ ListElement{ year: "2010"; month: "Jul"; s1: "18"; s2: "19"; s3: "24" }
+ ListElement{ year: "2010"; month: "Aug"; s1: "15"; s2: "13"; s3: "16" }
+ ListElement{ year: "2010"; month: "Sep"; s1: "6"; s2: "3"; s3: "4" }
+ ListElement{ year: "2010"; month: "Oct"; s1: "1"; s2: "2"; s3: "-2" }
+ ListElement{ year: "2010"; month: "Nov"; s1: "-2"; s2: "-5"; s3: "-6" }
+ ListElement{ year: "2010"; month: "Dec"; s1: "-3"; s2: "-3"; s3: "-9" }
+
+ ListElement{ year: "2011"; month: "Jan"; s1: "-12"; s2: "-11"; s3: "-14" }
+ ListElement{ year: "2011"; month: "Feb"; s1: "-13"; s2: "-12"; s3: "-10" }
+ ListElement{ year: "2011"; month: "Mar"; s1: "-6"; s2: "-4"; s3: "-3" }
+ ListElement{ year: "2011"; month: "Apr"; s1: "0"; s2: "1"; s3: "3" }
+ ListElement{ year: "2011"; month: "May"; s1: "4"; s2: "12"; s3: "11" }
+ ListElement{ year: "2011"; month: "Jun"; s1: "9"; s2: "17"; s3: "23" }
+ ListElement{ year: "2011"; month: "Jul"; s1: "15"; s2: "22"; s3: "25" }
+ ListElement{ year: "2011"; month: "Aug"; s1: "12"; s2: "15"; s3: "12" }
+ ListElement{ year: "2011"; month: "Sep"; s1: "2"; s2: "4"; s3: "7" }
+ ListElement{ year: "2011"; month: "Oct"; s1: "-2"; s2: "4"; s3: "-4" }
+ ListElement{ year: "2011"; month: "Nov"; s1: "-4"; s2: "-8"; s3: "-5" }
+ ListElement{ year: "2011"; month: "Dec"; s1: "-6"; s2: "-6"; s3: "-7" }
+
+ ListElement{ year: "2012"; month: "Jan"; s1: "-10"; s2: "-19"; s3: "-11" }
+ ListElement{ year: "2012"; month: "Feb"; s1: "-11"; s2: "-17"; s3: "-4" }
+ ListElement{ year: "2012"; month: "Mar"; s1: "-6"; s2: "-3"; s3: "-1" }
+ ListElement{ year: "2012"; month: "Apr"; s1: "5"; s2: "1"; s3: "2" }
+ ListElement{ year: "2012"; month: "May"; s1: "9"; s2: "12"; s3: "13" }
+ ListElement{ year: "2012"; month: "Jun"; s1: "11"; s2: "16"; s3: "26" }
+ ListElement{ year: "2012"; month: "Jul"; s1: "18"; s2: "20"; s3: "23" }
+ ListElement{ year: "2012"; month: "Aug"; s1: "19"; s2: "12"; s3: "12" }
+ ListElement{ year: "2012"; month: "Sep"; s1: "9"; s2: "1"; s3: "3" }
+ ListElement{ year: "2012"; month: "Oct"; s1: "-3"; s2: "2"; s3: "-1" }
+ ListElement{ year: "2012"; month: "Nov"; s1: "-5"; s2: "-4"; s3: "-3" }
+ ListElement{ year: "2012"; month: "Dec"; s1: "-7"; s2: "-2"; s3: "-4" }
+
+ ListElement{ year: "2013"; month: "Jan"; s1: "-18"; s2: "-19"; s3: "-19" }
+ ListElement{ year: "2013"; month: "Feb"; s1: "-17"; s2: "-19"; s3: "-12" }
+ ListElement{ year: "2013"; month: "Mar"; s1: "-9"; s2: "-6"; s3: "-5" }
+ ListElement{ year: "2013"; month: "Apr"; s1: "0"; s2: "0"; s3: "0" }
+ ListElement{ year: "2013"; month: "May"; s1: "4"; s2: "7"; s3: "9" }
+ ListElement{ year: "2013"; month: "Jun"; s1: "9"; s2: "11"; s3: "18" }
+ ListElement{ year: "2013"; month: "Jul"; s1: "13"; s2: "15"; s3: "20" }
+ ListElement{ year: "2013"; month: "Aug"; s1: "10"; s2: "11"; s3: "13" }
+ ListElement{ year: "2013"; month: "Sep"; s1: "3"; s2: "1"; s3: "2" }
+ ListElement{ year: "2013"; month: "Oct"; s1: "0"; s2: "1"; s3: "-4" }
+ ListElement{ year: "2013"; month: "Nov"; s1: "-5"; s2: "-6"; s3: "-5" }
+ ListElement{ year: "2013"; month: "Dec"; s1: "-6"; s2: "-7"; s3: "-10" }
+ }
+}
diff --git a/examples/qmllegend/qml/qmllegend/legenditem.qml b/examples/qmllegend/qml/qmllegend/legenditem.qml
new file mode 100644
index 00000000..c423d0d3
--- /dev/null
+++ b/examples/qmllegend/qml/qmllegend/legenditem.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import QtQuick.Window 2.1
+import QtDataVisualization 1.0
+
+Rectangle {
+ //! [0]
+ property Theme3D theme
+ property Bar3DSeries series
+ //! [0]
+ property point previousSelection
+
+ id: legendItem
+ state: "unselected"
+
+ //! [1]
+ RowLayout {
+ anchors.fill: parent
+ spacing: 0
+ clip: true
+ Item {
+ id: markerSpace
+ Layout.minimumWidth: 20
+ Layout.minimumHeight: 20
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.alignment: Qt.AlignVCenter
+ Rectangle {
+ x: parent.x + parent.width / 4
+ y: parent.y + parent.height / 4
+ width: parent.width / 2
+ height: width
+ border.color: "black"
+ color: series.baseColor
+ }
+ }
+ Item {
+ height: markerSpace.height
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.alignment: Qt.AlignVCenter
+ Layout.minimumWidth: 100
+ Text {
+ anchors.fill: parent
+ text: series.name
+ verticalAlignment: Text.AlignVCenter
+ clip: true
+ color: theme.labelTextColor
+ font: theme.font
+ }
+ }
+ }
+ //! [1]
+
+ //! [2]
+ MouseArea {
+ id: mouseArea
+ anchors.fill: legendItem
+ onClicked: {
+ if (legendItem.state === "selected") {
+ series.selectedBar = series.invalidSelectionPosition
+ } else {
+ series.selectedBar = previousSelection
+ }
+ }
+ }
+ //! [2]
+
+ //! [4]
+ Connections {
+ target: series
+ onSelectedBarChanged: {
+ if (position != series.invalidSelectionPosition) {
+ previousSelection = position
+ }
+ }
+ }
+ //! [4]
+
+ //! [3]
+ states: [
+ State {
+ name: "selected"
+ when: series.selectedBar != series.invalidSelectionPosition
+ PropertyChanges {
+ target: legendItem
+ color: series.singleHighlightColor
+ }
+ },
+ State {
+ name: "unselected"
+ when: series.selectedBar == series.invalidSelectionPosition
+ PropertyChanges {
+ target: legendItem
+ color: theme.labelBackgroundColor
+ }
+ }
+ ]
+ //! [3]
+}
diff --git a/examples/qmllegend/qml/qmllegend/main.qml b/examples/qmllegend/qml/qmllegend/main.qml
new file mode 100644
index 00000000..bab4c652
--- /dev/null
+++ b/examples/qmllegend/qml/qmllegend/main.qml
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import QtDataVisualization 1.0
+import "."
+
+Item {
+ id: mainView
+ width: 800
+ height: 600
+
+ property int buttonLayoutHeight: 180;
+
+ Data {
+ id: graphData
+ }
+
+ Theme3D {
+ id: firstTheme
+ type: Theme3D.ThemeQt
+ }
+
+ Theme3D {
+ id: secondTheme
+ type: Theme3D.ThemeEbony
+ }
+
+ Item {
+ id: dataView
+ anchors.top: buttonLayout.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ Bars3D {
+ id: barGraph
+ anchors.fill: parent
+ selectionMode: AbstractGraph3D.SelectionItemAndRow
+ scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeftHigh
+ theme: firstTheme
+
+ Bar3DSeries {
+ id: station1
+ name: "Station 1"
+ itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel"
+
+ ItemModelBarDataProxy {
+ itemModel: graphData.model
+ rowRole: "year"
+ columnRole: "month"
+ valueRole: "s1"
+ }
+ }
+ Bar3DSeries {
+ id: station2
+ name: "Station 2"
+ itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel"
+
+ ItemModelBarDataProxy {
+ itemModel: graphData.model
+ rowRole: "year"
+ columnRole: "month"
+ valueRole: "s2"
+ }
+ }
+ Bar3DSeries {
+ id: station3
+ name: "Station 3"
+ itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel"
+
+ ItemModelBarDataProxy {
+ itemModel: graphData.model
+ rowRole: "year"
+ columnRole: "month"
+ valueRole: "s2"
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ property int legendLocation: 3
+
+ id: legendPanel
+ width: 200
+ height: 100
+ border.color: barGraph.theme.labelTextColor
+ border.width: 2
+ color: "#00000000" // Transparent
+
+ //! [0]
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.margins: parent.border.width
+ spacing: 0
+ clip: true
+ LegendItem {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ series: station1
+ theme: barGraph.theme
+ onColorChanged: legendPanel.relayout()
+ }
+ LegendItem {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ series: station2
+ theme: barGraph.theme
+ onColorChanged: legendPanel.relayout()
+ }
+ LegendItem {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ series: station3
+ theme: barGraph.theme
+ onColorChanged: legendPanel.relayout()
+ }
+ }
+ //! [0]
+
+ function relayout() {
+ // Workaround for a layout bug that causes transparent colors to use black background
+ // instead of what is actually under the items if just the color changes.
+ // Forcing a relayout by adjusting layout's available area fixes the background.
+ var originalWidth = border.width
+ border.width = originalWidth + 1
+ border.width = originalWidth
+ }
+
+ states: [
+ State {
+ name: "topleft"
+ when: legendPanel.legendLocation === 1
+ AnchorChanges {
+ target: legendPanel
+ anchors.top: dataView.top
+ anchors.bottom: undefined
+ anchors.left: dataView.left
+ anchors.right: undefined
+ }
+ },
+ State {
+ name: "topright"
+ when: legendPanel.legendLocation === 2
+ AnchorChanges {
+ target: legendPanel
+ anchors.top: dataView.top
+ anchors.bottom: undefined
+ anchors.left: undefined
+ anchors.right: dataView.right
+ }
+ },
+ State {
+ name: "bottomleft"
+ when: legendPanel.legendLocation === 3
+ AnchorChanges {
+ target: legendPanel
+ anchors.top: undefined
+ anchors.bottom: dataView.bottom
+ anchors.left: dataView.left
+ anchors.right: undefined
+ }
+ },
+ State {
+ name: "bottomright"
+ when: legendPanel.legendLocation === 4
+ AnchorChanges {
+ target: legendPanel
+ anchors.top: undefined
+ anchors.bottom: dataView.bottom
+ anchors.left: undefined
+ anchors.right: dataView.right
+ }
+ }
+ ]
+ }
+
+ RowLayout {
+ id: buttonLayout
+ Layout.minimumHeight: themeToggle.height
+ width: parent.width
+ anchors.left: parent.left
+ spacing: 0
+
+ NewButton {
+ id: themeToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Change Theme"
+ onClicked: {
+ if (barGraph.theme === firstTheme) {
+ barGraph.theme = secondTheme
+ } else {
+ barGraph.theme = firstTheme
+ }
+ }
+ }
+ NewButton {
+ id: repositionLegend
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Reposition Legend"
+ onClicked: {
+ if (legendPanel.legendLocation === 4) {
+ legendPanel.legendLocation = 1
+ } else {
+ legendPanel.legendLocation++
+ }
+ }
+ }
+ NewButton {
+ id: exitButton
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Quit"
+ onClicked: Qt.quit(0);
+ }
+ }
+
+}
diff --git a/examples/qmllegend/qml/qmllegend/newbutton.qml b/examples/qmllegend/qml/qmllegend/newbutton.qml
new file mode 100644
index 00000000..e44c9d1a
--- /dev/null
+++ b/examples/qmllegend/qml/qmllegend/newbutton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ id: newbutton
+
+ property alias text: buttonText.text
+
+ signal clicked
+
+ implicitWidth: buttonText.implicitWidth + 5
+ implicitHeight: buttonText.implicitHeight + 10
+
+ Button {
+ id: buttonText
+ width: parent.width
+ height: parent.height
+
+ style: ButtonStyle {
+ label: Component {
+ Text {
+ text: buttonText.text
+ clip: true
+ wrapMode: Text.WordWrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ }
+ }
+ }
+ onClicked: newbutton.clicked()
+ }
+}
diff --git a/examples/qmllegend/qmllegend.desktop b/examples/qmllegend/qmllegend.desktop
new file mode 100644
index 00000000..6ad68edd
--- /dev/null
+++ b/examples/qmllegend/qmllegend.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Terminal=false
+Name=qmllegend
+Exec=/opt/qmllegend/bin/qmllegend
+Icon=qmllegend64
+X-Window-Icon=
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
diff --git a/examples/qmllegend/qmllegend.pro b/examples/qmllegend/qmllegend.pro
new file mode 100644
index 00000000..d896e7ac
--- /dev/null
+++ b/examples/qmllegend/qmllegend.pro
@@ -0,0 +1,25 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += widgets
+
+# Add more folders to ship with the application, here
+folder_01.source = qml/qmllegend
+folder_01.target = qml
+DEPLOYMENTFOLDERS = folder_01
+
+# Additional import path used to resolve QML modules in Creator's code model
+QML_IMPORT_PATH =
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+# Please do not modify the following two lines. Required for deployment.
+include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
+qtcAddDeployment()
+
+RESOURCES += qmllegend.qrc
+
+OTHER_FILES += doc/src/* \
+ doc/images/*
diff --git a/examples/qmllegend/qmllegend.qrc b/examples/qmllegend/qmllegend.qrc
new file mode 100644
index 00000000..6496cfdb
--- /dev/null
+++ b/examples/qmllegend/qmllegend.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/qml">
+ <file alias="Data.qml">qml/qmllegend/data.qml</file>
+ <file alias="main.qml">qml/qmllegend/main.qml</file>
+ <file alias="LegendItem.qml">qml/qmllegend/legenditem.qml</file>
+ <file alias="NewButton.qml">qml/qmllegend/newbutton.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/qmllegend/qmllegend64.png b/examples/qmllegend/qmllegend64.png
new file mode 100644
index 00000000..707d5c4e
--- /dev/null
+++ b/examples/qmllegend/qmllegend64.png
Binary files differ
diff --git a/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp
new file mode 100644
index 00000000..10709d7a
--- /dev/null
+++ b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.cpp
@@ -0,0 +1,81 @@
+// checksum 0x4f6f version 0x90005
+/*
+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#include "qtquick2applicationviewer.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+class QtQuick2ApplicationViewerPrivate
+{
+ QString mainQmlFile;
+ friend class QtQuick2ApplicationViewer;
+ static QString adjustPath(const QString &path);
+};
+
+QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path)
+{
+#if defined(Q_OS_MAC)
+ if (!QDir::isAbsolutePath(path))
+ return QString::fromLatin1("%1/../Resources/%2")
+ .arg(QCoreApplication::applicationDirPath(), path);
+#elif defined(Q_OS_BLACKBERRY)
+ if (!QDir::isAbsolutePath(path))
+ return QString::fromLatin1("app/native/%1").arg(path);
+#elif !defined(Q_OS_ANDROID)
+ QString pathInInstallDir =
+ QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+ pathInInstallDir =
+ QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+#endif
+ return path;
+}
+
+QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
+ : QQuickView(parent)
+ , d(new QtQuick2ApplicationViewerPrivate())
+{
+ connect(engine(), SIGNAL(quit()), SLOT(close()));
+ setResizeMode(QQuickView::SizeRootObjectToView);
+}
+
+QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer()
+{
+ delete d;
+}
+
+void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file)
+{
+ d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
+#ifdef Q_OS_ANDROID
+ setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
+#else
+ setSource(QUrl::fromLocalFile(d->mainQmlFile));
+#endif
+}
+
+void QtQuick2ApplicationViewer::addImportPath(const QString &path)
+{
+ engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
+}
+
+void QtQuick2ApplicationViewer::showExpanded()
+{
+#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)
+ showFullScreen();
+#else
+ show();
+#endif
+}
diff --git a/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h
new file mode 100644
index 00000000..cf66f140
--- /dev/null
+++ b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.h
@@ -0,0 +1,33 @@
+// checksum 0xfde6 version 0x90005
+/*
+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#ifndef QTQUICK2APPLICATIONVIEWER_H
+#define QTQUICK2APPLICATIONVIEWER_H
+
+#include <QtQuick/QQuickView>
+
+class QtQuick2ApplicationViewer : public QQuickView
+{
+ Q_OBJECT
+
+public:
+ explicit QtQuick2ApplicationViewer(QWindow *parent = 0);
+ virtual ~QtQuick2ApplicationViewer();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+
+ void showExpanded();
+
+private:
+ class QtQuick2ApplicationViewerPrivate *d;
+};
+
+#endif // QTQUICK2APPLICATIONVIEWER_H
diff --git a/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri
new file mode 100644
index 00000000..e5f7990f
--- /dev/null
+++ b/examples/qmllegend/qtquick2applicationviewer/qtquick2applicationviewer.pri
@@ -0,0 +1,180 @@
+# checksum 0x7b0d version 0x90005
+# This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+# The code below adds the QtQuick2ApplicationViewer to the project and handles
+# the activation of QML debugging.
+# It is recommended not to modify this file, since newer versions of Qt Creator
+# may offer an updated version of it.
+
+QT += qml quick
+
+SOURCES += $$PWD/qtquick2applicationviewer.cpp
+HEADERS += $$PWD/qtquick2applicationviewer.h
+INCLUDEPATH += $$PWD
+# This file was generated by an application wizard of Qt Creator.
+# The code below handles deployment to Android and Maemo, aswell as copying
+# of the application data to shadow build directories on desktop.
+# It is recommended not to modify this file, since newer versions of Qt Creator
+# may offer an updated version of it.
+
+defineTest(qtcAddDeployment) {
+for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ greaterThan(QT_MAJOR_VERSION, 4) {
+ itemsources = $${item}.files
+ } else {
+ itemsources = $${item}.sources
+ }
+ $$itemsources = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath= $$eval($${deploymentfolder}.target)
+ export($$itemsources)
+ export($$itempath)
+ DEPLOYMENT += $$item
+}
+
+MAINPROFILEPWD = $$PWD
+
+android-no-sdk {
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ itemfiles = $${item}.files
+ $$itemfiles = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target)
+ export($$itemfiles)
+ export($$itempath)
+ INSTALLS += $$item
+ }
+
+ target.path = /data/user/qt
+
+ export(target.path)
+ INSTALLS += target
+} else:android {
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ itemfiles = $${item}.files
+ $$itemfiles = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath = /assets/$$eval($${deploymentfolder}.target)
+ export($$itemfiles)
+ export($$itempath)
+ INSTALLS += $$item
+ }
+
+ x86 {
+ target.path = /libs/x86
+ } else: armeabi-v7a {
+ target.path = /libs/armeabi-v7a
+ } else {
+ target.path = /libs/armeabi
+ }
+
+ export(target.path)
+ INSTALLS += target
+} else:win32 {
+ copyCommand =
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
+ source = $$replace(source, /, \\)
+ sourcePathSegments = $$split(source, \\)
+ target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
+ target = $$replace(target, /, \\)
+ target ~= s,\\\\\\.?\\\\,\\,
+ !isEqual(source,$$target) {
+ !isEmpty(copyCommand):copyCommand += &&
+ isEqual(QMAKE_DIR_SEP, \\) {
+ copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
+ } else {
+ source = $$replace(source, \\\\, /)
+ target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
+ target = $$replace(target, \\\\, /)
+ copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
+ }
+ }
+ }
+ !isEmpty(copyCommand) {
+ copyCommand = @echo Copying application data... && $$copyCommand
+ copydeploymentfolders.commands = $$copyCommand
+ first.depends = $(first) copydeploymentfolders
+ export(first.depends)
+ export(copydeploymentfolders.commands)
+ QMAKE_EXTRA_TARGETS += first copydeploymentfolders
+ }
+} else:unix {
+ maemo5 {
+ desktopfile.files = $${TARGET}.desktop
+ desktopfile.path = /usr/share/applications/hildon
+ icon.files = $${TARGET}64.png
+ icon.path = /usr/share/icons/hicolor/64x64/apps
+ } else:!isEmpty(MEEGO_VERSION_MAJOR) {
+ desktopfile.files = $${TARGET}_harmattan.desktop
+ desktopfile.path = /usr/share/applications
+ icon.files = $${TARGET}80.png
+ icon.path = /usr/share/icons/hicolor/80x80/apps
+ } else { # Assumed to be a Desktop Unix
+ copyCommand =
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
+ source = $$replace(source, \\\\, /)
+ macx {
+ target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
+ } else {
+ target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
+ }
+ target = $$replace(target, \\\\, /)
+ sourcePathSegments = $$split(source, /)
+ targetFullPath = $$target/$$last(sourcePathSegments)
+ targetFullPath ~= s,/\\.?/,/,
+ !isEqual(source,$$targetFullPath) {
+ !isEmpty(copyCommand):copyCommand += &&
+ copyCommand += $(MKDIR) \"$$target\"
+ copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
+ }
+ }
+ !isEmpty(copyCommand) {
+ copyCommand = @echo Copying application data... && $$copyCommand
+ copydeploymentfolders.commands = $$copyCommand
+ first.depends = $(first) copydeploymentfolders
+ export(first.depends)
+ export(copydeploymentfolders.commands)
+ QMAKE_EXTRA_TARGETS += first copydeploymentfolders
+ }
+ }
+ !isEmpty(target.path) {
+ installPrefix = $${target.path}
+ } else {
+ installPrefix = /opt/$${TARGET}
+ }
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ itemfiles = $${item}.files
+ $$itemfiles = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
+ export($$itemfiles)
+ export($$itempath)
+ INSTALLS += $$item
+ }
+
+ !isEmpty(desktopfile.path) {
+ export(icon.files)
+ export(icon.path)
+ export(desktopfile.files)
+ export(desktopfile.path)
+ INSTALLS += icon desktopfile
+ }
+
+ isEmpty(target.path) {
+ target.path = $${installPrefix}/bin
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export (ICON)
+export (INSTALLS)
+export (DEPLOYMENT)
+export (LIBS)
+export (QMAKE_EXTRA_TARGETS)
+}
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index b7440c84..3426a715 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.cpp
@@ -29,6 +29,7 @@
#include "qtouch3dinputhandler.h"
#include "qabstract3dseries_p.h"
#include "thememanager_p.h"
+#include "q3dtheme_p.h"
#include "q3dscene_p.h"
#include "q3dscene.h"
@@ -57,7 +58,9 @@ Abstract3DController::Abstract3DController(QRect initialViewport, Q3DScene *scen
m_scene = new Q3DScene;
// Set initial theme
- setActiveTheme(new Q3DTheme(Q3DTheme::ThemeQt));
+ Q3DTheme *defaultTheme = new Q3DTheme(Q3DTheme::ThemeQt);
+ defaultTheme->d_ptr->setDefaultTheme(true);
+ setActiveTheme(defaultTheme);
m_scene->d_ptr->setViewport(initialViewport);
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
index e023c76e..69b22124 100644
--- a/src/datavisualization/theme/q3dtheme.h
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -178,6 +178,8 @@ protected:
friend class ThemeManager;
friend class Abstract3DRenderer;
friend class Bars3DController;
+ friend class AbstractDeclarative;
+ friend class Abstract3DController;
private:
Q_DISABLE_COPY(Q3DTheme)
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index e573b6f2..d04301cf 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -18,6 +18,7 @@
#include "abstractdeclarative_p.h"
#include "qvalue3daxis.h"
+#include "declarativetheme_p.h"
#include <QThread>
#include <QGuiApplication>
@@ -99,6 +100,13 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller)
{
Q_ASSERT(controller);
m_controller = controller;
+
+ // Reset default theme, as the default C++ theme is Q3DTheme, not DeclarativeTheme3D.
+ DeclarativeTheme3D *defaultTheme = new DeclarativeTheme3D;
+ defaultTheme->d_ptr->setDefaultTheme(true);
+ defaultTheme->setType(Q3DTheme::ThemeQt);
+ m_controller->setActiveTheme(defaultTheme);
+
QObject::connect(m_controller, &Abstract3DController::shadowQualityChanged, this,
&AbstractDeclarative::handleShadowQualityChange);
QObject::connect(m_controller, &Abstract3DController::activeInputHandlerChanged, this,