Item {
property alias image: image.source
- property alias text: text.text
+ property alias text: messageEditor.text
property int textSingleLineHeight: 0
+ property int animationDuration: 150
anchors.left: parent.left
anchors.right: parent.right
- width: childrenRect.width
- height: text.height > image.height ? text.height : image.height
-
- state: parent.state
+ width: parent.width
+// height: messageEditor.height > image.height ? messageEditor.height : image.height
+ height: messageEditor.height
Image {
id: image
anchors { left: parent.left; top: parent.top }
}
+ Rectangle {
+ id: messageEditorRect
+ anchors { fill: messageEditor; margins: -2 }
+ border { color: "black"; width: 1 }
+ color: "white"
+ radius: 5
+ opacity: 0
+
+ Behavior on opacity { NumberAnimation { duration: animationDuration } }
+ }
+
TextEdit {
- id: text
- anchors { leftMargin: 5; left: image.right; right: sendButton.left; top: parent.top }
+ id: messageEditor
+ anchors { leftMargin: 5; left: image.right; right: buttonsArea.left; rightMargin: 5; top: parent.top }
+ height: paintedHeight > buttonsArea.height ? paintedHeight : buttonsArea.height
focus: true
selectByMouse: true
font.pixelSize: image.height * 0.7
clip: true;
-// elide: Text.ElideRight
- state: parent.state
- Behavior on height {
- id: textHeightBehavior
- NumberAnimation { duration: 150 }
- }
+ wrapMode: TextEdit.Wrap
onActiveFocusChanged: {
- if (activeFocus)
+ if (activeFocus) {
+ console.log("messageEditor got focus")
parent.state = "edit"
+ } else {
+ console.log("messageEditor lost focus")
+ }
+
}
}
Button {
id: sendButton
text: "Send"
- anchors { left: cancelButton.left; right: cancelButton.right; top: text.top }
+ anchors { left: cancelButton.left; right: cancelButton.right; top: messageEditor.top }
visible: false
scale: cancelButton.scale
transformOrigin: Item.Right
onButtonClicked: {
- locationUpdate.setMessage(text.text)
+ locationUpdate.setMessage(messageEditor.text)
locationUpdate.send()
parent.state = ""
+ sendButton.forceActiveFocus()
}
}
transformOrigin: Item.TopRight
onButtonClicked: {
parent.state = ""
+ cancelButton.forceActiveFocus()
}
}
- onStateChanged: {
- console.log("onStateChanged, state: " + state)
+ Item {
+ id: buttonsArea
+ anchors {
+ top: parent.top
+ right: cancelButton.right
+ left: cancelButton.right
+ bottom: parent.top
+ }
}
Component.onCompleted: {
- textSingleLineHeight = text.height
+ textSingleLineHeight = messageEditor.height
}
states: [
State {
- name: "expanded"
- PropertyChanges {
- target: text
- height: paintedHeight
- }
- },
- State {
- name: ""
- PropertyChanges {
- target: text
- explicit: true
- height: textSingleLineHeight
- }
- },
- State {
name: "edit"
PropertyChanges {
- target: text
+ target: messageEditor
text: locationUpdate.message
+ height: cancelButton.y + cancelButton.height
+ }
+ PropertyChanges {
+ target: messageEditorRect
+ opacity: 0.3
}
PropertyChanges {
target: cancelButton
scale: 1
}
+ AnchorChanges {
+ target: buttonsArea
+ anchors.left: cancelButton.left
+ anchors.bottom: cancelButton.bottom
+ }
}
-
]
transitions: [
Transition {
from: ""
- to: "expanded"
- SequentialAnimation {
- PropertyAction { target: textHeightBehavior; property: "enabled"; value: true }
- PropertyAction { target: text; property: "wrapMode"; value: Text.Wrap }
- PropertyAction { target: text; property: "elide"; value: Text.ElideNone }
- }
- },
- Transition {
- from: "expanded"
- to: ""
- SequentialAnimation {
- PropertyAction { target: textHeightBehavior; property: "enabled"; value: false }
- NumberAnimation { target: text; properties: "height"; duration: 150 }
- PropertyAction { target: text; property: "wrapMode"; value: Text.NoWrap }
- PropertyAction { target: text; property: "elide"; value: Text.ElideRight }
- }
- },
- Transition {
- from: ""
to: "edit"
SequentialAnimation {
PropertyAction { target: sendButton; property: "visible"; value: true }
PropertyAction { target: cancelButton; property: "visible"; value: true }
- NumberAnimation { target: cancelButton; properties: "scale"; duration: 150 }
+ ParallelAnimation {
+ NumberAnimation { target: cancelButton; properties: "scale"; duration: animationDuration }
+ AnchorAnimation { targets: buttonsArea; duration: animationDuration }
+ NumberAnimation { target: messageEditor; properties: "height"; duration: animationDuration }
+ }
+
}
},
Transition {
from: "edit"
to: ""
SequentialAnimation {
- NumberAnimation { target: sendButton; properties: "scale"; duration: 150 }
+ ParallelAnimation {
+ NumberAnimation { target: cancelButton; properties: "scale"; duration: animationDuration }
+ AnchorAnimation { targets: buttonsArea; duration: animationDuration }
+ NumberAnimation { target: messageEditor; properties: "height"; duration: animationDuration }
+ }
PropertyAction { target: sendButton; property: "visible"; value: false }
PropertyAction { target: cancelButton; property: "visible"; value: false }
- PropertyAction { target: text; property: "visible"; value: text }
}
}
]
property int textSingleLineHeight: 0
- height: buttons.y + buttons.height + 5
- anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: 10 }
+ height: details.item.y + details.item.height + 5
+// anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: 10 }
+ anchors.fill: parent
clip: true
Rectangle {
anchors { left: primaryText.left; right: primaryText.right; top: primaryText.bottom }
}
- Loader {
- id: buttons
- height: 0
- anchors { horizontalCenter: parent.horizontalCenter; top: details.bottom }
- onLoaded: {
- item.visible = false
- }
- }
+// Loader {
+// id: buttons
+// height: 0
+// anchors { horizontalCenter: parent.horizontalCenter; top: details.bottom }
+// onLoaded: {
+// item.visible = false
+// }
+// }
Component {
id: detailsComponent
height: messageRow.height + addressRow.height + timeRow.height
width: parent.width
DetailEditorRow { id: messageRow; image: "qrc:/res/images/envelope.png"; text: userProfile.message }
- DetailRow { id: addressRow; anchors.top: messageRow.bottom; image: "qrc:/res/images/compass.png"; text: userProfile.address }
- DetailRow { id: timeRow; anchors.top: addressRow.bottom; image: "qrc:/res/images/clock.png"; text: userProfile.time }
+ DetailRow { id: addressRow; state: "expanded"; anchors.top: messageRow.bottom; image: "qrc:/res/images/compass.png"; text: userProfile.address }
+ DetailRow { id: timeRow; state: "expanded"; anchors.top: addressRow.bottom; image: "qrc:/res/images/clock.png"; text: userProfile.time }
}
}