summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml')
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml69
1 files changed, 69 insertions, 0 deletions
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml
new file mode 100644
index 0000000..2d3d58a
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml
@@ -0,0 +1,69 @@
+//! [all]
+Item {
+ id: contactField
+ clip: true
+ width: 230
+ height: 30
+ properties: Property {
+ name: "label"
+ value: "Name"
+ }
+ properties: Property {
+ name: "icon"
+ value: "../../shared/pics/phone.png"
+ }
+ properties: Property {
+ name: "value"
+ }
+ RemoveButton {
+ id: removeButton
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ expandedWidth: contactField.width
+ onConfirmed: { fieldText.text='' }
+ }
+ FieldText {
+ id: fieldText
+ width: contactField.width-70
+ anchors.right: removeButton.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ label: contactField.label
+ text: contactField.value
+ }
+ Image {
+ anchors.right: fieldText.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: contactField.icon
+ }
+ states: [
+ State {
+ name: "editingText"
+ when: fieldText.state == 'editing'
+ SetProperty {
+ target: removeButton.anchors
+ property: "rightMargin"
+ value: -35
+ }
+ SetProperty {
+ target: fieldText
+ property: "width"
+ value: contactField.width
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ fromState: ""
+ toState: "*"
+ reversible: true
+ NumericAnimation {
+ properties: "width,rightMargin"
+ duration: 200
+ }
+ }
+ ]
+}
+//! [all]