~nicohman/signal-rs

ref: 21d519db83d3c672c89259ac11661434f0dbdc34 signal-rs/qml/ChatHistory.qml -rw-r--r-- 2.9 KiB
21d519db — nicohman Save to try kirigami 7 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
94
95
96
97
98
99
100
101
102
import QtQuick 2.0
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.15
import QtQuick.Dialogs 1.3

Page {
    //anchors.fill: stackView
    id: chatHistory
    objectName: "chatHistory"
    background:Rectangle {
        color: theme.background
    }
    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);
        }
        }
    }
    ColumnLayout {
        anchors.fill: parent
        ListView {
            Layout.topMargin: 10
            highlight: Rectangle {
                color: "transparent"
            }
            Component.onCompleted: {
                chatView.positionViewAtEnd()
            }
            id: chatView
            x: 0
            y: 0
            //anchors.left: parent.left
            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
        }
        Row {
            Layout.fillWidth: true
            TextField {
                id: msgTextInput
                width: parent.width - addAttachmentButton.width
                onAccepted: {
                    chatHistory.sendMessage();
                }
            }
            Button {
                id: addAttachmentButton
                icon.name: "edit-add"
                display:AbstractButton.IconOnly
                onClicked: {
                    fd.visible = true;
                }
            }
        }
        Row {
            Layout.fillWidth: true
            Button {
                background: Rectangle {
                    color:theme.button
                }
                width: parent.width
                id: sendButton
                contentItem: Text {
                    color: theme.text
                }
                text: "Send Message"
                onClicked: {
                    chatHistory.sendMessage();
                }
            }
        }
    }
}