telephant/qml/MessageView.qml

298 lines
10 KiB
QML
Raw Normal View History

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
ColumnLayout {
property bool fadeMedia
property bool showActionButtons: true
2017-08-29 05:02:56 +00:00
property string name: model.name
property string messageid: model.messageid
property string posturl: model.posturl
2017-08-29 05:02:56 +00:00
property string author: model.author
property string authorurl: model.authorurl
property string authorid: model.authorid
2017-08-29 05:02:56 +00:00
property string avatar: model.avatar
property string body: model.body
property string createdat: model.createdat
property string actor: model.actor
property string actorname: model.actorname
property bool reply: model.reply
property string replytoid: model.replytoid
property string replytoauthor: model.replytoauthor
property bool forward: model.forward
property bool mention: model.mention
property bool like: model.like
property bool followed: model.followed
property bool following: model.following
property bool followedby: model.followedby
property string mediapreview: model.mediapreview
property string mediaurl: model.mediaurl
property bool liked: model.liked
property bool shared: model.shared
2017-08-29 05:02:56 +00:00
RowLayout {
visible: forward && !like
Item {
width: 32
}
Image {
smooth: true
source: "images/share.png"
sourceSize.height: 14
opacity: 0.5
}
Label {
font.pointSize: 10
text: qsTr("%1 shared").arg(actorname)
opacity: (accountBridge.username == author && (like || forward)) ? 0.8 : 0.3
}
}
RowLayout {
visible: like
Item {
width: 32
}
Image {
smooth: true
source: "images/like.png"
sourceSize.height: 14
opacity: 0.5
}
Label {
font.pointSize: 10
text: qsTr("%1 liked").arg(actorname)
opacity: (accountBridge.username == author && (like || forward)) ? 0.8 : 0.3
}
}
2017-08-29 05:02:56 +00:00
RowLayout {
spacing: 8
2017-08-29 05:02:56 +00:00
ImageButton {
id: image
2019-05-05 13:17:46 +00:00
Layout.alignment: Qt.AlignTop
2017-08-29 05:02:56 +00:00
source: avatar
sourceSize.width: 48
width: 48
2017-08-29 05:02:56 +00:00
fillMode: Image.PreserveAspectCrop
2019-05-05 13:57:12 +00:00
roundness: 4
2017-08-29 05:02:56 +00:00
rounded: true
opacity: 1.0
onClicked: function() {
uiBridge.loadAccount(authorid)
accountPopup.open()
}
2017-08-29 05:02:56 +00:00
}
RowLayout {
visible: followed
Layout.fillWidth: true
spacing: 4
ColumnLayout {
Layout.fillWidth: true
Label {
font.pointSize: 11
font.bold: true
text: qsTr("%1 followed you").arg(actorname)
textFormat: Text.PlainText
Layout.fillWidth: true
elide: Text.ElideRight
opacity: 1.0
}
Label {
font.pointSize: 11
text: actor
textFormat: Text.PlainText
Layout.fillWidth: true
elide: Text.ElideRight
opacity: 1.0
}
}
Button {
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
highlighted: true
text: following ? qsTr("Unfollow") : qsTr("Follow")
onClicked: {
uiBridge.followButton(authorid, !following)
}
}
}
2017-08-29 05:02:56 +00:00
ColumnLayout {
visible: !followed
Layout.fillWidth: true
2017-08-29 05:02:56 +00:00
spacing: 4
RowLayout {
anchors.left: parent.left
anchors.right: parent.right
Label {
id: namelabel
font.pointSize: 11
2017-08-29 05:02:56 +00:00
font.bold: true
text: name
2017-08-29 07:55:28 +00:00
textFormat: Text.PlainText
Layout.fillWidth: true
2017-08-29 15:45:22 +00:00
Layout.maximumWidth: implicitWidth + 1
2017-08-29 07:55:28 +00:00
elide: Text.ElideRight
opacity: (accountBridge.username == author && (like || forward)) ? 0.4 : 1.0
2017-08-29 05:02:56 +00:00
}
Label {
// anchors.bottom: parent.bottom
font.pointSize: 9
opacity: 0.4
2017-08-29 05:02:56 +00:00
text: "@" + author
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
2017-08-29 05:02:56 +00:00
onClicked: {
Qt.openUrlExternally(authorurl)
2017-08-29 05:02:56 +00:00
}
}
}
Label {
anchors.right: parent.right
font.pointSize: 9
opacity: 0.4
2017-08-29 05:02:56 +00:00
text: createdat
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
2017-08-29 05:02:56 +00:00
onClicked: {
2019-05-01 15:17:09 +00:00
Qt.openUrlExternally(posturl)
2017-08-29 05:02:56 +00:00
}
}
}
}
ColumnLayout {
visible: !followed
// width: parent.width
// anchors.bottom: parent.bottom
2017-08-29 05:02:56 +00:00
spacing: 4
Label {
2017-09-09 08:22:47 +00:00
visible: body.length > 0
text: "<style>a:link { visibility: hidden; text-decoration: none; color: " + Material.accent + "; }</style>" + body
2017-08-29 05:02:56 +00:00
textFormat: Text.RichText
font.pointSize: 11
2017-08-29 05:02:56 +00:00
Layout.fillWidth: true
wrapMode: Text.WordWrap
opacity: (accountBridge.username == author && (like || forward)) ? 0.4 : 1.0
2019-05-09 23:42:42 +00:00
onLinkActivated: function(link) {
if (link.startsWith("telephant://")) {
var us = link.split("/")
uiBridge.loadAccount(us[us.length-1])
accountPopup.open()
} else
Qt.openUrlExternally(link)
}
MouseArea {
anchors.fill: parent
// we don't want to eat clicks on the Label
acceptedButtons: parent.hoveredLink ? Qt.NoButton : Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: function() {
uiBridge.loadConversation(messageid)
conversationPopup.open()
}
}
2017-08-29 05:02:56 +00:00
}
ImageButton {
visible: mediapreview != ""
Layout.topMargin: 4
Layout.fillWidth: true
// Layout.maximumWidth: sourceSize.width
Layout.maximumHeight: (accountBridge.username == author && (like || forward)) ?
Math.min(384 / 3, paintedHeight + 8) :
Math.min(384, paintedHeight + 8)
source: mediapreview
fillMode: Image.PreserveAspectFit
verticalAlignment: Image.AlignBottom
autoTransform: true
opacity: fadeMedia ? 0.2 : 1.0
onClicked: function() {
Qt.openUrlExternally(mediaurl)
}
}
2017-08-29 05:02:56 +00:00
RowLayout {
anchors.left: parent.left
anchors.right: parent.right
RowLayout {
visible: reply
Label {
font.pointSize: 10
2017-08-29 05:02:56 +00:00
text: qsTr("Replying to %1").arg(
"@" + replytoauthor)
opacity: 0.4
2017-08-29 05:02:56 +00:00
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
2017-08-29 05:02:56 +00:00
onClicked: {
2019-05-01 15:17:09 +00:00
Qt.openUrlExternally(posturl)
2017-08-29 05:02:56 +00:00
}
}
}
}
RowLayout {
visible: showActionButtons && !(accountBridge.username == author && (like || forward))
2017-08-29 05:02:56 +00:00
anchors.right: parent.right
2019-05-05 13:19:40 +00:00
Layout.topMargin: 4
2017-08-29 05:02:56 +00:00
ImageButton {
source: "images/reply.png"
animationDuration: 200
sourceSize.height: 20
2017-08-29 05:02:56 +00:00
onClicked: function () {
messagePopup.message = model
2019-05-02 08:37:04 +00:00
messagePopup.open()
2017-08-29 05:02:56 +00:00
}
}
ImageButton {
source: "images/share.png"
animationDuration: 200
sourceSize.height: 20
2019-05-06 20:51:31 +00:00
opacity: shared ? 1.0 : 0.3
2017-08-29 05:02:56 +00:00
onClicked: function () {
2019-05-06 20:51:31 +00:00
if (shared) {
uiBridge.unshareButton(messageid)
shared = false
} else {
sharePopup.message = model
sharePopup.open()
2019-05-06 20:51:31 +00:00
}
2017-08-29 05:02:56 +00:00
}
}
ImageButton {
source: liked ? "images/liked.png" : "images/like.png"
animationDuration: 200
sourceSize.height: 20
2017-08-29 05:02:56 +00:00
onClicked: function () {
2019-05-06 20:51:31 +00:00
if (liked) {
uiBridge.unlikeButton(messageid)
liked = false
} else {
uiBridge.likeButton(messageid)
liked = true
}
2017-08-29 05:02:56 +00:00
}
}
}
}
}
}
}
}