moment/src/gui/Pages/Chat/RoomPane/SettingsView.qml

151 lines
4.1 KiB
QML
Raw Normal View History

2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
2019-12-18 19:53:08 +11:00
import "../../../Base"
HBox {
2020-03-18 04:40:58 +11:00
color: theme.chat.roomPane.roomSettings.background
2019-12-14 01:14:54 +11:00
buttonModel: [
{
name: "apply",
text: qsTr("Save"),
iconName: "apply",
// enabled: anyChange, TODO
enabled: false,
2019-12-14 01:14:54 +11:00
loading: saveFuture !== null,
disableWhileLoading: false,
},
{
name: "cancel",
text: qsTr("Cancel"),
iconName: "cancel",
enabled: anyChange || saveFuture !== null,
},
]
buttonCallbacks: ({
apply: button => {
if (saveFuture) saveFuture.cancel()
// TODO
2019-12-14 01:14:54 +11:00
},
cancel: button => {
if (saveFuture) {
saveFuture.cancel()
saveFuture = null
}
2020-03-18 04:40:58 +11:00
nameField.field.reset()
topicField.field.reset()
2019-12-14 01:14:54 +11:00
encryptCheckBox.reset()
requireInviteCheckbox.reset()
forbidGuestsCheckBox.reset()
},
})
property var saveFuture: null
readonly property bool anyChange:
2020-03-18 04:40:58 +11:00
nameField.field.changed || topicField.field.changed ||
encryptCheckBox.changed || requireInviteCheckbox.changed ||
forbidGuestsCheckBox.changed
2019-12-14 01:14:54 +11:00
readonly property Item keybindFocusItem: {
for (let i = 0; i < visibleChildren.length; i++) {
const child = visibleChildren[i]
if (child.focus || (child.field && child.field.focus))
return visibleChildren[i]
}
return nameField.field
}
HRoomAvatar {
id: avatar
roomId: chat.roomId
displayName: chat.roomInfo.display_name
mxc: chat.roomInfo.avatar_url
// enabled: chat.roomInfo.can_set_avatar # put this in "change avatar"
Layout.fillWidth: true
Layout.preferredHeight: width
Layout.maximumWidth: 256 * theme.uiScale
}
2020-03-18 04:40:58 +11:00
HLabeledTextField {
id: nameField
2020-03-18 04:40:58 +11:00
label.text: qsTr("Name:")
field.maximumLength: 255
field.defaultText: chat.roomInfo.given_name
field.enabled: chat.roomInfo.can_set_name
Layout.fillWidth: true
Component.onCompleted: field.forceActiveFocus()
}
2020-03-18 04:40:58 +11:00
HLabeledTextField {
id: topicField
2020-03-18 04:40:58 +11:00
label.text: qsTr("Topic:")
field.placeholderText: qsTr("This room is about...")
field.defaultText: chat.roomInfo.plain_topic
field.enabled: chat.roomInfo.can_set_topic
Layout.fillWidth: true
}
HCheckBox {
id: encryptCheckBox
text: qsTr("Encrypt messages")
subtitle.text:
qsTr("Only you and those you trust will be able to read the " +
"conversation") +
2020-03-10 23:58:14 +11:00
`<br><font color="${theme.colors.warningText}">` +
(
chat.roomInfo.encrypted ?
qsTr("Cannot be disabled") :
qsTr("Cannot be disabled later!")
) +
"</font>"
subtitle.textFormat: Text.StyledText
2019-12-14 01:14:54 +11:00
defaultChecked: chat.roomInfo.encrypted
enabled: chat.roomInfo.can_set_encryption && ! chat.roomInfo.encrypted
Layout.fillWidth: true
}
HCheckBox {
id: requireInviteCheckbox
text: qsTr("Require being invited")
subtitle.text: qsTr("Users will need an invite to join the room")
2019-12-14 01:14:54 +11:00
defaultChecked: chat.roomInfo.invite_required
enabled: chat.roomInfo.can_set_join_rules
Layout.fillWidth: true
}
HCheckBox {
2019-12-14 01:14:54 +11:00
id: forbidGuestsCheckBox
text: qsTr("Forbid guests")
subtitle.text: qsTr("Users without an account won't be able to join")
2019-12-14 01:14:54 +11:00
defaultChecked: ! chat.roomInfo.guests_allowed
enabled: chat.roomInfo.can_set_guest_access
Layout.fillWidth: true
}
// HCheckBox { TODO
// text: qsTr("Make this room visible in the public room directory")
// checked: chat.roomInfo.published_in_directory
// Layout.fillWidth: true
// }
2019-12-14 01:14:54 +11:00
HSpacer {}
}