From a3c9f188b4afd9e0a5dfb621b1d995688206400f Mon Sep 17 00:00:00 2001 From: Tomi Korpipaa Date: Thu, 12 Jan 2023 12:28:00 +0200 Subject: Fix qmlscatter example for portrait mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pick-to: 6.2 6.4 6.5 Fixes: QTBUG-110042 Change-Id: If9751ac3402c5ef202e62569b48aae48fe067c27 Reviewed-by: Sami Varanka Reviewed-by: Amr Elsayed Reviewed-by: Tomi Korpipää --- .../qmlscatter/qml/qmlscatter/main.qml | 179 +++++++++++---------- 1 file changed, 93 insertions(+), 86 deletions(-) (limited to 'examples/datavisualization/qmlscatter/qml/qmlscatter') diff --git a/examples/datavisualization/qmlscatter/qml/qmlscatter/main.qml b/examples/datavisualization/qmlscatter/qml/qmlscatter/main.qml index da260298..b2ac523f 100644 --- a/examples/datavisualization/qmlscatter/qml/qmlscatter/main.qml +++ b/examples/datavisualization/qmlscatter/qml/qmlscatter/main.qml @@ -3,9 +3,8 @@ //! [0] import QtQuick -import QtQuick.Layouts import QtQuick.Controls -import QtDataVisualization 1.2 +import QtDataVisualization import "." //! [0] @@ -16,6 +15,8 @@ Item { width: 500 height: 500 + property bool portraitMode: width < height + //! [4] Data { id: seriesData @@ -42,7 +43,8 @@ Item { anchors.bottom: parent.bottom //! [9] width: parent.width - height: parent.height - buttonLayout.height + height: parent.height - (portraitMode ? shadowToggle.implicitHeight * 3 + 25 + : shadowToggle.implicitHeight + 10) //! [8] //! [2] @@ -115,103 +117,108 @@ Item { } } - RowLayout { - id: buttonLayout - Layout.minimumHeight: cameraToggle.height - width: parent.width + //! [7] + Button { + id: shadowToggle + width: portraitMode ? implicitWidth : (mainView.width / 6 - 6) anchors.left: parent.left - spacing: 0 - //! [7] - Button { - id: shadowToggle - Layout.fillHeight: true - Layout.fillWidth: true - text: scatterGraph.shadowsSupported ? "Hide Shadows" : "Shadows not supported" - enabled: scatterGraph.shadowsSupported - onClicked: { - if (scatterGraph.shadowQuality === AbstractGraph3D.ShadowQualityNone) { - scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualitySoftLow; - text = "Hide Shadows"; - } else { - scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualityNone; - text = "Show Shadows"; - } + anchors.top: parent.top + anchors.margins: 5 + text: scatterGraph.shadowsSupported ? "Hide Shadows" : "Shadows not supported" + enabled: scatterGraph.shadowsSupported + onClicked: { + if (scatterGraph.shadowQuality === AbstractGraph3D.ShadowQualityNone) { + scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualitySoftLow; + text = "Hide Shadows"; + } else { + scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualityNone; + text = "Show Shadows"; } } - //! [7] - - Button { - id: smoothToggle - Layout.fillHeight: true - Layout.fillWidth: true - text: "Use Smooth for Series One" - onClicked: { - if (scatterSeries.meshSmooth === false) { - text = "Use Flat for Series One"; - scatterSeries.meshSmooth = true; - } else { - text = "Use Smooth for Series One" - scatterSeries.meshSmooth = false; - } + } + //! [7] + + Button { + id: smoothToggle + width: portraitMode ? implicitWidth : (mainView.width / 6 - 6) + anchors.left: shadowToggle.right + anchors.top: parent.top + anchors.margins: 5 + text: "Use Smooth for Series One" + onClicked: { + if (scatterSeries.meshSmooth === false) { + text = "Use Flat for Series One"; + scatterSeries.meshSmooth = true; + } else { + text = "Use Smooth for Series One" + scatterSeries.meshSmooth = false; } } + } - Button { - id: cameraToggle - Layout.fillHeight: true - Layout.fillWidth: true - text: "Change Camera Placement" - onClicked: { - if (scatterGraph.scene.activeCamera.cameraPreset === Camera3D.CameraPresetFront) { - scatterGraph.scene.activeCamera.cameraPreset = - Camera3D.CameraPresetIsometricRightHigh; - } else { - scatterGraph.scene.activeCamera.cameraPreset = Camera3D.CameraPresetFront; - } + Button { + id: cameraToggle + width: portraitMode ? implicitWidth : (mainView.width / 6 - 6) + anchors.left: portraitMode ? parent.left : smoothToggle.right + anchors.top: portraitMode ? smoothToggle.bottom : parent.top + anchors.margins: 5 + text: "Change Camera Placement" + onClicked: { + if (scatterGraph.scene.activeCamera.cameraPreset === Camera3D.CameraPresetFront) { + scatterGraph.scene.activeCamera.cameraPreset = + Camera3D.CameraPresetIsometricRightHigh; + } else { + scatterGraph.scene.activeCamera.cameraPreset = Camera3D.CameraPresetFront; } } + } - Button { - id: themeToggle - Layout.fillHeight: true - Layout.fillWidth: true - text: "Change Theme" - onClicked: { - if (scatterGraph.theme.type === Theme3D.ThemeArmyBlue) { - scatterGraph.theme = themeIsabelle - } else { - scatterGraph.theme = themeArmyBlue - } - if (scatterGraph.theme.backgroundEnabled === true) { - backgroundToggle.text = "Hide Background"; - } else { - backgroundToggle.text = "Show Background"; - } + Button { + id: themeToggle + width: portraitMode ? implicitWidth : (mainView.width / 6 - 6) + anchors.left: cameraToggle.right + anchors.top: portraitMode ? smoothToggle.bottom : parent.top + anchors.margins: 5 + text: "Change Theme" + onClicked: { + if (scatterGraph.theme.type === Theme3D.ThemeArmyBlue) { + scatterGraph.theme = themeIsabelle + } else { + scatterGraph.theme = themeArmyBlue + } + if (scatterGraph.theme.backgroundEnabled === true) { + backgroundToggle.text = "Hide Background"; + } else { + backgroundToggle.text = "Show Background"; } } + } - Button { - id: backgroundToggle - Layout.fillHeight: true - Layout.fillWidth: true - text: "Hide Background" - onClicked: { - if (scatterGraph.theme.backgroundEnabled === true) { - scatterGraph.theme.backgroundEnabled = false; - text = "Show Background"; - } else { - scatterGraph.theme.backgroundEnabled = true; - text = "Hide Background"; - } + Button { + id: backgroundToggle + width: portraitMode ? implicitWidth : (mainView.width / 6 - 6) + anchors.left: portraitMode ? parent.left : themeToggle.right + anchors.top: portraitMode ? themeToggle.bottom : parent.top + anchors.margins: 5 + text: "Hide Background" + onClicked: { + if (scatterGraph.theme.backgroundEnabled === true) { + scatterGraph.theme.backgroundEnabled = false; + text = "Show Background"; + } else { + scatterGraph.theme.backgroundEnabled = true; + text = "Hide Background"; } } + } - Button { - id: exitButton - Layout.fillHeight: true - Layout.fillWidth: true - text: "Quit" - onClicked: Qt.quit(); - } + Button { + id: exitButton + width: portraitMode ? implicitWidth : (mainView.width / 6 - 6) + anchors.left: backgroundToggle.right + anchors.top: portraitMode ? themeToggle.bottom : parent.top + anchors.margins: 5 + text: "Quit" + onClicked: Qt.quit(); } } -- cgit v1.2.3