Compare commits

..

No commits in common. "f014b5eb3a6e32281536a894b7bbc10f4acfe3ea" and "05e88b5e4beacb2e73bbdaa082ab07d4fba4b27c" have entirely different histories.

13 changed files with 216 additions and 341 deletions

View File

@ -1,8 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
ListView { ListView {
pixelAligned: true
ScrollHelper { ScrollHelper {
anchors.fill: parent anchors.fill: parent

View File

@ -18,6 +18,7 @@ Item {
sourceSize.width: width sourceSize.width: width
sourceSize.height: width sourceSize.height: width
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
mipmap: true
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
maskSource: Rectangle { maskSource: Rectangle {

View File

@ -1,49 +1,34 @@
/*
* Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
* Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
/*
* The MouseArea + interactive: false + maximumFlickVelocity are required
* to fix scrolling for desktop systems where we don't want flicking behaviour.
*
* See also:
* ScrollView.qml in qtquickcontrols
* qquickwheelarea.cpp in qtquickcontrols
*/
MouseArea { MouseArea {
id: root id: root
propagateComposedEvents: true propagateComposedEvents: true
property Flickable flickable property Flickable flickable
property alias enabled: root.enabled
//Place the mouse area under the flickable //Place the mouse area under the flickable
z: -1 z: -1
onFlickableChanged: { onFlickableChanged: {
if (enabled) { flickable.interactive = false
flickable.interactive = false flickable.maximumFlickVelocity = 100000
flickable.maximumFlickVelocity = 100000 flickable.boundsBehavior = Flickable.StopAtBounds
flickable.boundsBehavior = Flickable.StopAtBounds }
root.parent = flickable
function scrollByPixelDelta(flickableItem, pixelDelta) {
if (!pixelDelta) {
return flickableItem.contentY;
} }
var minYExtent = flickableItem.originY + flickableItem.topMargin;
var maxYExtent = (flickableItem.contentHeight + flickableItem.bottomMargin + flickableItem.originY) - flickableItem.height;
if (typeof(flickableItem.headerItem) !== "undefined" && flickableItem.headerItem) {
minYExtent += flickableItem.headerItem.height
}
//Avoid overscrolling
return Math.max(minYExtent, Math.min(maxYExtent, flickableItem.contentY - pixelDelta));
} }
function calculateNewPosition(flickableItem, wheel) { function calculateNewPosition(flickableItem, wheel) {
@ -67,30 +52,27 @@ MouseArea {
pixelDelta = wheel.pixelDelta.y pixelDelta = wheel.pixelDelta.y
} }
if (!pixelDelta) { return scrollByPixelDelta(flickableItem, pixelDelta);
return flickableItem.contentY; }
}
var minYExtent = flickableItem.originY + flickableItem.topMargin; function scrollDown() {
var maxYExtent = (flickableItem.contentHeight + flickableItem.bottomMargin + flickableItem.originY) - flickableItem.height; flickable.flick(0, 0);
flickable.contentY = scrollByPixelDelta(flickable, -60); //3 lines * 20 pixels
}
if (typeof(flickableItem.headerItem) !== "undefined" && flickableItem.headerItem) { function scrollUp() {
minYExtent += flickableItem.headerItem.height flickable.flick(0, 0);
} flickable.contentY = scrollByPixelDelta(flickable, 60); //3 lines * 20 pixels
//Avoid overscrolling
return Math.max(minYExtent, Math.min(maxYExtent, flickableItem.contentY - pixelDelta));
} }
onWheel: { onWheel: {
var newPos = calculateNewPosition(flickable, wheel);
// console.warn("Delta: ", wheel.pixelDelta.y); // console.warn("Delta: ", wheel.pixelDelta.y);
// console.warn("Old position: ", flickable.contentY); // console.warn("Old position: ", flickable.contentY);
// console.warn("New position: ", newPos); // console.warn("New position: ", newPos);
// Show the scrollbars // Show the scrollbars
flickable.flick(0, 0); flickable.flick(0, 0);
flickable.contentY = newPos; flickable.contentY = calculateNewPosition(flickable, wheel);
cancelFlickStateTimer.start() cancelFlickStateTimer.start()
} }

View File

@ -76,7 +76,7 @@ ColumnLayout {
visible: !(sentByMe || avatarVisible) visible: !(sentByMe || avatarVisible)
text: Qt.formatTime(time, "hh:mm AP") text: Qt.formatDateTime(time, "hh:mm")
color: "#5B7480" color: "#5B7480"
font.pixelSize: 10 font.pixelSize: 10
@ -119,58 +119,6 @@ ColumnLayout {
color: MPalette.background color: MPalette.background
radius: 18 radius: 18
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
width: parent.width / 2
height: parent.height / 2
visible: !sentByMe && (bubbleShape == 3 || bubbleShape == 2)
color: sentByMe ? MPalette.background : eventType === "notice" ? MPalette.primary : MPalette.accent
radius: 2
}
Rectangle {
anchors.top: parent.top
anchors.right: parent.right
width: parent.width / 2
height: parent.height / 2
visible: sentByMe && (bubbleShape == 3 || bubbleShape == 2)
color: sentByMe ? MPalette.background : eventType === "notice" ? MPalette.primary : MPalette.accent
radius: 2
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
width: parent.width / 2
height: parent.height / 2
visible: !sentByMe && (bubbleShape == 1 || bubbleShape == 2)
color: sentByMe ? MPalette.background : eventType === "notice" ? MPalette.primary : MPalette.accent
radius: 2
}
Rectangle {
anchors.bottom: parent.bottom
anchors.right: parent.right
width: parent.width / 2
height: parent.height / 2
visible: sentByMe && (bubbleShape == 1 || bubbleShape == 2)
color: sentByMe ? MPalette.background : eventType === "notice" ? MPalette.primary : MPalette.accent
radius: 2
}
AutoMouseArea { AutoMouseArea {
anchors.fill: parent anchors.fill: parent

View File

@ -14,8 +14,8 @@ import Spectral.Menu.Timeline 2.0
import Spectral.Effect 2.0 import Spectral.Effect 2.0
import Spectral.Font 0.1 import Spectral.Font 0.1
RowLayout { ColumnLayout {
readonly property bool avatarVisible: showAuthor && !sentByMe readonly property bool avatarVisible: !sentByMe && showAuthor
readonly property bool sentByMe: author === currentRoom.localUser readonly property bool sentByMe: author === currentRoom.localUser
property bool openOnFinished: false property bool openOnFinished: false
@ -23,9 +23,7 @@ RowLayout {
id: root id: root
spacing: 4 spacing: 0
z: -5
onDownloadedChanged: { onDownloadedChanged: {
if (downloaded && openOnFinished) { if (downloaded && openOnFinished) {
@ -34,164 +32,161 @@ RowLayout {
} }
} }
Avatar { Label {
Layout.preferredWidth: 32 Layout.leftMargin: 48
Layout.preferredHeight: 32
Layout.alignment: Qt.AlignBottom text: author.displayName
visible: avatarVisible visible: avatarVisible
hint: author.displayName
source: author.avatarMediaId
Component { font.pixelSize: 13
id: userDetailDialog verticalAlignment: Text.AlignVCenter
UserDetailDialog {}
}
RippleEffect {
anchors.fill: parent
circular: true
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
}
} }
Label { RowLayout {
Layout.preferredWidth: 32 z: -5
Layout.preferredHeight: 32
visible: !(sentByMe || avatarVisible) id: messageRow
}
BusyIndicator { spacing: 4
Layout.preferredWidth: 64
Layout.preferredHeight: 64
visible: img.status == Image.Loading Avatar {
} Layout.preferredWidth: 32
Layout.preferredHeight: 32
Layout.alignment: Qt.AlignTop
Image { visible: avatarVisible
Layout.maximumWidth: messageListView.width - (!sentByMe ? 32 + root.spacing : 0) - 48 hint: author.displayName
source: author.avatarMediaId
id: img Component {
id: userDetailDialog
source: "image://mxc/" + UserDetailDialog {}
(content.info && content.info.thumbnail_info ? }
content.thumbnailMediaId : content.mediaId)
sourceSize.width: 720 RippleEffect {
sourceSize.height: 720 anchors.fill: parent
fillMode: Image.PreserveAspectCrop circular: true
layer.enabled: true onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
layer.effect: OpacityMask {
maskSource: Rectangle {
width: img.width
height: img.height
radius: 5
} }
} }
Control { Label {
anchors.bottom: parent.bottom Layout.preferredWidth: 32
anchors.bottomMargin: 8 Layout.preferredHeight: 32
anchors.right: parent.right Layout.alignment: Qt.AlignTop
anchors.rightMargin: 8
horizontalPadding: 8 visible: !(sentByMe || avatarVisible)
verticalPadding: 4
contentItem: RowLayout { text: Qt.formatDateTime(time, "hh:mm")
Label { color: "#5B7480"
text: Qt.formatTime(time, "hh:mm AP")
color: "white"
font.pixelSize: 12
}
Label { font.pixelSize: 10
text: author.displayName horizontalAlignment: Label.AlignHCenter
color: "white" verticalAlignment: Label.AlignVCenter
font.pixelSize: 12 }
BusyIndicator {
Layout.preferredWidth: 64
Layout.preferredHeight: 64
visible: img.status == Image.Loading
}
Image {
Layout.maximumWidth: messageListView.width - (!sentByMe ? 32 + messageRow.spacing : 0) - 48
id: img
source: "image://mxc/" +
(content.info && content.info.thumbnail_info ?
content.thumbnailMediaId : content.mediaId)
sourceSize.width: 720
sourceSize.height: 720
fillMode: Image.PreserveAspectCrop
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle {
width: img.width
height: img.height
radius: 6
} }
} }
background: Rectangle { Rectangle {
radius: height / 2 anchors.fill: parent
color: "black"
opacity: 0.3
}
}
Rectangle { visible: progressInfo.active && !downloaded
anchors.fill: parent
visible: progressInfo.active && !downloaded color: "#BB000000"
color: "#BB000000" ProgressBar {
anchors.centerIn: parent
ProgressBar { width: parent.width * 0.8
anchors.centerIn: parent
width: parent.width * 0.8 from: 0
to: progressInfo.total
from: 0 value: progressInfo.progress
to: progressInfo.total }
value: progressInfo.progress
}
}
RippleEffect {
anchors.fill: parent
id: messageMouseArea
onPrimaryClicked: fullScreenImage.createObject(parent, {"filename": eventId, "localPath": currentRoom.urlToDownload(eventId)}).show()
onSecondaryClicked: {
var contextMenu = imageDelegateContextMenu.createObject(ApplicationWindow.overlay)
contextMenu.viewSource.connect(function() {
messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
})
contextMenu.downloadAndOpen.connect(downloadAndOpen)
contextMenu.saveFileAs.connect(saveFileAs)
contextMenu.reply.connect(function() {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = message
roomPanelInput.isReply = true
roomPanelInput.focus()
})
contextMenu.redact.connect(function() {
currentRoom.redactEvent(eventId)
})
contextMenu.popup()
} }
Component { RippleEffect {
id: messageSourceDialog anchors.fill: parent
MessageSourceDialog {} id: messageMouseArea
}
Component { onPrimaryClicked: fullScreenImage.createObject(parent, {"filename": eventId, "localPath": currentRoom.urlToDownload(eventId)}).show()
id: openFolderDialog
OpenFolderDialog {} onSecondaryClicked: {
} var contextMenu = imageDelegateContextMenu.createObject(ApplicationWindow.overlay)
contextMenu.viewSource.connect(function() {
messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
})
contextMenu.downloadAndOpen.connect(downloadAndOpen)
contextMenu.saveFileAs.connect(saveFileAs)
contextMenu.reply.connect(function() {
roomPanelInput.replyUser = author
roomPanelInput.replyEventID = eventId
roomPanelInput.replyContent = message
roomPanelInput.isReply = true
roomPanelInput.focus()
})
contextMenu.redact.connect(function() {
currentRoom.redactEvent(eventId)
})
contextMenu.popup()
}
Component { Component {
id: imageDelegateContextMenu id: messageSourceDialog
FileDelegateContextMenu {} MessageSourceDialog {}
} }
Component { Component {
id: fullScreenImage id: openFolderDialog
FullScreenImage {} OpenFolderDialog {}
}
Component {
id: imageDelegateContextMenu
FileDelegateContextMenu {}
}
Component {
id: fullScreenImage
FullScreenImage {}
}
} }
} }
} }

View File

@ -27,8 +27,6 @@ ColumnLayout {
spacing: 0 spacing: 0
RowLayout { RowLayout {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
id: messageRow id: messageRow
spacing: 4 spacing: 4
@ -36,7 +34,7 @@ ColumnLayout {
Avatar { Avatar {
Layout.preferredWidth: 32 Layout.preferredWidth: 32
Layout.preferredHeight: 32 Layout.preferredHeight: 32
Layout.alignment: Qt.AlignBottom Layout.alignment: Qt.AlignTop
visible: avatarVisible visible: avatarVisible
hint: author.displayName hint: author.displayName
@ -191,8 +189,6 @@ ColumnLayout {
Control { Control {
Layout.fillWidth: true Layout.fillWidth: true
visible: replyVisible
padding: 0 padding: 0
background: RippleEffect { background: RippleEffect {
@ -200,6 +196,9 @@ ColumnLayout {
} }
contentItem: Label { contentItem: Label {
Layout.fillWidth: true
visible: replyVisible
color: darkBackground ? "white" : MPalette.lighter color: darkBackground ? "white" : MPalette.lighter
text: "<style>a{color: " + (darkBackground ? "white" : MPalette.foreground) + ";} .user-pill{}</style>" + (replyDisplay || "") text: "<style>a{color: " + (darkBackground ? "white" : MPalette.foreground) + ";} .user-pill{}</style>" + (replyDisplay || "")
@ -263,18 +262,20 @@ ColumnLayout {
Layout.rightMargin: sentByMe ? 12 : undefined Layout.rightMargin: sentByMe ? 12 : undefined
Layout.bottomMargin: 4 Layout.bottomMargin: 4
visible: showAuthor visible: showTimestamp || (showAuthor && !sentByMe)
Label { Label {
visible: !sentByMe visible: showTimestamp
text: Qt.formatDateTime(time, "hh:mm")
color: MPalette.lighter
}
Label {
visible: showAuthor && !sentByMe
text: author.displayName text: author.displayName
color: MPalette.lighter color: MPalette.lighter
} }
Label {
text: Qt.formatTime(time, "hh:mm AP")
color: MPalette.lighter
}
} }
} }

View File

@ -3,11 +3,10 @@ import QtQuick.Controls 2.12
import Spectral.Setting 0.1 import Spectral.Setting 0.1
Label { Label {
text: section + " • " + Qt.formatTime(time, "hh:mm AP") text: section + " • " + Qt.formatTime(time, "hh:mm")
color: MPalette.foreground color: MPalette.foreground
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Medium font.weight: Font.Medium
font.capitalization: Font.AllUppercase font.capitalization: Font.AllUppercase
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
padding: 8
} }

View File

@ -3,33 +3,26 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtQuick.Controls.Material 2.12 import QtQuick.Controls.Material 2.12
import Spectral.Component 2.0
import Spectral.Setting 0.1 import Spectral.Setting 0.1
Control { Label {
padding: 8 text: "<b>" + author.displayName + "</b> " + display
color: MPalette.foreground
font.pixelSize: 13
font.weight: Font.Medium
contentItem: RowLayout { topPadding: 8
Avatar { bottomPadding: 8
Layout.preferredWidth: 24 leftPadding: 24
Layout.preferredHeight: 24 rightPadding: 24
hint: author.displayName wrapMode: Label.Wrap
source: author.avatarMediaId textFormat: MSettings.richText ? Text.RichText : Text.StyledText
} onLinkActivated: Qt.openUrlExternally(link)
Label { background: Rectangle {
Layout.fillWidth: true color: MPalette.background
Layout.maximumWidth: messageListView.width - 48 radius: 4
antialiasing: true
text: "<b>" + author.displayName + "</b> " + display + " • " + Qt.formatTime(time, "hh:mm AP")
color: MPalette.foreground
font.pixelSize: 13
font.weight: Font.Medium
textFormat: Label.StyledText
wrapMode: Label.Wrap
onLinkActivated: Qt.openUrlExternally(link)
}
} }
} }

View File

@ -201,8 +201,6 @@ Item {
background: Rectangle { background: Rectangle {
color: Material.background color: Material.background
opacity: listView.atYBeginning ? 0 : 1
layer.enabled: true layer.enabled: true
layer.effect: ElevationEffect { layer.effect: ElevationEffect {
elevation: 2 elevation: 2

View File

@ -155,6 +155,8 @@ Item {
roleValue: "state" roleValue: "state"
delegate: StateDelegate { delegate: StateDelegate {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(implicitWidth, parent.width)
} }
} }
@ -162,78 +164,40 @@ Item {
roleValue: "emote" roleValue: "emote"
delegate: StateDelegate { delegate: StateDelegate {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(implicitWidth, parent.width)
} }
} }
DelegateChoice { DelegateChoice {
roleValue: "message" roleValue: "message"
delegate: ColumnLayout { delegate: MessageDelegate {
width: messageListView.width anchors.right: sentByMe ? parent.right : undefined
SectionDelegate {
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width
visible: showSection
}
MessageDelegate {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
}
} }
} }
DelegateChoice { DelegateChoice {
roleValue: "notice" roleValue: "notice"
delegate: ColumnLayout { delegate: MessageDelegate {
width: messageListView.width anchors.right: sentByMe ? parent.right : undefined
SectionDelegate {
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width
visible: showSection
}
MessageDelegate {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
}
} }
} }
DelegateChoice { DelegateChoice {
roleValue: "image" roleValue: "image"
delegate: ColumnLayout { delegate: ImageDelegate {
width: messageListView.width anchors.right: sentByMe ? parent.right : undefined
SectionDelegate { Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width
visible: showSection
}
ImageDelegate {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
}
} }
} }
DelegateChoice { DelegateChoice {
roleValue: "file" roleValue: "file"
delegate: ColumnLayout { delegate: FileDelegate {
width: messageListView.width anchors.right: sentByMe ? parent.right : undefined
SectionDelegate { Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width
visible: showSection
}
FileDelegate {
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
}
} }
} }

View File

@ -34,8 +34,8 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const {
roles[ReplyAuthorRole] = "replyAuthor"; roles[ReplyAuthorRole] = "replyAuthor";
roles[ReplyDisplayRole] = "replyDisplay"; roles[ReplyDisplayRole] = "replyDisplay";
roles[UserMarkerRole] = "userMarker"; roles[UserMarkerRole] = "userMarker";
roles[ShowTimestampRole] = "showTimestamp";
roles[ShowAuthorRole] = "showAuthor"; roles[ShowAuthorRole] = "showAuthor";
roles[ShowSectionRole] = "showSection";
roles[BubbleShapeRole] = "bubbleShape"; roles[BubbleShapeRole] = "bubbleShape";
return roles; return roles;
} }
@ -83,8 +83,9 @@ void MessageEventModel::setRoom(SpectralRoom* room) {
if (biggest < m_currentRoom->maxTimelineIndex()) { if (biggest < m_currentRoom->maxTimelineIndex()) {
auto rowBelowInserted = m_currentRoom->maxTimelineIndex() - auto rowBelowInserted = m_currentRoom->maxTimelineIndex() -
biggest + timelineBaseIndex() - 1; biggest + timelineBaseIndex() - 1;
refreshEventRoles(rowBelowInserted, refreshEventRoles(
{ShowAuthorRole, BubbleShapeRole}); rowBelowInserted,
{ShowTimestampRole, ShowAuthorRole, BubbleShapeRole});
} }
for (auto i = m_currentRoom->maxTimelineIndex() - biggest; for (auto i = m_currentRoom->maxTimelineIndex() - biggest;
i <= m_currentRoom->maxTimelineIndex() - lowest; ++i) i <= m_currentRoom->maxTimelineIndex() - lowest; ++i)
@ -115,7 +116,7 @@ void MessageEventModel::setRoom(SpectralRoom* room) {
refreshEventRoles(timelineBaseIndex() + 1, {ReadMarkerRole}); refreshEventRoles(timelineBaseIndex() + 1, {ReadMarkerRole});
if (timelineBaseIndex() > 0) // Refresh below, see #312 if (timelineBaseIndex() > 0) // Refresh below, see #312
refreshEventRoles(timelineBaseIndex() - 1, refreshEventRoles(timelineBaseIndex() - 1,
{ShowAuthorRole, BubbleShapeRole}); {ShowTimestampRole, ShowAuthorRole, BubbleShapeRole});
}); });
connect(m_currentRoom, &Room::pendingEventChanged, this, connect(m_currentRoom, &Room::pendingEventChanged, this,
&MessageEventModel::refreshRow); &MessageEventModel::refreshRow);
@ -289,11 +290,9 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
return "image"; return "image";
case MessageEventType::Audio: case MessageEventType::Audio:
return "audio"; return "audio";
default:
return e->hasFileContent() ? "file" : "message";
} }
if (e->hasFileContent())
return "file";
return "message";
} }
if (evt.isStateEvent()) if (evt.isStateEvent())
return "state"; return "state";
@ -416,28 +415,25 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
return {}; return {};
} }
if (role == ShowAuthorRole) { if (role == ShowTimestampRole) {
for (auto r = row - 1; r >= 0; --r) { for (auto r = row - 1; r >= 0; --r) {
auto i = index(r); auto i = index(r);
if (data(i, SpecialMarksRole) != EventStatus::Hidden) { if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
return data(i, AuthorRole) != data(idx, AuthorRole) || return data(idx, TimeRole)
data(i, EventTypeRole) != data(idx, EventTypeRole) || .toDateTime()
data(idx, TimeRole) .msecsTo(data(i, TimeRole).toDateTime()) > 600000;
.toDateTime()
.msecsTo(data(i, TimeRole).toDateTime()) > 600000;
} }
} }
return true; return true;
} }
if (role == ShowSectionRole) { if (role == ShowAuthorRole) {
for (auto r = row + 1; r < rowCount(); ++r) { for (auto r = row - 1; r >= 0; --r) {
auto i = index(r); auto i = index(r);
if (data(i, SpecialMarksRole) != EventStatus::Hidden) { if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
return data(i, TimeRole) return data(i, AuthorRole) != data(idx, AuthorRole) ||
.toDateTime() data(i, EventTypeRole) != data(idx, EventTypeRole);
.msecsTo(data(idx, TimeRole).toDateTime()) > 600000;
} }
} }
@ -459,9 +455,11 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
if (aboveRow == -1) { if (aboveRow == -1) {
aboveShow = true; aboveShow = true;
} else { } else {
aboveShow = data(index(aboveRow), ShowAuthorRole).toBool(); aboveShow = data(index(aboveRow), ShowAuthorRole).toBool() ||
data(index(aboveRow), ShowTimestampRole).toBool();
} }
belowShow = data(idx, ShowAuthorRole).toBool(); belowShow = data(idx, ShowAuthorRole).toBool() ||
data(idx, ShowTimestampRole).toBool();
if (aboveShow && belowShow) if (aboveShow && belowShow)
return BubbleShapes::NoShape; return BubbleShapes::NoShape;

View File

@ -31,8 +31,8 @@ class MessageEventModel : public QAbstractListModel {
ReplyAuthorRole, ReplyAuthorRole,
ReplyDisplayRole, ReplyDisplayRole,
ShowTimestampRole,
ShowAuthorRole, ShowAuthorRole,
ShowSectionRole,
BubbleShapeRole, BubbleShapeRole,
// For debugging // For debugging
EventResolvedTypeRole, EventResolvedTypeRole,

View File

@ -144,10 +144,8 @@ class SpectralRoom : public Room {
text += " and "; text += " and ";
if (e.avatarUrl().isEmpty()) if (e.avatarUrl().isEmpty())
text += tr("cleared the avatar"); text += tr("cleared the avatar");
else if (e.prevContent()->avatarUrl.isEmpty())
text += tr("set an avatar");
else else
text += tr("updated their avatar"); text += tr("updated the avatar");
} }
return text; return text;
} }