2017-06-08 01:53:54 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
import "../lib/API.js" as Logic
|
|
|
|
import "./components/"
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: conversationPage
|
|
|
|
property string type;
|
|
|
|
property alias title: header.title
|
|
|
|
property alias description: header.description
|
|
|
|
property alias avatar: header.image
|
|
|
|
property int toot_id
|
2017-06-15 17:03:20 +03:00
|
|
|
property ListModel mdl;
|
2017-06-08 01:53:54 +03:00
|
|
|
|
|
|
|
WorkerScript {
|
|
|
|
id: worker
|
|
|
|
source: "../lib/Worker.js"
|
|
|
|
onMessage: {
|
|
|
|
console.log(JSON.stringify(messageObject))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfileHeader {
|
|
|
|
id: header
|
2017-06-15 17:03:20 +03:00
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
SilicaListView {
|
|
|
|
id: conversationList
|
|
|
|
header: PageHeader {
|
|
|
|
title: qsTr("Conversation")
|
|
|
|
}
|
|
|
|
clip: true;
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: panel.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
model: mdl
|
|
|
|
delegate: VisualContainer {}
|
|
|
|
onCountChanged: {
|
|
|
|
for (var i = 0; i < mdl.count; i++){
|
|
|
|
if (mdl.get(i).status_id === toot_id) {
|
|
|
|
console.log(mdl.get(i).status_id)
|
|
|
|
positionViewAtIndex(i, ListView.Center )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//last_id_MN
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-06-08 01:53:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DockedPanel {
|
|
|
|
id: panel
|
|
|
|
open: true
|
|
|
|
width: parent.width
|
2017-06-13 17:45:52 +03:00
|
|
|
height: toot.height + btnContentWarning.height + Theme.paddingMedium + (warningContent.visible ? warningContent.height : 0)
|
2017-06-08 01:53:54 +03:00
|
|
|
dock: Dock.Bottom
|
|
|
|
TextField {
|
|
|
|
id: warningContent
|
|
|
|
visible: false
|
|
|
|
height: visible ? implicitHeight : 0;
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
topMargin: Theme.paddingMedium
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
autoScrollEnabled: true
|
|
|
|
labelVisible: false
|
|
|
|
placeholderText: qsTr("Content warning!")
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
EnterKey.onClicked: {
|
|
|
|
//tweet()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TextArea {
|
|
|
|
id: toot
|
|
|
|
anchors {
|
|
|
|
top: warningContent.bottom
|
|
|
|
topMargin: Theme.paddingMedium
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
autoScrollEnabled: true
|
|
|
|
labelVisible: false
|
2017-06-15 17:03:20 +03:00
|
|
|
// focus: true
|
2017-06-08 01:53:54 +03:00
|
|
|
text: description !== "" && (description.charAt(0) == '@' || description.charAt(0) == '#') ? description+' ' : ''
|
|
|
|
height: implicitHeight
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
EnterKey.onClicked: {
|
|
|
|
//tweet()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IconButton {
|
2017-06-13 17:45:52 +03:00
|
|
|
id: btnContentWarning
|
2017-06-08 01:53:54 +03:00
|
|
|
anchors {
|
2017-06-13 17:45:52 +03:00
|
|
|
verticalCenter: privacy.verticalCenter
|
2017-06-08 01:53:54 +03:00
|
|
|
left: parent.left
|
|
|
|
leftMargin: Theme.paddingMedium
|
|
|
|
}
|
|
|
|
icon.source: "image://theme/icon-s-high-importance?" + (pressed
|
2017-06-15 17:03:20 +03:00
|
|
|
? Theme.highlightColor
|
|
|
|
: (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor))
|
2017-06-08 01:53:54 +03:00
|
|
|
onClicked: warningContent.visible = !warningContent.visible
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: privacy
|
|
|
|
anchors {
|
|
|
|
top: toot.bottom
|
2017-06-13 17:45:52 +03:00
|
|
|
topMargin: -Theme.paddingSmall*2
|
2017-06-08 01:53:54 +03:00
|
|
|
left: btnContentWarning.right
|
|
|
|
right: btnSend.left
|
|
|
|
}
|
|
|
|
menu: ContextMenu {
|
|
|
|
MenuItem { text: qsTr("public") }
|
|
|
|
MenuItem { text: qsTr("unlisted") }
|
|
|
|
MenuItem { text: qsTr("followers only") }
|
|
|
|
MenuItem { text: qsTr("direct") }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IconButton {
|
|
|
|
id: btnSend
|
|
|
|
icon.source: "image://theme/icon-m-enter?" + (pressed
|
2017-06-15 17:03:20 +03:00
|
|
|
? Theme.highlightColor
|
|
|
|
: Theme.primaryColor)
|
2017-06-08 01:53:54 +03:00
|
|
|
anchors {
|
|
|
|
top: toot.bottom
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: Theme.paddingLarge
|
|
|
|
}
|
2017-06-09 17:56:16 +03:00
|
|
|
enabled: toot.text !== ""
|
2017-06-08 01:53:54 +03:00
|
|
|
onClicked: {
|
|
|
|
var visibility = [ "public", "unlisted", "private", "direct"];
|
|
|
|
var msg = {
|
|
|
|
'action' : 'statuses',
|
|
|
|
'method' : 'POST',
|
|
|
|
'params' : {
|
|
|
|
"status": toot.text,
|
|
|
|
"visibility": visibility[privacy.currentIndex]
|
|
|
|
},
|
|
|
|
'conf' : Logic.conf
|
|
|
|
};
|
|
|
|
if (toot_id > 0)
|
|
|
|
msg.params['in_reply_to_id'] = toot_id
|
|
|
|
|
|
|
|
if (warningContent.visible && warningContent.text.length > 0){
|
|
|
|
msg.params['sensitive'] = 1
|
|
|
|
msg.params['spoiler_text'] = warningContent.text
|
|
|
|
}
|
|
|
|
|
2017-06-15 01:48:53 +03:00
|
|
|
worker.sendMessage(msg);
|
2017-06-09 17:56:16 +03:00
|
|
|
warningContent.text = ""
|
|
|
|
toot.text = ""
|
2017-06-08 01:53:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-14 17:42:28 +03:00
|
|
|
Component.onCompleted: {
|
|
|
|
toot.cursorPosition = toot.text.length
|
2017-06-15 17:03:20 +03:00
|
|
|
worker.sendMessage({
|
|
|
|
'action' : 'statuses/'+mdl.get(0).status_id+'/context',
|
|
|
|
'method' : 'GET',
|
|
|
|
'model' : mdl,
|
|
|
|
'params' : { },
|
|
|
|
'conf' : Logic.conf
|
|
|
|
});
|
2017-06-14 17:42:28 +03:00
|
|
|
}
|
2017-06-08 01:53:54 +03:00
|
|
|
}
|