| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import QtQuick |
| 6 |
import QtQuick.Controls |
| 7 |
import QtQuick.Window |
| 8 |
import im.nheko |
| 9 |
|
| 10 |
Image { |
| 11 |
id: stateImg |
| 12 |
|
| 13 |
property bool encrypted: false |
| 14 |
property bool hovered: ma.hovered |
| 15 |
property string sourceUrl: { |
| 16 |
if (!encrypted) |
| 17 |
return "image://colorimage/" + unencryptedIcon + "?"; |
| 18 |
switch (trust) { |
| 19 |
case Crypto.Verified: |
| 20 |
return "image://colorimage/:/icons/icons/ui/shield-filled-checkmark.svg?"; |
| 21 |
case Crypto.TOFU: |
| 22 |
return "image://colorimage/:/icons/icons/ui/shield-filled.svg?"; |
| 23 |
case Crypto.Unverified: |
| 24 |
case Crypto.MessageUnverified: |
| 25 |
return "image://colorimage/:/icons/icons/ui/shield-filled-exclamation-mark.svg?"; |
| 26 |
default: |
| 27 |
return "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?"; |
| 28 |
} |
| 29 |
} |
| 30 |
property int trust: Crypto.Unverified |
| 31 |
property color unencryptedColor: Nheko.theme.error |
| 32 |
property color unencryptedHoverColor: unencryptedColor |
| 33 |
property string unencryptedIcon: ":/icons/icons/ui/shield-filled-cross.svg" |
| 34 |
|
| 35 |
ToolTip.text: { |
| 36 |
if (!encrypted) |
| 37 |
return qsTr("This message is not encrypted!"); |
| 38 |
switch (trust) { |
| 39 |
case Crypto.Verified: |
| 40 |
return qsTr("Encrypted by a verified device"); |
| 41 |
case Crypto.TOFU: |
| 42 |
return qsTr("Encrypted by an unverified device, but you have trusted that user so far."); |
| 43 |
case Crypto.MessageUnverified: |
| 44 |
return qsTr("Key is from an untrusted source, possibly forwarded from another user or the online key backup. For this reason we can't verify who sent the message."); |
| 45 |
default: |
| 46 |
return qsTr("Encrypted by an unverified device."); |
| 47 |
} |
| 48 |
} |
| 49 |
ToolTip.visible: stateImg.hovered |
| 50 |
height: 16 |
| 51 |
source: { |
| 52 |
if (encrypted) { |
| 53 |
switch (trust) { |
| 54 |
case Crypto.Verified: |
| 55 |
return sourceUrl + Nheko.theme.green; |
| 56 |
case Crypto.TOFU: |
| 57 |
return sourceUrl + palette.buttonText; |
| 58 |
default: |
| 59 |
return sourceUrl + Nheko.theme.error; |
| 60 |
} |
| 61 |
} else { |
| 62 |
return sourceUrl + (stateImg.hovered ? unencryptedHoverColor : unencryptedColor); |
| 63 |
} |
| 64 |
} |
| 65 |
width: 16 |
| 66 |
|
| 67 |
HoverHandler { |
| 68 |
id: ma |
| 69 |
|
| 70 |
} |
| 71 |
} |