Fix inactive "Send Arrow" in smsapp after first message sent
The "enabled" property of the button was set to false and has overwritten the default value based on the message length. The message field had "anchors.fill" positioning and raised "Binding loop detected for property "implicitHeight"" error. attachmentList property of ChatMessage didn't have the default value and was undefined. BUG: 455149
This commit is contained in:
parent
ccb4a62f9c
commit
0d02a6f99e
2 changed files with 14 additions and 11 deletions
|
@ -21,7 +21,7 @@ Item {
|
||||||
property date dateTime
|
property date dateTime
|
||||||
property string name
|
property string name
|
||||||
property bool multiTarget
|
property bool multiTarget
|
||||||
property var attachmentList
|
property var attachmentList: []
|
||||||
|
|
||||||
signal messageCopyRequested(string message)
|
signal messageCopyRequested(string message)
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ ColumnLayout {
|
||||||
Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff
|
Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff
|
||||||
|
|
||||||
Controls.TextArea {
|
Controls.TextArea {
|
||||||
anchors.fill: parent
|
width: parent.width
|
||||||
id: messageField
|
id: messageField
|
||||||
placeholderText: i18nd("kdeconnect-sms", "Compose message")
|
placeholderText: i18nd("kdeconnect-sms", "Compose message")
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
|
@ -144,15 +144,14 @@ ColumnLayout {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
selectedFileUrls = []
|
selectedFileUrls = []
|
||||||
if (messageField.text == "") {
|
|
||||||
sendButton.enabled = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.ToolButton {
|
Controls.ToolButton {
|
||||||
|
property bool isSendingInProcess: false
|
||||||
|
|
||||||
id: sendButton
|
id: sendButton
|
||||||
enabled: messageField.text.length || selectedFileUrls.length
|
enabled: (messageField.text.length || selectedFileUrls.length) && !isSendingInProcess
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||||
padding: 0
|
padding: 0
|
||||||
|
@ -169,9 +168,13 @@ ColumnLayout {
|
||||||
property bool messageSent: false
|
property bool messageSent: false
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// disable the button to prevent sending
|
|
||||||
// the same message several times
|
// prevent sending the same message several times
|
||||||
sendButton.enabled = false
|
// and don't touch enabled property
|
||||||
|
if (isSendingInProcess){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isSendingInProcess = true
|
||||||
|
|
||||||
if (SmsHelper.totalMessageSize(selectedFileUrls, messageField.text) > maxMessageSize) {
|
if (SmsHelper.totalMessageSize(selectedFileUrls, messageField.text) > maxMessageSize) {
|
||||||
messageDialog.visible = true
|
messageDialog.visible = true
|
||||||
|
@ -184,14 +187,14 @@ ColumnLayout {
|
||||||
if (messageSent) {
|
if (messageSent) {
|
||||||
messageField.text = ""
|
messageField.text = ""
|
||||||
selectedFileUrls = []
|
selectedFileUrls = []
|
||||||
sendButton.enabled = false
|
|
||||||
}
|
}
|
||||||
|
isSendingInProcess = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
id: "charCount"
|
id: charCount
|
||||||
text: conversationModel.getCharCountInfo(messageField.text)
|
text: conversationModel.getCharCountInfo(messageField.text)
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
Layout.minimumWidth: Math.max(Layout.minimumWidth, width) // Make this label only grow, never shrink
|
Layout.minimumWidth: Math.max(Layout.minimumWidth, width) // Make this label only grow, never shrink
|
||||||
|
|
Loading…
Reference in a new issue