nheko/resources/qml/RoomSettings.qml

304 lines
8.3 KiB
QML
Raw Normal View History

2021-03-05 00:35:15 +01:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// SPDX-License-Identifier: GPL-3.0-or-later
import "./ui"
2021-02-23 05:24:34 +01:00
import Qt.labs.platform 1.1 as Platform
import QtQuick 2.15
2021-02-09 18:41:39 +01:00
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.13
2021-02-09 18:41:39 +01:00
import im.nheko 1.0
ApplicationWindow {
id: roomSettingsDialog
2021-02-09 18:41:39 +01:00
property var roomSettings
2021-08-08 11:34:15 +02:00
minimumWidth: 450
minimumHeight: 680
2021-05-13 08:23:56 +02:00
palette: Nheko.colors
color: Nheko.colors.window
modality: Qt.NonModal
2021-08-19 16:55:54 +02:00
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
Component.onCompleted: Nheko.reparent(roomSettingsDialog)
2021-04-17 20:40:31 +02:00
title: qsTr("Room Settings")
2021-02-09 18:41:39 +01:00
Shortcut {
sequence: StandardKey.Cancel
onActivated: roomSettingsDialog.close()
}
ColumnLayout {
2021-02-13 14:38:52 +01:00
id: contentLayout1
2021-02-09 18:41:39 +01:00
2021-02-13 16:16:40 +01:00
anchors.fill: parent
2021-02-09 18:41:39 +01:00
anchors.margins: 10
spacing: 10
Avatar {
2021-02-11 19:09:11 +01:00
url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
2021-03-03 17:54:00 +01:00
displayName: roomSettings.roomName
2021-02-09 18:41:39 +01:00
height: 130
width: 130
Layout.alignment: Qt.AlignHCenter
2021-02-11 19:09:11 +01:00
onClicked: {
if (roomSettings.canChangeAvatar)
roomSettings.updateAvatar();
2021-02-11 19:09:11 +01:00
}
}
Spinner {
2021-02-11 19:09:11 +01:00
Layout.alignment: Qt.AlignHCenter
visible: roomSettings.isLoading
foreground: Nheko.colors.mid
running: roomSettings.isLoading
2021-02-11 19:09:11 +01:00
}
Text {
id: errorText
2021-02-11 19:09:11 +01:00
color: "red"
visible: opacity > 0
opacity: 0
Layout.alignment: Qt.AlignHCenter
}
SequentialAnimation {
id: hideErrorAnimation
2021-02-11 19:09:11 +01:00
running: false
2021-02-11 19:09:11 +01:00
PauseAnimation {
duration: 4000
}
2021-02-11 19:09:11 +01:00
NumberAnimation {
target: errorText
property: 'opacity'
to: 0
duration: 1000
}
2021-02-11 19:09:11 +01:00
}
Connections {
2021-02-11 19:09:11 +01:00
target: roomSettings
onDisplayError: {
errorText.text = errorMessage;
errorText.opacity = 1;
hideErrorAnimation.restart();
2021-02-11 19:09:11 +01:00
}
2021-02-09 18:41:39 +01:00
}
ColumnLayout {
Layout.alignment: Qt.AlignHCenter
MatrixText {
2021-02-11 16:53:33 +01:00
text: roomSettings.roomName
font.pixelSize: fontMetrics.font.pixelSize * 2
2021-02-09 18:41:39 +01:00
Layout.alignment: Qt.AlignHCenter
}
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("%1 member(s)").arg(roomSettings.memberCount)
2021-02-09 18:41:39 +01:00
Layout.alignment: Qt.AlignHCenter
TapHandler {
onTapped: TimelineManager.openRoomMembers(roomSettings.roomId)
}
CursorShape {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
}
2021-02-09 18:41:39 +01:00
}
2021-02-09 18:41:39 +01:00
}
ImageButton {
Layout.alignment: Qt.AlignHCenter
image: ":/icons/icons/ui/edit.png"
visible: roomSettings.canChangeNameAndTopic
onClicked: roomSettings.openEditModal()
2021-02-09 18:41:39 +01:00
}
2021-02-13 14:38:52 +01:00
2021-02-13 16:16:40 +01:00
ScrollView {
Layout.fillHeight: true
2021-02-13 16:16:40 +01:00
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.leftMargin: Nheko.paddingLarge
Layout.rightMargin: Nheko.paddingLarge
2021-02-13 14:38:52 +01:00
2021-02-13 16:16:40 +01:00
TextArea {
text: TimelineManager.escapeEmoji(roomSettings.roomTopic)
2021-02-23 05:24:34 +01:00
wrapMode: TextEdit.WordWrap
textFormat: TextEdit.RichText
2021-02-13 16:16:40 +01:00
readOnly: true
background: null
selectByMouse: true
2021-05-13 08:23:56 +02:00
color: Nheko.colors.text
2021-02-23 05:24:34 +01:00
horizontalAlignment: TextEdit.AlignHCenter
2021-05-13 08:52:02 +02:00
onLinkActivated: Nheko.openLink(link)
2021-02-23 05:24:34 +01:00
CursorShape {
anchors.fill: parent
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
2021-02-13 16:16:40 +01:00
}
2021-02-13 14:38:52 +01:00
}
2021-02-09 18:41:39 +01:00
GridLayout {
columns: 2
2021-08-06 01:45:47 +02:00
rowSpacing: Nheko.paddingLarge
2021-02-09 18:41:39 +01:00
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("SETTINGS")
font.bold: true
2021-02-09 18:41:39 +01:00
}
Item {
Layout.fillWidth: true
}
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("Notifications")
Layout.fillWidth: true
}
2021-02-09 18:41:39 +01:00
ComboBox {
2021-03-31 23:07:07 +02:00
model: [qsTr("Muted"), qsTr("Mentions only"), qsTr("All messages")]
currentIndex: roomSettings.notifications
onActivated: {
roomSettings.changeNotifications(index);
}
Layout.fillWidth: true
2021-02-09 18:41:39 +01:00
}
MatrixText {
2021-08-06 01:45:47 +02:00
text: qsTr("Room access")
Layout.fillWidth: true
2021-02-09 18:41:39 +01:00
}
ComboBox {
enabled: roomSettings.canChangeJoinRules
model: {
let opts = [qsTr("Anyone and guests"), qsTr("Anyone"), qsTr("Invited users")];
if (roomSettings.supportsKnocking)
opts.push(qsTr("By knocking"));
if (roomSettings.supportsRestricted)
opts.push(qsTr("Restricted by membership in other rooms"));
return opts;
}
currentIndex: roomSettings.accessJoinRules
onActivated: {
roomSettings.changeAccessRules(index);
}
Layout.fillWidth: true
2021-02-09 18:41:39 +01:00
}
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("Encryption")
2021-02-09 18:41:39 +01:00
}
2021-02-13 16:16:40 +01:00
ToggleButton {
id: encryptionToggle
checked: roomSettings.isEncryptionEnabled
2021-02-13 17:19:21 +01:00
onClicked: {
if (roomSettings.isEncryptionEnabled) {
checked = true;
return ;
}
confirmEncryptionDialog.open();
}
Layout.alignment: Qt.AlignRight
}
Platform.MessageDialog {
id: confirmEncryptionDialog
title: qsTr("End-to-End Encryption")
text: qsTr("Encryption is currently experimental and things might break unexpectedly. <br>
Please take note that it can't be disabled afterwards.")
modality: Qt.Modal
onAccepted: {
if (roomSettings.isEncryptionEnabled)
return ;
roomSettings.enableEncryption();
}
onRejected: {
encryptionToggle.checked = false;
}
buttons: Dialog.Ok | Dialog.Cancel
2021-02-09 18:41:39 +01:00
}
MatrixText {
text: qsTr("Sticker & Emote Settings")
}
Button {
text: qsTr("Change")
ToolTip.text: qsTr("Change what packs are enabled, remove packs or create new ones")
onClicked: TimelineManager.openImagePackSettings(roomSettings.roomId)
Layout.alignment: Qt.AlignRight
}
Item {
// for adding extra space between sections
Layout.fillWidth: true
}
Item {
// for adding extra space between sections
Layout.fillWidth: true
}
2021-02-09 18:41:39 +01:00
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("INFO")
font.bold: true
2021-02-09 18:41:39 +01:00
}
Item {
Layout.fillWidth: true
}
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("Internal ID")
}
2021-02-09 18:41:39 +01:00
MatrixText {
2021-02-11 16:53:33 +01:00
text: roomSettings.roomId
font.pixelSize: fontMetrics.font.pixelSize * 1.2
Layout.alignment: Qt.AlignRight
2021-02-09 18:41:39 +01:00
}
MatrixText {
2021-03-31 23:07:07 +02:00
text: qsTr("Room Version")
2021-02-09 18:41:39 +01:00
}
MatrixText {
2021-02-11 16:53:33 +01:00
text: roomSettings.roomVersion
font.pixelSize: fontMetrics.font.pixelSize * 1.2
Layout.alignment: Qt.AlignRight
2021-02-09 18:41:39 +01:00
}
2021-02-09 18:41:39 +01:00
}
2021-06-15 18:32:00 +02:00
DialogButtonBox {
Layout.fillWidth: true
standardButtons: DialogButtonBox.Ok
onAccepted: close()
2021-02-09 18:41:39 +01:00
}
2021-02-09 18:41:39 +01:00
}
}