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
|
2020-06-25 08:32:08 -04:00
|
|
|
import "../.."
|
2019-11-07 09:50:59 -04:00
|
|
|
import "../../Base"
|
2020-06-25 08:32:08 -04:00
|
|
|
import "../../Base/ButtonLayout"
|
2019-11-07 09:50:59 -04:00
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
HFlickableColumnPage {
|
|
|
|
id: page
|
|
|
|
|
|
|
|
|
|
|
|
property string userId
|
|
|
|
readonly property QtObject account: ModelStore.get("accounts").find(userId)
|
|
|
|
|
|
|
|
|
|
|
|
function takeFocus() { nameField.item.forceActiveFocus() }
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
applyButton.loading = true
|
|
|
|
errorMessage.text = ""
|
|
|
|
|
|
|
|
const args = [
|
|
|
|
nameField.item.text,
|
|
|
|
topicArea.item.text,
|
|
|
|
publicCheckBox.checked,
|
|
|
|
encryptCheckBox.checked,
|
|
|
|
! blockOtherServersCheckBox.checked,
|
|
|
|
]
|
|
|
|
|
|
|
|
py.callClientCoro(userId, "new_group_chat", args, roomId => {
|
|
|
|
applyButton.loading = false
|
|
|
|
pageLoader.showRoom(userId, roomId)
|
|
|
|
mainPane.roomList.startCorrectItemSearch()
|
|
|
|
|
|
|
|
}, (type, args) => {
|
|
|
|
applyButton.loading = false
|
|
|
|
errorMessage.text =
|
|
|
|
qsTr("Unknown error - %1: %2").arg(type).arg(args)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancel() {
|
|
|
|
nameField.item.reset()
|
|
|
|
topicArea.item.reset()
|
|
|
|
publicCheckBox.reset()
|
|
|
|
encryptCheckBox.reset()
|
|
|
|
blockOtherServersCheckBox.reset()
|
|
|
|
|
|
|
|
pageLoader.showPrevious()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
footer: ButtonLayout {
|
|
|
|
ApplyButton {
|
|
|
|
id: applyButton
|
|
|
|
text: qsTr("Create")
|
|
|
|
icon.name: "room-create"
|
|
|
|
onClicked: create()
|
2019-11-08 15:56:20 -04:00
|
|
|
}
|
2019-11-07 09:50:59 -04:00
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
CancelButton {
|
|
|
|
onClicked: cancel()
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 15:32:12 -04:00
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
Keys.onEscapePressed: cancel()
|
2019-11-08 15:32:12 -04:00
|
|
|
|
|
|
|
|
2019-11-07 11:08:47 -04:00
|
|
|
HRoomAvatar {
|
|
|
|
id: avatar
|
2020-03-09 11:46:08 -04:00
|
|
|
roomId: ""
|
2020-06-02 20:14:55 -04:00
|
|
|
displayName: nameField.item.text
|
2019-11-07 11:08:47 -04:00
|
|
|
|
|
|
|
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
|
2020-06-02 20:14:55 -04:00
|
|
|
opacity: nameField.item.text ? 0 : 1
|
2019-11-07 11:08:47 -04:00
|
|
|
visible: opacity > 0
|
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
userId: page.userId
|
|
|
|
account: page.account
|
|
|
|
|
2019-12-16 04:42:41 -04:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
2019-11-07 11:08:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-02 20:14:55 -04:00
|
|
|
HLabeledItem {
|
2019-11-07 09:50:59 -04:00
|
|
|
id: nameField
|
2020-03-17 13:40:58 -04:00
|
|
|
label.text: qsTr("Name:")
|
2019-11-07 09:50:59 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-06-02 20:14:55 -04:00
|
|
|
|
|
|
|
HTextField {
|
|
|
|
width: parent.width
|
|
|
|
maximumLength: 255
|
|
|
|
}
|
2019-11-07 09:50:59 -04:00
|
|
|
}
|
|
|
|
|
2020-06-02 20:14:55 -04:00
|
|
|
HLabeledItem {
|
2020-06-02 21:50:47 -04:00
|
|
|
id: topicArea
|
2020-03-17 13:40:58 -04:00
|
|
|
label.text: qsTr("Topic:")
|
2019-11-07 09:50:59 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-06-02 20:14:55 -04:00
|
|
|
|
2020-06-02 21:50:47 -04:00
|
|
|
HTextArea {
|
2020-06-02 20:14:55 -04:00
|
|
|
width: parent.width
|
|
|
|
placeholderText: qsTr("This room is about...")
|
2020-06-03 04:58:09 -04:00
|
|
|
focusItemOnTab: publicCheckBox
|
2020-06-02 20:14:55 -04:00
|
|
|
}
|
2019-11-07 09:50:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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!")
|
2020-03-10 08:58:14 -04:00
|
|
|
subtitle.color: theme.colors.warningText
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|