telephant/qml/MessagePopup.qml

150 lines
4.3 KiB
QML
Raw Normal View History

2017-08-29 05:02:56 +00:00
import QtQuick 2.4
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
Popup {
property var message
2017-08-29 05:02:56 +00:00
id: popup
modal: true
focus: true
height: Math.min(mainWindow.height * 0.8, layout.implicitHeight + 32)
width: Math.min(mainWindow.width * 0.66, 500)
anchors.centerIn: mainWindow.overlay
2017-08-29 05:02:56 +00:00
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Flickable {
id: flickable
2017-08-29 05:02:56 +00:00
anchors.fill: parent
clip: true
contentHeight: layout.height
2017-08-29 05:02:56 +00:00
BusyIndicator {
z: 1
id: busy
running: false
anchors.centerIn: parent
}
DropArea {
id: drop
anchors.fill: parent
enabled: true
onEntered:
console.log("entered")
onExited:
console.log("exited")
onDropped: {
console.log("dropped", drop.urls.length, "urls")
for (var i = 0; i < drop.urls.length; i++) {
console.log(drop.urls[i])
busy.running = true
var media = uiBridge.uploadAttachment(drop.urls[i])
/*if (media != '') {
attachments.append({"id": media, "url": drop.urls[i]})
}*/
}
drop.acceptProposedAction()
}
}
ColumnLayout {
id: layout
width: parent.width
MessageView {
showActionButtons: false
visible: message != null
message: popup.message
}
2017-08-29 05:02:56 +00:00
Label {
visible: message != null
2019-05-10 18:17:45 +00:00
text: qsTr("Replying to %1").arg(message.name)
opacity: 0.3
}
2017-08-29 05:02:56 +00:00
TextArea {
id: messageArea
Layout.fillWidth: true
Layout.minimumHeight: 128
focus: true
selectByMouse: true
placeholderText: message != null ? qsTr("Post your reply") : qsTr("What's happening?")
wrapMode: TextArea.Wrap
}
2017-08-29 05:02:56 +00:00
Connections {
target: accountBridge.attachments
onRowsInserted: {
busy.running = false
}
onRowsRemoved: {
}
}
Flow {
id: attachmentLayout
Layout.fillWidth: true
Repeater {
model: accountBridge.attachments
Image {
smooth: true
source: model.attachmentPreview
sourceSize.height: 64
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: function() {
accountBridge.attachments.removeAttachment(index)
}
}
}
}
}
RowLayout {
Layout.alignment: Qt.AlignRight
2017-08-29 05:02:56 +00:00
Label {
id: remCharsLabel
2017-08-29 05:02:56 +00:00
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
2017-08-29 05:02:56 +00:00
font.pointSize: 12
text: accountBridge.postSizeLimit - uiBridge.postLimitCount(messageArea.text)
}
2017-08-29 05:02:56 +00:00
Button {
id: sendButton
enabled: remCharsLabel.text >= 0 && messageArea.text.length > 0
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
highlighted: true
text: message != null ? qsTr("Reply") : qsTr("Post")
2017-08-29 05:02:56 +00:00
onClicked: {
popup.close()
var msg = messageArea.text
2019-05-12 00:49:27 +00:00
var msgid = "";
if (message != null) {
2019-05-12 00:49:27 +00:00
msgid = message.messageid
2019-05-10 18:17:45 +00:00
msg = "@" + message.author + " " + msg
}
2019-05-12 00:49:27 +00:00
uiBridge.postButton(msgid, msg)
messageArea.clear()
}
2017-08-29 05:02:56 +00:00
}
}
}
}
}