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
|
2020-03-03 04:43:24 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2017-08-29 05:02:56 +00:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: popup
|
|
|
|
|
2020-02-28 02:01:06 +00:00
|
|
|
property var message
|
2020-04-18 13:16:16 +00:00
|
|
|
property var visibility
|
2020-02-28 02:01:06 +00:00
|
|
|
|
2017-08-29 05:02:56 +00:00
|
|
|
modal: true
|
2019-05-12 02:00:54 +00:00
|
|
|
focus: true
|
2019-05-06 18:19:57 +00:00
|
|
|
height: Math.min(mainWindow.height * 0.8, layout.implicitHeight + 32)
|
2019-05-17 14:27:12 +00:00
|
|
|
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
|
|
|
|
|
2020-04-18 13:16:16 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (message != null) {
|
|
|
|
visibility = message.visibility
|
|
|
|
} else {
|
|
|
|
visibility = "public"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-03 04:43:24 +00:00
|
|
|
FileDialog {
|
|
|
|
id: imageFileDialog
|
|
|
|
title: "Please choose an image"
|
|
|
|
folder: shortcuts.home
|
|
|
|
nameFilters: [ "Image files (*.jpg *.jpeg *.png *.gif)", "All files (*)" ]
|
|
|
|
selectExisting: true
|
|
|
|
selectMultiple: true
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
console.log("chose", imageFileDialog.fileUrls.length)
|
|
|
|
|
|
|
|
for (var i = 0; i < imageFileDialog.fileUrls.length; i++) {
|
|
|
|
console.log(imageFileDialog.fileUrls[i])
|
|
|
|
|
|
|
|
busy.running = true
|
|
|
|
var media = uiBridge.uploadAttachment(imageFileDialog.fileUrls[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
console.log("Canceled")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
Flickable {
|
|
|
|
id: flickable
|
2017-08-29 05:02:56 +00:00
|
|
|
anchors.fill: parent
|
2019-05-06 18:19:57 +00:00
|
|
|
clip: true
|
|
|
|
contentHeight: layout.height
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-19 06:08:40 +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])
|
2020-03-03 04:43:24 +00:00
|
|
|
/*
|
|
|
|
if (media != '') {
|
2019-05-19 06:08:40 +00:00
|
|
|
attachments.append({"id": media, "url": drop.urls[i]})
|
2020-03-03 04:43:24 +00:00
|
|
|
}
|
|
|
|
*/
|
2019-05-19 06:08:40 +00:00
|
|
|
}
|
|
|
|
drop.acceptProposedAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
width: parent.width
|
2019-05-13 06:08:11 +00:00
|
|
|
|
2020-04-17 16:50:35 +00:00
|
|
|
Loader {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: item !== null ? item.implicitHeight : 0
|
|
|
|
|
|
|
|
sourceComponent: message !== null ? messageViewComponent : null
|
|
|
|
Component {
|
|
|
|
id: messageViewComponent
|
|
|
|
MessageView {
|
|
|
|
showActionButtons: false
|
|
|
|
message: popup.message
|
|
|
|
}
|
|
|
|
}
|
2019-05-06 18:19:57 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
Label {
|
2020-04-17 16:50:35 +00:00
|
|
|
visible: message !== null
|
|
|
|
text: message !== null ? qsTr("Replying to %1").arg(message.name) : ""
|
2019-05-06 18:19:57 +00:00
|
|
|
opacity: 0.3
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
TextArea {
|
|
|
|
id: messageArea
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumHeight: 128
|
|
|
|
focus: true
|
|
|
|
selectByMouse: true
|
2020-04-17 16:50:35 +00:00
|
|
|
placeholderText: message !== null ? qsTr("Post your reply") : qsTr("What's happening?")
|
|
|
|
text: message !== null ? message.mentions : ""
|
2019-05-06 18:19:57 +00:00
|
|
|
wrapMode: TextArea.Wrap
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-19 06:08:40 +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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-03 04:43:24 +00:00
|
|
|
TextButton {
|
2020-03-03 04:12:09 +00:00
|
|
|
text: "Attach files by dragging & dropping them."
|
|
|
|
font.pointSize: 9
|
2020-03-03 04:43:24 +00:00
|
|
|
onClicked: function() {
|
|
|
|
imageFileDialog.open()
|
|
|
|
}
|
2020-03-03 04:12:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
RowLayout {
|
2020-04-18 13:16:16 +00:00
|
|
|
RoundButton {
|
|
|
|
id: scopePrivateButton
|
|
|
|
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
|
|
|
highlighted: visibility === "direct"
|
|
|
|
|
|
|
|
icon.name: "scope-private"
|
|
|
|
icon.source: "images/scope-private.svg"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
visibility = "direct"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
id: scopeFollowersButton
|
|
|
|
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
|
|
|
highlighted: visibility === "private"
|
|
|
|
|
|
|
|
icon.name: "scope-followers"
|
|
|
|
icon.source: "images/scope-followers.svg"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
visibility = "private"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
id: scopeUnlistedButton
|
|
|
|
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
|
|
|
highlighted: visibility === "unlisted"
|
|
|
|
|
|
|
|
icon.name: "scope-unlisted"
|
|
|
|
icon.source: "images/scope-unlisted.svg"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
visibility = "unlisted"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
id: scopePublicButton
|
|
|
|
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
|
|
|
highlighted: visibility === "public"
|
|
|
|
|
|
|
|
icon.name: "scope-public"
|
|
|
|
icon.source: "images/scope-public.svg"
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
visibility = "public"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
// fills all the empty space so the following items align right
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
Label {
|
|
|
|
id: remCharsLabel
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-09 03:37:31 +00:00
|
|
|
font.pointSize: 12
|
2019-05-15 03:57:12 +00:00
|
|
|
text: accountBridge.postSizeLimit - uiBridge.postLimitCount(messageArea.text)
|
2019-05-06 18:19:57 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
Button {
|
|
|
|
id: sendButton
|
|
|
|
enabled: remCharsLabel.text >= 0 && messageArea.text.length > 0
|
|
|
|
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
|
|
|
highlighted: true
|
2019-05-09 04:19:52 +00:00
|
|
|
text: message != null ? qsTr("Reply") : qsTr("Post")
|
2017-08-29 05:02:56 +00:00
|
|
|
|
2019-05-06 18:19:57 +00:00
|
|
|
onClicked: {
|
|
|
|
popup.close()
|
|
|
|
var msg = messageArea.text
|
2020-02-28 02:01:06 +00:00
|
|
|
var msgid = ""
|
|
|
|
|
2019-05-09 04:19:52 +00:00
|
|
|
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-06 18:19:57 +00:00
|
|
|
}
|
2020-02-28 02:01:06 +00:00
|
|
|
|
2020-04-18 13:16:16 +00:00
|
|
|
uiBridge.postButton(msgid, msg, visibility)
|
2019-05-06 18:19:57 +00:00
|
|
|
messageArea.clear()
|
2017-08-31 14:20:52 +00:00
|
|
|
}
|
2020-04-18 13:16:16 +00:00
|
|
|
}
|
2017-08-29 05:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|