2017-08-30 23:30:39 +00:00
|
|
|
import QtQuick 2.5
|
2017-08-29 14:28:33 +00:00
|
|
|
import QtQuick.Controls 2.1
|
|
|
|
import QtQuick.Controls.Material 2.1
|
2017-08-29 05:02:56 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
2019-05-17 14:27:12 +00:00
|
|
|
import "componentCreator.js" as ComponentCreator
|
|
|
|
|
2019-05-02 13:02:18 +00:00
|
|
|
ColumnLayout {
|
2019-05-06 18:18:56 +00:00
|
|
|
property bool fadeMedia
|
2019-05-09 03:38:10 +00:00
|
|
|
property bool showActionButtons: true
|
2019-05-13 06:08:11 +00:00
|
|
|
property var message: model
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-13 12:51:47 +00:00
|
|
|
property bool following: message.following
|
|
|
|
property bool liked: message.liked
|
|
|
|
property bool shared: message.shared
|
|
|
|
|
2019-05-13 05:20:43 +00:00
|
|
|
clip: true
|
|
|
|
|
2019-05-02 13:02:18 +00:00
|
|
|
RowLayout {
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: message.forward && !message.like
|
2019-05-02 13:02:18 +00:00
|
|
|
Item {
|
|
|
|
width: 32
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
smooth: true
|
2019-05-05 13:15:23 +00:00
|
|
|
source: "images/share.png"
|
2019-05-02 13:02:18 +00:00
|
|
|
sourceSize.height: 14
|
|
|
|
opacity: 0.5
|
|
|
|
}
|
|
|
|
Label {
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 10
|
2019-05-13 06:08:11 +00:00
|
|
|
text: qsTr("%1 shared").arg(message.actorname)
|
|
|
|
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.8 : 0.3
|
2019-05-10 14:47:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.actorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-10 14:47:26 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-02 13:02:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout {
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: message.like
|
2019-05-02 13:02:18 +00:00
|
|
|
Item {
|
|
|
|
width: 32
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
smooth: true
|
2019-05-05 13:15:23 +00:00
|
|
|
source: "images/like.png"
|
2019-05-02 13:02:18 +00:00
|
|
|
sourceSize.height: 14
|
|
|
|
opacity: 0.5
|
|
|
|
}
|
|
|
|
Label {
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 10
|
2019-05-13 06:08:11 +00:00
|
|
|
text: qsTr("%1 liked").arg(message.actorname)
|
|
|
|
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.8 : 0.3
|
2019-05-10 14:47:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.actorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-10 14:47:26 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-02 13:02:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 05:02:56 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 8
|
2019-05-13 05:20:43 +00:00
|
|
|
Layout.fillWidth: true
|
2019-05-02 13:02:18 +00:00
|
|
|
|
2017-08-29 05:02:56 +00:00
|
|
|
ImageButton {
|
|
|
|
id: image
|
2019-05-05 13:17:46 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2019-05-13 06:08:11 +00:00
|
|
|
source: message.avatar
|
2017-08-29 05:02:56 +00:00
|
|
|
sourceSize.width: 48
|
2019-05-02 11:39:04 +00:00
|
|
|
width: 48
|
2017-08-29 05:02:56 +00:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
2019-05-05 13:57:12 +00:00
|
|
|
roundness: 4
|
2019-05-06 18:16:20 +00:00
|
|
|
opacity: 1.0
|
|
|
|
|
|
|
|
onClicked: function() {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.authorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-06 18:16:20 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
2019-05-09 01:45:07 +00:00
|
|
|
RowLayout {
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: message.followed
|
2019-05-09 01:45:07 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 4
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Label {
|
|
|
|
font.pointSize: 11
|
|
|
|
font.bold: true
|
2019-05-13 06:08:11 +00:00
|
|
|
text: qsTr("%1 followed you").arg(message.actorname)
|
2019-05-09 01:45:07 +00:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
Layout.fillWidth: true
|
|
|
|
elide: Text.ElideRight
|
2019-05-10 14:47:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.authorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-10 14:47:26 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-09 01:45:07 +00:00
|
|
|
}
|
|
|
|
Label {
|
|
|
|
font.pointSize: 11
|
2019-05-13 06:08:11 +00:00
|
|
|
text: message.actor
|
2019-05-09 01:45:07 +00:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
Layout.fillWidth: true
|
|
|
|
elide: Text.ElideRight
|
2019-05-10 14:47:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.authorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-10 14:47:26 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-09 01:45:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
|
|
|
highlighted: true
|
2019-05-13 12:51:47 +00:00
|
|
|
text: following ? qsTr("Unfollow") : qsTr("Follow")
|
2019-05-09 01:45:07 +00:00
|
|
|
|
|
|
|
onClicked: {
|
2019-05-13 12:51:47 +00:00
|
|
|
uiBridge.followButton(message.authorid, !following)
|
|
|
|
following = !following
|
2019-05-09 01:45:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
ColumnLayout {
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: !message.followed
|
2017-08-30 23:30:39 +00:00
|
|
|
Layout.fillWidth: true
|
2017-08-29 05:02:56 +00:00
|
|
|
spacing: 4
|
|
|
|
|
|
|
|
RowLayout {
|
2019-05-13 05:20:43 +00:00
|
|
|
width: parent.width
|
2017-08-29 05:02:56 +00:00
|
|
|
Label {
|
|
|
|
id: namelabel
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 11
|
2017-08-29 05:02:56 +00:00
|
|
|
font.bold: true
|
2019-05-13 06:08:11 +00:00
|
|
|
text: message.name
|
2017-08-29 07:55:28 +00:00
|
|
|
textFormat: Text.PlainText
|
|
|
|
elide: Text.ElideRight
|
2019-05-13 06:08:11 +00:00
|
|
|
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.4 : 1.0
|
2019-05-13 05:20:43 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: implicitWidth + 1
|
2019-05-10 14:47:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.authorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-10 14:47:26 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
Label {
|
|
|
|
// anchors.bottom: parent.bottom
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 9
|
|
|
|
opacity: 0.4
|
2019-05-13 06:08:11 +00:00
|
|
|
text: "@" + message.author
|
2019-05-10 22:39:02 +00:00
|
|
|
textFormat: Text.PlainText
|
2019-05-13 05:20:43 +00:00
|
|
|
elide: Text.ElideRight
|
2019-05-10 22:39:02 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: implicitWidth + 1
|
2019-05-10 14:47:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadAccount(message.authorid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-10 14:47:26 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
Label {
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 9
|
|
|
|
opacity: 0.4
|
2019-05-13 06:08:11 +00:00
|
|
|
text: message.createdat
|
2019-05-15 03:27:48 +00:00
|
|
|
width: implicitWidth + 1
|
2019-05-13 05:20:43 +00:00
|
|
|
horizontalAlignment: Text.AlignRight
|
2017-08-29 05:02:56 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2017-08-29 12:38:45 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2017-08-29 05:02:56 +00:00
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
Qt.openUrlExternally(message.posturl)
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ColumnLayout {
|
2019-05-13 05:20:43 +00:00
|
|
|
Layout.fillWidth: true
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: !message.followed
|
2019-05-09 01:45:07 +00:00
|
|
|
// width: parent.width
|
2017-08-30 23:30:39 +00:00
|
|
|
// anchors.bottom: parent.bottom
|
2017-08-29 05:02:56 +00:00
|
|
|
spacing: 4
|
|
|
|
Label {
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: message.body.length > 0
|
|
|
|
text: "<style>a:link { visibility: hidden; text-decoration: none; color: " + Material.accent + "; }</style>" + message.body
|
2017-08-29 05:02:56 +00:00
|
|
|
textFormat: Text.RichText
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 11
|
2017-08-29 05:02:56 +00:00
|
|
|
Layout.fillWidth: true
|
2019-05-12 01:00:34 +00:00
|
|
|
wrapMode: Text.WordWrap
|
2019-05-13 06:08:11 +00:00
|
|
|
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.4 : 1.0
|
2019-05-09 23:42:42 +00:00
|
|
|
onLinkActivated: function(link) {
|
|
|
|
if (link.startsWith("telephant://")) {
|
2019-05-13 20:44:23 +00:00
|
|
|
var us = link.substr(12, link.length).split("/")
|
|
|
|
|
|
|
|
if (us[1] == "user") {
|
|
|
|
uiBridge.loadAccount(us[us.length-1])
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createAccountPopup(this).open();
|
2019-05-13 20:44:23 +00:00
|
|
|
}
|
|
|
|
if (us[1] == "tag") {
|
|
|
|
uiBridge.tag(us[us.length-1])
|
|
|
|
}
|
2019-05-09 23:42:42 +00:00
|
|
|
} else
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
2017-08-29 12:38:45 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2019-05-05 16:42:37 +00:00
|
|
|
// we don't want to eat clicks on the Label
|
|
|
|
acceptedButtons: parent.hoveredLink ? Qt.NoButton : Qt.LeftButton
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
|
|
|
onClicked: function() {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.loadConversation(message.messageid)
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createConversationPopup(this).open();
|
2019-05-05 16:42:37 +00:00
|
|
|
}
|
2017-08-29 12:38:45 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
2019-05-05 12:52:07 +00:00
|
|
|
|
2019-05-20 02:44:03 +00:00
|
|
|
Flow {
|
|
|
|
id: flowgrid
|
|
|
|
visible: message.mediapreview.length > 0
|
2019-05-05 12:52:07 +00:00
|
|
|
Layout.fillWidth: true
|
2019-05-20 02:44:03 +00:00
|
|
|
Layout.topMargin: 4
|
|
|
|
|
|
|
|
property int cols: message.mediapreview.length >= 2 ? Math.min(message.mediapreview.length, width / 140) : 1
|
|
|
|
spacing: 4
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: message.mediapreview
|
2019-05-05 12:52:07 +00:00
|
|
|
|
2019-05-20 02:44:03 +00:00
|
|
|
ImageButton {
|
|
|
|
source: modelData
|
|
|
|
height: Math.min(sourceSize.height, flowgrid.width / 2)
|
|
|
|
width: Math.min(sourceSize.width, flowgrid.width / flowgrid.cols - flowgrid.spacing)
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
2019-05-20 05:03:51 +00:00
|
|
|
verticalAlignment: Image.AlignVCenter
|
|
|
|
horizontalAlignment: Image.AlignHCenter
|
2019-05-20 02:44:03 +00:00
|
|
|
autoTransform: true
|
|
|
|
opacity: fadeMedia ? 0.2 : 1.0
|
2019-05-20 07:25:00 +00:00
|
|
|
roundness: 4
|
2019-05-20 02:44:03 +00:00
|
|
|
|
|
|
|
onClicked: function() {
|
|
|
|
Qt.openUrlExternally(message.mediaurl[index])
|
|
|
|
}
|
|
|
|
}
|
2019-05-05 12:52:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 05:02:56 +00:00
|
|
|
RowLayout {
|
2019-05-13 05:20:43 +00:00
|
|
|
Layout.fillWidth: true
|
2017-08-29 05:02:56 +00:00
|
|
|
RowLayout {
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: message.reply
|
2017-08-29 05:02:56 +00:00
|
|
|
Label {
|
2019-05-05 12:50:37 +00:00
|
|
|
font.pointSize: 10
|
2017-08-29 05:02:56 +00:00
|
|
|
text: qsTr("Replying to %1").arg(
|
2019-05-13 06:08:11 +00:00
|
|
|
"@" + message.replytoauthor)
|
2019-05-05 12:50:37 +00:00
|
|
|
opacity: 0.4
|
2017-08-29 05:02:56 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2017-08-29 12:38:45 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2017-08-29 05:02:56 +00:00
|
|
|
onClicked: {
|
2019-05-13 06:08:11 +00:00
|
|
|
Qt.openUrlExternally(message.posturl)
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
2019-05-13 05:20:43 +00:00
|
|
|
width: parent.width
|
2019-05-13 06:08:11 +00:00
|
|
|
visible: showActionButtons && !(accountBridge.username == message.author && (message.like || message.forward))
|
2019-05-05 13:19:40 +00:00
|
|
|
Layout.topMargin: 4
|
2017-08-30 23:30:39 +00:00
|
|
|
|
2019-05-13 05:20:43 +00:00
|
|
|
Item {
|
|
|
|
// spacer item
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
ImageButton {
|
2019-05-05 13:15:23 +00:00
|
|
|
source: "images/reply.png"
|
|
|
|
animationDuration: 200
|
|
|
|
sourceSize.height: 20
|
2017-08-29 05:02:56 +00:00
|
|
|
onClicked: function () {
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createMessagePopup(this, message).open();
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ImageButton {
|
2019-05-05 13:15:23 +00:00
|
|
|
source: "images/share.png"
|
|
|
|
animationDuration: 200
|
|
|
|
sourceSize.height: 20
|
2019-05-13 12:51:47 +00:00
|
|
|
opacity: shared ? 1.0 : 0.3
|
2017-08-29 05:02:56 +00:00
|
|
|
onClicked: function () {
|
2019-05-13 12:51:47 +00:00
|
|
|
if (shared) {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.unshareButton(message.messageid)
|
2019-05-13 12:51:47 +00:00
|
|
|
shared = false
|
2019-05-06 20:51:31 +00:00
|
|
|
} else {
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createSharePopup(this, message).open();
|
2019-05-06 20:51:31 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ImageButton {
|
2019-05-13 12:51:47 +00:00
|
|
|
source: liked ? "images/liked.png" : "images/like.png"
|
2019-05-05 13:15:23 +00:00
|
|
|
animationDuration: 200
|
|
|
|
sourceSize.height: 20
|
2019-05-13 12:51:47 +00:00
|
|
|
opacity: liked ? 1.0 : 0.3
|
2017-08-29 05:02:56 +00:00
|
|
|
onClicked: function () {
|
2019-05-13 12:51:47 +00:00
|
|
|
if (liked) {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.unlikeButton(message.messageid)
|
2019-05-13 12:51:47 +00:00
|
|
|
liked = false
|
2019-05-06 20:51:31 +00:00
|
|
|
} else {
|
2019-05-13 06:08:11 +00:00
|
|
|
uiBridge.likeButton(message.messageid)
|
2019-05-13 12:51:47 +00:00
|
|
|
liked = true
|
2019-05-06 20:51:31 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-15 03:01:21 +00:00
|
|
|
ImageButton {
|
|
|
|
source: "images/menu.png"
|
|
|
|
visible: accountBridge.username == message.author
|
|
|
|
animationDuration: 200
|
|
|
|
sourceSize.height: 20
|
|
|
|
opacity: liked ? 1.0 : 0.3
|
|
|
|
onClicked: function() {
|
|
|
|
postMenu.open()
|
|
|
|
}
|
|
|
|
Menu {
|
|
|
|
id: postMenu
|
|
|
|
x: -width + parent.width
|
|
|
|
y: parent.height
|
|
|
|
transformOrigin: Menu.TopRight
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Delete")
|
|
|
|
onTriggered: function() {
|
2019-05-17 14:27:12 +00:00
|
|
|
ComponentCreator.createDeletePopup(this, message).open();
|
2019-05-15 03:01:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|