matrixion/qml/dialogs/HiddenEventsDialog.qml

117 lines
3.3 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2022 Nheko Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
2022-04-16 03:13:01 +03:00
import "../"
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import im.nheko
ApplicationWindow {
id: hiddenEventsDialog
property var onAccepted: undefined
2022-04-16 03:13:01 +03:00
property string roomName: ""
property string roomid: ""
flags: Qt.Dialog | Qt.WindowTitleHint
minimumHeight: 220
2022-04-16 03:13:01 +03:00
minimumWidth: 250
modality: Qt.NonModal
title: {
if (roomid) {
return qsTr("Hidden events for %1").arg(roomName);
2022-04-16 03:13:01 +03:00
} else {
return qsTr("Hidden events");
}
}
2022-04-16 03:13:01 +03:00
footer: DialogButtonBox {
id: dbb
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
onAccepted: {
hiddenEvents.save();
hiddenEventsDialog.close();
}
onRejected: hiddenEventsDialog.close()
}
HiddenEvents {
id: hiddenEvents
roomid: hiddenEventsDialog.roomid
}
Shortcut {
sequence: StandardKey.Cancel
2022-04-16 03:13:01 +03:00
onActivated: dbb.rejected()
}
ColumnLayout {
anchors.fill: parent
2022-04-16 03:13:01 +03:00
anchors.margins: Nheko.paddingMedium
spacing: Nheko.paddingMedium
MatrixText {
id: promptLabel
2022-04-16 03:13:01 +03:00
Layout.fillHeight: false
Layout.fillWidth: true
font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.2)
text: {
if (roomid) {
return qsTr("These events will be <b>shown</b> in %1:").arg(roomName);
2022-04-16 03:13:01 +03:00
} else {
return qsTr("These events will be <b>shown</b> in all rooms:");
}
}
}
GridLayout {
2022-04-16 03:13:01 +03:00
Layout.fillHeight: true
Layout.fillWidth: true
columns: 2
rowSpacing: Nheko.paddingMedium
MatrixText {
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
ToolTip.text: qsTr("Joins, leaves, avatar and name changes, bans, …")
ToolTip.visible: hh1.hovered
2022-04-16 03:13:01 +03:00
text: qsTr("User events")
HoverHandler {
id: hh1
}
}
ToggleButton {
Layout.alignment: Qt.AlignRight
checked: !hiddenEvents.hiddenEvents.includes(MtxEvent.Member)
2022-04-16 03:13:01 +03:00
onToggled: hiddenEvents.toggle(MtxEvent.Member)
}
MatrixText {
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
ToolTip.text: qsTr("Sent when a moderator is added/removed or the permissions of a room are changed.")
ToolTip.visible: hh2.hovered
2022-04-16 03:13:01 +03:00
text: qsTr("Power level changes")
HoverHandler {
id: hh2
}
}
ToggleButton {
Layout.alignment: Qt.AlignRight
checked: !hiddenEvents.hiddenEvents.includes(MtxEvent.PowerLevels)
2022-04-16 03:13:01 +03:00
onToggled: hiddenEvents.toggle(MtxEvent.PowerLevels)
}
MatrixText {
Layout.fillWidth: true
2022-04-16 03:13:01 +03:00
text: qsTr("Stickers")
}
ToggleButton {
Layout.alignment: Qt.AlignRight
checked: !hiddenEvents.hiddenEvents.includes(MtxEvent.Sticker)
2022-04-16 03:13:01 +03:00
onToggled: hiddenEvents.toggle(MtxEvent.Sticker)
}
}
}
}