From 18f934efad19821bb2932ba687b2f3c42735add2 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 14 May 2020 20:35:29 -0400 Subject: [PATCH] Add un-encrypted warning icon for messages in encrypted rooms --- resources/icons/ui/unlock.png | Bin 0 -> 385 bytes resources/icons/ui/unlock@2x.png | Bin 0 -> 741 bytes resources/langs/nheko_de.ts | 15 ++++++++++----- resources/langs/nheko_el.ts | 15 ++++++++++----- resources/langs/nheko_en.ts | 15 ++++++++++----- resources/langs/nheko_fi.ts | 15 ++++++++++----- resources/langs/nheko_fr.ts | 15 ++++++++++----- resources/langs/nheko_ja.ts | 15 ++++++++++----- resources/langs/nheko_nl.ts | 15 ++++++++++----- resources/langs/nheko_pl.ts | 15 ++++++++++----- resources/langs/nheko_ru.ts | 15 ++++++++++----- resources/langs/nheko_zh_CN.ts | 15 ++++++++++----- resources/qml/EncryptionIndicator.qml | 19 +++++++++++++++++-- resources/qml/TimelineRow.qml | 3 ++- resources/res.qrc | 2 ++ src/timeline/TimelineModel.cpp | 5 +++++ src/timeline/TimelineModel.h | 1 + 17 files changed, 127 insertions(+), 53 deletions(-) create mode 100644 resources/icons/ui/unlock.png create mode 100644 resources/icons/ui/unlock@2x.png diff --git a/resources/icons/ui/unlock.png b/resources/icons/ui/unlock.png new file mode 100644 index 0000000000000000000000000000000000000000..90e4602ad885027a149068503c6a088790856cd1 GIT binary patch literal 385 zcmV-{0e=38P)4B=R zkd(vChl(c@JdrJ+FX8gG;yDmJ-z`f( ziSTWkyElA6eHOd&K$-%eLpmj6cAv76ihs`}%k@{Eh4(et!8#+qN=ym>_ZdWzJ;&6n zOx5@>RP$FY%q4fF(s9tprf!rxkR}hL$pdNfK$;o}6z?&gy2J;-;~qeAZI!D-x~D|A fTRTh(+J=4r_P*gJYff0x00000NkvXXu0mjfa$1|{ literal 0 HcmV?d00001 diff --git a/resources/icons/ui/unlock@2x.png b/resources/icons/ui/unlock@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..8df18143680089562e4ed06499c99c2d8ef3cbc6 GIT binary patch literal 741 zcmeAS@N?(olHy`uVBq!ia0vp^9zg8C!3HFE?laT^Qfx`y?k)`fL2$v|<&zm0m}Ysp zIEGZrc{}H9mPnw0oB#GnjJx3KyN~hQ~>|UVc#3HYtEzYIX+2OzN{K7>)xc(`y z__R12SyxMwV_e|gIcugh)TXxU95Q_c)Dm-3k$ow1jhfvB z?+0uJY!)561#F(yf6Hm8tG&OxFh*VPg!_Xehx?lKIX>^Ly=I0~I#)EfKJajPZDzg87=#Gao*wWjuL8`#zjzeKx0m#^n{4-!LY2&kLXN)u!Ou z=x%JQB7q;Cq+(Sn1u)vNLB@d%2$0ufP8( zd;aIh5J~oX&v@jwMSYw3>4(sTYYLA)ttTsebcY} zKK{BY?i|OFyX%##(!pHOmDP(I%XA-?r)L=4GxAiFUa?5> u;M?Vq2j2czVV#nb`{>{P<2qgM=h*)#h)&Cn5dH*Aw+x=HelF{r5}E+;u0(MF literal 0 HcmV?d00001 diff --git a/resources/langs/nheko_de.ts b/resources/langs/nheko_de.ts index fcbf8b31..2b5a5393 100644 --- a/resources/langs/nheko_de.ts +++ b/resources/langs/nheko_de.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted Verschlüsselt + + + This message is not encrypted! + + InviteeItem @@ -310,7 +315,7 @@ Beispiel: https://mein.server:8787 MessageDelegate - + redacted gelöscht @@ -548,7 +553,7 @@ Beispiel: https://mein.server:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. -- Entschlüsselungsfehler (Fehler bei Kommunikation mit Datenbank) -- @@ -746,7 +751,7 @@ Beispiel: https://mein.server:8787 TimelineRow - + Reply Antworten @@ -799,7 +804,7 @@ Beispiel: https://mein.server:8787 Kein Raum geöffnet - + Close Schließen diff --git a/resources/langs/nheko_el.ts b/resources/langs/nheko_el.ts index 39ed1442..a6e4ff7d 100644 --- a/resources/langs/nheko_el.ts +++ b/resources/langs/nheko_el.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. @@ -742,7 +747,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -795,7 +800,7 @@ Example: https://server.my:8787 - + Close diff --git a/resources/langs/nheko_en.ts b/resources/langs/nheko_en.ts index e7631462..1fd9b86c 100644 --- a/resources/langs/nheko_en.ts +++ b/resources/langs/nheko_en.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted Encrypted + + + This message is not encrypted! + + InviteeItem @@ -310,7 +315,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted redacted @@ -548,7 +553,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. -- Decryption Error (failed to communicate with DB) -- @@ -746,7 +751,7 @@ Example: https://server.my:8787 TimelineRow - + Reply Reply @@ -799,7 +804,7 @@ Example: https://server.my:8787 No room open - + Close Close diff --git a/resources/langs/nheko_fi.ts b/resources/langs/nheko_fi.ts index 01b9d75d..069fb6b2 100644 --- a/resources/langs/nheko_fi.ts +++ b/resources/langs/nheko_fi.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. -- Virhe purkaessa salausta (tietokannan kanssa kommunikointi epäonnistui) -- @@ -742,7 +747,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -795,7 +800,7 @@ Example: https://server.my:8787 - + Close Sulje diff --git a/resources/langs/nheko_fr.ts b/resources/langs/nheko_fr.ts index 9e47702b..d50b5fb8 100644 --- a/resources/langs/nheko_fr.ts +++ b/resources/langs/nheko_fr.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. @@ -742,7 +747,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -795,7 +800,7 @@ Example: https://server.my:8787 - + Close diff --git a/resources/langs/nheko_ja.ts b/resources/langs/nheko_ja.ts index 049c4189..63522065 100644 --- a/resources/langs/nheko_ja.ts +++ b/resources/langs/nheko_ja.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted 暗号化されています + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted 編集済み @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. -- 復号エラー (データベースと通信できませんでした) -- @@ -741,7 +746,7 @@ Example: https://server.my:8787 TimelineRow - + Reply 返信 @@ -794,7 +799,7 @@ Example: https://server.my:8787 部屋が開いていません - + Close 閉じる diff --git a/resources/langs/nheko_nl.ts b/resources/langs/nheko_nl.ts index 205de986..2c3eeee3 100644 --- a/resources/langs/nheko_nl.ts +++ b/resources/langs/nheko_nl.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. @@ -742,7 +747,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -795,7 +800,7 @@ Example: https://server.my:8787 - + Close diff --git a/resources/langs/nheko_pl.ts b/resources/langs/nheko_pl.ts index c089a5b4..f68ca8b3 100644 --- a/resources/langs/nheko_pl.ts +++ b/resources/langs/nheko_pl.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. @@ -743,7 +748,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -796,7 +801,7 @@ Example: https://server.my:8787 - + Close diff --git a/resources/langs/nheko_ru.ts b/resources/langs/nheko_ru.ts index 761110f0..95f75081 100644 --- a/resources/langs/nheko_ru.ts +++ b/resources/langs/nheko_ru.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. @@ -743,7 +748,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -796,7 +801,7 @@ Example: https://server.my:8787 - + Close Закрыть diff --git a/resources/langs/nheko_zh_CN.ts b/resources/langs/nheko_zh_CN.ts index 5b080b74..6b6c0646 100644 --- a/resources/langs/nheko_zh_CN.ts +++ b/resources/langs/nheko_zh_CN.ts @@ -189,10 +189,15 @@ EncryptionIndicator - + Encrypted + + + This message is not encrypted! + + InviteeItem @@ -306,7 +311,7 @@ Example: https://server.my:8787 MessageDelegate - + redacted @@ -544,7 +549,7 @@ Example: https://server.my:8787 TimelineModel - + -- Decryption Error (failed to communicate with DB) -- Placeholder, when the message can't be decrypted, because the DB access failed when trying to lookup the session. @@ -741,7 +746,7 @@ Example: https://server.my:8787 TimelineRow - + Reply @@ -794,7 +799,7 @@ Example: https://server.my:8787 - + Close diff --git a/resources/qml/EncryptionIndicator.qml b/resources/qml/EncryptionIndicator.qml index 00fe2ee4..428c2fae 100644 --- a/resources/qml/EncryptionIndicator.qml +++ b/resources/qml/EncryptionIndicator.qml @@ -3,13 +3,14 @@ import QtQuick.Controls 2.1 import im.nheko 1.0 Rectangle { + property bool encrypted: false id: indicator color: "transparent" width: 16 height: 16 ToolTip.visible: ma.containsMouse && indicator.visible - ToolTip.text: qsTr("Encrypted") + ToolTip.text: getEncryptionTooltip() MouseArea{ id: ma @@ -20,7 +21,21 @@ Rectangle { Image { id: stateImg anchors.fill: parent - source: "image://colorimage/:/icons/icons/ui/lock.png?"+colors.buttonText + source: getEncryptionImage() + } + + function getEncryptionImage() { + if (encrypted) + return "image://colorimage/:/icons/icons/ui/lock.png?"+colors.buttonText + else + return "image://colorimage/:/icons/icons/ui/unlock.png?#dd3d3d" + } + + function getEncryptionTooltip() { + if (encrypted) + return qsTr("Encrypted") + else + return qsTr("This message is not encrypted!") } } diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 22222ef3..8dcd0056 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -66,7 +66,8 @@ MouseArea { } EncryptionIndicator { - visible: model.isEncrypted + visible: model.isRoomEncrypted + encrypted: model.isEncrypted Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.preferredHeight: 16 width: 16 diff --git a/resources/res.qrc b/resources/res.qrc index 64a5b3cb..a57d0416 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -14,6 +14,8 @@ icons/ui/double-tick-indicator@2x.png icons/ui/lock.png icons/ui/lock@2x.png + icons/ui/unlock.png + icons/ui/unlock@2x.png icons/ui/clock.png icons/ui/clock@2x.png icons/ui/checkmark.png diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index b7e90034..6e653f10 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -224,6 +224,7 @@ TimelineModel::roleNames() const {Id, "id"}, {State, "state"}, {IsEncrypted, "isEncrypted"}, + {IsRoomEncrypted, "isRoomEncrypted"}, {ReplyTo, "replyTo"}, {Reactions, "reactions"}, {RoomId, "roomId"}, @@ -350,6 +351,9 @@ TimelineModel::data(const QString &id, int role) const return std::holds_alternative< mtx::events::EncryptedEvent>(events[id]); } + case IsRoomEncrypted: { + return cache::isRoomEncrypted(room_id_.toStdString()); + } case ReplyTo: return QVariant(QString::fromStdString(in_reply_to_event(event))); case Reactions: @@ -387,6 +391,7 @@ TimelineModel::data(const QString &id, int role) const m.insert(names[Id], data(id, static_cast(Id))); m.insert(names[State], data(id, static_cast(State))); m.insert(names[IsEncrypted], data(id, static_cast(IsEncrypted))); + m.insert(names[IsRoomEncrypted], data(id, static_cast(IsRoomEncrypted))); m.insert(names[ReplyTo], data(id, static_cast(ReplyTo))); m.insert(names[RoomName], data(id, static_cast(RoomName))); m.insert(names[RoomTopic], data(id, static_cast(RoomTopic))); diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index a737aac7..0e9ddb72 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -157,6 +157,7 @@ public: Id, State, IsEncrypted, + IsRoomEncrypted, ReplyTo, Reactions, RoomId,