diff options
Diffstat (limited to 'qml/ComposePane.qml')
-rw-r--r-- | qml/ComposePane.qml | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/qml/ComposePane.qml b/qml/ComposePane.qml index 5cd0603..2f6145c 100644 --- a/qml/ComposePane.qml +++ b/qml/ComposePane.qml @@ -1,26 +1,22 @@ +import DeltaChat 1.0 import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 -import DeltaChat 1.0 - Pane { id: root required property DcContext context required property var chatId required property var chat - property bool canSend: root.chat && root.chat.canSend property bool isContactRequest: root.chat && root.chat.isContactRequest - function createMessage() - { + function createMessage() { let DC_MSG_TEXT = 10; - - var msg = root.context.newMessage(DC_MSG_TEXT) - msg.setText(messageField.text) - return msg + var msg = root.context.newMessage(DC_MSG_TEXT); + msg.setText(messageField.text); + return msg; } padding: 0 @@ -30,50 +26,48 @@ Pane { TextArea { id: messageField - visible: root.canSend + visible: root.canSend Layout.fillWidth: true placeholderText: qsTr("Message") wrapMode: TextArea.Wrap selectByMouse: true - Component.onCompleted: { - let draft = root.context.getDraft(chatId) - if (draft) { - messageField.text = draft.text - } + let draft = root.context.getDraft(chatId); + if (draft) + messageField.text = draft.text; + } Connections { function onEditingFinished() { - let msg = root.createMessage() - root.context.setDraft(chatId, msg) + let msg = root.createMessage(); + root.context.setDraft(chatId, msg); } + } + } Button { id: sendButton - visible: root.canSend + visible: root.canSend Layout.alignment: Qt.AlignBottom - icon.name: "document-send" text: qsTr("Send") enabled: messageField.length > 0 onClicked: { - let msg = root.createMessage() - root.context.sendMessage(root.chatId, msg) - - messageField.text = "" - root.context.setDraft(chatId, null) + let msg = root.createMessage(); + root.context.sendMessage(root.chatId, msg); + messageField.text = ""; + root.context.setDraft(chatId, null); } } Button { Layout.alignment: Qt.AlignBottom Layout.fillWidth: true - text: "Accept" onClicked: root.context.acceptChat(root.chatId) visible: root.isContactRequest @@ -83,11 +77,12 @@ Pane { Button { Layout.alignment: Qt.AlignBottom Layout.fillWidth: true - text: "Block" onClicked: root.context.acceptChat(root.chatId) visible: root.isContactRequest icon.name: "call-stop" } + } + } |