Debian Codegraph @

resources/qml/dialogs/EventExpirationDialog.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import ".."
6 import QtQuick
7 import QtQuick.Controls
8 import QtQuick.Layouts
9 import im.nheko
10
11 ApplicationWindow {
12 id: dialog
13
14 property string roomid: ""
15 property string roomName: ""
16 property var onAccepted: undefined
17
18 modality: Qt.NonModal
19 flags: Qt.Dialog | Qt.WindowTitleHint
20 width: 275
21 height: 330
22 minimumWidth: 250
23 minimumHeight: 220
24
25 EventExpiry {
26 id: eventExpiry
27
28 roomid: dialog.roomid
29 }
30
31 title: {
32 if (roomid) {
33 return qsTr("Event expiration for %1").arg(roomName);
34 }
35 else {
36 return qsTr("Event expiration");
37 }
38 }
39
40 Shortcut {
41 sequence: StandardKey.Cancel
42 onActivated: dbb.rejected()
43 }
44
45 ColumnLayout {
46 spacing: Nheko.paddingMedium
47 anchors.margins: Nheko.paddingMedium
48 anchors.fill: parent
49
50 MatrixText {
51 id: promptLabel
52 text: {
53 if (roomid) {
54 return qsTr("You can configure when your messages will be deleted in %1. This only happens when Nheko is open and has permissions to delete messages until Matrix servers support this feature natively. In general 0 means disable.").arg(roomName);
55 }
56 else {
57 return qsTr("You can configure when your messages will be deleted in all rooms unless configured otherwise. This only happens when Nheko is open and has permissions to delete messages until Matrix servers support this feature natively. In general 0 means disable.");
58 }
59 }
60 font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 1.2)
61 Layout.fillWidth: true
62 Layout.fillHeight: false
63 }
64
65 GridLayout {
66 columns: 2
67 rowSpacing: Nheko.paddingMedium
68 Layout.fillWidth: true
69 Layout.fillHeight: true
70
71 MatrixText {
72 text: qsTr("Expire events after X days")
73 ToolTip.text: qsTr("Automatically redacts messages after X days, unless otherwise protected. Set to 0 to disable.")
74 ToolTip.visible: hh1.hovered
75 Layout.fillWidth: true
76
77 HoverHandler {
78 id: hh1
79 }
80 }
81
82 SpinBox {
83 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
84 from: 0
85 to: 1000
86 stepSize: 1
87 value: eventExpiry.expireEventsAfterDays
88 onValueChanged: eventExpiry.expireEventsAfterDays = value
89 editable: true
90 }
91
92 MatrixText {
93 text: qsTr("Only keep latest X events")
94 ToolTip.text: qsTr("Deletes your events in this room if there are more than X newer messages unless otherwise protected. Set to 0 to disable.")
95 ToolTip.visible: hh2.hovered
96 Layout.fillWidth: true
97
98 HoverHandler {
99 id: hh2
100 }
101 }
102
103
104 SpinBox {
105 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
106 from: 0
107 to: 1000000
108 stepSize: 1
109 value: eventExpiry.expireEventsAfterCount
110 onValueChanged: eventExpiry.expireEventsAfterCount = value
111 editable: true
112 }
113
114 MatrixText {
115 text: qsTr("Always keep latest X events")
116 ToolTip.text: qsTr("This prevents events to be deleted by the above 2 settings if they are the latest X messages from you in the room.")
117 ToolTip.visible: hh3.hovered
118 Layout.fillWidth: true
119
120 HoverHandler {
121 id: hh3
122 }
123 }
124
125
126 SpinBox {
127 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
128 from: 0
129 to: 1000000
130 stepSize: 1
131 value: eventExpiry.protectLatestEvents
132 onValueChanged: eventExpiry.protectLatestEvents = value
133 editable: true
134 }
135
136 MatrixText {
137 text: qsTr("Include state events")
138 ToolTip.text: qsTr("If this is turned on, old state events also get redacted. The latest state event of any type+key combination is excluded from redaction to not remove the room name and similar state by accident.")
139 ToolTip.visible: hh4.hovered
140 Layout.fillWidth: true
141
142 HoverHandler {
143 id: hh4
144 }
145 }
146
147 ToggleButton {
148 Layout.alignment: Qt.AlignRight
149 checked: eventExpiry.expireStateEvents
150 onToggled: eventExpiry.expireStateEvents = checked
151 }
152 }
153 }
154
155 footer: DialogButtonBox {
156 id: dbb
157
158 standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
159 onAccepted: {
160 eventExpiry.save();
161 dialog.close();
162 }
163 onRejected: dialog.close();
164 }
165
166 }
167