From 904d3f257ac7775ee3cde91b919b364824329061 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 26 Oct 2023 01:51:45 +0200 Subject: Fix some qml warnings --- resources/qml/EncryptionIndicator.qml | 8 +- resources/qml/ImageButton.qml | 6 +- resources/qml/Root.qml | 2 +- resources/qml/TopBar.qml | 8 +- resources/qml/UploadBox.qml | 2 - resources/qml/components/AdaptiveLayout.qml | 7 +- resources/qml/components/AdaptiveLayoutElement.qml | 4 +- resources/qml/components/AvatarListTile.qml | 38 +- resources/qml/components/MainWindowDialog.qml | 8 +- resources/qml/components/ReorderableListview.qml | 7 +- resources/qml/delegates/Encrypted.qml | 5 +- resources/qml/delegates/FileMessage.qml | 8 +- resources/qml/delegates/ImageMessage.qml | 26 +- resources/qml/delegates/PlayableMediaMessage.qml | 12 +- resources/qml/delegates/Redacted.qml | 2 +- resources/qml/delegates/Reply.qml | 12 +- resources/qml/delegates/TextMessage.qml | 25 +- resources/qml/dialogs/IgnoredUsers.qml | 13 +- resources/qml/dialogs/RoomSettings.qml | 678 --------------------- resources/qml/dialogs/RoomSettingsDialog.qml | 678 +++++++++++++++++++++ resources/qml/ui/Ripple.qml | 1 - resources/qml/ui/media/MediaControls.qml | 6 +- resources/qml/voip/CallInviteBar.qml | 8 +- resources/qml/voip/ScreenShare.qml | 8 +- resources/qml/voip/VideoCall.qml | 1 - 25 files changed, 777 insertions(+), 796 deletions(-) delete mode 100644 resources/qml/dialogs/RoomSettings.qml create mode 100644 resources/qml/dialogs/RoomSettingsDialog.qml (limited to 'resources') diff --git a/resources/qml/EncryptionIndicator.qml b/resources/qml/EncryptionIndicator.qml index 347220d7..b606a531 100644 --- a/resources/qml/EncryptionIndicator.qml +++ b/resources/qml/EncryptionIndicator.qml @@ -2,10 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.12 -import QtQuick.Controls 2.1 -import QtQuick.Window 2.15 -import im.nheko 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Window +import im.nheko Image { id: stateImg diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index ddc0b7d8..783a01d0 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -4,9 +4,9 @@ pragma ComponentBehavior: Bound import "./ui" -import QtQuick 2.3 -import QtQuick.Controls 2.3 -import im.nheko 1.0 // for cursor shape +import QtQuick +import QtQuick.Controls +import im.nheko // for cursor shape AbstractButton { id: button diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index 09a8f442..2b1454e4 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -245,7 +245,7 @@ Pane { } } function onOpenRoomSettingsDialog(settings) { - var component = Qt.createComponent("qrc:/resources/qml/dialogs/RoomSettings.qml"); + var component = Qt.createComponent("qrc:/resources/qml/dialogs/RoomSettingsDialog.qml"); if (component.status == Component.Ready) { var roomSettings = component.createObject(timelineRoot, { "roomSettings": settings diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index b7cd3ff0..6d1cc445 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -56,11 +56,11 @@ Pane { Layout.row: 0 displayName: communityName enabled: false - height: fontMetrics.lineSpacing + implicitHeight: fontMetrics.lineSpacing + implicitWidth: fontMetrics.lineSpacing roomid: communityId url: avatarUrl.replace("mxc://", "image://MxcImage/") visible: roomid && room.parentSpace.isLoaded && ("space:" + room.parentSpace.roomid != Communities.currentTagId) - width: fontMetrics.lineSpacing } Label { id: communityLabel @@ -98,11 +98,11 @@ Pane { Layout.rowSpan: 2 displayName: roomName enabled: false - height: Nheko.avatarSize + implicitHeight: Nheko.avatarSize + implicitWidth: Nheko.avatarSize roomid: roomId url: avatarUrl.replace("mxc://", "image://MxcImage/") userid: isDirect ? directChatOtherUserId : "" - width: Nheko.avatarSize } Label { Layout.column: 2 diff --git a/resources/qml/UploadBox.qml b/resources/qml/UploadBox.qml index 990fa422..1d9415e5 100644 --- a/resources/qml/UploadBox.qml +++ b/resources/qml/UploadBox.qml @@ -2,8 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import "./components" -import "./ui" import QtQuick 2.9 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 diff --git a/resources/qml/components/AdaptiveLayout.qml b/resources/qml/components/AdaptiveLayout.qml index eea74006..86a0d4b6 100644 --- a/resources/qml/components/AdaptiveLayout.qml +++ b/resources/qml/components/AdaptiveLayout.qml @@ -2,10 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.12 -import QtQuick.Controls 2.5 -import QtQuick.Layouts 1.12 -import im.nheko 1.0 +import QtQuick +import QtQuick.Controls +import im.nheko Container { //Component.onCompleted: { diff --git a/resources/qml/components/AdaptiveLayoutElement.qml b/resources/qml/components/AdaptiveLayoutElement.qml index 5d003f05..9c8d4622 100644 --- a/resources/qml/components/AdaptiveLayoutElement.qml +++ b/resources/qml/components/AdaptiveLayoutElement.qml @@ -2,9 +2,7 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.12 -import QtQuick.Controls 2.5 -import QtQuick.Layouts 1.12 +import QtQuick Item { property int minimumWidth: 100 diff --git a/resources/qml/components/AvatarListTile.qml b/resources/qml/components/AvatarListTile.qml index dad20e52..75c69098 100644 --- a/resources/qml/components/AvatarListTile.qml +++ b/resources/qml/components/AvatarListTile.qml @@ -3,10 +3,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later import ".." -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 -import im.nheko 1.0 +import QtQuick +import QtQuick.Layouts +import im.nheko Rectangle { id: tile @@ -36,12 +35,13 @@ Rectangle { when: hovered.hovered && !(index == selectedIndex) PropertyChanges { - target: tile - background: palette.dark - importantText: palette.brightText - unimportantText: palette.brightText - bubbleBackground: palette.highlight - bubbleText: palette.highlightedText + tile { + background: palette.dark + importantText: palette.brightText + unimportantText: palette.brightText + bubbleBackground: palette.highlight + bubbleText: palette.highlightedText + } } }, @@ -50,12 +50,13 @@ Rectangle { when: index == selectedIndex PropertyChanges { - target: tile - background: palette.highlight - importantText: palette.highlightedText - unimportantText: palette.highlightedText - bubbleBackground: palette.highlightedText - bubbleText: palette.highlight + tile { + background: palette.highlight + importantText: palette.highlightedText + unimportantText: palette.highlightedText + bubbleBackground: palette.highlightedText + bubbleText: palette.highlight + } } } @@ -75,8 +76,8 @@ Rectangle { enabled: false Layout.alignment: Qt.AlignVCenter - height: avatarSize - width: avatarSize + implicitHeight: avatarSize + implicitWidth: avatarSize url: tile.avatarUrl.replace("mxc://", "image://MxcImage/") displayName: title crop: tile.crop @@ -88,7 +89,6 @@ Rectangle { Layout.alignment: Qt.AlignLeft Layout.fillWidth: true Layout.minimumWidth: 100 - width: parent.width - avatar.width Layout.preferredWidth: parent.width - avatar.width spacing: Nheko.paddingSmall diff --git a/resources/qml/components/MainWindowDialog.qml b/resources/qml/components/MainWindowDialog.qml index 10c07aae..3372d429 100644 --- a/resources/qml/components/MainWindowDialog.qml +++ b/resources/qml/components/MainWindowDialog.qml @@ -2,11 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import Qt.labs.platform 1.1 as P -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.3 -import im.nheko 1.0 +import QtQuick +import QtQuick.Controls +import im.nheko Dialog { default property alias inner: scroll.data diff --git a/resources/qml/components/ReorderableListview.qml b/resources/qml/components/ReorderableListview.qml index 1e8ab7b0..689f8267 100644 --- a/resources/qml/components/ReorderableListview.qml +++ b/resources/qml/components/ReorderableListview.qml @@ -2,10 +2,9 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.15 -import QtQml.Models 2.1 -import im.nheko 1.0 -import ".." +import QtQuick +import QtQml.Models +import im.nheko Item { id: root diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml index 7aeeb28a..42a61918 100644 --- a/resources/qml/delegates/Encrypted.qml +++ b/resources/qml/delegates/Encrypted.qml @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import ".." import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 @@ -38,7 +37,7 @@ Control { Label { id: encryptedText text: { - switch (encryptionError) { + switch (r.encryptionError) { case Olm.MissingSession: return qsTr("There is no key to unlock this message. We requested the key automatically, but you can try requesting it again if you are impatient."); case Olm.MissingSessionIndex: @@ -63,7 +62,7 @@ Control { } Button { - visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex + visible: r.encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex text: qsTr("Request key") onClicked: room.requestKeyForEvent(eventId) } diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 9f350123..3f31e7ed 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -32,8 +32,8 @@ Control { color: palette.light radius: 22 - height: 44 - width: 44 + Layout.preferredHeight: 44 + Layout.preferredWidth: 44 Image { id: img @@ -68,7 +68,7 @@ Control { Layout.fillWidth: true Layout.maximumWidth: implicitWidth + 1 - text: filename + text: evRoot.filename textFormat: Text.PlainText elide: Text.ElideRight color: palette.text @@ -79,7 +79,7 @@ Control { Layout.fillWidth: true Layout.maximumWidth: implicitWidth + 1 - text: filesize + text: evRoot.filesize textFormat: Text.PlainText elide: Text.ElideRight color: palette.text diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 9c93c25b..18ff11d2 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -34,38 +34,36 @@ AbstractButton { name: "BlurhashVisible" PropertyChanges { - target: blurhash_ - opacity: (img.status != Image.Ready) || (timeline.privacyScreen.active && blurhash) ? 1 : 0 - visible: (img.status != Image.Ready) || (timeline.privacyScreen.active && blurhash) + blurhash_ { + opacity: (img.status != Image.Ready) || (timeline.privacyScreen.active && blurhash) ? 1 : 0 + visible: (img.status != Image.Ready) || (timeline.privacyScreen.active && blurhash) + } } PropertyChanges { - target: img - opacity: 0 + img.opacity: 0 } PropertyChanges { - target: mxcimage - opacity: 0 + mxcimage.opacity: 0 } }, State { name: "ImageVisible" PropertyChanges { - target: blurhash_ - opacity: 0 - visible: false + blurhash_ { + opacity: 0 + visible: false + } } PropertyChanges { - target: img - opacity: 1 + img.opacity: 1 } PropertyChanges { - target: mxcimage - opacity: 1 + mxcimage.opacity: 1 } } ] diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 99928369..2a47d275 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -2,12 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import "../" import "../ui/media" import QtMultimedia import QtQuick import QtQuick.Controls -import QtQuick.Layouts import im.nheko Item { @@ -47,7 +45,7 @@ Item { Rectangle { id: videoContainer - color: type == MtxEvent.VideoMessage ? palette.window : "transparent" + color: content.type == MtxEvent.VideoMessage ? palette.window : "transparent" width: parent.width height: parent.height - fileInfoLabel.height @@ -57,14 +55,14 @@ Item { Image { anchors.fill: parent - source: thumbnailUrl ? thumbnailUrl.replace("mxc://", "image://MxcImage/") + "?scale" : "image://colorimage/:/icons/icons/ui/video-file.svg?" + palette.windowText + source: content.thumbnailUrl ? thumbnailUrl.replace("mxc://", "image://MxcImage/") + "?scale" : "image://colorimage/:/icons/icons/ui/video-file.svg?" + palette.windowText asynchronous: true fillMode: Image.PreserveAspectFit VideoOutput { id: videoOutput - visible: type == MtxEvent.VideoMessage + visible: content.type == MtxEvent.VideoMessage clip: true anchors.fill: parent fillMode: VideoOutput.PreserveAspectFit @@ -79,7 +77,7 @@ Item { anchors.left: videoContainer.left anchors.right: videoContainer.right anchors.bottom: videoContainer.bottom - playingVideo: type == MtxEvent.VideoMessage + playingVideo: content.type == MtxEvent.VideoMessage positionValue: mxcmedia.position duration: mediaLoaded ? mxcmedia.duration : content.duration mediaLoaded: mxcmedia.loaded @@ -95,7 +93,7 @@ Item { id: fileInfoLabel anchors.top: videoContainer.bottom - text: body + " [" + filesize + "]" + text: content.body + " [" + filesize + "]" textFormat: Text.RichText elide: Text.ElideRight color: palette.text diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml index 3c496f08..1bf87f91 100644 --- a/resources/qml/delegates/Redacted.qml +++ b/resources/qml/delegates/Redacted.qml @@ -33,7 +33,7 @@ Control { Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.maximumWidth: implicitWidth + 1 Layout.fillWidth: true - property var redactedPair: room.formatRedactedEvent(msgRoot.eventId) + property var redactedPair: msgRoot.room.formatRedactedEvent(msgRoot.eventId) text: redactedPair["first"] wrapMode: Label.WordWrap diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index ece838b7..ff46347f 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -2,12 +2,10 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import Qt.labs.platform 1.1 as Platform -import QtQuick 2.12 -import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.2 -import QtQuick.Window 2.13 -import im.nheko 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Window +import im.nheko import "../" AbstractButton { @@ -45,7 +43,7 @@ AbstractButton { id: timelineEvent isStateEvent: false - room: room_ + room: r.room_ eventId: r.eventId replyTo: "" mainInset: 4 + Nheko.paddingMedium diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml index d17e61d2..3625aea1 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml @@ -3,7 +3,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later import ".." -import QtQuick.Controls import im.nheko MatrixText { @@ -18,28 +17,28 @@ MatrixText { property bool fitsMetadata: false //positionAt(width,height-4) == positionAt(width-metadataWidth-10, height-4) // table border-collapse doesn't seem to work - text: " - - " + formatted.replace(//g, "").replace(/<\/del>/g, "").replace(//g, "").replace(/<\/strike>/g, "") + background-color: ` + palette.text + `; + }` : "") + // TODO(Nico): Figure out how to support mobile + ` + ` + formatted.replace(//g, "").replace(/<\/del>/g, "").replace(//g, "").replace(/<\/strike>/g, "") enabled: !isReply font.pointSize: (Settings.enlargeEmojiOnlyMessages && isOnlyEmoji > 0 && isOnlyEmoji < 4) ? Settings.fontSize * 3 : Settings.fontSize diff --git a/resources/qml/dialogs/IgnoredUsers.qml b/resources/qml/dialogs/IgnoredUsers.qml index 2d8cc920..6d6585f0 100644 --- a/resources/qml/dialogs/IgnoredUsers.qml +++ b/resources/qml/dialogs/IgnoredUsers.qml @@ -2,12 +2,13 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQml 2.15 -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 2.15 -import QtQuick.Window 2.15 -import im.nheko 1.0 +import QtQml +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Window +import im.nheko +import "../" Window { id: ignoredUsers diff --git a/resources/qml/dialogs/RoomSettings.qml b/resources/qml/dialogs/RoomSettings.qml deleted file mode 100644 index 1ff6876e..00000000 --- a/resources/qml/dialogs/RoomSettings.qml +++ /dev/null @@ -1,678 +0,0 @@ -// SPDX-FileCopyrightText: Nheko Contributors -// -// SPDX-License-Identifier: GPL-3.0-or-later - -import ".." -import "../ui" -import Qt.labs.platform 1.1 as Platform -import QtQuick 2.15 -import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.2 -import QtQuick.Window 2.13 -import im.nheko 1.0 - -ApplicationWindow { - id: roomSettingsDialog - - property var roomSettings - - minimumWidth: 340 - minimumHeight: 450 - width: 450 - height: 680 - color: palette.window - modality: Qt.NonModal - flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - title: qsTr("Room Settings") - - Shortcut { - sequence: StandardKey.Cancel - onActivated: roomSettingsDialog.close() - } - - Flickable { - id: flickable - boundsBehavior: Flickable.StopAtBounds - anchors.fill: parent - clip: true - flickableDirection: Flickable.VerticalFlick - contentWidth: roomSettingsDialog.width - contentHeight: contentLayout1.height - ColumnLayout { - id: contentLayout1 - width: parent.width - spacing: Nheko.paddingMedium - - Avatar { - id: displayAvatar - - Layout.topMargin: Nheko.paddingMedium - url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/") - roomid: roomSettings.roomId - displayName: roomSettings.roomName - height: 130 - width: 130 - 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: { - roomSettings.updateAvatar(); - } - - } - } - - Spinner { - Layout.alignment: Qt.AlignHCenter - visible: roomSettings.isLoading - foreground: palette.mid - running: roomSettings.isLoading - } - - Text { - id: errorText - - color: "red" - visible: opacity > 0 - opacity: 0 - Layout.alignment: Qt.AlignHCenter - wrapMode: Text.Wrap // somehow still doesn't wrap - Layout.fillWidth: true - } - - SequentialAnimation { - id: hideErrorAnimation - - running: false - - PauseAnimation { - duration: 4000 - } - - NumberAnimation { - target: errorText - property: 'opacity' - to: 0 - duration: 1000 - } - - } - - Connections { - target: roomSettings - function onDisplayError(errorMessage) { - errorText.text = errorMessage; - errorText.opacity = 1; - hideErrorAnimation.restart(); - } - } - - 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(); - } - } - } - - } - - RowLayout { - spacing: Nheko.paddingMedium - Layout.alignment: Qt.AlignHCenter - - Label { - text: qsTr("%n member(s)", "", roomSettings.memberCount) - color: palette.text - } - - 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)) - } - - } - - TextArea { - id: roomTopic - property bool cut: implicitHeight > 100 - property bool showMore: false - clip: true - Layout.maximumHeight: showMore? Number.POSITIVE_INFINITY : 100 - Layout.preferredHeight: implicitHeight - Layout.alignment: Qt.AlignHCenter - Layout.fillWidth: true - Layout.leftMargin: Nheko.paddingLarge - Layout.rightMargin: Nheko.paddingLarge - - property bool isTopicEditingAllowed: false - - readOnly: !isTopicEditingAllowed - textFormat: isTopicEditingAllowed ? TextEdit.PlainText : TextEdit.RichText - text: isTopicEditingAllowed - ? roomSettings.plainRoomTopic - : (roomSettings.plainRoomTopic === "" ? ("" + qsTr("No topic set") + "") : roomSettings.roomTopic) - wrapMode: TextEdit.WordWrap - background: null - color: palette.text - horizontalAlignment: TextEdit.AlignHCenter - onLinkActivated: Nheko.openLink(link) - - NhekoCursorShape { - anchors.fill: parent - cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor - } - - } - - 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(); - } - } - } - - Item { - Layout.alignment: Qt.AlignHCenter - id: showMorePlaceholder - Layout.preferredHeight: showMoreButton.height - Layout.preferredWidth: showMoreButton.width - visible: roomTopic.cut - } - - GridLayout { - columns: 2 - rowSpacing: Nheko.paddingMedium - Layout.margins: Nheko.paddingMedium - Layout.fillWidth: true - - Label { - text: qsTr("NOTIFICATIONS") - font.bold: true - color: palette.text - Layout.columnSpan: 2 - Layout.fillWidth: true - Layout.topMargin: Nheko.paddingLarge - } - - Label { - text: qsTr("Notifications") - Layout.fillWidth: true - color: palette.text - } - - ComboBox { - model: [qsTr("Muted"), qsTr("Mentions only"), qsTr("All messages")] - currentIndex: roomSettings.notifications - onActivated: { - roomSettings.changeNotifications(index); - } - Layout.fillWidth: true - WheelHandler{} // suppress scrolling changing values - } - - Label { - text: qsTr("ENTRY PERMISSIONS") - font.bold: true - color: palette.text - Layout.columnSpan: 2 - Layout.fillWidth: true - Layout.topMargin: Nheko.paddingLarge - } - - Label { - text: qsTr("Anyone can join") - Layout.fillWidth: true - color: palette.text - } - - ToggleButton { - id: publicRoomButton - - 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 - - visible: !publicRoomButton.checked - enabled: roomSettings.canChangeJoinRules && roomSettings.supportsKnocking - checked: roomSettings.knockingEnabled - onCheckedChanged: { - if (checked && !roomSettings.supportsKnockRestricted) restrictedButton.checked = false; - } - 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; - } - 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 - Layout.fillWidth: true - } - - 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 - } - - Label { - text: qsTr("Encryption") - color: palette.text - } - - ToggleButton { - id: encryptionToggle - - checked: roomSettings.isEncryptionEnabled - onCheckedChanged: { - if (roomSettings.isEncryptionEnabled) { - checked = true; - return ; - } - if (checked === true) - 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.
- Please take note that it can't be disabled afterwards.") - modality: Qt.NonModal - onAccepted: { - if (roomSettings.isEncryptionEnabled) - return ; - - roomSettings.enableEncryption(); - } - onRejected: { - encryptionToggle.checked = false; - } - buttons: Platform.MessageDialog.Ok | Platform.MessageDialog.Cancel - } - - Label { - text: qsTr("Permission") - color: palette.text - } - - Button { - text: qsTr("Configure") - ToolTip.text: qsTr("View and change the permissions in this room") - onClicked: timelineRoot.showPLEditor(roomSettings) - Layout.alignment: Qt.AlignRight - } - - Label { - text: qsTr("Aliases") - color: palette.text - } - - Button { - text: qsTr("Configure") - ToolTip.text: qsTr("View and change the addresses/aliases of this room") - onClicked: timelineRoot.showAliasEditor(roomSettings) - Layout.alignment: Qt.AlignRight - } - - Label { - text: qsTr("Sticker & Emote Settings") - color: palette.text - } - - 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 - } - - Label { - text: qsTr("INFO") - font.bold: true - color: palette.text - Layout.columnSpan: 2 - Layout.topMargin: Nheko.paddingLarge - Layout.fillWidth: true - } - - Label { - text: qsTr("Internal ID") - color: palette.text - } - - AbstractButton { // AbstractButton does not allow setting text color - Layout.alignment: Qt.AlignRight - 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 - 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 - } - } - - Label { - text: qsTr("Room Version") - color: palette.text - } - - Label { - text: roomSettings.roomVersion - font.pixelSize: fontMetrics.font.pixelSize - Layout.alignment: Qt.AlignRight - color: palette.text - } - - } - } - } - Button { - id: showMoreButton - anchors.horizontalCenter: flickable.horizontalCenter - y: Math.min(showMorePlaceholder.y+contentLayout1.y-flickable.contentY,flickable.height-height) - visible: roomTopic.cut - text: roomTopic.showMore? qsTr("show less") : qsTr("show more") - onClicked: {roomTopic.showMore = !roomTopic.showMore - console.log(flickable.visibleArea) - } - } - footer: DialogButtonBox { - standardButtons: DialogButtonBox.Ok - onAccepted: close() - } -} diff --git a/resources/qml/dialogs/RoomSettingsDialog.qml b/resources/qml/dialogs/RoomSettingsDialog.qml new file mode 100644 index 00000000..73dcac8c --- /dev/null +++ b/resources/qml/dialogs/RoomSettingsDialog.qml @@ -0,0 +1,678 @@ +// SPDX-FileCopyrightText: Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import ".." +import "../ui" +import Qt.labs.platform 1.1 as Platform +import QtQuick 2.15 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.2 +import QtQuick.Window 2.13 +import im.nheko 1.0 + +ApplicationWindow { + id: roomSettingsDialog + + property var roomSettings + + minimumWidth: 340 + minimumHeight: 450 + width: 450 + height: 680 + color: palette.window + modality: Qt.NonModal + flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + title: qsTr("Room Settings") + + Shortcut { + sequence: StandardKey.Cancel + onActivated: roomSettingsDialog.close() + } + + Flickable { + id: flickable + boundsBehavior: Flickable.StopAtBounds + anchors.fill: parent + clip: true + flickableDirection: Flickable.VerticalFlick + contentWidth: roomSettingsDialog.width + contentHeight: contentLayout1.height + ColumnLayout { + id: contentLayout1 + width: parent.width + spacing: Nheko.paddingMedium + + Avatar { + id: displayAvatar + + Layout.topMargin: Nheko.paddingMedium + url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/") + roomid: roomSettings.roomId + displayName: roomSettings.roomName + height: 130 + width: 130 + 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: { + roomSettings.updateAvatar(); + } + + } + } + + Spinner { + Layout.alignment: Qt.AlignHCenter + visible: roomSettings.isLoading + foreground: palette.mid + running: roomSettings.isLoading + } + + Text { + id: errorText + + color: "red" + visible: opacity > 0 + opacity: 0 + Layout.alignment: Qt.AlignHCenter + wrapMode: Text.Wrap // somehow still doesn't wrap + Layout.fillWidth: true + } + + SequentialAnimation { + id: hideErrorAnimation + + running: false + + PauseAnimation { + duration: 4000 + } + + NumberAnimation { + target: errorText + property: 'opacity' + to: 0 + duration: 1000 + } + + } + + Connections { + target: roomSettings + function onDisplayError(errorMessage) { + errorText.text = errorMessage; + errorText.opacity = 1; + hideErrorAnimation.restart(); + } + } + + 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(); + } + } + } + + } + + RowLayout { + spacing: Nheko.paddingMedium + Layout.alignment: Qt.AlignHCenter + + Label { + text: qsTr("%n member(s)", "", roomSettings.memberCount) + color: palette.text + } + + 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)) + } + + } + + TextArea { + id: roomTopic + property bool cut: implicitHeight > 100 + property bool showMore: false + clip: true + Layout.maximumHeight: showMore? Number.POSITIVE_INFINITY : 100 + Layout.preferredHeight: implicitHeight + Layout.alignment: Qt.AlignHCenter + Layout.fillWidth: true + Layout.leftMargin: Nheko.paddingLarge + Layout.rightMargin: Nheko.paddingLarge + + property bool isTopicEditingAllowed: false + + readOnly: !isTopicEditingAllowed + textFormat: isTopicEditingAllowed ? TextEdit.PlainText : TextEdit.RichText + text: isTopicEditingAllowed + ? roomSettings.plainRoomTopic + : (roomSettings.plainRoomTopic === "" ? ("" + qsTr("No topic set") + "") : roomSettings.roomTopic) + wrapMode: TextEdit.WordWrap + background: null + color: palette.text + horizontalAlignment: TextEdit.AlignHCenter + onLinkActivated: Nheko.openLink(link) + + NhekoCursorShape { + anchors.fill: parent + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } + + } + + 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(); + } + } + } + + Item { + Layout.alignment: Qt.AlignHCenter + id: showMorePlaceholder + Layout.preferredHeight: showMoreButton.height + Layout.preferredWidth: showMoreButton.width + visible: roomTopic.cut + } + + GridLayout { + columns: 2 + rowSpacing: Nheko.paddingMedium + Layout.margins: Nheko.paddingMedium + Layout.fillWidth: true + + Label { + text: qsTr("NOTIFICATIONS") + font.bold: true + color: palette.text + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.topMargin: Nheko.paddingLarge + } + + Label { + text: qsTr("Notifications") + Layout.fillWidth: true + color: palette.text + } + + ComboBox { + model: [qsTr("Muted"), qsTr("Mentions only"), qsTr("All messages")] + currentIndex: roomSettings.notifications + onActivated: { + roomSettings.changeNotifications(index); + } + Layout.fillWidth: true + WheelHandler{} // suppress scrolling changing values + } + + Label { + text: qsTr("ENTRY PERMISSIONS") + font.bold: true + color: palette.text + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.topMargin: Nheko.paddingLarge + } + + Label { + text: qsTr("Anyone can join") + Layout.fillWidth: true + color: palette.text + } + + ToggleButton { + id: publicRoomButton + + 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 + + visible: !publicRoomButton.checked + enabled: roomSettings.canChangeJoinRules && roomSettings.supportsKnocking + checked: roomSettings.knockingEnabled + onCheckedChanged: { + if (checked && !roomSettings.supportsKnockRestricted) restrictedButton.checked = false; + } + 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; + } + 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 + Layout.fillWidth: true + } + + 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 + } + + Label { + text: qsTr("Encryption") + color: palette.text + } + + ToggleButton { + id: encryptionToggle + + checked: roomSettings.isEncryptionEnabled + onCheckedChanged: { + if (roomSettings.isEncryptionEnabled) { + checked = true; + return ; + } + if (checked === true) + 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.
+ Please take note that it can't be disabled afterwards.`) + modality: Qt.NonModal + onAccepted: { + if (roomSettings.isEncryptionEnabled) + return ; + + roomSettings.enableEncryption(); + } + onRejected: { + encryptionToggle.checked = false; + } + buttons: Platform.MessageDialog.Ok | Platform.MessageDialog.Cancel + } + + Label { + text: qsTr("Permission") + color: palette.text + } + + Button { + text: qsTr("Configure") + ToolTip.text: qsTr("View and change the permissions in this room") + onClicked: timelineRoot.showPLEditor(roomSettings) + Layout.alignment: Qt.AlignRight + } + + Label { + text: qsTr("Aliases") + color: palette.text + } + + Button { + text: qsTr("Configure") + ToolTip.text: qsTr("View and change the addresses/aliases of this room") + onClicked: timelineRoot.showAliasEditor(roomSettings) + Layout.alignment: Qt.AlignRight + } + + Label { + text: qsTr("Sticker & Emote Settings") + color: palette.text + } + + 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 + } + + Label { + text: qsTr("INFO") + font.bold: true + color: palette.text + Layout.columnSpan: 2 + Layout.topMargin: Nheko.paddingLarge + Layout.fillWidth: true + } + + Label { + text: qsTr("Internal ID") + color: palette.text + } + + AbstractButton { // AbstractButton does not allow setting text color + Layout.alignment: Qt.AlignRight + 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 + 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 + } + } + + Label { + text: qsTr("Room Version") + color: palette.text + } + + Label { + text: roomSettings.roomVersion + font.pixelSize: fontMetrics.font.pixelSize + Layout.alignment: Qt.AlignRight + color: palette.text + } + + } + } + } + Button { + id: showMoreButton + anchors.horizontalCenter: flickable.horizontalCenter + y: Math.min(showMorePlaceholder.y+contentLayout1.y-flickable.contentY,flickable.height-height) + visible: roomTopic.cut + text: roomTopic.showMore? qsTr("show less") : qsTr("show more") + onClicked: {roomTopic.showMore = !roomTopic.showMore + console.log(flickable.visibleArea) + } + } + footer: DialogButtonBox { + standardButtons: DialogButtonBox.Ok + onAccepted: close() + } +} diff --git a/resources/qml/ui/Ripple.qml b/resources/qml/ui/Ripple.qml index 911b88cf..9d871419 100644 --- a/resources/qml/ui/Ripple.qml +++ b/resources/qml/ui/Ripple.qml @@ -3,7 +3,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick -import QtQuick.Controls Item { id: ripple diff --git a/resources/qml/ui/media/MediaControls.qml b/resources/qml/ui/media/MediaControls.qml index bd5f6ddc..0519a194 100644 --- a/resources/qml/ui/media/MediaControls.qml +++ b/resources/qml/ui/media/MediaControls.qml @@ -198,13 +198,11 @@ Rectangle { when: Settings.mobileMode || volumeButton.hovered || volumeSlider.hovered || volumeSlider.pressed PropertyChanges { - target: volumeSlider - Layout.preferredWidth: 100 + volumeSlider.implicitWidth: 100 } PropertyChanges { - target: volumeSlider - opacity: 1 + volumeSlider.opacity: 1 } } diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index d82bd143..419181ca 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -3,10 +3,10 @@ // SPDX-License-Identifier: GPL-3.0-or-later import "../" -import QtQuick 2.9 -import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.2 -import im.nheko 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import im.nheko Rectangle { visible: CallManager.haveCallInvite && !Settings.mobileMode diff --git a/resources/qml/voip/ScreenShare.qml b/resources/qml/voip/ScreenShare.qml index 7f8665bc..d3661933 100644 --- a/resources/qml/voip/ScreenShare.qml +++ b/resources/qml/voip/ScreenShare.qml @@ -3,10 +3,10 @@ // SPDX-License-Identifier: GPL-3.0-or-later import "../" -import QtQuick 2.9 -import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.2 -import im.nheko 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import im.nheko Popup { modal: true diff --git a/resources/qml/voip/VideoCall.qml b/resources/qml/voip/VideoCall.qml index bd160d3e..f083d998 100644 --- a/resources/qml/voip/VideoCall.qml +++ b/resources/qml/voip/VideoCall.qml @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.9 import org.freedesktop.gstreamer.GLVideoItem 1.0 GstGLVideoItem { -- cgit 1.5.1