Debian Codegraph @

resources/qml/delegates/Encrypted.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import QtQuick 2.15
6 import QtQuick.Controls 2.15
7 import QtQuick.Layouts 1.15
8 import im.nheko 1.0
9
10 Control {
11 id: r
12
13 required property int encryptionError
14 required property string eventId
15
16 padding: Nheko.paddingMedium
17 implicitHeight: contents.implicitHeight + Nheko.paddingMedium * 2
18 Layout.maximumWidth: contents.Layout.maximumWidth + padding * 2
19 Layout.fillWidth: true
20
21 contentItem: RowLayout {
22 id: contents
23
24 spacing: Nheko.paddingMedium
25
26 Image {
27 source: "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?" + Nheko.theme.error
28 Layout.alignment: Qt.AlignVCenter
29 Layout.preferredWidth: 24
30 Layout.preferredHeight: 24
31 }
32
33 ColumnLayout {
34 spacing: Nheko.paddingSmall
35 Layout.fillWidth: true
36
37 Label {
38 id: encryptedText
39 text: {
40 switch (r.encryptionError) {
41 case Olm.MissingSession:
42 return qsTr("There is no key to unlock this message. We requested the key automatically, but you can try requesting it again if you are impatient.");
43 case Olm.MissingSessionIndex:
44 return qsTr("This message couldn't be decrypted, because we only have a key for newer messages. You can try requesting access to this message.");
45 case Olm.DbError:
46 return qsTr("There was an internal error reading the decryption key from the database.");
47 case Olm.DecryptionFailed:
48 return qsTr("There was an error decrypting this message.");
49 case Olm.ParsingFailed:
50 return qsTr("The message couldn't be parsed.");
51 case Olm.ReplayAttack:
52 return qsTr("The encryption key was reused! Someone is possibly trying to insert false messages into this chat!");
53 default:
54 return qsTr("Unknown decryption error");
55 }
56 }
57 textFormat: Text.PlainText
58 wrapMode: Label.WordWrap
59 color: palette.text
60 Layout.fillWidth: true
61 Layout.maximumWidth: implicitWidth + 1
62 }
63
64 Button {
65 visible: r.encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex
66 text: qsTr("Request key")
67 onClicked: room.requestKeyForEvent(eventId)
68 }
69
70 }
71
72 }
73
74 background: Rectangle {
75 color: palette.alternateBase
76 radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingMedium
77 visible: !Settings.bubbles // the bubble in a bubble looks odd
78 }
79 }