summary refs log tree commit diff
path: root/resources/qml/dialogs/HiddenEventsDialog.qml
blob: e0e7960477d4b7e9f19fa706ae726b450a7ed2fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// 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 string roomid: ""
    property string roomName: ""
    property var onAccepted: undefined

    modality: Qt.NonModal
    flags: Qt.Dialog | Qt.WindowTitleHint
    minimumWidth: 250
    minimumHeight: 220

    HiddenEvents {
        id: hiddenEvents

        roomid: hiddenEventsDialog.roomid
    }

    title: {
        if (roomid) {
            return qsTr("Hidden events for %1").arg(roomName);
        }
        else {
            return qsTr("Hidden events");
        }
    }

    Shortcut {
        sequence: StandardKey.Cancel
        onActivated: dbb.rejected()
    }

    ColumnLayout {
        spacing: Nheko.paddingMedium
        anchors.margins: Nheko.paddingMedium
        anchors.fill: parent

        MatrixText {
            id: promptLabel
            text: {
                if (roomid) {
                    return qsTr("These events will be <b>shown</b> in %1:").arg(roomName);
                }
                else {
                    return qsTr("These events will be <b>shown</b> in all rooms:");
                }
            }
            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, avatar and name changes, bans, …")
                ToolTip.visible: hh1.hovered
                Layout.fillWidth: true

                HoverHandler {
                    id: hh1
                }
            }

            ToggleButton {
                Layout.alignment: Qt.AlignRight
                checked: !hiddenEvents.hiddenEvents.includes(MtxEvent.Member)
                onToggled: hiddenEvents.toggle(MtxEvent.Member)
            }

            MatrixText {
                text: qsTr("Power level changes")
                ToolTip.text: qsTr("Sent when a moderator is added/removed or the permissions of a room are changed.")
                ToolTip.visible: hh2.hovered
                Layout.fillWidth: true

                HoverHandler {
                    id: hh2
                }
            }

            ToggleButton {
                Layout.alignment: Qt.AlignRight
                checked: !hiddenEvents.hiddenEvents.includes(MtxEvent.PowerLevels)
                onToggled: hiddenEvents.toggle(MtxEvent.PowerLevels)
            }

            MatrixText {
                text: qsTr("Stickers")
                Layout.fillWidth: true
            }

            ToggleButton {
                Layout.alignment: Qt.AlignRight
                checked: !hiddenEvents.hiddenEvents.includes(MtxEvent.Sticker)
                onToggled: hiddenEvents.toggle(MtxEvent.Sticker)
            }
        }
    }

    footer: DialogButtonBox {
        id: dbb

        standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
        onAccepted: {
            hiddenEvents.save();
            hiddenEventsDialog.close();
        }
        onRejected: hiddenEventsDialog.close();
    }

}