From d98362f5e9cc5c07cff5f32672aa448b0a0c31c4 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Fri, 2 May 2014 14:14:55 +0300 Subject: StocQt demo improvement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Along with general demo improvements, this task implements the new layout to the StocQt demo. Also few bugs on the functionality are corrected, like drawing the stock graph on right way and initial values reset on stock model when changing active stock. Task-number: QTBUG-38254 Change-Id: I9d3387ed0e3f23512b8e60c70246589c10237818 Reviewed-by: Topi Reiniƶ --- examples/quick/demos/stocqt/content/StockView.qml | 92 ++++++++--------------- 1 file changed, 30 insertions(+), 62 deletions(-) (limited to 'examples/quick/demos/stocqt/content/StockView.qml') diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml index ce55fdf3d3..e503cbea04 100644 --- a/examples/quick/demos/stocqt/content/StockView.qml +++ b/examples/quick/demos/stocqt/content/StockView.qml @@ -39,95 +39,63 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQuick.Window 2.1 Rectangle { id: root width: 320 height: 480 - color: "#423A2F" + color: "transparent" property var stock: null property var stocklist: null - property var settings: null - signal listViewClicked signal settingsClicked function update() { - if (!settings) - return; - chart.endDate = settings.endDate chart.update() } Rectangle { - color: "#272822" + id: mainRect + color: "transparent" anchors.fill: parent - radius: 20 - Image { - source: "images/icon-items.png" + StockInfo { + id: stockInfo anchors.left: parent.left anchors.leftMargin: 10 anchors.top: parent.top - anchors.topMargin: 10 - MouseArea { - anchors.fill: parent - onClicked: listViewClicked() - } - } - Image { - source: "images/icon-settings.png" - anchors.right: parent.right - anchors.rightMargin: 10 - anchors.top: parent.top - anchors.topMargin: 10 - MouseArea { - anchors.fill: parent - onClicked: settingsClicked() - } - } - - Text { - id: desc - anchors.left: parent.left - anchors.leftMargin: 20 - anchors.top: parent.top - anchors.topMargin: 40 - color: "#564c3A" - font.pointSize: 15 - text: root.stock.stockId + " - " + root.stock.stockName + anchors.topMargin: 15 + height: 160 + anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left + anchors.rightMargin: 20 + stock: root.stock } - Text { - id: price - anchors.left: parent.left - anchors.leftMargin: 20 - anchors.top: desc.bottom - anchors.topMargin: 5 - color: "#ECC089" - font.pointSize: 30 - text: root.stock.stockPrice + StockChart { + id: chart + anchors.bottom: Screen.primaryOrientation === Qt.PortraitOrientation ? settingsPanel.top : parent.bottom + anchors.bottomMargin: 20 + anchors.top : Screen.primaryOrientation === Qt.PortraitOrientation ? stockInfo.bottom : parent.top + anchors.topMargin: 20 + anchors.right: parent.right + anchors.rightMargin: 20 + width: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.width - 40 : 0.6 * parent.width + stockModel: root.stock + settings: settingsPanel } - Text { - id: priceChange + StockSettingsPanel { + id: settingsPanel anchors.left: parent.left anchors.leftMargin: 20 - anchors.top: price.bottom - anchors.topMargin: 5 - color: root.stock.stockPriceChanged < 0 ? "#A43D3D" : "#679B3A" - font.pointSize: 25 - text: root.stock.stockPriceChanged + " (" + Math.abs(Math.round(root.stock.stockPriceChanged/(root.stock.stockPrice - root.stock.stockPriceChanged) * 100))/100 +"%)" - } - - StockChart { - id: chart + anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left + anchors.rightMargin: 20 anchors.bottom: parent.bottom - anchors.top : priceChange.bottom - anchors.topMargin: 30 - width: parent.width - stockModel: root.stock - settings: root.settings + onDrawOpenPriceChanged: root.update() + onDrawClosePriceChanged: root.update(); + onDrawHighPriceChanged: root.update(); + onDrawLowPriceChanged: root.update(); } } } -- cgit v1.2.3