2022-01-11 09:38:27 +03:00
|
|
|
// 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
|
|
|
|
|
2022-01-13 01:52:32 +03:00
|
|
|
property var isRoomSetting: false
|
2022-01-11 09:38:27 +03:00
|
|
|
property var onAccepted: undefined
|
|
|
|
|
|
|
|
modality: Qt.NonModal
|
2022-01-13 01:26:50 +03:00
|
|
|
flags: Qt.Dialog | Qt.WindowTitleHint
|
2022-01-11 09:38:27 +03:00
|
|
|
minimumWidth: 250
|
|
|
|
minimumHeight: 220
|
|
|
|
Component.onCompleted: Nheko.reparent(hiddenEventsDialog)
|
2022-01-13 01:52:32 +03:00
|
|
|
title: {
|
|
|
|
if (isRoomSetting) {
|
|
|
|
return qsTr("Hidden events for %1").arg(roomSettings.roomName);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return qsTr("Hidden events");
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 09:38:27 +03:00
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Cancel
|
|
|
|
onActivated: dbb.rejected()
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
MatrixText {
|
|
|
|
id: promptLabel
|
2022-01-13 01:52:32 +03:00
|
|
|
text: {
|
|
|
|
if (isRoomSetting) {
|
|
|
|
return qsTr("These events will be be <b>shown</b> in %1:").arg(roomSettings.roomName);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return qsTr("These events will be be <b>shown</b>:");
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 09:38:27 +03:00
|
|
|
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")
|
2022-01-12 12:03:47 +03:00
|
|
|
ToolTip.text: qsTr("Joins, leaves, avatar and name changes, bans, …")
|
2022-01-11 09:38:27 +03:00
|
|
|
ToolTip.visible: hh1.hovered
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hh1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
id: toggleRoomMember
|
2022-01-13 01:26:50 +03:00
|
|
|
checked: !roomSettings.eventHidden("m.room.member")
|
2022-01-11 09:38:27 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
|
|
|
text: qsTr("Power level changes")
|
2022-01-12 12:03:47 +03:00
|
|
|
ToolTip.text: qsTr("Sent when a moderator is added/removed or the permissions of a room are changed.")
|
2022-01-11 09:38:27 +03:00
|
|
|
ToolTip.visible: hh2.hovered
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hh2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
id: toggleRoomPowerLevels
|
2022-01-13 01:26:50 +03:00
|
|
|
checked: !roomSettings.eventHidden("m.room.power_levels")
|
2022-01-11 09:38:27 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
|
|
|
text: qsTr("Stickers")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
id: toggleSticker
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2022-01-13 01:26:50 +03:00
|
|
|
checked: !roomSettings.eventHidden("m.sticker")
|
2022-01-11 09:38:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: DialogButtonBox {
|
|
|
|
id: dbb
|
|
|
|
|
|
|
|
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
|
|
|
|
onAccepted: {
|
2022-01-13 01:26:50 +03:00
|
|
|
let events = new Array;
|
|
|
|
if (!toggleRoomMember.checked) {
|
|
|
|
events.push("m.room.member");
|
|
|
|
}
|
|
|
|
if (!toggleRoomPowerLevels.checked) {
|
|
|
|
events.push("m.room.power_levels");
|
|
|
|
}
|
|
|
|
if (!toggleSticker.checked) {
|
|
|
|
events.push("m.sticker");
|
|
|
|
}
|
2022-01-13 02:39:26 +03:00
|
|
|
roomSettings.saveHiddenEventsSettings(events, roomSettings.roomId);
|
2022-01-11 09:38:27 +03:00
|
|
|
|
|
|
|
hiddenEventsDialog.close();
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
hiddenEventsDialog.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|