Warn about room name and topic not being encrypted

This commit is contained in:
Nicolas Werner 2024-08-17 00:46:01 +02:00
parent b86221bdbe
commit c1038a3e4a
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 77 additions and 34 deletions

View file

@ -130,7 +130,7 @@ ApplicationWindow {
color: palette.text
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width - (Nheko.paddingSmall * 2) - nameChangeButton.anchors.leftMargin - (nameChangeButton.width * 2)
Layout.maximumWidth: parent.width - (Nheko.paddingSmall + roomNameButtons.anchors.leftMargin + roomNameButtons.implicitWidth) * 2
horizontalAlignment: TextEdit.AlignHCenter
wrapMode: TextEdit.Wrap
selectByMouse: true
@ -144,12 +144,16 @@ ApplicationWindow {
}
}
ImageButton {
id: nameChangeButton
visible: roomSettings.canChangeName
RowLayout {
id: roomNameButtons
anchors.leftMargin: Nheko.paddingSmall
anchors.left: roomName.right
anchors.verticalCenter: roomName.verticalCenter
ImageButton {
id: nameChangeButton
visible: roomSettings.canChangeName
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("Change name of this room")
@ -167,6 +171,18 @@ ApplicationWindow {
}
}
EncryptionIndicator {
Layout.preferredHeight: 16
Layout.preferredWidth: 16
sourceSize.width: width
sourceSize.height: height
encrypted: true
visible: roomSettings.isEncryptionEnabled && (roomSettings.isRoomNameSet || !roomName.readOnly)
trust: Crypto.Unverified
ToolTip.text: qsTr("Since room state can't be encrypted, make sure no confidential information is stored in the room name!")
}
}
}
RowLayout {
@ -220,9 +236,13 @@ ApplicationWindow {
}
RowLayout {
spacing: Nheko.paddingMedium
Layout.alignment: Qt.AlignHCenter
ImageButton {
id: topicChangeButton
Layout.alignment: Qt.AlignHCenter
visible: roomSettings.canChangeTopic
hoverEnabled: true
ToolTip.visible: hovered
@ -242,6 +262,18 @@ ApplicationWindow {
}
}
EncryptionIndicator {
Layout.preferredHeight: 16
Layout.preferredWidth: 16
sourceSize.width: width
sourceSize.height: height
encrypted: true
visible: roomSettings.isEncryptionEnabled && (roomSettings.plainRoomTopic != "" || !roomTopic.readOnly)
trust: Crypto.Unverified
ToolTip.text: qsTr("Since room state can't be encrypted, make sure no confidential information is stored in the room topic!")
}
}
Item {
Layout.alignment: Qt.AlignHCenter
id: showMorePlaceholder

View file

@ -81,6 +81,15 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
this->allowedRoomsModel = new RoomSettingsAllowedRoomsModel(this);
}
bool
RoomSettings::isRoomNameSet() const
{
return !cache::client()
->getStateEvent<mtx::events::state::Name>(roomid_.toStdString())
.value_or(mtx::events::StateEvent<mtx::events::state::Name>{})
.content.name.empty();
}
QString
RoomSettings::roomName() const
{

View file

@ -100,6 +100,7 @@ class RoomSettings final : public QObject
Q_PROPERTY(bool supportsKnocking READ supportsKnocking CONSTANT)
Q_PROPERTY(bool supportsRestricted READ supportsRestricted CONSTANT)
Q_PROPERTY(bool supportsKnockRestricted READ supportsKnockRestricted CONSTANT)
Q_PROPERTY(bool isRoomNameSet READ isRoomNameSet NOTIFY roomNameChanged)
Q_PROPERTY(
QStringList allowedRooms READ allowedRooms WRITE setAllowedRooms NOTIFY allowedRoomsChanged)
Q_PROPERTY(RoomSettingsAllowedRoomsModel *allowedRoomsModel MEMBER allowedRoomsModel CONSTANT)
@ -128,6 +129,7 @@ public:
QString roomAvatarUrl();
int memberCount() const;
int notifications();
bool isRoomNameSet() const;
bool privateAccess() const;
bool guestAccess() const;
bool knockingEnabled() const;