From 95887c87dbabd9894d8f4015b6c3ef23bd682634 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 20 Nov 2021 22:07:57 -0500 Subject: [PATCH 1/7] Make it obvious that this is a notification and not the actual message --- resources/qml/delegates/Encrypted.qml | 80 ++++++++++++++++++--------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml index 6616d3ce..7361341d 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: height / 4 width: parent ? parent.width : undefined + height: contents.implicitHeight + Nheko.paddingMedium * 2 + color: Nheko.colors.alternateBase - 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"); + 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.buttonText + width: parent ? parent.width : undefined } + + Button { + palette: Nheko.colors + visible: encryptionError == Olm.MissingSession || encryptionError == Olm.MissingSessionIndex + text: qsTr("Request key") + onClicked: room.requestKeyForEvent(eventId) + } + } - 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) } } From c09c0d35b8597f93f4ee9b46c068e1aa59c59e2d Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Mon, 22 Nov 2021 18:41:08 -0500 Subject: [PATCH 2/7] Make opening room members from rooms settings dialog work --- resources/qml/dialogs/RoomSettings.qml | 2 +- src/timeline/RoomlistModel.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/qml/dialogs/RoomSettings.qml b/resources/qml/dialogs/RoomSettings.qml index 1eeef98b..1e365456 100644 --- a/resources/qml/dialogs/RoomSettings.qml +++ b/resources/qml/dialogs/RoomSettings.qml @@ -108,7 +108,7 @@ ApplicationWindow { 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..bfd640fd 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -170,6 +170,7 @@ 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(); From d15094b21ecd619f15f2e32b98258e1de7c0f7f8 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Mon, 22 Nov 2021 19:13:14 -0500 Subject: [PATCH 3/7] Use better translation method --- resources/qml/dialogs/RoomSettings.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/dialogs/RoomSettings.qml b/resources/qml/dialogs/RoomSettings.qml index 1e365456..0eefe955 100644 --- a/resources/qml/dialogs/RoomSettings.qml +++ b/resources/qml/dialogs/RoomSettings.qml @@ -104,7 +104,7 @@ ApplicationWindow { } MatrixText { - text: qsTr("%1 member(s)").arg(roomSettings.memberCount) + text: qsTr("%n member(s)", "", roomSettings.memberCount) Layout.alignment: Qt.AlignHCenter TapHandler { From b25cda69398de5db2c77d71d6ac7ee2350614166 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 4 Dec 2021 17:52:14 -0500 Subject: [PATCH 4/7] Don't get too large of corners --- resources/qml/delegates/Encrypted.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml index 7361341d..0486737e 100644 --- a/resources/qml/delegates/Encrypted.qml +++ b/resources/qml/delegates/Encrypted.qml @@ -14,7 +14,7 @@ Rectangle { required property int encryptionError required property string eventId - radius: height / 4 + radius: fontMetrics.xHeight + Nheko.paddingMedium width: parent ? parent.width : undefined height: contents.implicitHeight + Nheko.paddingMedium * 2 color: Nheko.colors.alternateBase From 45b150fb58d14970e5e393190a21e5f7a4d457e9 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Mon, 13 Dec 2021 19:05:22 -0500 Subject: [PATCH 5/7] make lint --- src/timeline/RoomlistModel.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h index bfd640fd..b98a0dba 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h @@ -170,7 +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(); } + TimelineModel *getRoomById(const QString &id) const + { + return roomlistmodel->getRoomById(id).data(); + } void nextRoomWithActivity(); void nextRoom(); From 6e7e22b0e7a9edaa52024e21f45a12aa1c30f930 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Mon, 13 Dec 2021 19:05:35 -0500 Subject: [PATCH 6/7] Make notification count bubbles expand some more --- resources/qml/RoomList.qml | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index 3d17b4ae..d972f8cd 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -31,7 +31,7 @@ Page { anchors.right: parent.right height: parent.height model: Rooms - reuseItems: true + reuseItems: false ScrollHelper { flickable: parent @@ -139,7 +139,7 @@ Page { height: avatarSize + 2 * Nheko.paddingMedium width: ListView.view.width state: "normal" - ToolTip.visible: hovered && collapsed + ToolTip.visible: hovered && collapsed && !collapsedBubbleHover.hovered && !notificationBubbleHover.hovered ToolTip.text: roomName onClicked: { console.log("tapped " + roomId); @@ -236,21 +236,27 @@ 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 + ToolTip.text: notificationCount + ToolTip.visible: collapsedBubbleHover.hovered && (notificationCount > 9999) 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 + } + + HoverHandler { + id: collapsedBubbleHover } } @@ -320,22 +326,35 @@ 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 + + onTextChanged: { + let old = parent.width + parent.width = Math.max(probableWidth + Nheko.paddingMedium, parent.height) + console.log(old + " changed to " + parent.width) + } + + HoverHandler { + id: notificationBubbleHover + } + } } From 4a7e6d3f48ed2f39beae64a306ee6d8688b8c08b Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Mon, 13 Dec 2021 22:07:59 -0500 Subject: [PATCH 7/7] Fix a few things --- resources/qml/RoomList.qml | 16 ++-------------- resources/qml/delegates/Encrypted.qml | 4 ++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index d972f8cd..d40ff2b3 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -31,7 +31,7 @@ Page { anchors.right: parent.right height: parent.height model: Rooms - reuseItems: false + reuseItems: true ScrollHelper { flickable: parent @@ -139,7 +139,7 @@ Page { height: avatarSize + 2 * Nheko.paddingMedium width: ListView.view.width state: "normal" - ToolTip.visible: hovered && collapsed && !collapsedBubbleHover.hovered && !notificationBubbleHover.hovered + ToolTip.visible: hovered && collapsed ToolTip.text: roomName onClicked: { console.log("tapped " + roomId); @@ -239,8 +239,6 @@ Page { width: Math.min(Math.max(collapsedBubbleText.width + Nheko.paddingMedium, height), parent.width) radius: height / 2 color: hasLoudNotification ? Nheko.theme.red : roomItem.bubbleBackground - ToolTip.text: notificationCount - ToolTip.visible: collapsedBubbleHover.hovered && (notificationCount > 9999) Label { id: collapsedBubbleText @@ -255,10 +253,6 @@ Page { text: notificationCount > 9999 ? "9999+" : notificationCount } - HoverHandler { - id: collapsedBubbleHover - } - } } @@ -345,12 +339,6 @@ Page { color: hasLoudNotification ? "white" : roomItem.bubbleText text: notificationCount > 9999 ? "9999+" : notificationCount - onTextChanged: { - let old = parent.width - parent.width = Math.max(probableWidth + Nheko.paddingMedium, parent.height) - console.log(old + " changed to " + parent.width) - } - HoverHandler { id: notificationBubbleHover } diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml index 0486737e..076b5a5e 100644 --- a/resources/qml/delegates/Encrypted.qml +++ b/resources/qml/delegates/Encrypted.qml @@ -14,7 +14,7 @@ Rectangle { required property int encryptionError required property string eventId - radius: fontMetrics.xHeight + Nheko.paddingMedium + radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium width: parent ? parent.width : undefined height: contents.implicitHeight + Nheko.paddingMedium * 2 color: Nheko.colors.alternateBase @@ -56,7 +56,7 @@ Rectangle { return qsTr("Unknown decryption error"); } } - color: Nheko.colors.buttonText + color: Nheko.colors.text width: parent ? parent.width : undefined }