Show a placeholder for encrypted messages

Tells the user that the message could not be decrypted because the key
was not shared with the device. At the moment, this is technically not
completely correct, but it will be when libQuotient supports reading
encrypted messages
This commit is contained in:
Tobias Fella
2021-08-18 21:54:06 +02:00
parent 94c4bbc3db
commit d7ce0b7468
5 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.neochat 1.0
TextEdit {
text: i18n("This message is encrypted and the sender has not shared the key with this device.")
color: Kirigami.Theme.disabledTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize
selectByMouse: !Kirigami.Settings.isMobile
readOnly: true
wrapMode: Text.WordWrap
textFormat: Text.RichText
width: messageContainer.bubbleMaxWidth
}

View File

@@ -8,3 +8,4 @@ FileDelegate 1.0 FileDelegate.qml
VideoDelegate 1.0 VideoDelegate.qml
ReactionDelegate 1.0 ReactionDelegate.qml
AudioDelegate 1.0 AudioDelegate.qml
EncryptedDelegate 1.0 EncryptedDelegate.qml

View File

@@ -557,6 +557,22 @@ Kirigami.ScrollablePage {
}
}
DelegateChoice {
roleValue: "encrypted"
delegate: TimelineContainer {
id: encryptedContainer
width: messageListView.width
isLoaded: timelineDelegateChooser.delegateLoaded
innerObject: EncryptedDelegate {
Layout.fillWidth: Config.compactLayout
Layout.maximumWidth: encryptedContainer.bubbleMaxWidth
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.leftMargin: Config.showAvatarInTimeline ? Kirigami.Units.largeSpacing : 0
}
}
}
DelegateChoice {
roleValue: "readMarker"
delegate: QQC2.ItemDelegate {

View File

@@ -40,6 +40,7 @@
<file>imports/NeoChat/Component/Timeline/AudioDelegate.qml</file>
<file>imports/NeoChat/Component/Timeline/FileDelegate.qml</file>
<file>imports/NeoChat/Component/Timeline/ImageDelegate.qml</file>
<file>imports/NeoChat/Component/Timeline/EncryptedDelegate.qml</file>
<file>imports/NeoChat/Component/Login/qmldir</file>
<file>imports/NeoChat/Component/Login/LoginStep.qml</file>
<file>imports/NeoChat/Component/Login/Login.qml</file>

View File

@@ -490,6 +490,9 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
if (evt.isStateEvent()) {
return "state";
}
if (is<const EncryptedEvent>(evt)) {
return "encrypted";
}
return "other";
}