diff options
author | Malte E <97891689+maltee1@users.noreply.github.com> | 2022-02-21 01:39:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 00:39:32 +0000 |
commit | 1c8a5c645d44fdeb0319cd03dd6986b168d3bf1b (patch) | |
tree | 86728c3a544ac5c898a3a34ddc5dff5e4c5202d0 | |
parent | Merge pull request #951 from maltee1/fix_timeline_scrollbar (diff) | |
download | nheko-1c8a5c645d44fdeb0319cd03dd6986b168d3bf1b.tar.xz |
Add sender names to state events (#948)
* add sendernames to state events * Center state events and make them less tiny
-rw-r--r-- | resources/qml/TimelineRow.qml | 11 | ||||
-rw-r--r-- | resources/qml/delegates/NoticeMessage.qml | 4 | ||||
-rw-r--r-- | resources/qml/delegates/Pill.qml | 5 | ||||
-rw-r--r-- | src/timeline/TimelineModel.cpp | 16 |
4 files changed, 20 insertions, 16 deletions
diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 0ff33bf8..02a9579b 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -53,7 +53,7 @@ Item { Rectangle { color: (Settings.messageHoverHighlight && hovered) ? Nheko.colors.alternateBase : "transparent" anchors.fill: parent - anchors.leftMargin: Settings.smallAvatars? 0 : Nheko.avatarSize+8 + // this looks better without margins } TapHandler { @@ -72,10 +72,11 @@ Item { id: row property bool bubbleOnRight : isSender && Settings.bubbles property int bubblePadding: (parent.width-(Settings.smallAvatars? 0 : Nheko.avatarSize+8))/10 - anchors.rightMargin: isSender || !Settings.bubbles? 0 : bubblePadding - anchors.leftMargin: (Settings.smallAvatars? 0 : Nheko.avatarSize+8) + (bubbleOnRight? bubblePadding : 0) // align bubble with section header - anchors.left: bubbleOnRight? undefined : parent.left - anchors.right: bubbleOnRight? parent.right : undefined + anchors.rightMargin: isStateEvent? 0 : (isSender || !Settings.bubbles? 0 : bubblePadding) + anchors.leftMargin: isStateEvent? 0 :((Settings.smallAvatars? 0 : Nheko.avatarSize+8) + (bubbleOnRight? bubblePadding : 0)) // align bubble with section header + anchors.left: isStateEvent? undefined : (bubbleOnRight? undefined : parent.left) + anchors.right: isStateEvent? undefined: (bubbleOnRight? parent.right : undefined) + anchors.horizontalCenter: isStateEvent? parent.horizontalCenter : undefined property int maxWidth: parent.width-anchors.leftMargin-anchors.rightMargin width: Settings.bubbles? Math.min(maxWidth,implicitWidth+metadata.width+12) : maxWidth leftPadding: 4 diff --git a/resources/qml/delegates/NoticeMessage.qml b/resources/qml/delegates/NoticeMessage.qml index 544af109..342469db 100644 --- a/resources/qml/delegates/NoticeMessage.qml +++ b/resources/qml/delegates/NoticeMessage.qml @@ -3,6 +3,7 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +import QtQuick 2.5 import im.nheko 1.0 @@ -10,5 +11,6 @@ TextMessage { property bool isStateEvent font.italic: true color: Nheko.colors.buttonText - font.pointSize: isStateEvent? 0.75*fontMetrics.font.pointSize : 1*fontMetrics.font.pointSize + font.pointSize: isStateEvent? 0.8*Settings.fontSize : Settings.fontSize + horizontalAlignment: isStateEvent? Text.AlignHCenter : undefined } diff --git a/resources/qml/delegates/Pill.qml b/resources/qml/delegates/Pill.qml index a3964f73..8b67c346 100644 --- a/resources/qml/delegates/Pill.qml +++ b/resources/qml/delegates/Pill.qml @@ -11,9 +11,8 @@ Label { property bool isStateEvent color: Nheko.colors.text horizontalAlignment: Text.AlignHCenter - //height: contentHeight * 1.2 - //width: contentWidth * 1.2 - font.pointSize: isStateEvent? 0.75*fontMetrics.font.pointSize : 1*fontMetrics.font.pointSize + height: Math.round(fontMetrics.height * 1.4) + width: contentWidth * 1.2 background: Rectangle { radius: parent.height / 2 diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index fe92fcf7..43c72e1d 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -2031,12 +2031,14 @@ TimelineModel::formatMemberEvent(const QString &id) QString user = QString::fromStdString(event->state_key); QString name = utils::replaceEmoji(displayName(user)); QString rendered; + QString sender = QString::fromStdString(event->sender); + QString senderName = utils::replaceEmoji(displayName(sender)); // see table https://matrix.org/docs/spec/client_server/latest#m-room-member using namespace mtx::events::state; switch (event->content.membership) { case Membership::Invite: - rendered = tr("%1 was invited.").arg(name); + rendered = tr("%1 invited %2.").arg(senderName, name); break; case Membership::Join: if (prevEvent && prevEvent->content.membership == Membership::Join) { @@ -2077,19 +2079,19 @@ TimelineModel::formatMemberEvent(const QString &id) if (event->state_key == event->sender) rendered = tr("%1 rejected their invite.").arg(name); else - rendered = tr("Revoked the invite to %1.").arg(name); + rendered = tr("%2 revoked the invite to %1.").arg(name, senderName); } else if (prevEvent->content.membership == Membership::Join) { if (event->state_key == event->sender) rendered = tr("%1 left the room.").arg(name); else - rendered = tr("Kicked %1.").arg(name); + rendered = tr("%2 kicked %1.").arg(name, senderName); } else if (prevEvent->content.membership == Membership::Ban) { - rendered = tr("Unbanned %1.").arg(name); + rendered = tr("%2 unbanned %1.").arg(name, senderName); } else if (prevEvent->content.membership == Membership::Knock) { if (event->state_key == event->sender) rendered = tr("%1 redacted their knock.").arg(name); else - rendered = tr("Rejected the knock from %1.").arg(name); + rendered = tr("%2 rejected the knock from %1.").arg(name, senderName); } else return tr("%1 left after having already left!", "This is a leave event after the user already left and shouldn't " @@ -2098,7 +2100,7 @@ TimelineModel::formatMemberEvent(const QString &id) break; case Membership::Ban: - rendered = tr("%1 was banned.").arg(name); + rendered = tr("%1 banned %2").arg(senderName, name); break; case Membership::Knock: rendered = tr("%1 knocked.").arg(name); @@ -2197,7 +2199,7 @@ TimelineModel::resetState() room_id_.toStdString(), [this](const mtx::responses::StateEvents &events_, mtx::http::RequestErr e) { if (e) { - nhlog::net()->error("Failed to retrive current room state: {}", *e); + nhlog::net()->error("Failed to retrieve current room state: {}", *e); return; } |