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