summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authortastytea <tastytea@tastytea.de>2022-01-11 07:38:27 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-02-10 00:48:35 +0100
commit5cd3e61cb0e39bdbbef0ccf3c252c3c65ba2824f (patch)
tree7d86f1e9bbb3a2729cabed56abe9d7afa8a4f813 /resources
parentFix application name on Wayland in flatpak (diff)
downloadnheko-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')
-rw-r--r--resources/qml/dialogs/HiddenEventsDialog.qml108
-rw-r--r--resources/qml/dialogs/RoomSettings.qml17
-rw-r--r--resources/res.qrc1
3 files changed, 125 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 { } } - } diff --git a/resources/res.qrc b/resources/res.qrc
index 2fba5f4c..c8659150 100644 --- a/resources/res.qrc +++ b/resources/res.qrc
@@ -152,6 +152,7 @@ <file>qml/dialogs/RoomMembers.qml</file> <file>qml/dialogs/RoomSettings.qml</file> <file>qml/dialogs/UserProfile.qml</file> + <file>qml/dialogs/HiddenEventsDialog.qml</file> <file>qml/emoji/EmojiPicker.qml</file> <file>qml/emoji/StickerPicker.qml</file> <file>qml/ui/NhekoSlider.qml</file>