diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index 3d17b4ae..d40ff2b3 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -236,21 +236,21 @@ Page { enabled: false Layout.alignment: Qt.AlignRight height: fontMetrics.averageCharacterWidth * 3 - width: height + width: Math.min(Math.max(collapsedBubbleText.width + Nheko.paddingMedium, height), parent.width) radius: height / 2 color: hasLoudNotification ? Nheko.theme.red : roomItem.bubbleBackground Label { + id: collapsedBubbleText + anchors.centerIn: parent - width: parent.width * 0.8 - height: parent.height * 0.8 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter fontSizeMode: Text.Fit font.bold: true font.pixelSize: fontMetrics.font.pixelSize * 0.8 color: hasLoudNotification ? "white" : roomItem.bubbleText - text: notificationCount > 99 ? "99+" : notificationCount + text: notificationCount > 9999 ? "9999+" : notificationCount } } @@ -320,22 +320,29 @@ Page { visible: notificationCount > 0 Layout.alignment: Qt.AlignRight - height: fontMetrics.averageCharacterWidth * 3 - width: height + height: notificationBubbleText.height + Nheko.paddingMedium + Layout.preferredWidth: Math.max(notificationBubbleText.width + Nheko.paddingMedium, height) radius: height / 2 color: hasLoudNotification ? Nheko.theme.red : roomItem.bubbleBackground + ToolTip.text: notificationCount + ToolTip.visible: notificationBubbleHover.hovered && (notificationCount > 9999) Label { + id: notificationBubbleText + anchors.centerIn: parent - width: parent.width * 0.8 - height: parent.height * 0.8 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter fontSizeMode: Text.Fit font.bold: true font.pixelSize: fontMetrics.font.pixelSize * 0.8 color: hasLoudNotification ? "white" : roomItem.bubbleText - text: notificationCount > 99 ? "99+" : notificationCount + text: notificationCount > 9999 ? "9999+" : notificationCount + + HoverHandler { + id: notificationBubbleHover + } + } } diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml index 6616d3ce..076b5a5e 100644 --- a/resources/qml/delegates/Encrypted.qml +++ b/resources/qml/delegates/Encrypted.qml @@ -4,45 +4,71 @@ import ".." import QtQuick 2.15 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 import im.nheko 1.0 -Column { +Rectangle { id: r required property int encryptionError required property string eventId + radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium width: parent ? parent.width : undefined + height: contents.implicitHeight + Nheko.paddingMedium * 2 + color: Nheko.colors.alternateBase + + RowLayout { + id: contents + + anchors.fill: parent + anchors.margins: Nheko.paddingMedium + spacing: Nheko.paddingMedium + + Image { + source: "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?" + Nheko.theme.error + Layout.alignment: Qt.AlignVCenter + width: 24 + height: width + } + + Column { + spacing: Nheko.paddingSmall + Layout.fillWidth: true + + MatrixText { + text: { + switch (encryptionError) { + case Olm.MissingSession: + return qsTr("There is no key to unlock this message. We requested the key automatically, but you can try requesting it again if you are impatient."); + case Olm.MissingSessionIndex: + return qsTr("This message couldn't be decrypted, because we only have a key for newer messages. You can try requesting access to this message."); + case Olm.DbError: + return qsTr("There was an internal error reading the decryption key from the database."); + case Olm.DecryptionFailed: + return qsTr("There was an error decrypting this message."); + case Olm.ParsingFailed: + return qsTr("The message couldn't be parsed."); + case Olm.ReplayAttack: + return qsTr("The encryption key was reused! Someone is possibly trying to insert false messages into this chat!"); + default: + return qsTr("Unknown decryption error"); + } + } + color: Nheko.colors.text + width: parent ? parent.width : undefined + } + + Button { + palette: Nheko.colors + visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex + text: qsTr("Request key") + onClicked: room.requestKeyForEvent(eventId) + } - MatrixText { - text: { - switch (encryptionError) { - case Olm.MissingSession: - return qsTr("There is no key to unlock this message. We requested the key automatically, but you can try requesting it again if you are impatient."); - case Olm.MissingSessionIndex: - return qsTr("This message couldn't be decrypted, because we only have a key for newer messages. You can try requesting access to this message."); - case Olm.DbError: - return qsTr("There was an internal error reading the decryption key from the database."); - case Olm.DecryptionFailed: - return qsTr("There was an error decrypting this message."); - case Olm.ParsingFailed: - return qsTr("The message couldn't be parsed."); - case Olm.ReplayAttack: - return qsTr("The encryption key was reused! Someone is possibly trying to insert false messages into this chat!"); - default: - return qsTr("Unknown decryption error"); - } } - color: Nheko.colors.buttonText - width: r ? r.width : undefined - } - Button { - palette: Nheko.colors - visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex - text: qsTr("Request key") - onClicked: room.requestKeyForEvent(eventId) } } diff --git a/resources/qml/dialogs/RoomSettings.qml b/resources/qml/dialogs/RoomSettings.qml index 1eeef98b..0eefe955 100644 --- a/resources/qml/dialogs/RoomSettings.qml +++ b/resources/qml/dialogs/RoomSettings.qml @@ -104,11 +104,11 @@ ApplicationWindow { } MatrixText { - text: qsTr("%1 member(s)").arg(roomSettings.memberCount) + text: qsTr("%n member(s)", "", roomSettings.memberCount) Layout.alignment: Qt.AlignHCenter TapHandler { - onTapped: TimelineManager.openRoomMembers(roomSettings.roomId) + onSingleTapped: TimelineManager.openRoomMembers(Rooms.getRoomById(roomSettings.roomId)) } CursorShape { diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index 5d0bcd53..b98a0dba 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -170,6 +170,10 @@ public slots: RoomPreview currentRoomPreview() const { return roomlistmodel->currentRoomPreview(); } void setCurrentRoom(QString roomid) { roomlistmodel->setCurrentRoom(std::move(roomid)); } void resetCurrentRoom() { roomlistmodel->resetCurrentRoom(); } + TimelineModel *getRoomById(const QString &id) const + { + return roomlistmodel->getRoomById(id).data(); + } void nextRoomWithActivity(); void nextRoom();