2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-11-07 09:50:59 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../../Base"
|
|
|
|
|
|
|
|
HBox {
|
|
|
|
id: addChatBox
|
2019-11-09 11:18:36 -04:00
|
|
|
clickButtonOnEnter: "apply"
|
2019-11-07 09:50:59 -04:00
|
|
|
|
|
|
|
onFocusChanged: nameField.forceActiveFocus()
|
|
|
|
|
|
|
|
buttonModel: [
|
2019-11-09 11:10:00 -04:00
|
|
|
{ name: "apply", text: qsTr("Create"), iconName: "room-create" },
|
2019-11-07 09:50:59 -04:00
|
|
|
{ name: "cancel", text: qsTr("Cancel"), iconName: "cancel" },
|
|
|
|
]
|
|
|
|
|
|
|
|
buttonCallbacks: ({
|
2019-11-08 15:32:12 -04:00
|
|
|
apply: button => {
|
2019-11-09 11:15:24 -04:00
|
|
|
button.loading = true
|
|
|
|
errorMessage.text = ""
|
2019-11-08 15:32:12 -04:00
|
|
|
|
|
|
|
let args = [
|
2019-11-09 13:41:12 -04:00
|
|
|
nameField.text,
|
|
|
|
topicField.text,
|
2019-11-08 15:32:12 -04:00
|
|
|
publicCheckBox.checked,
|
|
|
|
encryptCheckBox.checked,
|
|
|
|
! blockOtherServersCheckBox.checked,
|
|
|
|
]
|
|
|
|
|
2019-11-09 14:20:53 -04:00
|
|
|
py.callClientCoro(userId, "new_group_chat", args, roomId => {
|
2019-11-08 15:32:12 -04:00
|
|
|
button.loading = false
|
|
|
|
pageLoader.showRoom(userId, roomId)
|
2019-11-09 10:39:43 -04:00
|
|
|
|
|
|
|
}, (type, args) => {
|
|
|
|
button.loading = false
|
|
|
|
errorMessage.text =
|
2019-11-09 14:20:53 -04:00
|
|
|
qsTr("Unknown error - %1: %2").arg(type).arg(args)
|
2019-11-08 15:32:12 -04:00
|
|
|
})
|
|
|
|
},
|
2019-11-08 15:56:20 -04:00
|
|
|
|
|
|
|
cancel: button => {
|
|
|
|
nameField.text = ""
|
|
|
|
topicField.text = ""
|
|
|
|
publicCheckBox.checked = false
|
|
|
|
encryptCheckBox.checked = false
|
|
|
|
blockOtherServersCheckBox.checked = false
|
|
|
|
|
|
|
|
pageLoader.showPrevious()
|
|
|
|
}
|
2019-11-07 09:50:59 -04:00
|
|
|
})
|
|
|
|
|
2019-11-08 15:32:12 -04:00
|
|
|
|
|
|
|
readonly property string userId: addChatPage.userId
|
|
|
|
|
|
|
|
|
2019-11-07 11:08:47 -04:00
|
|
|
HRoomAvatar {
|
|
|
|
id: avatar
|
|
|
|
displayName: nameField.text
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
Layout.preferredWidth: 128
|
|
|
|
Layout.preferredHeight: Layout.preferredWidth
|
|
|
|
|
2019-11-09 15:19:10 -04:00
|
|
|
CurrentUserAvatar {
|
2019-11-07 11:08:47 -04:00
|
|
|
anchors.fill: parent
|
|
|
|
z: 10
|
|
|
|
opacity: nameField.text ? 0 : 1
|
|
|
|
visible: opacity > 0
|
|
|
|
|
2019-12-16 04:42:41 -04:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-11-07 11:08:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 09:50:59 -04:00
|
|
|
HTextField {
|
|
|
|
id: nameField
|
2019-11-07 10:41:10 -04:00
|
|
|
placeholderText: qsTr("Name")
|
2019-12-13 09:22:29 -04:00
|
|
|
maximumLength: 255
|
2019-11-07 09:50:59 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HTextField {
|
|
|
|
id: topicField
|
|
|
|
placeholderText: qsTr("Topic (optional)")
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HCheckBox {
|
|
|
|
id: publicCheckBox
|
|
|
|
text: qsTr("Make this room public")
|
2019-12-22 11:36:31 -04:00
|
|
|
subtitle.text:
|
|
|
|
qsTr("Anyone will be able to join with no invite required")
|
2019-11-07 09:50:59 -04:00
|
|
|
|
2019-12-07 09:38:36 -04:00
|
|
|
Layout.fillWidth: true
|
2019-11-07 09:50:59 -04:00
|
|
|
}
|
|
|
|
|
2019-11-09 14:57:46 -04:00
|
|
|
EncryptCheckBox {
|
2019-11-07 09:50:59 -04:00
|
|
|
id: encryptCheckBox
|
|
|
|
|
2019-12-07 09:38:36 -04:00
|
|
|
Layout.fillWidth: true
|
2019-11-07 09:50:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HCheckBox {
|
|
|
|
id: blockOtherServersCheckBox
|
|
|
|
text: qsTr("Reject users from other matrix servers")
|
|
|
|
subtitle.text: qsTr("Cannot be changed later!")
|
|
|
|
subtitle.color: theme.colors.middleBackground
|
|
|
|
|
2019-12-07 09:38:36 -04:00
|
|
|
Layout.fillWidth: true
|
2019-11-07 09:50:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
id: errorMessage
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: theme.colors.errorText
|
|
|
|
|
|
|
|
visible: Layout.maximumHeight > 0
|
|
|
|
Layout.maximumHeight: text ? implicitHeight : 0
|
|
|
|
Behavior on Layout.maximumHeight { HNumberAnimation {} }
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|