telephant/qml/MessageView.qml

230 lines
8 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 {
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
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 string media: model.media
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: 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: 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:18:37 +00:00
// roundness: 8
2017-08-29 05:02:56 +00:00
rounded: true
opacity: 0.8
}
ColumnLayout {
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
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 {
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
onLinkActivated: Qt.openUrlExternally(link)
font.pointSize: 11
2017-08-29 05:02:56 +00:00
Layout.fillWidth: true
wrapMode: Text.WordWrap
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Label
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
2017-08-29 05:02:56 +00:00
}
ImageButton {
visible: media != ""
Layout.topMargin: 4
Layout.fillWidth: true
// Layout.maximumWidth: sourceSize.width
Layout.maximumHeight: Math.min(384, paintedHeight + 8)
source: media
fillMode: Image.PreserveAspectFit
verticalAlignment: Image.AlignBottom
autoTransform: true
opacity: 0.2
onClicked: function() {
Qt.openUrlExternally(media)
}
}
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 {
anchors.right: parent.right
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 () {
2019-05-02 08:37:04 +00:00
messagePopup.messageid = messageid
messagePopup.posturl = posturl
messagePopup.name = name
2019-05-02 08:37:04 +00:00
messagePopup.author = author
messagePopup.avatar = avatar
messagePopup.body = body
messagePopup.createdat = createdat
messagePopup.actor = actor
messagePopup.actorname = actorname
messagePopup.reply = reply
messagePopup.replytoid = replytoid
messagePopup.replytoauthor = replytoauthor
messagePopup.forward = forward
messagePopup.mention = mention
messagePopup.like = like
messagePopup.open()
2017-08-29 05:02:56 +00:00
}
}
ImageButton {
source: "images/share.png"
animationDuration: 200
sourceSize.height: 20
2017-08-29 05:02:56 +00:00
onClicked: function () {
uiBridge.shareButton(messageid)
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 () {
uiBridge.likeButton(messageid)
}
}
}
}
}
}
}
}