summary refs log tree commit diff
path: root/resources/qml/UserProfile.qml
blob: 6ef75031998c82da00fd835704d04cb26ff9ef01 (plain) (blame)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.3

import im.nheko 1.0

import "./device-verification"

ApplicationWindow{
    property var user_data
    property var colors: currentActivePalette

    id:userProfileDialog
    height: 650
    width: 420
    modality:Qt.WindowModal
    Layout.alignment: Qt.AlignHCenter
    palette: colors

    UserProfileList{
        id: userProfileList
        userId: user_data.userId
        onUserIdChanged : {
            userProfileList.updateDeviceList()
        }
        onDeviceListUpdated : {
            modelDeviceList.deviceList = userProfileList
        }
    }

    Component {
		id: deviceVerificationDialog
		DeviceVerification {}
	}
    Component{
        id: deviceVerificationFlow
        DeviceVerificationFlow {}
    }

    background: Item{
        id: userProfileItem
        width: userProfileDialog.width
        height: userProfileDialog.height

        // Layout.fillHeight : true

        ColumnLayout{
            anchors.fill: userProfileItem
            width: userProfileDialog.width
            spacing: 10

            Avatar{
                id: userProfileAvatar
                url:chat.model.avatarUrl(user_data.userId).replace("mxc://", "image://MxcImage/")
                height: 130
                width: 130
                displayName: modelData.userName
		        userid: modelData.userId
                Layout.alignment: Qt.AlignHCenter
                Layout.margins : {
                    top: 10
                }
            }

            Label{
                id: userProfileName
                text: user_data.userName
                fontSizeMode: Text.HorizontalFit
                font.pixelSize: 20
                color:TimelineManager.userColor(modelData.userId, colors.window)
                font.bold: true
                Layout.alignment: Qt.AlignHCenter
            }

            Label{
                id: matrixUserID
                text: user_data.userId
                fontSizeMode: Text.HorizontalFit
                font.pixelSize: 15
                color:colors.text
                Layout.alignment: Qt.AlignHCenter
            }

            RowLayout{
                Layout.alignment: Qt.AlignHCenter
                ImageButton{
                    image:":/icons/icons/ui/do-not-disturb-rounded-sign.png"
                    Layout.margins: {
                        left: 5
                        right: 5
                    }
                    ToolTip.visible: hovered
			        ToolTip.text: qsTr("Ban the user")
                    onClicked : {
                        userProfileList.banUser()
                    }
                }
                // ImageButton{
                //     image:":/icons/icons/ui/volume-off-indicator.png"
                //     Layout.margins: {
                //         left: 5
                //         right: 5
                //     }
                //     ToolTip.visible: hovered
			    //     ToolTip.text: qsTr("Ignore messages from this user")
                //     onClicked : {
                //         userProfileList.ignoreUser()
                //     }
                // }
                ImageButton{
                    image:":/icons/icons/ui/black-bubble-speech.png"
                    Layout.margins: {
                        left: 5
                        right: 5
                    }
                    ToolTip.visible: hovered
			        ToolTip.text: qsTr("Start a private chat")
                    onClicked : {
                        userProfileList.startChat()
                    }
                }
                ImageButton{
                    image:":/icons/icons/ui/round-remove-button.png"
                    Layout.margins: {
                        left: 5
                        right: 5
                    }
                    ToolTip.visible: hovered
			        ToolTip.text: qsTr("Kick the user")
                    onClicked : {
                        userProfileList.kickUser()
                    }
                }
            }

            ScrollView {
                implicitHeight: userProfileDialog.height/2 + 20
                implicitWidth: userProfileDialog.width-20
                clip: true
                Layout.alignment: Qt.AlignHCenter

                ListView{
                    id: deviceList
                    anchors.fill: parent
                    clip: true
                    spacing: 4

                    model: UserProfileModel{
                        id: modelDeviceList
                    } 

                    delegate: RowLayout{
                        width: parent.width
                        Layout.margins : {
                            top : 50
                        }
                        ColumnLayout{
                            Text{
                                Layout.fillWidth: true
                                color: colors.text
                                font.bold: true
                                Layout.alignment: Qt.AlignRight
                                text: deviceID
                            }
                            Text{
                                Layout.fillWidth: true
                                color:colors.text
                                Layout.alignment: Qt.AlignRight
                                text: displayName
                            }
                        }
                        Button{
                            id: verifyButton
                            text:"Verify"
                            onClicked: {
                                var newFlow = deviceVerificationFlow.createObject(userProfileDialog,
                                {userId : user_data.userId,sender: true,deviceId : model.deviceID});
                                deviceVerificationList.add(newFlow.tranId);
								var dialog = deviceVerificationDialog.createObject(userProfileDialog, 
                                    {flow: newFlow});
				                dialog.show();
                            }
                            Layout.margins:{
                                right: 10
                            }
                            palette {
                                button: "white"
                            }
                            contentItem: Text {
                                text: verifyButton.text
                                color: "black"
                                horizontalAlignment: Text.AlignHCenter
                                verticalAlignment: Text.AlignVCenter
                            }
                        }
                    }
                }
            }

            Button{
                id: okbutton
                text:"OK"
                onClicked: userProfileDialog.close()
                
                Layout.alignment: Qt.AlignRight | Qt.AlignBottom

                Layout.margins : {
                    right : 10
                    bottom : 10
                }

                palette {
                    button: "white"
                }

                contentItem: Text {
                    text: okbutton.text
                    color: "black"
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }
            }
        }

        Item { Layout.fillHeight: true }
    }
}