summaryrefslogtreecommitdiffstats
path: root/examples/demos
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-07-02 10:17:04 +0200
committerAndrei Golubev <andrei.golubev@qt.io>2021-07-05 09:32:03 +0200
commit4bb8995364ce151b000a3db0e9c2f4a3ed0f0724 (patch)
tree68498f0d1a565fa86977a13485ebbbbb9911652b /examples/demos
parent3f6b0e5306b1fb3cf2c5fb2a401f5b817d69a66e (diff)
Modernize calqlatr example
Several things are addressed: * some unqualified accesses fixed * parent is replaced with actual ids Change-Id: I5ee1d1a2b1abad468ea330cd4eca0bf0b9b993ed Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'examples/demos')
-rw-r--r--examples/demos/calqlatr/calqlatr.qml14
-rw-r--r--examples/demos/calqlatr/content/Button.qml14
-rw-r--r--examples/demos/calqlatr/content/Display.qml21
3 files changed, 25 insertions, 24 deletions
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
}