2017-06-08 01:53:54 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
2020-05-04 11:30:25 +03:00
|
|
|
import harbour.tooterb.Uploader 1.0
|
2017-06-08 01:53:54 +03:00
|
|
|
import "../lib/API.js" as Logic
|
|
|
|
import "./components/"
|
|
|
|
|
2020-05-24 20:54:46 +03:00
|
|
|
|
2017-06-08 01:53:54 +03:00
|
|
|
Page {
|
2020-06-18 19:40:24 +03:00
|
|
|
id: conversationPage
|
2020-06-03 12:52:07 +03:00
|
|
|
|
2022-11-30 18:50:50 +03:00
|
|
|
property bool debug: false
|
2020-06-18 19:40:24 +03:00
|
|
|
property ListModel suggestedModel
|
2020-07-12 10:12:34 +03:00
|
|
|
property ListModel mdl
|
|
|
|
property int tootMaxChar: 500
|
2020-06-15 11:42:10 +03:00
|
|
|
property bool bot: false //otherwise ReferenceError ProfileHeader.qml
|
|
|
|
property bool followed_by: false //otherwise ReferenceError ProfileHeader.qml
|
|
|
|
property bool locked: false //otherwise ReferenceError ProfileHeader.qml
|
2020-06-18 19:40:24 +03:00
|
|
|
property bool group: false //otherwise ReferenceError ProfileHeader.qml
|
2020-05-24 20:54:46 +03:00
|
|
|
property string type
|
2020-06-22 21:13:05 +03:00
|
|
|
property string username: ""
|
2020-06-15 11:42:10 +03:00
|
|
|
property string headerTitle: ""
|
2020-06-18 19:40:24 +03:00
|
|
|
property string suggestedUser: ""
|
2020-06-22 21:13:05 +03:00
|
|
|
property string status_id: ""
|
|
|
|
property string status_url: ""
|
|
|
|
property string status_uri: ""
|
2020-07-12 10:12:34 +03:00
|
|
|
property string status_link:
|
|
|
|
if (status_url === "") {
|
|
|
|
var test = status_uri.split("/")
|
2022-11-30 18:50:50 +03:00
|
|
|
if (debug) {
|
|
|
|
console.log(status_uri)
|
|
|
|
console.log(JSON.stringify(test))
|
|
|
|
console.log(JSON.stringify(test.length))
|
|
|
|
}
|
2020-07-12 10:12:34 +03:00
|
|
|
if (test.length === 8 && (test[7] === "activity")) {
|
|
|
|
var urialt = status_uri.replace("activity", "")
|
|
|
|
status_link = urialt
|
|
|
|
}
|
|
|
|
else status_link = status_uri
|
|
|
|
} else status_link = status_url
|
2020-06-03 12:52:07 +03:00
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
onSuggestedUserChanged: {
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log(suggestedUser)
|
2020-07-03 11:45:30 +03:00
|
|
|
suggestedModel = Qt.createQmlObject( 'import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject' )
|
2020-06-18 19:40:24 +03:00
|
|
|
predictionList.visible = false
|
|
|
|
if (suggestedUser.length > 0) {
|
|
|
|
var msg = {
|
|
|
|
"action": 'accounts/search',
|
|
|
|
"method": 'GET',
|
|
|
|
"model": suggestedModel,
|
|
|
|
"mode": "append",
|
|
|
|
"params": [{
|
|
|
|
"name": "q",
|
|
|
|
"data": suggestedUser
|
|
|
|
}],
|
|
|
|
"conf": Logic.conf
|
|
|
|
}
|
|
|
|
worker.sendMessage(msg)
|
|
|
|
predictionList.visible = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: mediaModel
|
|
|
|
onCountChanged: {
|
|
|
|
btnAddImage.enabled = mediaModel.count < 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WorkerScript {
|
|
|
|
id: worker
|
|
|
|
source: "../lib/Worker.js"
|
2022-11-30 18:50:50 +03:00
|
|
|
onMessage: {
|
|
|
|
//console.log(JSON.stringify(messageObject))
|
|
|
|
}
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-06-07 00:17:27 +03:00
|
|
|
SilicaListView {
|
|
|
|
id: myList
|
2020-07-06 11:28:42 +03:00
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
header: PageHeader {
|
2020-05-24 20:54:46 +03:00
|
|
|
title: headerTitle // pageTitle pushed from MainPage.qml or VisualContainer.qml
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
clip: true
|
2020-06-03 08:34:33 +03:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: if (panel.open == true) {
|
|
|
|
panel.top
|
|
|
|
} else {
|
|
|
|
hiddenPanel.top
|
|
|
|
}
|
2020-06-18 19:40:24 +03:00
|
|
|
model: mdl
|
|
|
|
section {
|
|
|
|
property: 'section'
|
|
|
|
delegate: SectionHeader {
|
|
|
|
height: Theme.itemSizeExtraSmall
|
|
|
|
text: Format.formatDate(section, Formatter.DateMedium)
|
|
|
|
}
|
|
|
|
}
|
2020-07-03 11:45:30 +03:00
|
|
|
delegate: VisualContainer {}
|
2020-06-18 19:40:24 +03:00
|
|
|
onCountChanged: {
|
|
|
|
if (mdl)
|
|
|
|
for (var i = 0; i < mdl.count; i++) {
|
2020-06-22 21:13:05 +03:00
|
|
|
if (mdl.get(i).status_id === status_id) {
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log(mdl.get(i).status_id)
|
2020-06-18 19:40:24 +03:00
|
|
|
positionViewAtIndex(i, ListView.Center)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-05-25 18:54:02 +03:00
|
|
|
PullDownMenu {
|
2020-06-09 19:46:36 +03:00
|
|
|
id: pulleyConversation
|
2020-06-10 18:50:00 +03:00
|
|
|
visible: type === "reply"
|
2020-06-15 14:29:01 +03:00
|
|
|
|
2020-07-12 10:12:34 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Open in Browser")
|
|
|
|
onClicked: {
|
|
|
|
Qt.openUrlExternally(status_link)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 19:46:36 +03:00
|
|
|
MenuItem {
|
2020-06-18 09:32:52 +03:00
|
|
|
//: Use the translation of "Copy Link" for a shorter PullDownMenu label
|
2020-06-09 19:46:36 +03:00
|
|
|
text: qsTr("Copy Link to Clipboard")
|
2020-07-12 10:12:34 +03:00
|
|
|
onClicked: Clipboard.text = status_link
|
2020-06-15 14:29:01 +03:00
|
|
|
}
|
2020-06-09 19:46:36 +03:00
|
|
|
|
2020-06-15 14:29:01 +03:00
|
|
|
MenuItem {
|
2020-06-18 09:32:52 +03:00
|
|
|
//: "Reply" will show the Toot text entry Panel. "Hide Reply" closes it. Alternative: Use "Close Reply"
|
2020-06-15 14:29:01 +03:00
|
|
|
text: !panel.open ? qsTr("Reply") : qsTr("Hide Reply")
|
|
|
|
visible: type == "reply"
|
2020-07-03 11:45:30 +03:00
|
|
|
onClicked: !panel.open ? panel.open = true : panel.open = false
|
2020-06-09 19:46:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
Rectangle {
|
|
|
|
id: predictionList
|
|
|
|
visible: false
|
2020-06-03 12:52:07 +03:00
|
|
|
color: Theme.highlightDimmerColor
|
|
|
|
height: parent.height - panel.height - (Theme.paddingLarge * 4.5)
|
|
|
|
anchors {
|
|
|
|
left: panel.left
|
|
|
|
right: panel.right
|
2020-07-03 11:45:30 +03:00
|
|
|
bottom: panel.open == true ? panel.top : hiddenPanel.top
|
2020-06-03 12:52:07 +03:00
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-06-03 12:52:07 +03:00
|
|
|
SilicaListView {
|
2020-07-03 11:45:30 +03:00
|
|
|
id: predictionResults
|
|
|
|
rotation: 180 // shows best matching result on the bottom
|
2020-06-03 12:52:07 +03:00
|
|
|
anchors.fill: parent
|
2020-06-18 19:40:24 +03:00
|
|
|
model: suggestedModel
|
|
|
|
clip: true
|
2020-05-29 21:05:05 +03:00
|
|
|
quickScroll: false
|
2020-06-18 19:40:24 +03:00
|
|
|
delegate: ItemUser {
|
2020-06-03 08:34:33 +03:00
|
|
|
rotation: 180
|
2020-06-18 19:40:24 +03:00
|
|
|
onClicked: {
|
|
|
|
var start = toot.cursorPosition
|
|
|
|
while (toot.text[start] !== "@" && start > 0) {
|
|
|
|
start--
|
|
|
|
}
|
|
|
|
textOperations.text = toot.text
|
|
|
|
textOperations.cursorPosition = toot.cursorPosition
|
|
|
|
textOperations.moveCursorSelection(start - 1, TextInput.SelectWords)
|
|
|
|
toot.text = textOperations.text.substring(0, textOperations.selectionStart)
|
|
|
|
+ ' @'
|
|
|
|
+ model.account_acct
|
|
|
|
+ ' '
|
|
|
|
+ textOperations.text.substring(textOperations.selectionEnd).trim()
|
|
|
|
toot.cursorPosition = toot.text.indexOf('@' + model.account_acct)
|
2020-06-16 17:09:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
onCountChanged: {
|
|
|
|
if (count > 0) {
|
|
|
|
positionViewAtBeginning(suggestedModel.count - 1, ListView.Beginning)
|
|
|
|
}
|
|
|
|
}
|
2020-07-03 11:45:30 +03:00
|
|
|
|
|
|
|
VerticalScrollDecorator {}
|
2020-06-16 17:09:28 +03:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
DockedPanel {
|
|
|
|
id: panel
|
|
|
|
width: parent.width
|
2020-07-03 11:45:30 +03:00
|
|
|
height: progressBar.height + toot.height + (mediaModel.count ? uploadedImages.height : 0) + btnContentWarning.height + Theme.paddingMedium + (warningContent.visible ? warningContent.height : 0)
|
2020-05-29 21:05:05 +03:00
|
|
|
dock: Dock.Bottom
|
2020-06-03 08:34:33 +03:00
|
|
|
open: true
|
2020-06-15 14:29:01 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
Rectangle {
|
2020-07-03 11:45:30 +03:00
|
|
|
id: progressBarBg
|
2020-06-18 19:40:24 +03:00
|
|
|
width: parent.width
|
|
|
|
height: progressBar.height
|
|
|
|
color: Theme.highlightBackgroundColor
|
|
|
|
opacity: 0.2
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
top: parent.top
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: progressBar
|
|
|
|
width: toot.text.length ? panel.width * (toot.text.length / tootMaxChar) : 0
|
2020-05-29 21:05:05 +03:00
|
|
|
height: Theme.itemSizeSmall * 0.05
|
2020-06-18 19:40:24 +03:00
|
|
|
color: Theme.highlightBackgroundColor
|
|
|
|
opacity: 0.7
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
2020-05-29 21:05:05 +03:00
|
|
|
top: parent.top
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: warningContent
|
|
|
|
visible: false
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
autoScrollEnabled: true
|
|
|
|
labelVisible: false
|
2020-05-04 15:55:52 +03:00
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2020-07-03 11:45:30 +03:00
|
|
|
//: placeholderText in Toot content warning panel
|
2020-01-25 00:00:04 +03:00
|
|
|
placeholderText: qsTr("Write your warning here")
|
|
|
|
placeholderColor: palette.highlightColor
|
|
|
|
color: palette.highlightColor
|
2020-06-18 19:40:24 +03:00
|
|
|
horizontalAlignment: Text.AlignLeft
|
2020-07-03 11:45:30 +03:00
|
|
|
EnterKey.onClicked: {}
|
2020-06-19 11:16:13 +03:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
topMargin: Theme.paddingMedium
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
id: textOperations
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
|
|
|
TextArea {
|
|
|
|
id: toot
|
|
|
|
autoScrollEnabled: true
|
|
|
|
labelVisible: false
|
2020-06-29 11:48:06 +03:00
|
|
|
//: placeholderText in Toot text panel
|
|
|
|
placeholderText: qsTr("What's on your mind?")
|
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2020-06-22 21:13:05 +03:00
|
|
|
text: username !== "" && (username.charAt(0) === '@'
|
|
|
|
|| username.charAt(
|
|
|
|
0) === '#') ? username + ' ' : ''
|
2020-05-29 21:05:05 +03:00
|
|
|
height: if (type !== "reply") {
|
2020-06-29 11:48:06 +03:00
|
|
|
isPortrait ? Math.max(conversationPage.height / 3, Math.min(conversationPage.height * 0.65, implicitHeight)) : Math.max(conversationPage.height / 2, Math.min(conversationPage.height * 0.65, implicitHeight))
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
else {
|
2020-06-29 11:48:06 +03:00
|
|
|
isPortrait ? Math.max(conversationPage.height / 4, Math.min(conversationPage.height * 0.65, implicitHeight)) : Math.max(conversationPage.height / 2.5, Math.min(conversationPage.height * 0.65, implicitHeight))
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
2020-05-04 12:48:29 +03:00
|
|
|
horizontalAlignment: Text.AlignLeft
|
2020-06-19 11:16:13 +03:00
|
|
|
anchors {
|
|
|
|
top: warningContent.bottom
|
|
|
|
topMargin: Theme.paddingMedium
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: Theme.paddingLarge * 2
|
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
EnterKey.onClicked: {}
|
2020-06-18 19:40:24 +03:00
|
|
|
onTextChanged: {
|
|
|
|
textOperations.text = toot.text
|
|
|
|
textOperations.cursorPosition = toot.cursorPosition
|
|
|
|
textOperations.selectWord()
|
|
|
|
textOperations.select(
|
|
|
|
textOperations.selectionStart ? textOperations.selectionStart - 1 : 0,
|
|
|
|
textOperations.selectionEnd)
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log(toot.text.length)
|
2020-06-18 19:40:24 +03:00
|
|
|
suggestedUser = ""
|
|
|
|
if (textOperations.selectedText.charAt(0) === "@") {
|
|
|
|
suggestedUser = textOperations.selectedText.trim().substring(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: btnSmileys
|
2020-06-10 11:17:51 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
property string selection
|
2020-06-10 11:17:51 +03:00
|
|
|
|
2020-06-03 08:34:33 +03:00
|
|
|
opacity: 0.7
|
|
|
|
icon {
|
2020-06-18 19:40:24 +03:00
|
|
|
source: "../../qml/images/icon-m-emoji.svg?"
|
2020-06-04 20:44:12 +03:00
|
|
|
color: Theme.secondaryColor
|
2020-06-03 08:34:33 +03:00
|
|
|
width: Theme.iconSizeSmallPlus
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
2020-06-18 19:40:24 +03:00
|
|
|
anchors {
|
2020-01-31 10:48:08 +03:00
|
|
|
top: warningContent.bottom
|
2020-06-18 19:40:24 +03:00
|
|
|
bottom: bottom.top
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: Theme.paddingSmall
|
|
|
|
}
|
2022-11-30 18:50:50 +03:00
|
|
|
onSelectionChanged: {
|
|
|
|
//console.log(selection)
|
|
|
|
}
|
2020-06-29 11:48:06 +03:00
|
|
|
onClicked: pageStack.push(emojiDialog)
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
SilicaGridView {
|
|
|
|
id: uploadedImages
|
|
|
|
width: parent.width
|
2020-01-30 12:09:11 +03:00
|
|
|
anchors.top: bottom.toot
|
2020-06-18 19:40:24 +03:00
|
|
|
anchors.bottom: parent.bottom
|
2020-05-29 21:05:05 +03:00
|
|
|
height: mediaModel.count ? Theme.itemSizeExtraLarge : 0
|
|
|
|
model: mediaModel
|
2020-06-18 19:40:24 +03:00
|
|
|
cellWidth: uploadedImages.width / 4
|
2020-06-29 12:23:44 +03:00
|
|
|
cellHeight: isPortrait ? cellWidth : Theme.itemSizeExtraLarge
|
2020-06-18 19:40:24 +03:00
|
|
|
delegate: BackgroundItem {
|
|
|
|
id: myDelegate
|
|
|
|
width: uploadedImages.cellWidth
|
|
|
|
height: uploadedImages.cellHeight
|
|
|
|
RemorseItem {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: remorse
|
2020-06-22 21:13:05 +03:00
|
|
|
cancelText: ""
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
anchors.fill: parent
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
source: model.preview_url
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
var idx = index
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log(idx)
|
2020-06-18 19:40:24 +03:00
|
|
|
//mediaModel.remove(idx)
|
2020-06-22 21:13:05 +03:00
|
|
|
remorse.execute(myDelegate, "", function () {
|
2020-06-18 19:40:24 +03:00
|
|
|
mediaModel.remove(idx)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity"
|
|
|
|
from: 0
|
|
|
|
to: 1.0
|
|
|
|
duration: 800
|
|
|
|
}
|
|
|
|
}
|
|
|
|
remove: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity"
|
|
|
|
from: 1.0
|
|
|
|
to: 0
|
|
|
|
duration: 800
|
|
|
|
}
|
|
|
|
}
|
|
|
|
displaced: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
properties: "x,y"
|
|
|
|
duration: 800
|
|
|
|
easing.type: Easing.InOutBack
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: btnContentWarning
|
2020-07-03 11:45:30 +03:00
|
|
|
icon.source: "image://theme/icon-s-warning?" + ( pressed ? Theme.highlightColor : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor) )
|
|
|
|
onClicked: warningContent.visible = !warningContent.visible
|
2020-06-18 19:40:24 +03:00
|
|
|
anchors {
|
2020-05-04 12:48:29 +03:00
|
|
|
top: toot.bottom
|
|
|
|
topMargin: -Theme.paddingSmall * 1.5
|
2020-06-18 19:40:24 +03:00
|
|
|
left: parent.left
|
|
|
|
leftMargin: Theme.paddingMedium
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: btnAddImage
|
|
|
|
enabled: mediaModel.count < 4
|
2020-07-03 11:45:30 +03:00
|
|
|
icon.source: "image://theme/icon-s-attach?" + ( pressed ? Theme.highlightColor : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor) )
|
2020-06-18 19:40:24 +03:00
|
|
|
anchors {
|
2020-05-04 12:48:29 +03:00
|
|
|
top: toot.bottom
|
|
|
|
topMargin: -Theme.paddingSmall * 1.5
|
2020-06-18 19:40:24 +03:00
|
|
|
left: btnContentWarning.right
|
|
|
|
leftMargin: Theme.paddingSmall
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
btnAddImage.enabled = false
|
|
|
|
var once = true
|
2020-07-03 11:45:30 +03:00
|
|
|
var imagePicker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { "allowedOrientations": Orientation.All })
|
2020-06-18 19:40:24 +03:00
|
|
|
imagePicker.selectedContentChanged.connect(function () {
|
|
|
|
var imagePath = imagePicker.selectedContent
|
2022-11-30 18:50:50 +03:00
|
|
|
|
|
|
|
// console.log(imagePath)
|
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
imageUploader.setUploadUrl(Logic.conf.instance + "/api/v1/media")
|
|
|
|
imageUploader.setFile(imagePath)
|
|
|
|
imageUploader.setAuthorizationHeader(Logic.conf.api_user_token)
|
|
|
|
imageUploader.upload()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageUploader {
|
|
|
|
id: imageUploader
|
|
|
|
onProgressChanged: {
|
2022-11-30 18:50:50 +03:00
|
|
|
// console.log("progress " + progress)
|
2020-06-18 19:40:24 +03:00
|
|
|
uploadProgress.width = parent.width * progress
|
|
|
|
}
|
|
|
|
onSuccess: {
|
|
|
|
uploadProgress.width = 0
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log(replyData)
|
2020-06-18 19:40:24 +03:00
|
|
|
mediaModel.append(JSON.parse(replyData))
|
|
|
|
}
|
|
|
|
onFailure: {
|
|
|
|
uploadProgress.width = 0
|
|
|
|
btnAddImage.enabled = true
|
2022-11-30 18:50:50 +03:00
|
|
|
//console.log(status)
|
|
|
|
//console.log(statusText)
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox {
|
2020-05-29 21:05:05 +03:00
|
|
|
id: privacy
|
|
|
|
menu: ContextMenu {
|
2020-06-18 19:40:24 +03:00
|
|
|
MenuItem {
|
2020-01-30 12:09:11 +03:00
|
|
|
text: qsTr("Public")
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
MenuItem {
|
2020-01-30 12:09:11 +03:00
|
|
|
text: qsTr("Unlisted")
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
MenuItem {
|
2020-01-30 12:09:11 +03:00
|
|
|
text: qsTr("Followers-only")
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
MenuItem {
|
2020-01-30 12:09:11 +03:00
|
|
|
text: qsTr("Direct")
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
}
|
2020-07-03 11:45:30 +03:00
|
|
|
anchors {
|
|
|
|
top: toot.bottom
|
|
|
|
topMargin: -Theme.paddingSmall * 1.5
|
|
|
|
left: btnAddImage.right
|
|
|
|
right: btnSend.left
|
|
|
|
}
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: btnSend
|
2020-07-03 11:45:30 +03:00
|
|
|
icon.source: "image://theme/icon-m-send?" + (pressed ? Theme.highlightColor : Theme.primaryColor)
|
2020-06-22 21:13:05 +03:00
|
|
|
enabled: toot.text !== "" && toot.text.length < tootMaxChar && uploadProgress.width == 0
|
2020-06-18 19:40:24 +03:00
|
|
|
anchors {
|
2017-06-08 01:53:54 +03:00
|
|
|
top: toot.bottom
|
2020-05-07 17:58:06 +03:00
|
|
|
topMargin: -Theme.paddingSmall * 1.5
|
2020-06-18 19:40:24 +03:00
|
|
|
right: parent.right
|
2020-01-30 12:09:11 +03:00
|
|
|
rightMargin: Theme.paddingSmall
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
onClicked: {
|
2020-01-30 12:09:11 +03:00
|
|
|
var visibility = ["public", "unlisted", "private", "direct"]
|
2020-06-18 19:40:24 +03:00
|
|
|
var media_ids = []
|
|
|
|
for (var k = 0; k < mediaModel.count; k++) {
|
2022-11-30 18:50:50 +03:00
|
|
|
// console.log(mediaModel.get(k).id)
|
2020-06-18 19:40:24 +03:00
|
|
|
media_ids.push(mediaModel.get(k).id)
|
|
|
|
}
|
|
|
|
var msg = {
|
|
|
|
"action": 'statuses',
|
|
|
|
"method": 'POST',
|
|
|
|
"model": mdl,
|
|
|
|
"mode": "append",
|
|
|
|
"params": {
|
|
|
|
"status": toot.text,
|
|
|
|
"visibility": visibility[privacy.currentIndex],
|
|
|
|
"media_ids": media_ids
|
|
|
|
},
|
|
|
|
"conf": Logic.conf
|
|
|
|
}
|
2020-06-22 21:13:05 +03:00
|
|
|
if (status_id)
|
|
|
|
msg.params['in_reply_to_id'] = (status_id) + ""
|
2020-06-18 19:40:24 +03:00
|
|
|
|
|
|
|
if (warningContent.visible && warningContent.text.length > 0) {
|
|
|
|
msg.params['sensitive'] = 1
|
|
|
|
msg.params['spoiler_text'] = warningContent.text
|
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-05-24 20:54:46 +03:00
|
|
|
worker.sendMessage(msg)
|
|
|
|
warningContent.text = ""
|
|
|
|
toot.text = ""
|
2020-05-29 21:05:05 +03:00
|
|
|
mediaModel.clear()
|
2020-05-24 20:54:46 +03:00
|
|
|
sentBanner.showText(qsTr("Toot sent!"))
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-06-18 19:40:24 +03:00
|
|
|
Rectangle {
|
|
|
|
id: uploadProgress
|
|
|
|
color: Theme.highlightBackgroundColor
|
2020-05-29 21:05:05 +03:00
|
|
|
height: Theme.itemSizeSmall * 0.05
|
2020-07-03 11:45:30 +03:00
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
left: parent.left
|
|
|
|
}
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
toot.cursorPosition = toot.text.length
|
|
|
|
if (mdl.count > 0) {
|
|
|
|
var setIndex = 0
|
|
|
|
switch (mdl.get(0).status_visibility) {
|
|
|
|
case "unlisted":
|
|
|
|
setIndex = 1
|
|
|
|
break
|
|
|
|
case "private":
|
|
|
|
setIndex = 2
|
|
|
|
break
|
|
|
|
case "direct":
|
|
|
|
privacy.enabled = false
|
|
|
|
setIndex = 3
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
privacy.enabled = true
|
|
|
|
setIndex = 0
|
|
|
|
}
|
|
|
|
privacy.currentIndex = setIndex
|
|
|
|
}
|
|
|
|
|
2022-11-30 18:50:50 +03:00
|
|
|
// console.log(JSON.stringify())
|
2020-06-18 19:40:24 +03:00
|
|
|
|
|
|
|
worker.sendMessage({
|
|
|
|
"action": 'statuses/' + mdl.get(0).status_id + '/context',
|
|
|
|
"method": 'GET',
|
|
|
|
"model": mdl,
|
|
|
|
"params": { },
|
|
|
|
"conf": Logic.conf
|
|
|
|
})
|
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
BackgroundItem {
|
2020-06-03 08:34:33 +03:00
|
|
|
id: hiddenPanel
|
2020-05-29 21:05:05 +03:00
|
|
|
visible: !panel.open
|
2020-06-15 14:29:01 +03:00
|
|
|
height: Theme.paddingLarge * 0.7
|
2020-05-29 21:05:05 +03:00
|
|
|
width: parent.width
|
2020-06-03 08:34:33 +03:00
|
|
|
opacity: enabled ? 0.6 : 0.0
|
|
|
|
Behavior on opacity { FadeAnimator { duration: 400 } }
|
2020-05-29 21:05:05 +03:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: panel.open = !panel.open
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2020-06-03 08:34:33 +03:00
|
|
|
id: hiddenPanelBackground
|
2020-05-29 21:05:05 +03:00
|
|
|
width: parent.width
|
2020-06-03 08:34:33 +03:00
|
|
|
height: parent.height
|
2020-05-29 21:05:05 +03:00
|
|
|
color: Theme.highlightBackgroundColor
|
2020-06-03 08:34:33 +03:00
|
|
|
opacity: 0.4
|
|
|
|
anchors.fill: parent
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2020-06-03 08:34:33 +03:00
|
|
|
id: progressBarBackground
|
|
|
|
width: parent.width
|
|
|
|
height: progressBarHiddenPanel.height
|
2020-05-29 21:05:05 +03:00
|
|
|
color: Theme.highlightBackgroundColor
|
|
|
|
opacity: 0.2
|
|
|
|
anchors {
|
2020-07-03 11:45:30 +03:00
|
|
|
top: parent.top
|
2020-06-03 08:34:33 +03:00
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2020-06-03 08:34:33 +03:00
|
|
|
id: progressBarHiddenPanel
|
2020-05-29 21:05:05 +03:00
|
|
|
width: toot.text.length ? panel.width * (toot.text.length / tootMaxChar) : 0
|
|
|
|
height: Theme.itemSizeSmall * 0.05
|
|
|
|
color: Theme.highlightBackgroundColor
|
|
|
|
opacity: 0.7
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
2020-07-03 11:45:30 +03:00
|
|
|
left: parent.left
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
}
|
2020-01-30 12:09:11 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
EmojiSelect {
|
2020-06-29 11:48:06 +03:00
|
|
|
id: emojiDialog
|
2020-06-18 19:40:24 +03:00
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2020-06-03 08:34:33 +03:00
|
|
|
InfoBanner {
|
|
|
|
id: sentBanner
|
|
|
|
}
|
2017-06-08 01:53:54 +03:00
|
|
|
}
|