From 63c34dc6c1c6f24f8e83f295adc70fdcc392f8c5 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Fri, 18 Nov 2016 17:35:29 +0100 Subject: StocQt example: Use QtQuick.Layouts instead of anchors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move the StockListView delegate and the top banner to separate files. - Use QtQuick.Layouts in place of anchors for most parts, improving code readability and app scalability. Change-Id: Ie8f13ef261bb343f15e9484bd15f8b94101daeb5 Reviewed-by: Topi Reiniƶ --- .../demos/stocqt/content/StockSettingsPanel.qml | 204 +++++++++------------ 1 file changed, 89 insertions(+), 115 deletions(-) (limited to 'examples/quick/demos/stocqt/content/StockSettingsPanel.qml') diff --git a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml index 0c34e453de..1ac1035789 100644 --- a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml +++ b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml @@ -39,12 +39,11 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQuick.Layouts 1.1 import "." Rectangle { id: root - width: 440 - height: 160 color: "transparent" property bool drawOpenPrice: openButton.buttonEnabled @@ -58,118 +57,93 @@ Rectangle { property string lowColor: "#f30000" property string volumeColor: "#14aaff" - Text { - id: openText - anchors.left: root.left - anchors.top: root.top - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "Open" - } - - Text { - id: closeText - anchors.left: root.left - anchors.top: openText.bottom - anchors.topMargin: 10 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "Close" - } - - Text { - id: highText - anchors.left: root.left - anchors.top: closeText.bottom - anchors.topMargin: 10 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "High" - } - - Text { - id: lowText - anchors.left: root.left - anchors.top: highText.bottom - anchors.topMargin: 10 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "Low" - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: openButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: openText.verticalCenter - color: openColor - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: closeButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: closeText.verticalCenter - color: closeColor - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: highButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: highText.verticalCenter - color: highColor - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: lowButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: lowText.verticalCenter - color: lowColor - } - - CheckBox { - id: openButton - buttonEnabled: false - anchors.verticalCenter: openText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 - } - - CheckBox { - id: closeButton - buttonEnabled: false - anchors.verticalCenter: closeText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 - } - - CheckBox { - id: highButton - buttonEnabled: true - anchors.verticalCenter: highText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 - } - - CheckBox { - id: lowButton - buttonEnabled: true - anchors.verticalCenter: lowText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 + GridLayout { + id: settingsGrid + rows: 5 + columns: 3 + rowSpacing: 4 + anchors.fill: parent + + Item { + Layout.fillHeight: true + Layout.columnSpan: 3 + } + + Text { + id: openText + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "Open" + Layout.leftMargin: 10 + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: openColor + } + CheckBox { + id: openButton + buttonEnabled: false + Layout.rightMargin: 10 + } + + Text { + id: closeText + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "Close" + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: closeColor + } + CheckBox { + id: closeButton + buttonEnabled: false + Layout.rightMargin: 10 + } + + Text { + id: highText + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "High" + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: highColor + } + CheckBox { + id: highButton + buttonEnabled: true + Layout.rightMargin: 10 + } + + Text { + id: lowText + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "Low" + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: lowColor + } + + CheckBox { + id: lowButton + buttonEnabled: true + Layout.rightMargin: 10 + } } } -- cgit v1.2.3