2023-07-05 01:08:37 +03:00
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
import QtQuick
import QtQuick . Controls
import QtQuick . Layouts
import im . nheko
ApplicationWindow {
id: dialog
property var onAccepted: undefined
2023-10-31 05:11:03 +03:00
property string roomName: ""
property string roomid: ""
2023-07-05 01:08:37 +03:00
flags: Qt . Dialog | Qt . WindowTitleHint
height: 330
minimumHeight: 220
2023-10-31 05:11:03 +03:00
minimumWidth: 250
modality: Qt . NonModal
2023-07-05 01:08:37 +03:00
title: {
if ( roomid ) {
return qsTr ( "Event expiration for %1" ) . arg ( roomName ) ;
2023-10-31 05:11:03 +03:00
} else {
2023-07-05 01:08:37 +03:00
return qsTr ( "Event expiration" ) ;
}
}
2023-10-31 05:11:03 +03:00
width: 275
footer: DialogButtonBox {
id: dbb
2023-07-05 01:08:37 +03:00
2023-10-31 05:11:03 +03:00
standardButtons: DialogButtonBox . Ok | DialogButtonBox . Cancel
onAccepted: {
eventExpiry . save ( ) ;
dialog . close ( ) ;
}
onRejected: dialog . close ( )
}
EventExpiry {
id: eventExpiry
roomid: dialog . roomid
}
2023-07-05 01:08:37 +03:00
Shortcut {
sequence: StandardKey . Cancel
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
onActivated: dbb . rejected ( )
}
ColumnLayout {
anchors.fill: parent
2023-10-31 05:11:03 +03:00
anchors.margins: Nheko . paddingMedium
spacing: Nheko . paddingMedium
2023-07-05 01:08:37 +03:00
MatrixText {
id: promptLabel
2023-10-31 05:11:03 +03:00
Layout.fillHeight: false
Layout.fillWidth: true
font.pixelSize: Math . floor ( fontMetrics . font . pixelSize * 1.2 )
2023-07-05 01:08:37 +03:00
text: {
if ( roomid ) {
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 ) ;
2023-10-31 05:11:03 +03:00
} else {
2023-07-05 01:08:37 +03:00
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." ) ;
}
}
}
GridLayout {
2023-10-31 05:11:03 +03:00
Layout.fillHeight: true
Layout.fillWidth: true
2023-07-05 01:08:37 +03:00
columns: 2
rowSpacing: Nheko . paddingMedium
MatrixText {
2023-10-31 05:11:03 +03:00
Layout.fillWidth: true
2023-07-05 01:08:37 +03:00
ToolTip.text: qsTr ( "Automatically redacts messages after X days, unless otherwise protected. Set to 0 to disable." )
ToolTip.visible: hh1 . hovered
2023-10-31 05:11:03 +03:00
text: qsTr ( "Expire events after X days" )
2023-07-05 01:08:37 +03:00
HoverHandler {
id: hh1
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
}
}
SpinBox {
Layout.alignment: Qt . AlignRight | Qt . AlignVCenter
2023-10-31 05:11:03 +03:00
editable: true
2023-07-05 01:08:37 +03:00
from: 0
stepSize: 1
2023-10-31 05:11:03 +03:00
to: 1000
2023-07-05 01:08:37 +03:00
value: eventExpiry . expireEventsAfterDays
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
onValueChanged: eventExpiry . expireEventsAfterDays = value
}
MatrixText {
2023-10-31 05:11:03 +03:00
Layout.fillWidth: true
2023-07-05 01:08:37 +03:00
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." )
ToolTip.visible: hh2 . hovered
2023-10-31 05:11:03 +03:00
text: qsTr ( "Only keep latest X events" )
2023-07-05 01:08:37 +03:00
HoverHandler {
id: hh2
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
}
}
SpinBox {
Layout.alignment: Qt . AlignRight | Qt . AlignVCenter
2023-10-31 05:11:03 +03:00
editable: true
2023-07-05 01:08:37 +03:00
from: 0
stepSize: 1
2023-10-31 05:11:03 +03:00
to: 1000000
2023-07-05 01:08:37 +03:00
value: eventExpiry . expireEventsAfterCount
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
onValueChanged: eventExpiry . expireEventsAfterCount = value
}
MatrixText {
2023-10-31 05:11:03 +03:00
Layout.fillWidth: true
2023-07-05 01:08:37 +03:00
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." )
ToolTip.visible: hh3 . hovered
2023-10-31 05:11:03 +03:00
text: qsTr ( "Always keep latest X events" )
2023-07-05 01:08:37 +03:00
HoverHandler {
id: hh3
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
}
}
SpinBox {
Layout.alignment: Qt . AlignRight | Qt . AlignVCenter
2023-10-31 05:11:03 +03:00
editable: true
2023-07-05 01:08:37 +03:00
from: 0
stepSize: 1
2023-10-31 05:11:03 +03:00
to: 1000000
2023-07-05 01:08:37 +03:00
value: eventExpiry . protectLatestEvents
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
onValueChanged: eventExpiry . protectLatestEvents = value
}
MatrixText {
2023-10-31 05:11:03 +03:00
Layout.fillWidth: true
2023-07-05 01:08:37 +03:00
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." )
ToolTip.visible: hh4 . hovered
2023-10-31 05:11:03 +03:00
text: qsTr ( "Include state events" )
2023-07-05 01:08:37 +03:00
HoverHandler {
id: hh4
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
}
}
ToggleButton {
Layout.alignment: Qt . AlignRight
checked: eventExpiry . expireStateEvents
2023-10-31 05:11:03 +03:00
2023-07-05 01:08:37 +03:00
onToggled: eventExpiry . expireStateEvents = checked
}
}
}
}