From 4bb8995364ce151b000a3db0e9c2f4a3ed0f0724 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Fri, 2 Jul 2021 10:17:04 +0200 Subject: Modernize calqlatr example Several things are addressed: * some unqualified accesses fixed * parent is replaced with actual ids Change-Id: I5ee1d1a2b1abad468ea330cd4eca0bf0b9b993ed Reviewed-by: Ulf Hermann Reviewed-by: Maximilian Goldstein --- examples/demos/calqlatr/calqlatr.qml | 14 +++++++------- examples/demos/calqlatr/content/Button.qml | 14 +++++++------- examples/demos/calqlatr/content/Display.qml | 21 +++++++++++---------- 3 files changed, 25 insertions(+), 24 deletions(-) (limited to 'examples/demos') diff --git a/examples/demos/calqlatr/calqlatr.qml b/examples/demos/calqlatr/calqlatr.qml index 75d402d4b..863f8de49 100644 --- a/examples/demos/calqlatr/calqlatr.qml +++ b/examples/demos/calqlatr/calqlatr.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -78,7 +78,7 @@ Rectangle { Item { id: pad width: 180 - NumberPad { id: numPad; y: 10; anchors.horizontalCenter: parent.horizontalCenter } + NumberPad { id: numPad; y: 10; anchors.horizontalCenter: pad.horizontalCenter } } AnimationController { @@ -94,7 +94,7 @@ Rectangle { } } - Keys.onPressed: { + Keys.onPressed: function(event) { if (event.key == Qt.Key_0) digitPressed("0") else if (event.key == Qt.Key_1) @@ -135,7 +135,7 @@ Rectangle { id: display x: -16 width: window.width - pad.width - height: parent.height + height: window.height MouseArea { id: mouseInput @@ -144,9 +144,9 @@ Rectangle { property bool rewind: false anchors { - bottom: parent.bottom - left: parent.left - right: parent.right + bottom: display.bottom + left: display.left + right: display.right } height: 50 onPositionChanged: { diff --git a/examples/demos/calqlatr/content/Button.qml b/examples/demos/calqlatr/content/Button.qml index 41887b602..48960be9b 100644 --- a/examples/demos/calqlatr/content/Button.qml +++ b/examples/demos/calqlatr/content/Button.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -67,12 +67,12 @@ Item { font.pixelSize: 48 wrapMode: Text.WordWrap lineHeight: 0.75 - color: (dimmable && dimmed) ? Qt.darker(button.color) : button.color + color: (button.dimmable && button.dimmed) ? Qt.darker(button.color) : button.color Behavior on color { ColorAnimation { duration: 120; easing.type: Easing.OutElastic} } states: [ State { name: "pressed" - when: mouse.pressed && !dimmed + when: mouse.pressed && !button.dimmed PropertyChanges { target: textItem color: Qt.lighter(button.color) @@ -83,13 +83,13 @@ Item { MouseArea { id: mouse - anchors.fill: parent + anchors.fill: button anchors.margins: -5 onClicked: { - if (operator) - window.operatorPressed(parent.text) + if (button.operator) + window.operatorPressed(button.text) else - window.digitPressed(parent.text) + window.digitPressed(button.text) } } diff --git a/examples/demos/calqlatr/content/Display.qml b/examples/demos/calqlatr/content/Display.qml index ef1ef029b..9047b98b7 100644 --- a/examples/demos/calqlatr/content/Display.qml +++ b/examples/demos/calqlatr/content/Display.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -141,34 +141,34 @@ Item { Item { id: theItem - width: parent.width + 32 - height: parent.height + width: display.width + 32 + height: display.height Rectangle { id: rect x: 16 color: "white" - height: parent.height + height: theItem.height width: display.width - 16 } Image { anchors.right: rect.left source: "images/paper-edge-left.png" - height: parent.height + height: theItem.height fillMode: Image.TileVertically } Image { anchors.left: rect.right source: "images/paper-edge-right.png" - height: parent.height + height: theItem.height fillMode: Image.TileVertically } Image { id: grip source: "images/paper-grip.png" - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom + anchors.horizontalCenter: theItem.horizontalCenter + anchors.bottom: theItem.bottom anchors.bottomMargin: 20 } @@ -178,8 +178,9 @@ Item { width: display.width height: display.height - 50 - y delegate: Item { + id: delegateItem height: display.fontSize * 1.1 - width: parent.width + width: listView.width Text { id: operator x: 6 @@ -190,7 +191,7 @@ Item { Text { id: operand font.pixelSize: display.fontSize - anchors.right: parent.right + anchors.right: delegateItem.right anchors.rightMargin: 22 text: model.operand } -- cgit v1.2.3