diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-04-04 15:00:42 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-04-06 13:45:12 +0000 |
commit | 26453251cf21d44089a905c68d70752dbd0b2e5d (patch) | |
tree | 5d21f2642cc9b2ec70ea7b9561b43628ce16a166 /examples/scxml/calculator-qml | |
parent | 995938d2f17e32e75521fa8961daaed8bbbbc371 (diff) |
Adjust style of calculator example
Change-Id: If3dfab3d0ec1faaa7cbeb5d4da34a24f6da288c7
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Diana de Sousa <diana.desousa@theqtcompany.com>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'examples/scxml/calculator-qml')
-rw-r--r-- | examples/scxml/calculator-qml/Button.qml | 3 | ||||
-rw-r--r-- | examples/scxml/calculator-qml/calculator-qml.qml | 15 |
2 files changed, 15 insertions, 3 deletions
diff --git a/examples/scxml/calculator-qml/Button.qml b/examples/scxml/calculator-qml/Button.qml index de973a5..84f4d0e 100644 --- a/examples/scxml/calculator-qml/Button.qml +++ b/examples/scxml/calculator-qml/Button.qml @@ -59,15 +59,16 @@ Rectangle { property real textHeight: height - 2 property real fontHeight: 0.3 property bool pressed: mouse.pressed + property real implicitMargin: (width - text.implicitWidth) / 2 Text { + id: text anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top height: parent.textHeight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - id: text font.pixelSize: height * fontHeight color: "#1b1c1d" font.family: "Open Sans Regular" diff --git a/examples/scxml/calculator-qml/calculator-qml.qml b/examples/scxml/calculator-qml/calculator-qml.qml index ac60b5a..846589f 100644 --- a/examples/scxml/calculator-qml/calculator-qml.qml +++ b/examples/scxml/calculator-qml/calculator-qml.qml @@ -78,22 +78,33 @@ Window { color: "#46a2da" Text { id: resultText - anchors.leftMargin: 5 - anchors.rightMargin: 5 + anchors.leftMargin: operations.implicitMargin + anchors.rightMargin: operations.implicitMargin anchors.fill: parent horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter text: "0" color: "white" font.pixelSize: window.height * 3 / 32 + font.family: "Open Sans Regular" + fontSizeMode: Text.Fit } } Item { + id: operations anchors.top: resultArea.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom + property real implicitMargin: { + var ret = 0; + for (var i = 0; i < visibleChildren.length; ++i) { + var child = visibleChildren[i]; + ret += (child.implicitMargin || 0) / visibleChildren.length; + } + return ret; + } Repeater { model: ["÷", "×", "+", "-"] |