~nicohman/signal-rs

ref: 65a31f5a1c4562d1f216e9fef2048f50bddb4fe3 signal-rs/qml/ChatHistory.qml -rw-r--r-- 2.9 KiB
65a31f5a — nicohman More Krigami conversion and image overlay 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import QtQuick 2.0
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.15
import QtQuick.Dialogs 1.3
import org.kde.kirigami 2.13 as Kirigami

Kirigami.ScrollablePage {
    //anchors.fill: stackView
    id: chatHistory
    property var msgImgComponent: Qt.createComponent(Qt.resolvedUrl("MessageImage.qml"))
    objectName: "chatHistory"
    title: signalState.currentName
    function sendMessage() {
        console.log("Sending "+ msgTextInput.text +" to "+signalState.current);
        if (signalState.currentChat.is_group) {
            signal.send_group_message(signalState.current, msgTextInput.text, "");
        } else {
            signal.send_message(signalState.current, msgTextInput.text, "");
        }
        msgTextInput.text = "";
    }
    FileDialog {
        id: fd
        title: "Upload an attachment"
        selectExisting: true
        selectFolder: false
        selectMultiple: false
        onAccepted: {
            var path = fd.fileUrl.toString().replace("file://", "");
            if (signalState.currentChat.is_group) {
            signal.send_group_message(signalState.current, msgTextInput.text, path);

                } else {


            signal.send_message(signalState.current, msgTextInput.text, path);
        }
        }
    }
            ListView {
                anchors.fill: parent
            Layout.topMargin: 10
            highlight: Rectangle {
                color: "transparent"
            }
            Component.onCompleted: {
                chatView.positionViewAtEnd()
            }
            id: chatView
            x: 0
            y: 0
            Layout.fillWidth: true
            //Layout.maximumHeight:window.height - window.header.height - sendButton.height - msgTextInput.height
            Layout.fillHeight: true
            Layout.rightMargin: 5
            delegate:
                MessageUI {
                    outgoing: outgoing
                    message: model
                }
            model: signal.messages
        }

    footer:         Row {
            Layout.fillWidth: true
            TextField {
                placeholderText: "Write a message"
                id: msgTextInput
                width: parent.width - addAttachmentButton.width - sendButton.width
                onAccepted: {
                    chatHistory.sendMessage();
                }
            }
            Button {
                id: addAttachmentButton
                icon.name: "edit-add"
                display:AbstractButton.IconOnly
                onClicked: {
                    fd.visible = true;
                }
            }
            Button {
                id: sendButton
                icon.name: "document-send"
                display:AbstractButton.IconOnly
               action: Kirigami.Action {
                onTriggered: {
                    chatHistory.sendMessage();
                }
               }
            }
        }
}