2022-09-16 13:06:52 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
2022-11-16 17:17:38 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as CoreUtils
|
2022-09-16 13:06:52 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import shared 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
ActivityNotificationBase {
|
|
|
|
id: root
|
|
|
|
|
2022-11-30 11:15:29 +00:00
|
|
|
readonly property string timestampString: notification ?
|
|
|
|
new Date(notification.timestamp).toLocaleTimeString(Qt.locale(), Locale.ShortFormat) :
|
|
|
|
""
|
|
|
|
readonly property string timestampTooltipString: notification ?
|
|
|
|
new Date(notification.timestamp).toLocaleString() :
|
|
|
|
""
|
2022-09-20 16:11:29 +00:00
|
|
|
|
2022-11-16 17:17:38 +00:00
|
|
|
property int maximumLineCount: 2
|
2022-09-16 13:06:52 +00:00
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
signal messageClicked()
|
|
|
|
|
2022-11-16 17:17:38 +00:00
|
|
|
property StatusMessageDetails messageDetails: StatusMessageDetails {
|
2022-11-30 11:15:29 +00:00
|
|
|
messageText: notification ? notification.message.messageText : ""
|
|
|
|
amISender: notification ? notification.message.amISender : false
|
|
|
|
sender.id: notification ? notification.message.senderId : ""
|
|
|
|
sender.displayName: notification ? notification.message.senderDisplayName : ""
|
|
|
|
sender.secondaryName: notification ? notification.message.senderOptionalName : ""
|
|
|
|
sender.trustIndicator: notification ? notification.message.senderTrustStatus : Constants.trustStatus.unknown
|
2022-11-16 17:17:38 +00:00
|
|
|
sender.profileImage {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
2022-11-30 11:15:29 +00:00
|
|
|
name: notification ? notification.message.senderIcon || "" : ""
|
|
|
|
assetSettings.isImage: notification ? notification.message.senderIcon.startsWith("data") : false
|
|
|
|
pubkey: notification ? notification.message.senderId : ""
|
|
|
|
colorId: Utils.colorIdForPubkey(notification ? notification.message.senderId : "")
|
|
|
|
colorHash: Utils.getColorHashAsJson(notification ? notification.message.senderId : "")
|
2022-11-16 17:17:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property Component messageSubheaderComponent: null
|
|
|
|
property Component messageBadgeComponent: null
|
|
|
|
|
|
|
|
function openProfilePopup() {
|
|
|
|
closeActivityCenter()
|
|
|
|
Global.openProfilePopup(notification.message.senderId)
|
|
|
|
}
|
2022-11-30 11:15:29 +00:00
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
bodyComponent: MouseArea {
|
2022-11-30 11:15:29 +00:00
|
|
|
height: messageRow.implicitHeight
|
2022-11-22 22:01:30 +00:00
|
|
|
hoverEnabled: root.messageBadgeComponent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2022-12-01 10:24:25 +00:00
|
|
|
onClicked: {
|
|
|
|
root.activityCenterStore.switchTo(notification)
|
|
|
|
root.closeActivityCenter()
|
|
|
|
}
|
2022-11-30 11:15:29 +00:00
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
RowLayout {
|
|
|
|
id: messageRow
|
|
|
|
spacing: 8
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.preferredWidth: root.messageDetails.sender.profileImage.assetSettings.width
|
|
|
|
Layout.preferredHeight: profileImage.height
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.topMargin: 2
|
|
|
|
|
|
|
|
StatusSmartIdenticon {
|
|
|
|
id: profileImage
|
|
|
|
name: root.messageDetails.sender.displayName
|
|
|
|
asset: root.messageDetails.sender.profileImage.assetSettings
|
|
|
|
ringSettings: root.messageDetails.sender.profileImage.ringSettings
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: root.openProfilePopup()
|
|
|
|
}
|
2022-11-16 17:17:38 +00:00
|
|
|
}
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2022-11-16 17:17:38 +00:00
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
ColumnLayout {
|
2022-11-16 17:17:38 +00:00
|
|
|
spacing: 2
|
2022-11-22 22:01:30 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-11-16 17:17:38 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
StatusMessageHeader {
|
|
|
|
sender: root.messageDetails.sender
|
|
|
|
amISender: root.messageDetails.amISender
|
|
|
|
messageOriginInfo: root.messageDetails.messageOriginInfo
|
2022-11-29 11:57:07 +00:00
|
|
|
tertiaryDetail: Utils.getElidedCompressedPk(sender.id)
|
2022-11-22 22:01:30 +00:00
|
|
|
timestamp.text: root.timestampString
|
|
|
|
timestamp.tooltip.text: root.timestampTooltipString
|
|
|
|
onClicked: root.openProfilePopup()
|
2022-11-16 17:17:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
2022-11-22 22:01:30 +00:00
|
|
|
sourceComponent: root.messageSubheaderComponent
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 2
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: CoreUtils.Utils.stripHtmlTags(root.messageDetails.messageText)
|
|
|
|
maximumLineCount: root.maximumLineCount
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: 15
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
Layout.maximumWidth: 400 // From designs, fixed value to align all possible CTAs
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
sourceComponent: root.messageBadgeComponent
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2022-11-16 17:17:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2022-09-20 16:11:29 +00:00
|
|
|
}
|
2022-11-22 22:01:30 +00:00
|
|
|
}
|