2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-12-13 08:32:18 -04:00
|
|
|
import QtQuick 2.12
|
2020-06-05 05:48:25 -04:00
|
|
|
import QtQuick.Controls 2.12
|
2019-12-13 08:32:18 -04:00
|
|
|
import QtQuick.Layouts 1.12
|
2019-12-18 04:53:08 -04:00
|
|
|
import "../../../Base"
|
2020-06-05 05:42:12 -04:00
|
|
|
import "../../../Base/ButtonLayout"
|
2019-12-13 08:32:18 -04:00
|
|
|
|
2020-06-05 05:42:12 -04:00
|
|
|
HFlickableColumnPage {
|
2020-06-05 05:48:25 -04:00
|
|
|
id: settingsView
|
|
|
|
|
|
|
|
|
2019-12-13 10:14:54 -04:00
|
|
|
property var saveFuture: null
|
|
|
|
|
|
|
|
readonly property bool anyChange:
|
2020-06-05 06:33:55 -04:00
|
|
|
nameField.item.changed || topicArea.item.area.changed ||
|
2020-03-17 13:40:58 -04:00
|
|
|
encryptCheckBox.changed || requireInviteCheckbox.changed ||
|
|
|
|
forbidGuestsCheckBox.changed
|
2019-12-13 10:14:54 -04:00
|
|
|
|
2020-06-02 20:14:55 -04:00
|
|
|
readonly property Item keybindFocusItem: nameField.item
|
2020-03-17 16:39:29 -04:00
|
|
|
|
2019-12-13 08:32:18 -04:00
|
|
|
|
2020-06-05 05:42:12 -04:00
|
|
|
function save() {
|
|
|
|
if (saveFuture) saveFuture.cancel()
|
|
|
|
|
|
|
|
const args = [
|
|
|
|
chat.roomId,
|
|
|
|
nameField.item.changed ? nameField.item.text : undefined,
|
2020-06-05 06:33:55 -04:00
|
|
|
topicArea.item.area.changed ? topicArea.item.area.text : undefined,
|
2020-06-05 05:42:12 -04:00
|
|
|
encryptCheckBox.changed ? true : undefined,
|
|
|
|
|
|
|
|
requireInviteCheckbox.changed ?
|
|
|
|
requireInviteCheckbox.checked : undefined,
|
|
|
|
|
|
|
|
forbidGuestsCheckBox.changed ?
|
|
|
|
forbidGuestsCheckBox.checked : undefined,
|
|
|
|
]
|
|
|
|
|
|
|
|
function onDone() { saveFuture = null }
|
|
|
|
|
|
|
|
saveFuture = py.callClientCoro(
|
|
|
|
chat.userId, "room_set", args, onDone, onDone,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancel() {
|
|
|
|
if (saveFuture) {
|
|
|
|
saveFuture.cancel()
|
|
|
|
saveFuture = null
|
|
|
|
}
|
|
|
|
|
|
|
|
nameField.item.reset()
|
2020-06-05 06:33:55 -04:00
|
|
|
topicArea.item.area.reset()
|
2020-06-05 05:42:12 -04:00
|
|
|
encryptCheckBox.reset()
|
|
|
|
requireInviteCheckbox.reset()
|
|
|
|
forbidGuestsCheckBox.reset()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
flickShortcuts.active:
|
|
|
|
! mainUI.debugConsole.visible && ! chat.composerHasFocus
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: theme.chat.roomPane.roomSettings.background
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: ButtonLayout {
|
|
|
|
ApplyButton {
|
|
|
|
enabled: anyChange
|
|
|
|
loading: saveFuture !== null
|
|
|
|
disableWhileLoading: false
|
|
|
|
onClicked: save()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CancelButton {
|
|
|
|
enabled: anyChange || saveFuture !== null
|
|
|
|
onClicked: cancel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:32:08 -04:00
|
|
|
Keys.onEscapePressed: cancel()
|
|
|
|
|
2020-06-05 05:42:12 -04:00
|
|
|
|
2019-12-13 08:32:18 -04:00
|
|
|
HRoomAvatar {
|
|
|
|
id: avatar
|
2020-03-09 11:46:08 -04:00
|
|
|
roomId: chat.roomId
|
2020-06-25 10:06:03 -04:00
|
|
|
displayName: nameField.item.text || chat.roomInfo.display_name
|
2019-12-13 08:32:18 -04:00
|
|
|
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-17 17:16:03 -04:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
2019-12-13 08:32:18 -04:00
|
|
|
}
|
|
|
|
|
2020-06-02 20:14:55 -04:00
|
|
|
HLabeledItem {
|
2019-12-13 08:32:18 -04:00
|
|
|
id: nameField
|
2020-03-17 13:40:58 -04:00
|
|
|
label.text: qsTr("Name:")
|
2019-12-13 08:32:18 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-03-17 16:39:29 -04:00
|
|
|
|
2020-06-02 20:14:55 -04:00
|
|
|
HTextField {
|
|
|
|
width: parent.width
|
|
|
|
maximumLength: 255
|
|
|
|
defaultText: chat.roomInfo.given_name
|
|
|
|
enabled: chat.roomInfo.can_set_name
|
|
|
|
Component.onCompleted: forceActiveFocus()
|
|
|
|
}
|
2019-12-13 08:32:18 -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-12-13 08:32:18 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-06-02 20:14:55 -04:00
|
|
|
|
2020-06-22 13:57:49 -04:00
|
|
|
HScrollView {
|
2020-06-05 05:48:25 -04:00
|
|
|
clip: true
|
2020-06-02 20:14:55 -04:00
|
|
|
width: parent.width
|
2020-06-05 05:48:25 -04:00
|
|
|
height:
|
|
|
|
Math.min(topicAreaIn.implicitHeight, settingsView.height / 2)
|
|
|
|
|
2020-06-05 06:33:55 -04:00
|
|
|
readonly property alias area: topicAreaIn
|
|
|
|
|
2020-06-05 05:48:25 -04:00
|
|
|
HTextArea {
|
|
|
|
id: topicAreaIn
|
|
|
|
placeholderText: qsTr("This room is about...")
|
|
|
|
defaultText: chat.roomInfo.plain_topic
|
|
|
|
enabled: chat.roomInfo.can_set_topic
|
|
|
|
|
|
|
|
focusItemOnTab:
|
|
|
|
encryptCheckBox.checked ?
|
|
|
|
requireInviteCheckbox :
|
|
|
|
encryptCheckBox
|
|
|
|
}
|
2020-06-02 20:14:55 -04:00
|
|
|
}
|
2019-12-13 08:32:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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 08:58:14 -04:00
|
|
|
`<br><font color="${theme.colors.warningText}">` +
|
2019-12-13 08:32:18 -04:00
|
|
|
(
|
|
|
|
chat.roomInfo.encrypted ?
|
|
|
|
qsTr("Cannot be disabled") :
|
|
|
|
qsTr("Cannot be disabled later!")
|
|
|
|
) +
|
|
|
|
"</font>"
|
|
|
|
subtitle.textFormat: Text.StyledText
|
2019-12-13 10:14:54 -04:00
|
|
|
defaultChecked: chat.roomInfo.encrypted
|
2019-12-13 08:32:18 -04:00
|
|
|
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-13 10:14:54 -04:00
|
|
|
defaultChecked: chat.roomInfo.invite_required
|
2019-12-13 08:32:18 -04:00
|
|
|
enabled: chat.roomInfo.can_set_join_rules
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HCheckBox {
|
2019-12-13 10:14:54 -04:00
|
|
|
id: forbidGuestsCheckBox
|
2019-12-13 08:32:18 -04:00
|
|
|
text: qsTr("Forbid guests")
|
|
|
|
subtitle.text: qsTr("Users without an account won't be able to join")
|
2019-12-13 10:14:54 -04:00
|
|
|
defaultChecked: ! chat.roomInfo.guests_allowed
|
2019-12-13 08:32:18 -04:00
|
|
|
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-13 10:14:54 -04:00
|
|
|
HSpacer {}
|
2019-12-13 08:32:18 -04:00
|
|
|
}
|