From 3f7c15c7afeb029223a7507387a95752428bb689 Mon Sep 17 00:00:00 2001 From: Malte E Date: Fri, 4 Feb 2022 23:12:30 +0100 Subject: Add message bubbles --- src/UserSettingsPage.cpp | 30 ++++++++++++++++++++++++++++++ src/UserSettingsPage.h | 6 ++++++ 2 files changed, 36 insertions(+) (limited to 'src') diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index a0aa8f84..993b9a01 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -70,6 +70,7 @@ UserSettings::load(std::optional profile) enlargeEmojiOnlyMessages_ = settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); + bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = @@ -242,6 +243,16 @@ UserSettings::setMarkdown(bool state) save(); } +void +UserSettings::setBubbles(bool state) +{ + if (state == bubbles_) + return; + bubbles_ = state; + emit bubblesChanged(state); + save(); +} + void UserSettings::setAnimateImagesOnHover(bool state) { @@ -696,6 +707,7 @@ UserSettings::save() settings.setValue(QStringLiteral("read_receipts"), readReceipts_); settings.setValue(QStringLiteral("group_view"), groupView_); settings.setValue(QStringLiteral("markdown_enabled"), markdown_); + settings.setValue(QStringLiteral("bubbles_enabled"), bubbles_); settings.setValue(QStringLiteral("animate_images_on_hover"), animateImagesOnHover_); settings.setValue(QStringLiteral("desktop_notifications"), hasDesktopNotifications_); settings.setValue(QStringLiteral("alert_on_notification"), hasAlertOnNotification_); @@ -796,6 +808,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return tr("Group's sidebar"); case Markdown: return tr("Send messages as Markdown"); + case Bubbles: + return tr("Enable Message bubbles"); case AnimateImagesOnHover: return tr("Play animated images only on hover"); case TypingNotifications: @@ -916,6 +930,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return i->groupView(); case Markdown: return i->markdown(); + case Bubbles: + return i->bubbles(); case AnimateImagesOnHover: return i->animateImagesOnHover(); case TypingNotifications: @@ -1042,6 +1058,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return tr( "Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain " "text."); + case Bubbles: + return tr( + "Messages received a bubble background."); case AnimateImagesOnHover: return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); case TypingNotifications: @@ -1158,6 +1177,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case StartInTray: case GroupView: case Markdown: + case Bubbles: case AnimateImagesOnHover: case TypingNotifications: case SortByImportance: @@ -1375,6 +1395,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int } else return false; } + case Bubbles: { + if (value.userType() == QMetaType::Bool) { + i->setBubbles(value.toBool()); + return true; + } else + return false; + } case AnimateImagesOnHover: { if (value.userType() == QMetaType::Bool) { i->setAnimateImagesOnHover(value.toBool()); @@ -1737,6 +1764,9 @@ UserSettingsModel::UserSettingsModel(QObject *p) connect(s.get(), &UserSettings::markdownChanged, this, [this]() { emit dataChanged(index(Markdown), index(Markdown), {Value}); }); + connect(s.get(), &UserSettings::bubblesChanged, this, [this]() { + emit dataChanged(index(Bubbles), index(Bubbles), {Value}); + }); connect(s.get(), &UserSettings::groupViewStateChanged, this, [this]() { emit dataChanged(index(GroupView), index(GroupView), {Value}); diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h index e9b8763d..e5d22f6a 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h @@ -40,6 +40,7 @@ class UserSettings : public QObject Q_PROPERTY(bool startInTray READ startInTray WRITE setStartInTray NOTIFY startInTrayChanged) Q_PROPERTY(bool groupView READ groupView WRITE setGroupView NOTIFY groupViewStateChanged) Q_PROPERTY(bool markdown READ markdown WRITE setMarkdown NOTIFY markdownChanged) + Q_PROPERTY(bool bubbles READ bubbles WRITE setBubbles NOTIFY bubblesChanged) Q_PROPERTY(bool animateImagesOnHover READ animateImagesOnHover WRITE setAnimateImagesOnHover NOTIFY animateImagesOnHoverChanged) Q_PROPERTY(bool typingNotifications READ typingNotifications WRITE setTypingNotifications NOTIFY @@ -139,6 +140,7 @@ public: void setEmojiFontFamily(QString family); void setGroupView(bool state); void setMarkdown(bool state); + void setBubbles(bool state); void setAnimateImagesOnHover(bool state); void setReadReceipts(bool state); void setTypingNotifications(bool state); @@ -190,6 +192,7 @@ public: bool privacyScreen() const { return privacyScreen_; } int privacyScreenTimeout() const { return privacyScreenTimeout_; } bool markdown() const { return markdown_; } + bool bubbles() const { return bubbles_; } bool animateImagesOnHover() const { return animateImagesOnHover_; } bool typingNotifications() const { return typingNotifications_; } bool sortByImportance() const { return sortByImportance_; } @@ -247,6 +250,7 @@ signals: void trayChanged(bool state); void startInTrayChanged(bool state); void markdownChanged(bool state); + void bubblesChanged(bool state); void animateImagesOnHoverChanged(bool state); void typingNotificationsChanged(bool state); void buttonInTimelineChanged(bool state); @@ -302,6 +306,7 @@ private: bool startInTray_; bool groupView_; bool markdown_; + bool bubbles_; bool animateImagesOnHover_; bool typingNotifications_; bool sortByImportance_; @@ -380,6 +385,7 @@ class UserSettingsModel : public QAbstractListModel ReadReceipts, ButtonsInTimeline, Markdown, + Bubbles, SidebarSection, GroupView, -- cgit 1.5.1 From f5a693ac031c526774bc89b111e2771b6ef9eff9 Mon Sep 17 00:00:00 2001 From: Malte E Date: Sat, 5 Feb 2022 14:12:51 +0100 Subject: place metadata below message when the Layout is narrow (<350) --- resources/qml/TimelineRow.qml | 39 ++++++++++++++++++++------------------- src/UserSettingsPage.cpp | 5 ++--- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 876fc800..95dbec4e 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -97,10 +97,11 @@ Item { topMargin: 1 bottomMargin: 1 } + property bool narrowLayout: (row.width < 350) && Settings.bubbles rowSpacing: 0 columnSpacing: 0 - columns: 2 - rows: 2 + columns: narrowLayout? 1 : 2 + rows: narrowLayout? 3 : 2 // fancy reply, if this is a reply Reply { @@ -147,7 +148,7 @@ Item { Layout.leftMargin: 4 Layout.rightMargin: 4 Layout.topMargin: reply.visible ? 2 : 4 - Layout.bottomMargin: Settings.bubbles? 4: 2 + Layout.bottomMargin: Settings.bubbles? (msg.narrowLayout? 0 : 4) : 2 id: contentItem blurhash: r.blurhash @@ -174,17 +175,17 @@ Item { } RowLayout { - Layout.column: 1 - Layout.row: 0 - Layout.rowSpan: 2 + Layout.column: msg.narrowLayout? 0 : 1 + Layout.row: msg.narrowLayout? 2 : 0 + Layout.rowSpan: msg.narrowLayout? 1 : 2 Layout.alignment: Qt.AlignTop | Qt.AlignRight - Layout.topMargin: 4 + Layout.topMargin: msg.narrowLayout? 0 : 4 Layout.rightMargin: Settings.bubbles? 4 : 0 - + property double scaling: msg.narrowLayout? 0.75 : 1 StatusIndicator { Layout.alignment: Qt.AlignRight | Qt.AlignTop - Layout.preferredHeight: 16 - width: 16 + Layout.preferredHeight: 16*parent.scaling + width: 16*parent.scaling status: r.status eventId: r.eventId } @@ -192,12 +193,12 @@ Item { Image { visible: isEdited || eventId == chat.model.edit Layout.alignment: Qt.AlignRight | Qt.AlignTop - Layout.preferredHeight: 16 - Layout.preferredWidth: 16 - height: 16 - width: 16 - sourceSize.width: 16 * Screen.devicePixelRatio - sourceSize.height: 16 * Screen.devicePixelRatio + Layout.preferredHeight: 16*parent.scaling + Layout.preferredWidth: 16*parent.scaling + height: 16*parent.scaling + width: 16*parent.scaling + sourceSize.width: 16 * Screen.devicePixelRatio*parent.scaling + sourceSize.height: 16 * Screen.devicePixelRatio*parent.scaling source: "image://colorimage/:/icons/icons/ui/edit.svg?" + ((eventId == chat.model.edit) ? Nheko.colors.highlight : Nheko.colors.buttonText) ToolTip.visible: editHovered.hovered ToolTip.delay: Nheko.tooltipDelay @@ -214,8 +215,8 @@ Item { encrypted: isEncrypted trust: trustlevel Layout.alignment: Qt.AlignRight | Qt.AlignTop - Layout.preferredHeight: 16 - Layout.preferredWidth: 16 + Layout.preferredHeight: 16*parent.scaling + Layout.preferredWidth: 16*parent.scaling } Label { @@ -226,7 +227,7 @@ Item { ToolTip.visible: ma.hovered ToolTip.delay: Nheko.tooltipDelay ToolTip.text: Qt.formatDateTime(timestamp, Qt.DefaultLocaleLongDate) - + font.pointSize: 10*parent.scaling HoverHandler { id: ma } diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 993b9a01..c8ce19a7 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -70,7 +70,7 @@ UserSettings::load(std::optional profile) enlargeEmojiOnlyMessages_ = settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); - bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); + bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = @@ -1059,8 +1059,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const "Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain " "text."); case Bubbles: - return tr( - "Messages received a bubble background."); + return tr("Messages received a bubble background."); case AnimateImagesOnHover: return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); case TypingNotifications: -- cgit 1.5.1 From 9d194cc2e666cf8ff3141bac847f20423995d0ca Mon Sep 17 00:00:00 2001 From: Malte E Date: Sat, 5 Feb 2022 21:53:21 +0100 Subject: clean up margin setting --- resources/qml/TimelineRow.qml | 52 ++++++++++++++++++--------------------- resources/qml/delegates/Reply.qml | 2 +- src/UserSettingsPage.cpp | 5 ++-- 3 files changed, 28 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 95dbec4e..c221d43f 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -46,7 +46,7 @@ Item { anchors.left: parent.left anchors.right: parent.right - height: row.height + height: row.height+reactionRow.height+(Settings.bubbles? 8 : 4) Rectangle { color: (Settings.messageHoverHighlight && hoverHandler.hovered) ? Nheko.colors.alternateBase : "transparent" @@ -71,16 +71,20 @@ Item { gesturePolicy: TapHandler.ReleaseWithinBounds } - Item { + Control { id: row anchors.rightMargin: 1 - anchors.leftMargin: Nheko.avatarSize + 12 + anchors.leftMargin: Nheko.avatarSize + 12 // align bubble with section header anchors.left: parent.left anchors.right: parent.right - height: msg.height+(reactionRow.height> 0 ? reactionRow.height-4 : 0) - Rectangle { - anchors.fill: msg + height: msg.height + topInset: -4 + bottomInset: -4 + leftInset: -4 + rightInset: -4 + background: Rectangle { + //anchors.fill: msg property color userColor: TimelineManager.userColor(userId, Nheko.colors.base) property color bgColor: Nheko.colors.base color: Qt.rgba(userColor.r*0.1+bgColor.r*0.9,userColor.g*0.1+bgColor.g*0.9,userColor.b*0.1+bgColor.b*0.9,1) //TimelineManager.userColor(userId, Nheko.colors.base) @@ -94,12 +98,10 @@ Item { right: parent.right left: parent.left top: parent.top - topMargin: 1 - bottomMargin: 1 } property bool narrowLayout: (row.width < 350) && Settings.bubbles rowSpacing: 0 - columnSpacing: 0 + columnSpacing: 2 columns: narrowLayout? 1 : 2 rows: narrowLayout? 3 : 2 @@ -108,9 +110,7 @@ Item { Layout.row: 0 Layout.column: 0 Layout.fillWidth: true - Layout.margins: visible? 4 : 0 - Layout.bottomMargin: 0 - Layout.topMargin: visible? (Settings.bubbles? 4 : 2) : 0 + Layout.bottomMargin: visible? 2 : 0 id: reply function fromModel(role) { @@ -145,10 +145,6 @@ Item { Layout.row: 1 Layout.column: 0 Layout.fillWidth: true - Layout.leftMargin: 4 - Layout.rightMargin: 4 - Layout.topMargin: reply.visible ? 2 : 4 - Layout.bottomMargin: Settings.bubbles? (msg.narrowLayout? 0 : 4) : 2 id: contentItem blurhash: r.blurhash @@ -178,9 +174,9 @@ Item { Layout.column: msg.narrowLayout? 0 : 1 Layout.row: msg.narrowLayout? 2 : 0 Layout.rowSpan: msg.narrowLayout? 1 : 2 + Layout.bottomMargin: msg.narrowLayout? -4 : 0 Layout.alignment: Qt.AlignTop | Qt.AlignRight - Layout.topMargin: msg.narrowLayout? 0 : 4 - Layout.rightMargin: Settings.bubbles? 4 : 0 + property double scaling: msg.narrowLayout? 0.75 : 1 StatusIndicator { Layout.alignment: Qt.AlignRight | Qt.AlignTop @@ -235,17 +231,17 @@ Item { } } } + } + Reactions { + anchors { + top: row.bottom + left: parent.left + leftMargin: Nheko.avatarSize + 16 + } - Reactions { - anchors { - bottom: parent.bottom - left: parent.left - } - - id: reactionRow + id: reactionRow - reactions: r.reactions - eventId: r.eventId - } + reactions: r.reactions + eventId: r.eventId } } diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index 0d4ff041..cc7f8d8f 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -56,7 +56,7 @@ Item { id: replyContainer anchors.left: colorLine.right - width: parent.width - 8 + width: parent.width - 4 spacing: 0 TapHandler { diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index c8ce19a7..80947950 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -809,7 +809,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case Markdown: return tr("Send messages as Markdown"); case Bubbles: - return tr("Enable Message bubbles"); + return tr("Enable message bubbles"); case AnimateImagesOnHover: return tr("Play animated images only on hover"); case TypingNotifications: @@ -1059,7 +1059,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const "Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain " "text."); case Bubbles: - return tr("Messages received a bubble background."); + return tr( + "Messages get a bubble background. This also triggers some layout changes (WIP)."); case AnimateImagesOnHover: return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); case TypingNotifications: -- cgit 1.5.1 From 12d600db97db7e6e4d9f3acb2755c6dfb5071a83 Mon Sep 17 00:00:00 2001 From: Malte E Date: Mon, 7 Feb 2022 21:53:37 +0100 Subject: add translations and actually add changes to TimelineModel --- resources/qml/MessageView.qml | 5 +++-- resources/qml/delegates/MessageDelegate.qml | 10 +++++----- src/timeline/TimelineModel.cpp | 13 +++++++++++-- src/timeline/TimelineModel.h | 2 ++ 4 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 03ed1a8d..aef05a63 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -252,7 +252,7 @@ ScrollView { topPadding: 4 bottomPadding: 4 spacing: 8 - visible: (previousMessageUserId !== userId || previousMessageDay !== day || previousMessageIsStateEvent) && !isStateEvent + visible: (previousMessageUserId !== userId || previousMessageDay !== day || isStateEvent !== previousMessageIsStateEvent) width: parentWidth height: ((previousMessageDay !== day) ? dateBubble.height : 0) + (isStateEvent? 0 : userName.height +8 ) @@ -278,6 +278,7 @@ ScrollView { Row { height: userName_.height spacing: 8 + visible: !isStateEvent Avatar { id: messageUserAvatar @@ -289,7 +290,7 @@ ScrollView { userid: userId onClicked: room.openUserProfile(userId) ToolTip.visible: avatarHover.hovered - ToolTip.delay: Nheko.tooltipDelay + ToolTip.delay: Nheko.tooltipDelay ToolTip.text: userid HoverHandler { diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index aef69ba4..58f12c91 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -186,7 +186,7 @@ Item { roleValue: MtxEvent.Redaction Pill { - text: qsTr("removed") + text: qsTr("%1 removed a message").arg(d.userName) isStateEvent: d.isStateEvent } @@ -196,7 +196,7 @@ Item { roleValue: MtxEvent.Encryption Pill { - text: qsTr("Encryption enabled") + text: qsTr("%1 enabled encryption").arg(d.userName) isStateEvent: d.isStateEvent } @@ -220,7 +220,7 @@ Item { isOnlyEmoji: false isReply: d.isReply isStateEvent: d.isStateEvent - formatted: d.roomName ? qsTr("room name changed to: %1").arg(d.roomName) : qsTr("removed room name") + formatted: d.roomName ? qsTr("%2 changed the room name to: %1").arg(d.roomName).arg(d.userName) : qsTr("%1 removed the room name").arg(d.userName) } } @@ -233,7 +233,7 @@ Item { isOnlyEmoji: false isReply: d.isReply isStateEvent: d.isStateEvent - formatted: d.roomTopic ? qsTr("topic changed to: %1").arg(d.roomTopic) : qsTr("removed topic") + formatted: d.roomTopic ? qsTr("%2 changed the topic to: %1").arg(d.roomTopic).arg(d.userName): qsTr("%1 removed the topic").arg(d.userName) } } @@ -372,7 +372,7 @@ Item { isOnlyEmoji: false isReply: d.isReply isStateEvent: d.isStateEvent - formatted: qsTr("Negotiating call...") + formatted: qsTr("% is negotiating the call...").arg(d.userName) } } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 6b380f79..dfd06f0b 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -453,6 +453,7 @@ TimelineModel::roleNames() const {UserId, "userId"}, {UserName, "userName"}, {PreviousMessageDay, "previousMessageDay"}, + {PreviousMessageIsStateEvent, "previousMessageIsStateEvent"}, {Day, "day"}, {Timestamp, "timestamp"}, {Url, "url"}, @@ -469,6 +470,7 @@ TimelineModel::roleNames() const {IsEdited, "isEdited"}, {IsEditable, "isEditable"}, {IsEncrypted, "isEncrypted"}, + {IsStateEvent, "isStateEvent"}, {Trustlevel, "trustlevel"}, {EncryptionError, "encryptionError"}, {ReplyTo, "replyTo"}, @@ -666,6 +668,9 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r std::holds_alternative>( *encrypted_event); } + case IsStateEvent: { + return is_state_event(event); + } case Trustlevel: { auto encrypted_event = events.get(event_id(event), "", false); @@ -730,6 +735,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r m.insert(names[IsEdited], data(event, static_cast(IsEdited))); m.insert(names[IsEditable], data(event, static_cast(IsEditable))); m.insert(names[IsEncrypted], data(event, static_cast(IsEncrypted))); + m.insert(names[IsStateEvent], data(event, static_cast(IsStateEvent))); m.insert(names[ReplyTo], data(event, static_cast(ReplyTo))); m.insert(names[RoomName], data(event, static_cast(RoomName))); m.insert(names[RoomTopic], data(event, static_cast(RoomTopic))); @@ -762,7 +768,8 @@ TimelineModel::data(const QModelIndex &index, int role) const if (!event) return ""; - if (role == PreviousMessageDay || role == PreviousMessageUserId) { + if (role == PreviousMessageDay || role == PreviousMessageUserId || + role == PreviousMessageIsStateEvent) { int prevIdx = rowCount() - index.row() - 2; if (prevIdx < 0) return {}; @@ -771,8 +778,10 @@ TimelineModel::data(const QModelIndex &index, int role) const return {}; if (role == PreviousMessageUserId) return data(*tempEv, UserId); - else + else if (role == PreviousMessageDay) return data(*tempEv, Day); + else + return data(*tempEv, IsStateEvent); } return data(*event, role); diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 556f9f54..c50a2c06 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -205,6 +205,7 @@ public: UserId, UserName, PreviousMessageDay, + PreviousMessageIsStateEvent, Day, Timestamp, Url, @@ -221,6 +222,7 @@ public: IsEdited, IsEditable, IsEncrypted, + IsStateEvent, Trustlevel, EncryptionError, ReplyTo, -- cgit 1.5.1 From 987b9bed6bb2c1c75a81b099c007aeaedf00eb71 Mon Sep 17 00:00:00 2001 From: Malte E Date: Sun, 13 Feb 2022 13:12:51 +0100 Subject: add small avatars option and tweak colors and spacings --- resources/qml/MessageView.qml | 8 ++++---- resources/qml/TimelineRow.qml | 32 +++++++++++++++++--------------- resources/qml/delegates/Reply.qml | 2 +- src/UserSettingsPage.cpp | 31 ++++++++++++++++++++++++++++++- src/UserSettingsPage.h | 7 ++++++- 5 files changed, 58 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 3fddc782..c465c72e 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -249,8 +249,8 @@ ScrollView { id: sectionHeader Column { - topPadding: 0 - bottomPadding: 0 + topPadding: userName_.visible? 4: 0 + bottomPadding: Settings.bubbles? 0 : 3 spacing: 8 visible: (previousMessageUserId !== userId || previousMessageDay !== day || isStateEvent !== previousMessageIsStateEvent) width: parentWidth @@ -283,8 +283,8 @@ ScrollView { Avatar { id: messageUserAvatar - width: Nheko.avatarSize * (Settings.bubbles? 0.5 : 1) - height: Nheko.avatarSize * (Settings.bubbles? 0.5 : 1) + width: Nheko.avatarSize * (Settings.smallAvatars? 0.5 : 1) + height: Nheko.avatarSize * (Settings.smallAvatars? 0.5 : 1) url: !room ? "" : room.avatarUrl(userId).replace("mxc://", "image://MxcImage/") displayName: userName userid: userId diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index f189f042..c7508a1c 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -74,28 +74,31 @@ Item { Control { id: row property bool bubbleOnRight : isSender && Settings.bubbles - anchors.rightMargin: isSender || !Settings.bubbles? 0 : parent.width/8 - anchors.leftMargin: (Settings.bubbles? 0 : Nheko.avatarSize) + (bubbleOnRight? parent.width/8 : 8) // align bubble with section header + 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 property int maxWidth: parent.width-anchors.leftMargin-anchors.rightMargin width: Settings.bubbles? Math.min(maxWidth,implicitWidth+metadata.width) : maxWidth - padding: isStateEvent? 0 : 2 + leftPadding: 4 + rightPadding: (Settings.bubbles && !isStateEvent)? 4: 2 + topPadding: (Settings.bubbles && !isStateEvent)? 4: 2 + bottomPadding: topPadding background: Rectangle { property color userColor: TimelineManager.userColor(userId, Nheko.colors.base) property color bgColor: Nheko.colors.base - color: Qt.tint(bgColor, Qt.rgba(userColor.r, userColor.g, userColor.b, 0.2)) - radius: parent.padding*2 + color: Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.2)) + radius: 4 visible: Settings.bubbles && !isStateEvent } contentItem: GridLayout { id: msg - property bool narrowLayout: Settings.bubbles //&& (timelineView.width < 500) // timelineView causes fewew binding loops than r. But maybe it shouldn't depend on width anyway rowSpacing: 0 columnSpacing: 2 - columns: narrowLayout? 1 : 2 - rows: narrowLayout? 3 : 2 + columns: Settings.bubbles? 1 : 2 + rows: Settings.bubbles? 3 : 2 // fancy reply, if this is a reply Reply { @@ -170,15 +173,15 @@ Item { RowLayout { id: metadata - Layout.column: msg.narrowLayout? 0 : 1 - Layout.row: msg.narrowLayout? 2 : 0 - Layout.rowSpan: msg.narrowLayout? 1 : 2 - Layout.bottomMargin: -4 + Layout.column: Settings.bubbles? 0 : 1 + Layout.row: Settings.bubbles? 2 : 0 + Layout.rowSpan: Settings.bubbles? 1 : 2 + Layout.bottomMargin: -2 Layout.alignment: Qt.AlignTop | Qt.AlignRight Layout.preferredWidth: implicitWidth visible: !isStateEvent - property double scaling: msg.narrowLayout? 0.75 : 1 + property double scaling: Settings.bubbles? 0.75 : 1 StatusIndicator { Layout.alignment: Qt.AlignRight | Qt.AlignTop @@ -238,8 +241,7 @@ Item { anchors { top: row.bottom topMargin: -2 - left: parent.left - leftMargin: Nheko.avatarSize + 16 + left: row.left } id: reactionRow diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index c60867de..a439b2eb 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -137,7 +137,7 @@ Item { anchors.fill: replyContainer property color userColor: TimelineManager.userColor(userId, Nheko.colors.base) property color bgColor: Nheko.colors.base - color: Qt.tint(bgColor, Qt.rgba(userColor.r, userColor.g, userColor.b, 0.1)) + color: Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.1)) } } diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 80947950..265e45a6 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -71,6 +71,7 @@ UserSettings::load(std::optional profile) settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); + smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), true).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = @@ -253,6 +254,16 @@ UserSettings::setBubbles(bool state) save(); } +void +UserSettings::setSmallAvatars(bool state) +{ + if (state == smallAvatars_) + return; + smallAvatars_ = state; + emit smallAvatarsChanged(state); + save(); +} + void UserSettings::setAnimateImagesOnHover(bool state) { @@ -708,6 +719,7 @@ UserSettings::save() settings.setValue(QStringLiteral("group_view"), groupView_); settings.setValue(QStringLiteral("markdown_enabled"), markdown_); settings.setValue(QStringLiteral("bubbles_enabled"), bubbles_); + settings.setValue(QStringLiteral("small_avatars_enabled"), smallAvatars_); settings.setValue(QStringLiteral("animate_images_on_hover"), animateImagesOnHover_); settings.setValue(QStringLiteral("desktop_notifications"), hasDesktopNotifications_); settings.setValue(QStringLiteral("alert_on_notification"), hasAlertOnNotification_); @@ -810,6 +822,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return tr("Send messages as Markdown"); case Bubbles: return tr("Enable message bubbles"); + case SmallAvatars: + return tr("Enable small Avatars"); case AnimateImagesOnHover: return tr("Play animated images only on hover"); case TypingNotifications: @@ -932,6 +946,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return i->markdown(); case Bubbles: return i->bubbles(); + case SmallAvatars: + return i->smallAvatars(); case AnimateImagesOnHover: return i->animateImagesOnHover(); case TypingNotifications: @@ -1061,6 +1077,9 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case Bubbles: return tr( "Messages get a bubble background. This also triggers some layout changes (WIP)."); + case SmallAvatars: + return tr( + "Avatars are resized to fit above the message."); case AnimateImagesOnHover: return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); case TypingNotifications: @@ -1178,6 +1197,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const case GroupView: case Markdown: case Bubbles: + case SmallAvatars: case AnimateImagesOnHover: case TypingNotifications: case SortByImportance: @@ -1402,6 +1422,13 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int } else return false; } + case SmallAvatars: { + if (value.userType() == QMetaType::Bool) { + i->setSmallAvatars(value.toBool()); + return true; + } else + return false; + } case AnimateImagesOnHover: { if (value.userType() == QMetaType::Bool) { i->setAnimateImagesOnHover(value.toBool()); @@ -1767,7 +1794,9 @@ UserSettingsModel::UserSettingsModel(QObject *p) connect(s.get(), &UserSettings::bubblesChanged, this, [this]() { emit dataChanged(index(Bubbles), index(Bubbles), {Value}); }); - + connect(s.get(), &UserSettings::smallAvatarsChanged, this, [this]() { + emit dataChanged(index(SmallAvatars), index(SmallAvatars), {Value}); + }); connect(s.get(), &UserSettings::groupViewStateChanged, this, [this]() { emit dataChanged(index(GroupView), index(GroupView), {Value}); }); diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h index e5d22f6a..8f76c58f 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h @@ -41,6 +41,7 @@ class UserSettings : public QObject Q_PROPERTY(bool groupView READ groupView WRITE setGroupView NOTIFY groupViewStateChanged) Q_PROPERTY(bool markdown READ markdown WRITE setMarkdown NOTIFY markdownChanged) Q_PROPERTY(bool bubbles READ bubbles WRITE setBubbles NOTIFY bubblesChanged) + Q_PROPERTY(bool smallAvatars READ smallAvatars WRITE setSmallAvatars NOTIFY smallAvatarsChanged) Q_PROPERTY(bool animateImagesOnHover READ animateImagesOnHover WRITE setAnimateImagesOnHover NOTIFY animateImagesOnHoverChanged) Q_PROPERTY(bool typingNotifications READ typingNotifications WRITE setTypingNotifications NOTIFY @@ -141,6 +142,7 @@ public: void setGroupView(bool state); void setMarkdown(bool state); void setBubbles(bool state); + void setSmallAvatars(bool state); void setAnimateImagesOnHover(bool state); void setReadReceipts(bool state); void setTypingNotifications(bool state); @@ -193,6 +195,7 @@ public: int privacyScreenTimeout() const { return privacyScreenTimeout_; } bool markdown() const { return markdown_; } bool bubbles() const { return bubbles_; } + bool smallAvatars() const { return smallAvatars_; } bool animateImagesOnHover() const { return animateImagesOnHover_; } bool typingNotifications() const { return typingNotifications_; } bool sortByImportance() const { return sortByImportance_; } @@ -251,6 +254,7 @@ signals: void startInTrayChanged(bool state); void markdownChanged(bool state); void bubblesChanged(bool state); + void smallAvatarsChanged(bool state); void animateImagesOnHoverChanged(bool state); void typingNotificationsChanged(bool state); void buttonInTimelineChanged(bool state); @@ -307,6 +311,7 @@ private: bool groupView_; bool markdown_; bool bubbles_; + bool smallAvatars_; bool animateImagesOnHover_; bool typingNotifications_; bool sortByImportance_; @@ -386,7 +391,7 @@ class UserSettingsModel : public QAbstractListModel ButtonsInTimeline, Markdown, Bubbles, - + SmallAvatars, SidebarSection, GroupView, SortByImportance, -- cgit 1.5.1 From c70fe9c571e18c78f3a53488ffd49942e175582e Mon Sep 17 00:00:00 2001 From: Malte E Date: Sun, 13 Feb 2022 13:22:29 +0100 Subject: let lint fix the code formatting --- src/UserSettingsPage.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 265e45a6..000e2976 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -69,9 +69,9 @@ UserSettings::load(std::optional profile) settings.value(QStringLiteral("user/timeline/message_hover_highlight"), false).toBool(); enlargeEmojiOnlyMessages_ = settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); - markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); - bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); - smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), true).toBool(); + markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); + bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); + smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), true).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = @@ -1078,8 +1078,7 @@ UserSettingsModel::data(const QModelIndex &index, int role) const return tr( "Messages get a bubble background. This also triggers some layout changes (WIP)."); case SmallAvatars: - return tr( - "Avatars are resized to fit above the message."); + return tr("Avatars are resized to fit above the message."); case AnimateImagesOnHover: return tr("Plays media like GIFs or WEBPs only when explicitly hovering over them."); case TypingNotifications: -- cgit 1.5.1 From 414257bf0eba7f8415644509ae617883ac266e40 Mon Sep 17 00:00:00 2001 From: Malte E Date: Mon, 14 Feb 2022 14:03:17 +0100 Subject: fix bugs found by Nico --- resources/qml/MessageView.qml | 2 +- resources/qml/delegates/FileMessage.qml | 3 +-- resources/qml/delegates/PlayableMediaMessage.qml | 3 ++- resources/qml/delegates/Redacted.qml | 3 +-- src/UserSettingsPage.cpp | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index c465c72e..f32d68a0 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -250,7 +250,7 @@ ScrollView { Column { topPadding: userName_.visible? 4: 0 - bottomPadding: Settings.bubbles? 0 : 3 + bottomPadding: Settings.bubbles? 2 : 3 spacing: 8 visible: (previousMessageUserId !== userId || previousMessageDay !== day || isStateEvent !== previousMessageIsStateEvent) width: parentWidth diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 1e50fe3a..fd81b176 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -87,8 +87,7 @@ Item { color: Nheko.colors.alternateBase z: -1 radius: 10 - height: row.height + 24 - width: 44 + 24 + 24 + Math.max(Math.min(filesize_.width, filesize_.implicitWidth), Math.min(filename_.width, filename_.implicitWidth)) + anchors.fill: parent } } diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 9324cdaf..54813d23 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -23,7 +23,8 @@ Item { required property string body required property string filesize property double divisor: isReply ? 4 : 2 - implicitWidth: type == MtxEvent.VideoMessage ? Math.round(originalWidth*Math.min((timelineView.height/divisor)/(originalWidth*proportionalHeight), 1)) : 500 + property int tempWidth: originalWidth < 1? 400: originalWidth + implicitWidth: type == MtxEvent.VideoMessage ? Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1)) : 500 width: parent.width height: (type == MtxEvent.VideoMessage ? width*proportionalHeight : 80) + fileInfoLabel.height implicitHeight: height diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml index cf723988..7e5a10f9 100644 --- a/resources/qml/delegates/Redacted.qml +++ b/resources/qml/delegates/Redacted.qml @@ -10,10 +10,9 @@ import im.nheko 1.0 Rectangle{ - //required property real delegateWidth height: redactedLayout.implicitHeight + Nheko.paddingSmall implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium - //implicitWidth: width + width: parent.width radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall color: Nheko.colors.alternateBase diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 000e2976..e3f80699 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -70,8 +70,8 @@ UserSettings::load(std::optional profile) enlargeEmojiOnlyMessages_ = settings.value(QStringLiteral("user/timeline/enlarge_emoji_only_msg"), false).toBool(); markdown_ = settings.value(QStringLiteral("user/markdown_enabled"), true).toBool(); - bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), true).toBool(); - smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), true).toBool(); + bubbles_ = settings.value(QStringLiteral("user/bubbles_enabled"), false).toBool(); + smallAvatars_ = settings.value(QStringLiteral("user/small_avatars_enabled"), false).toBool(); animateImagesOnHover_ = settings.value(QStringLiteral("user/animate_images_on_hover"), false).toBool(); typingNotifications_ = -- cgit 1.5.1