diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -24,6 +24,7 @@ import org.kde.people 1.0 import org.kde.kirigami 2.4 as Kirigami import org.kde.kdeconnect.sms 1.0 +import QtGraphicalEffects 1.0 Kirigami.ScrollablePage { @@ -63,22 +64,78 @@ currentIndex } - footer: RowLayout { - enabled: page.device - TextField { - id: message - Layout.fillWidth: true - placeholderText: i18n("Say hi...") - onAccepted: { - console.log("sending sms", page.phoneNumber) - model.sourceModel.sendReplyToConversation(message.text) - text = "" - } + footer: Pane { + id: sendingArea + layer.enabled: sendingArea.enabled + layer.effect: DropShadow { + verticalOffset: 1 + color: Kirigami.Theme.disabledTextColor + samples: 20 + spread: 0.3 + } + Layout.fillWidth: true + padding: 0 + wheelEnabled: true + background: Rectangle { + color: Kirigami.Theme.viewBackgroundColor } - Button { - text: "Send" - onClicked: { - message.accepted() + + RowLayout { + anchors.fill: parent + + TextArea { + id: messageField + Layout.fillWidth: true + placeholderText: i18n("Compose message") + wrapMode: TextArea.Wrap + topPadding: Kirigami.Units.gridUnit * 0.5 + bottomPadding: topPadding + selectByMouse: true + background: Item {} + Keys.onReturnPressed: { + if (event.key === Qt.Key_Return) { + if (event.modifiers & Qt.ControlModifier) { + messageField.append("") + } else { + sendButton.onClicked() + event.accepted = true + } + } + } + } + + ToolButton { + id: sendButton + Layout.preferredWidth: Kirigami.Units.gridUnit * 2 + Layout.preferredHeight: Kirigami.Units.gridUnit * 2 + padding: 0 + Kirigami.Icon { + source: "document-send" + enabled: sendButton.enabled + isMask: true + smooth: true + anchors.centerIn: parent + width: Kirigami.Units.gridUnit * 1.5 + height: width + } + onClicked: { + // don't send empty messages + if (!messageField.text.length) { + return + } + + // disable the button to prevent sending + // the same message several times + sendButton.enabled = false + + // send the message + console.log("sending sms", page.phoneNumber) + model.sourceModel.sendReplyToConversation(messageField.text) + messageField.text = "" + + // re-enable the button + sendButton.enabled = true + } } } }