matrixion/resources/qml/dialogs/RoomSettingsDialog.qml

682 lines
26 KiB
QML
Raw Permalink Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
import "../ui"
2021-02-23 07:24:34 +03:00
import Qt.labs.platform 1.1 as Platform
import QtQuick 2.15
2021-02-09 20:41:39 +03:00
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.13
2021-02-09 20:41:39 +03:00
import im.nheko 1.0
ApplicationWindow {
id: roomSettingsDialog
2021-02-09 20:41:39 +03:00
property var roomSettings
minimumWidth: 340
2022-03-02 12:02:01 +03:00
minimumHeight: 450
2022-02-26 00:05:35 +03:00
width: 450
height: 680
color: palette.window
modality: Qt.NonModal
2021-08-19 17:55:54 +03:00
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
2021-04-17 21:40:31 +03:00
title: qsTr("Room Settings")
2021-02-09 20:41:39 +03:00
Shortcut {
sequence: StandardKey.Cancel
onActivated: roomSettingsDialog.close()
}
2023-06-02 02:36:01 +03:00
Flickable {
id: flickable
boundsBehavior: Flickable.StopAtBounds
anchors.fill: parent
clip: true
flickableDirection: Flickable.VerticalFlick
2022-03-02 12:02:01 +03:00
contentWidth: roomSettingsDialog.width
contentHeight: contentLayout1.height
2022-02-25 23:59:01 +03:00
ColumnLayout {
id: contentLayout1
2022-03-02 12:02:01 +03:00
width: parent.width
2022-02-25 23:59:01 +03:00
spacing: Nheko.paddingMedium
Avatar {
id: displayAvatar
2022-02-25 23:59:01 +03:00
Layout.topMargin: Nheko.paddingMedium
url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
roomid: roomSettings.roomId
displayName: roomSettings.roomName
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 130
Layout.preferredWidth: 130
2022-02-25 23:59:01 +03:00
Layout.alignment: Qt.AlignHCenter
onClicked: TimelineManager.openImageOverlay(null, roomSettings.roomAvatarUrl, "", 0, 0)
ImageButton {
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("Change room avatar.")
anchors.left: displayAvatar.left
anchors.top: displayAvatar.top
anchors.leftMargin: Nheko.paddingMedium
anchors.topMargin: Nheko.paddingMedium
visible: roomSettings.canChangeAvatar
image: ":/icons/icons/ui/edit.svg"
onClicked: {
2022-02-25 23:59:01 +03:00
roomSettings.updateAvatar();
}
2022-02-25 23:59:01 +03:00
}
2021-02-11 21:09:11 +03:00
}
2022-02-25 23:59:01 +03:00
Spinner {
Layout.alignment: Qt.AlignHCenter
visible: roomSettings.isLoading
foreground: palette.mid
2022-02-25 23:59:01 +03:00
running: roomSettings.isLoading
}
2022-02-25 23:59:01 +03:00
Text {
id: errorText
2021-02-11 21:09:11 +03:00
2022-02-25 23:59:01 +03:00
color: "red"
visible: opacity > 0
opacity: 0
Layout.alignment: Qt.AlignHCenter
wrapMode: Text.Wrap // somehow still doesn't wrap
2022-03-02 12:02:01 +03:00
Layout.fillWidth: true
2022-02-25 23:59:01 +03:00
}
2022-02-25 23:59:01 +03:00
SequentialAnimation {
id: hideErrorAnimation
2022-02-25 23:59:01 +03:00
running: false
2022-02-25 23:59:01 +03:00
PauseAnimation {
duration: 4000
}
2022-02-25 23:59:01 +03:00
NumberAnimation {
target: errorText
property: 'opacity'
to: 0
duration: 1000
}
2021-02-11 21:09:11 +03:00
}
2022-02-25 23:59:01 +03:00
Connections {
target: roomSettings
function onDisplayError(errorMessage) {
errorText.text = errorMessage;
errorText.opacity = 1;
hideErrorAnimation.restart();
}
2021-02-09 20:41:39 +03:00
}
TextEdit {
id: roomName
property bool isNameEditingAllowed: false
readOnly: !isNameEditingAllowed
textFormat: isNameEditingAllowed ? TextEdit.PlainText : TextEdit.RichText
text: isNameEditingAllowed ? roomSettings.plainRoomName : roomSettings.roomName
font.pixelSize: fontMetrics.font.pixelSize * 2
color: palette.text
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width - (Nheko.paddingSmall * 2) - nameChangeButton.anchors.leftMargin - (nameChangeButton.width * 2)
horizontalAlignment: TextEdit.AlignHCenter
wrapMode: TextEdit.Wrap
selectByMouse: true
Keys.onShortcutOverride: event.key === Qt.Key_Enter
Keys.onPressed: {
if (event.matches(StandardKey.InsertLineSeparator) || event.matches(StandardKey.InsertParagraphSeparator)) {
roomSettings.changeName(roomName.text);
roomName.isNameEditingAllowed = false;
event.accepted = true;
}
}
ImageButton {
id: nameChangeButton
visible: roomSettings.canChangeName
anchors.leftMargin: Nheko.paddingSmall
anchors.left: roomName.right
anchors.verticalCenter: roomName.verticalCenter
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("Change name of this room")
ToolTip.delay: Nheko.tooltipDelay
image: roomName.isNameEditingAllowed ? ":/icons/icons/ui/checkmark.svg" : ":/icons/icons/ui/edit.svg"
onClicked: {
if (roomName.isNameEditingAllowed) {
roomSettings.changeName(roomName.text);
roomName.isNameEditingAllowed = false;
} else {
roomName.isNameEditingAllowed = true;
roomName.focus = true;
roomName.selectAll();
}
}
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
}
2022-04-24 01:53:22 +03:00
RowLayout {
spacing: Nheko.paddingMedium
Layout.alignment: Qt.AlignHCenter
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("%n member(s)", "", roomSettings.memberCount)
color: palette.text
2022-04-24 01:53:22 +03:00
}
2022-04-24 01:53:22 +03:00
ImageButton {
image: ":/icons/icons/ui/people.svg"
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("View members of %1").arg(roomSettings.roomName)
onClicked: TimelineManager.openRoomMembers(Rooms.getRoomById(roomSettings.roomId))
}
2022-04-24 01:53:22 +03:00
}
2022-02-25 23:59:01 +03:00
TextArea {
2022-03-02 12:02:01 +03:00
id: roomTopic
property bool cut: implicitHeight > 100
property bool showMore: false
2022-03-02 12:02:01 +03:00
clip: true
2022-03-04 13:19:58 +03:00
Layout.maximumHeight: showMore? Number.POSITIVE_INFINITY : 100
Layout.preferredHeight: implicitHeight
2022-02-25 23:59:01 +03:00
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.leftMargin: Nheko.paddingLarge
Layout.rightMargin: Nheko.paddingLarge
2021-02-13 16:38:52 +03:00
property bool isTopicEditingAllowed: false
readOnly: !isTopicEditingAllowed
textFormat: isTopicEditingAllowed ? TextEdit.PlainText : TextEdit.RichText
2022-06-02 22:57:46 +03:00
text: isTopicEditingAllowed
? roomSettings.plainRoomTopic
: (roomSettings.plainRoomTopic === "" ? ("<i>" + qsTr("No topic set") + "</i>") : roomSettings.roomTopic)
2021-02-23 07:24:34 +03:00
wrapMode: TextEdit.WordWrap
2021-02-13 18:16:40 +03:00
background: null
color: palette.text
2021-02-23 07:24:34 +03:00
horizontalAlignment: TextEdit.AlignHCenter
2021-05-13 09:52:02 +03:00
onLinkActivated: Nheko.openLink(link)
2023-06-19 02:38:40 +03:00
NhekoCursorShape {
2021-02-23 07:24:34 +03:00
anchors.fill: parent
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
2022-02-25 23:59:01 +03:00
}
ImageButton {
id: topicChangeButton
Layout.alignment: Qt.AlignHCenter
visible: roomSettings.canChangeTopic
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("Change topic of this room")
ToolTip.delay: Nheko.tooltipDelay
image: roomTopic.isTopicEditingAllowed ? ":/icons/icons/ui/checkmark.svg" : ":/icons/icons/ui/edit.svg"
onClicked: {
if (roomTopic.isTopicEditingAllowed) {
roomSettings.changeTopic(roomTopic.text);
roomTopic.isTopicEditingAllowed = false;
} else {
roomTopic.isTopicEditingAllowed = true;
roomTopic.showMore = true;
roomTopic.focus = true;
//roomTopic.selectAll();
}
}
}
2022-03-02 12:02:01 +03:00
Item {
Layout.alignment: Qt.AlignHCenter
id: showMorePlaceholder
Layout.preferredHeight: showMoreButton.height
Layout.preferredWidth: showMoreButton.width
visible: roomTopic.cut
}
2021-02-09 20:41:39 +03:00
2022-02-25 23:59:01 +03:00
GridLayout {
columns: 2
rowSpacing: Nheko.paddingMedium
Layout.margins: Nheko.paddingMedium
2022-03-02 12:02:01 +03:00
Layout.fillWidth: true
2021-02-09 20:41:39 +03:00
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("NOTIFICATIONS")
2022-02-25 23:59:01 +03:00
font.bold: true
color: palette.text
Layout.columnSpan: 2
2022-02-25 23:59:01 +03:00
Layout.fillWidth: true
Layout.topMargin: Nheko.paddingLarge
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("Notifications")
Layout.fillWidth: true
color: palette.text
2022-02-25 23:59:01 +03:00
}
2022-02-25 23:59:01 +03:00
ComboBox {
model: [qsTr("Muted"), qsTr("Mentions only"), qsTr("All messages")]
currentIndex: roomSettings.notifications
onActivated: (index) => {
2022-02-25 23:59:01 +03:00
roomSettings.changeNotifications(index);
}
Layout.fillWidth: true
2022-03-02 12:02:01 +03:00
WheelHandler{} // suppress scrolling changing values
}
2021-02-09 20:41:39 +03:00
Label {
text: qsTr("ENTRY PERMISSIONS")
font.bold: true
color: palette.text
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.topMargin: Nheko.paddingLarge
}
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("Anyone can join")
2022-02-25 23:59:01 +03:00
Layout.fillWidth: true
color: palette.text
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
ToggleButton {
id: publicRoomButton
2022-02-25 23:59:01 +03:00
enabled: roomSettings.canChangeJoinRules
checked: !roomSettings.privateAccess
Layout.alignment: Qt.AlignRight
}
Label {
text: qsTr("Allow knocking")
Layout.fillWidth: true
color: palette.text
visible: knockingButton.visible
}
ToggleButton {
id: knockingButton
2022-06-18 01:17:24 +03:00
visible: !publicRoomButton.checked
enabled: roomSettings.canChangeJoinRules && roomSettings.supportsKnocking
checked: roomSettings.knockingEnabled
onCheckedChanged: {
if (checked && !roomSettings.supportsKnockRestricted) restrictedButton.checked = false;
2022-02-25 23:59:01 +03:00
}
Layout.alignment: Qt.AlignRight
}
Label {
text: qsTr("Allow joining via other rooms")
Layout.fillWidth: true
color: palette.text
visible: restrictedButton.visible
}
ToggleButton {
id: restrictedButton
visible: !publicRoomButton.checked
enabled: roomSettings.canChangeJoinRules && roomSettings.supportsRestricted
checked: roomSettings.restrictedEnabled
onCheckedChanged: {
if (checked && !roomSettings.supportsKnockRestricted) knockingButton.checked = false;
2022-02-25 23:59:01 +03:00
}
Layout.alignment: Qt.AlignRight
}
Label {
text: qsTr("Rooms to join via")
Layout.fillWidth: true
color: palette.text
visible: allowedRoomsButton.visible
}
Button {
id: allowedRoomsButton
visible: restrictedButton.checked && restrictedButton.visible
enabled: roomSettings.canChangeJoinRules && roomSettings.supportsRestricted
text: qsTr("Change")
ToolTip.text: qsTr("Change the list of rooms users can join this room via. Usually this is the official community of this room.")
onClicked: timelineRoot.showAllowedRoomsEditor(roomSettings)
Layout.alignment: Qt.AlignRight
}
Label {
text: qsTr("Allow guests to join")
Layout.fillWidth: true
color: palette.text
}
ToggleButton {
id: guestAccessButton
enabled: roomSettings.canChangeJoinRules
checked: roomSettings.guestAccess
Layout.alignment: Qt.AlignRight
}
Button {
visible: publicRoomButton.checked == roomSettings.privateAccess || knockingButton.checked != roomSettings.knockingEnabled || restrictedButton.checked != roomSettings.restrictedEnabled || guestAccessButton.checked != roomSettings.guestAccess || roomSettings.allowedRoomsModified
enabled: roomSettings.canChangeJoinRules
text: qsTr("Apply access rules")
onClicked: roomSettings.changeAccessRules(!publicRoomButton.checked, guestAccessButton.checked, knockingButton.checked, restrictedButton.checked)
Layout.columnSpan: 2
2022-02-25 23:59:01 +03:00
Layout.fillWidth: true
}
2021-02-09 20:41:39 +03:00
Label {
text: qsTr("MESSAGE VISIBILITY")
font.bold: true
color: palette.text
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.topMargin: Nheko.paddingLarge
}
Label {
text: qsTr("Allow viewing history without joining")
Layout.fillWidth: true
color: palette.text
ToolTip.text: qsTr("This is useful to see previews of the room or view it on public websites.")
ToolTip.visible: publicHistoryHover.hovered
ToolTip.delay: Nheko.tooltipDelay
HoverHandler {
id: publicHistoryHover
}
}
ToggleButton {
id: publicHistoryButton
enabled: roomSettings.canChangeHistoryVisibility
checked: roomSettings.historyVisibility == RoomSettings.WorldReadable
Layout.alignment: Qt.AlignRight
}
Label {
visible: !publicHistoryButton.checked
text: qsTr("Members can see messages since")
Layout.fillWidth: true
color: palette.text
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
ToolTip.text: qsTr("How much of the history is visible to joined members. Changing this won't affect the visibility of already sent messages. It only applies to new messages.")
ToolTip.visible: privateHistoryHover.hovered
ToolTip.delay: Nheko.tooltipDelay
HoverHandler {
id: privateHistoryHover
}
}
ColumnLayout {
Layout.fillWidth: true
visible: !publicHistoryButton.checked
enabled: roomSettings.canChangeHistoryVisibility
Layout.alignment: Qt.AlignTop | Qt.AlignRight
RadioButton {
id: sharedHistory
checked: roomSettings.historyVisibility == RoomSettings.Shared
text: qsTr("Everything")
ToolTip.text: qsTr("As long as the user joined, they can see all previous messages.")
ToolTip.visible: hovered
ToolTip.delay: Nheko.tooltipDelay
}
RadioButton {
id: invitedHistory
checked: roomSettings.historyVisibility == RoomSettings.Invited
text: qsTr("They got invited")
ToolTip.text: qsTr("Members can only see messages from when they got invited going forward.")
ToolTip.visible: hovered
ToolTip.delay: Nheko.tooltipDelay
}
RadioButton {
id: joinedHistory
checked: roomSettings.historyVisibility == RoomSettings.Joined || roomSettings.historyVisibility == RoomSettings.WorldReadable
text: qsTr("They joined")
ToolTip.text: qsTr("Members can only see messages since after they joined.")
ToolTip.visible: hovered
ToolTip.delay: Nheko.tooltipDelay
}
}
Button {
visible: roomSettings.historyVisibility != selectedVisibility
enabled: roomSettings.canChangeHistoryVisibility
text: qsTr("Apply visibility changes")
property int selectedVisibility: {
if (publicHistoryButton.checked)
return RoomSettings.WorldReadable;
else if (sharedHistory.checked)
return RoomSettings.Shared;
else if (invitedHistory.checked)
return RoomSettings.Invited;
return RoomSettings.Joined;
}
onClicked: roomSettings.changeHistoryVisibility(selectedVisibility)
Layout.columnSpan: 2
Layout.fillWidth: true
}
Label {
text: qsTr("Locally hidden events")
color: palette.text
}
HiddenEventsDialog {
id: hiddenEventsDialog
roomid: roomSettings.roomId
roomName: roomSettings.roomName
}
Button {
text: qsTr("Configure")
ToolTip.text: qsTr("Select events to hide in this room")
onClicked: hiddenEventsDialog.show()
Layout.alignment: Qt.AlignRight
}
Label {
text: qsTr("Automatic event deletion")
color: palette.text
}
EventExpirationDialog {
id: eventExpirationDialog
roomid: roomSettings.roomId
roomName: roomSettings.roomName
}
Button {
text: qsTr("Configure")
ToolTip.text: qsTr("Select if your events get automatically deleted in this room.")
onClicked: eventExpirationDialog.show()
Layout.alignment: Qt.AlignRight
}
Label {
text: qsTr("GENERAL SETTINGS")
font.bold: true
color: palette.text
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.topMargin: Nheko.paddingLarge
}
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("Encryption")
color: palette.text
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
2022-02-25 23:59:01 +03:00
ToggleButton {
id: encryptionToggle
2022-02-25 23:59:01 +03:00
checked: roomSettings.isEncryptionEnabled
onCheckedChanged: {
if (roomSettings.isEncryptionEnabled) {
checked = true;
return ;
}
2023-03-01 22:39:16 +03:00
if (checked === true)
confirmEncryptionDialog.open();
}
2022-02-25 23:59:01 +03:00
Layout.alignment: Qt.AlignRight
}
2022-02-25 23:59:01 +03:00
Platform.MessageDialog {
id: confirmEncryptionDialog
2022-02-25 23:59:01 +03:00
title: qsTr("End-to-End Encryption")
2023-10-26 02:51:45 +03:00
text: qsTr(`Encryption is currently experimental and things might break unexpectedly. <br>
Please take note that it can't be disabled afterwards.`)
2022-02-25 23:59:01 +03:00
modality: Qt.NonModal
// Broken on macos, see https://bugreports.qt.io/browse/QTBUG-102078
//onAccepted: {
onOkClicked: {
2022-02-25 23:59:01 +03:00
if (roomSettings.isEncryptionEnabled)
return ;
2022-02-25 23:59:01 +03:00
roomSettings.enableEncryption();
}
//onRejected: {
onCancelClicked: {
2022-02-25 23:59:01 +03:00
encryptionToggle.checked = false;
}
buttons: Platform.MessageDialog.Ok | Platform.MessageDialog.Cancel
}
2022-02-25 23:59:01 +03:00
2022-05-27 17:31:54 +03:00
Label {
text: qsTr("Permission")
color: palette.text
2022-05-27 17:31:54 +03:00
}
Button {
text: qsTr("Configure")
ToolTip.text: qsTr("View and change the permissions in this room")
onClicked: timelineRoot.showPLEditor(roomSettings)
Layout.alignment: Qt.AlignRight
2022-07-08 18:28:28 +03:00
}
Label {
2022-07-16 14:04:35 +03:00
text: qsTr("Aliases")
color: palette.text
2022-07-08 18:28:28 +03:00
}
Button {
text: qsTr("Configure")
ToolTip.text: qsTr("View and change the addresses/aliases of this room")
onClicked: timelineRoot.showAliasEditor(roomSettings)
Layout.alignment: Qt.AlignRight
2022-05-27 17:31:54 +03:00
}
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("Sticker & Emote Settings")
color: palette.text
}
2022-02-25 23:59:01 +03:00
Button {
text: qsTr("Change")
ToolTip.text: qsTr("Change what packs are enabled, remove packs, or create new ones")
2022-02-25 23:59:01 +03:00
onClicked: TimelineManager.openImagePackSettings(roomSettings.roomId)
Layout.alignment: Qt.AlignRight
}
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("INFO")
font.bold: true
color: palette.text
Layout.columnSpan: 2
Layout.topMargin: Nheko.paddingLarge
2022-02-25 23:59:01 +03:00
Layout.fillWidth: true
}
2021-02-09 20:41:39 +03:00
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("Internal ID")
color: palette.text
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
AbstractButton { // AbstractButton does not allow setting text color
2022-02-25 23:59:01 +03:00
Layout.alignment: Qt.AlignRight
2022-03-02 12:02:01 +03:00
Layout.fillWidth: true
Layout.preferredHeight: idLabel.height
Label { // TextEdit does not trigger onClicked
id: idLabel
text: roomSettings.roomId
font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 0.8)
color: palette.text
width: parent.width
2022-03-04 15:40:44 +03:00
horizontalAlignment: Text.AlignRight
wrapMode: Text.WrapAnywhere
ToolTip.text: qsTr("Copied to clipboard")
ToolTip.visible: toolTipTimer.running
}
TextEdit{ // label does not allow selection
id: textEdit
visible: false
text: roomSettings.roomId
}
onClicked: {
textEdit.selectAll()
textEdit.copy()
toolTipTimer.start()
}
Timer {
id: toolTipTimer
}
2022-02-25 23:59:01 +03:00
}
2022-02-25 23:59:01 +03:00
Label {
text: qsTr("Room Version")
color: palette.text
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
2022-02-25 23:59:01 +03:00
Label {
text: roomSettings.roomVersion
font.pixelSize: fontMetrics.font.pixelSize
Layout.alignment: Qt.AlignRight
color: palette.text
2022-02-25 23:59:01 +03:00
}
2021-02-09 20:41:39 +03:00
}
}
}
2022-03-02 12:02:01 +03:00
Button {
id: showMoreButton
2022-03-04 13:19:58 +03:00
anchors.horizontalCenter: flickable.horizontalCenter
y: Math.min(showMorePlaceholder.y+contentLayout1.y-flickable.contentY,flickable.height-height)
2022-03-02 12:02:01 +03:00
visible: roomTopic.cut
text: roomTopic.showMore? qsTr("show less") : qsTr("show more")
2022-03-02 12:02:01 +03:00
onClicked: {roomTopic.showMore = !roomTopic.showMore
console.log(flickable.visibleArea)
}
}
footer: DialogButtonBox {
standardButtons: DialogButtonBox.Ok
onAccepted: close()
2021-02-09 20:41:39 +03:00
}
}