Add lock to encrypted messages

This commit is contained in:
Nicolas Werner 2019-09-19 23:02:56 +02:00
parent a5ccd00be0
commit 82091999c4
5 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,30 @@
import QtQuick 2.5
import QtQuick.Controls 2.5
import QtGraphicalEffects 1.0
import com.github.nheko 1.0
Rectangle {
id: indicator
color: "transparent"
width: 16
height: 16
ToolTip.visible: ma.containsMouse && indicator.visible
ToolTip.text: qsTr("Encrypted")
MouseArea{
id: ma
anchors.fill: parent
hoverEnabled: true
}
Image {
id: stateImg
anchors.fill: parent
source: "qrc:/icons/icons/ui/lock.png"
}
ColorOverlay {
anchors.fill: stateImg
source: stateImg
color: colors.buttonText
}
}

View File

@ -124,6 +124,12 @@ Rectangle {
Layout.preferredHeight: 16 Layout.preferredHeight: 16
} }
EncryptionIndicator {
visible: model.isEncrypted
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
}
Button { Button {
Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.alignment: Qt.AlignRight | Qt.AlignTop
id: replyButton id: replyButton

View File

@ -118,6 +118,7 @@
<file>qml/TimelineView.qml</file> <file>qml/TimelineView.qml</file>
<file>qml/Avatar.qml</file> <file>qml/Avatar.qml</file>
<file>qml/StatusIndicator.qml</file> <file>qml/StatusIndicator.qml</file>
<file>qml/EncryptionIndicator.qml</file>
<file>qml/delegates/TextMessage.qml</file> <file>qml/delegates/TextMessage.qml</file>
<file>qml/delegates/NoticeMessage.qml</file> <file>qml/delegates/NoticeMessage.qml</file>
<file>qml/delegates/ImageMessage.qml</file> <file>qml/delegates/ImageMessage.qml</file>

View File

@ -293,6 +293,7 @@ TimelineModel::roleNames() const
{ProportionalHeight, "proportionalHeight"}, {ProportionalHeight, "proportionalHeight"},
{Id, "id"}, {Id, "id"},
{State, "state"}, {State, "state"},
{IsEncrypted, "isEncrypted"},
}; };
} }
int int
@ -391,6 +392,11 @@ TimelineModel::data(const QModelIndex &index, int role) const
return qml_mtx_events::Read; return qml_mtx_events::Read;
else else
return qml_mtx_events::Received; return qml_mtx_events::Received;
case IsEncrypted: {
auto tempEvent = events[id];
return boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
&tempEvent) != nullptr;
}
default: default:
return QVariant(); return QVariant();
} }

View File

@ -132,6 +132,7 @@ public:
ProportionalHeight, ProportionalHeight,
Id, Id,
State, State,
IsEncrypted,
}; };
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;