Build system, messages support and more

This commit is contained in:
miruka
2019-07-02 13:59:52 -04:00
parent 933341b7e6
commit 06c823aa67
53 changed files with 2264 additions and 446 deletions

View File

@@ -2,7 +2,7 @@ import QtQuick 2.7
import "../../Base"
HNoticePage {
text: dateTime.toLocaleDateString()
text: model.date.toLocaleDateString()
color: HStyle.chat.daybreak.foreground
backgroundColor: HStyle.chat.daybreak.background
radius: HStyle.chat.daybreak.radius

View File

@@ -16,7 +16,7 @@ Row {
HAvatar {
id: avatar
name: sender.displayName.value
name: sender.displayName || stripUserId(sender.userId)
hidden: combine
dimension: 28
}

View File

@@ -10,7 +10,7 @@ Row {
HAvatar {
id: avatar
hidden: combine
name: sender.displayName.value
name: senderInfo.displayName || stripUserId(model.senderId)
dimension: 48
}
@@ -38,8 +38,8 @@ Row {
visible: height > 0
id: nameLabel
text: sender.displayName.value
color: Qt.hsla(Backend.hueFromString(text),
text: senderInfo.displayName || model.senderId
color: Qt.hsla(avatar.hueFromName(avatar.name),
HStyle.displayName.saturation,
HStyle.displayName.lightness,
1)
@@ -56,17 +56,16 @@ Row {
width: parent.width
id: contentLabel
text: (dict.formatted_body ?
Backend.htmlFilter.filter(dict.formatted_body) :
dict.body) +
text: model.content +
"&nbsp;&nbsp;<font size=" + HStyle.fontSize.small +
"px color=" + HStyle.chat.message.date + ">" +
Qt.formatDateTime(dateTime, "hh:mm:ss") +
Qt.formatDateTime(model.date, "hh:mm:ss") +
"</font>" +
(isLocalEcho ?
(model.isLocalEcho ?
"&nbsp;<font size=" + HStyle.fontSize.small +
"px>⏳</font>" : "")
textFormat: Text.RichText
textFormat: model.type == "text" ?
Text.PlainText : Text.RichText
color: HStyle.chat.message.body
wrapMode: Text.Wrap

View File

@@ -1,7 +1,6 @@
import QtQuick 2.7
import QtQuick.Layouts 1.3
import "../../Base"
import "../utils.js" as ChatJS
Column {
id: roomEventDelegate
@@ -10,46 +9,47 @@ Column {
return Math.round((((date2 - date1) % 86400000) % 3600000) / 60000)
}
function getIsMessage(type_) { return type_.startsWith("RoomMessage") }
function getPreviousItem() {
return index < roomEventListView.model.count - 1 ?
roomEventListView.model.get(index + 1) : null
}
function getIsMessage(type) {
return true
}
property var previousItem: getPreviousItem()
signal reloadPreviousItem()
onReloadPreviousItem: previousItem = getPreviousItem()
readonly property bool isMessage: getIsMessage(type)
property var senderInfo: null
Component.onCompleted:
senderInfo = models.users.getUser(chatPage.userId, senderId)
readonly property bool isUndecryptableEvent:
type === "OlmEvent" || type === "MegolmEvent"
//readonly property bool isMessage: ! model.type.match(/^event.*/)
readonly property bool isMessage: getIsMessage(model.type)
readonly property var sender: Backend.users.get(dict.sender)
readonly property bool isOwn: chatPage.userId === senderId
readonly property bool isOwn:
chatPage.userId === dict.sender
readonly property bool isFirstEvent: type == "RoomCreateEvent"
readonly property bool isFirstEvent: model.type == "eventCreate"
readonly property bool combine:
previousItem &&
! talkBreak &&
! dayBreak &&
getIsMessage(previousItem.type) === isMessage &&
previousItem.dict.sender === dict.sender &&
minsBetween(previousItem.dateTime, dateTime) <= 5
previousItem.senderId === senderId &&
minsBetween(previousItem.date, model.date) <= 5
readonly property bool dayBreak:
isFirstEvent ||
previousItem &&
dateTime.getDate() != previousItem.dateTime.getDate()
model.date.getDate() != previousItem.date.getDate()
readonly property bool talkBreak:
previousItem &&
! dayBreak &&
minsBetween(previousItem.dateTime, dateTime) >= 20
minsBetween(previousItem.date, model.date) >= 20
property int standardSpacing: 16

View File

@@ -1,4 +1,5 @@
import QtQuick 2.7
import SortFilterProxyModel 0.2
import "../../Base"
HRectangle {
@@ -8,10 +9,19 @@ HRectangle {
HListView {
id: roomEventListView
delegate: RoomEventDelegate {}
model: Backend.roomEvents.get(chatPage.roomId)
clip: true
model: HListModel {
sourceModel: models.timelines
filters: ValueFilter {
roleName: "roomId"
value: chatPage.roomId
}
}
delegate: RoomEventDelegate {}
anchors.fill: parent
anchors.leftMargin: space
anchors.rightMargin: space
@@ -29,7 +39,7 @@ HRectangle {
onYPosChanged: {
if (chatPage.category != "Invites" && yPos <= 0.1) {
Backend.loadPastEvents(chatPage.roomId)
//Backend.loadPastEvents(chatPage.roomId)
}
}
}