telephant/qml/MessagePopup.qml
2019-05-09 05:39:02 +02:00

99 lines
3.1 KiB
QML

import QtQuick 2.4
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
Popup {
property var message
id: popup
modal: true
// focus: true
height: Math.min(mainWindow.height * 0.8, layout.implicitHeight + 32)
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Flickable {
id: flickable
anchors.fill: parent
clip: true
contentHeight: layout.height
ColumnLayout {
id: layout
width: parent.width
MessageView {
showActionButtons: false
visible: message.messageid > 0
name: message.name
messageid: message.messageid
posturl: message.posturl
author: message.author
authorid: message.authorid
authorurl: message.authorurl
avatar: message.avatar
body: message.body
createdat: message.createdat
actor: message.actor
actorname: message.actorname
reply: message.reply
replytoid: message.replytoid
replytoauthor: message.replytoauthor
forward: message.forward
mention: message.mention
like: message.like
mediapreview: message.mediapreview
mediaurl: message.mediaurl
liked: message.liked
shared: message.shared
}
Label {
visible: message.messageid > 0
text: qsTr("Replying to %1").arg(name)
opacity: 0.3
}
TextArea {
id: messageArea
Layout.fillWidth: true
Layout.minimumHeight: 128
focus: true
selectByMouse: true
placeholderText: message.messageid > 0 ? qsTr("Post your reply") : qsTr("What's happening?")
wrapMode: TextArea.Wrap
}
RowLayout {
Layout.alignment: Qt.AlignRight
Label {
id: remCharsLabel
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
font.pointSize: 12
text: accountBridge.postSizeLimit - messageArea.text.length
}
Button {
id: sendButton
enabled: remCharsLabel.text >= 0 && messageArea.text.length > 0
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
highlighted: true
text: message.messageid > 0 ? qsTr("Reply") : qsTr("Post")
onClicked: {
popup.close()
var msg = messageArea.text
if (message.messageid > 0) {
msg = "@" + author + " " + msg
}
uiBridge.postButton(message.messageid, msg)
messageArea.clear()
}
}
}
}
}
}