diff options
author | tastytea <tastytea@tastytea.de> | 2022-01-11 07:38:27 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-02-10 00:48:35 +0100 |
commit | 5cd3e61cb0e39bdbbef0ccf3c252c3c65ba2824f (patch) | |
tree | 7d86f1e9bbb3a2729cabed56abe9d7afa8a4f813 /resources/qml/dialogs | |
parent | Fix application name on Wayland in flatpak (diff) | |
download | nheko-5cd3e61cb0e39bdbbef0ccf3c252c3c65ba2824f.tar.xz |
Add GUI to change hidden events per room
This adds a dialog to the room settings in which the user can choose which of these three event types they want to hide (additionally to the default): - m.room.member - m.room.power_levels - m.sticker The current state is read when room settings are opened and saved when new settings are accepted.
Diffstat (limited to 'resources/qml/dialogs')
-rw-r--r-- | resources/qml/dialogs/HiddenEventsDialog.qml | 108 | ||||
-rw-r--r-- | resources/qml/dialogs/RoomSettings.qml | 17 |
2 files changed, 124 insertions, 1 deletions
diff --git a/resources/qml/dialogs/HiddenEventsDialog.qml b/resources/qml/dialogs/HiddenEventsDialog.qml new file mode 100644 index 00000000..cfe75b06 --- /dev/null +++ b/resources/qml/dialogs/HiddenEventsDialog.qml @@ -0,0 +1,108 @@ +// SPDX-FileCopyrightText: 2022 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import ".." +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.3 +import im.nheko 1.0 + +ApplicationWindow { + id: hiddenEventsDialog + + property alias prompt: promptLabel.text + property var onAccepted: undefined + + modality: Qt.NonModal + flags: Qt.Dialog + minimumWidth: 250 + minimumHeight: 220 + Component.onCompleted: Nheko.reparent(hiddenEventsDialog) + title: qsTr("Hidden events settings for %1").arg(roomSettings.roomName) + + Shortcut { + sequence: StandardKey.Cancel + onActivated: dbb.rejected() + } + + ColumnLayout { + spacing: Nheko.paddingMedium + anchors.margins: Nheko.paddingMedium + anchors.fill: parent + + MatrixText { + id: promptLabel + font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.2) + Layout.fillWidth: true + Layout.fillHeight: false + } + + GridLayout { + columns: 2 + rowSpacing: Nheko.paddingMedium + Layout.fillWidth: true + Layout.fillHeight: true + + MatrixText { + text: qsTr("User events") + ToolTip.text: qsTr("Joins, leaves, invites, knocks and bans") + ToolTip.visible: hh1.hovered + Layout.fillWidth: true + + HoverHandler { + id: hh1 + } + } + + ToggleButton { + id: toggleRoomMember + checked: roomSettings.eventHidden(0) + Layout.alignment: Qt.AlignRight + } + + MatrixText { + text: qsTr("Power level changes") + ToolTip.text: qsTr("Is sent when a moderator is added or removed or the permissions of a room are changed (happens a lot in some IRC rooms)") + ToolTip.visible: hh2.hovered + Layout.fillWidth: true + + HoverHandler { + id: hh2 + } + } + + ToggleButton { + id: toggleRoomPowerLevels + checked: roomSettings.eventHidden(1) + Layout.alignment: Qt.AlignRight + } + + MatrixText { + text: qsTr("Stickers") + Layout.fillWidth: true + } + + ToggleButton { + id: toggleSticker + Layout.alignment: Qt.AlignRight + checked: roomSettings.eventHidden(2) + } + } + } + + footer: DialogButtonBox { + id: dbb + + standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel + onAccepted: { + roomSettings.saveHiddenEventsSettings(toggleRoomMember.checked, toggleRoomPowerLevels.checked, toggleSticker.checked); + + hiddenEventsDialog.close(); + } + onRejected: { + hiddenEventsDialog.close(); + } + } + +} diff --git a/resources/qml/dialogs/RoomSettings.qml b/resources/qml/dialogs/RoomSettings.qml index fad7b4c7..dbf22b29 100644 --- a/resources/qml/dialogs/RoomSettings.qml +++ b/resources/qml/dialogs/RoomSettings.qml @@ -254,6 +254,22 @@ ApplicationWindow { Layout.alignment: Qt.AlignRight } + MatrixText { + text: qsTr("Hidden events") + } + + HiddenEventsDialog { + id: hiddenEventsDialog + prompt: qsTr("Select the events you want to hide from %1").arg(roomSettings.roomName) + } + + Button { + text: qsTr("Configure") + ToolTip.text: qsTr("Change which events are hidden in this room") + onClicked: hiddenEventsDialog.show() + Layout.alignment: Qt.AlignRight + } + Item { // for adding extra space between sections Layout.fillWidth: true @@ -302,5 +318,4 @@ ApplicationWindow { } } - } |