2017-06-22 15:49:39 +03:00
|
|
|
import QtQuick 2.2
|
2017-06-13 17:45:52 +03:00
|
|
|
import Sailfish.Silica 1.0
|
2017-07-04 02:07:39 +03:00
|
|
|
import "../../lib/API.js" as Logic
|
2017-06-13 17:45:52 +03:00
|
|
|
|
|
|
|
BackgroundItem {
|
2017-06-22 15:49:39 +03:00
|
|
|
|
2017-06-13 17:45:52 +03:00
|
|
|
id: delegate
|
|
|
|
signal send (string notice)
|
|
|
|
signal navigateTo(string link)
|
|
|
|
width: parent.width
|
2017-06-22 15:49:39 +03:00
|
|
|
height: mnu.height + miniHeader.height + (typeof attachments !== "undefined" && attachments.count ? media.height + Theme.paddingLarge + Theme.paddingMedium: Theme.paddingLarge) + lblContent.height + Theme.paddingLarge + (ministatus.visible ? ministatus.height : 0)
|
2017-10-20 16:20:33 +03:00
|
|
|
Rectangle {
|
|
|
|
x: 0;
|
|
|
|
y: 0;
|
|
|
|
visible: status_visibility == 'direct'
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
opacity: 0.3
|
|
|
|
color: Theme.highlightBackgroundColor;
|
|
|
|
}
|
|
|
|
|
2017-06-13 17:45:52 +03:00
|
|
|
MiniStatus {
|
|
|
|
id: ministatus
|
|
|
|
anchors {
|
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
rightMargin: Theme.horizontalPageMargin
|
|
|
|
top: parent.top
|
|
|
|
topMargin: Theme.paddingMedium
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: avatar
|
|
|
|
anchors {
|
|
|
|
top: ministatus.visible ? ministatus.bottom : parent.top
|
|
|
|
topMargin: ministatus.visible ? Theme.paddingMedium : Theme.paddingLarge
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
}
|
2017-06-16 17:45:04 +03:00
|
|
|
opacity: status === Image.Ready ? 1.0 : 0.0
|
|
|
|
Behavior on opacity { FadeAnimator {} }
|
2017-06-13 17:45:52 +03:00
|
|
|
asynchronous: true
|
|
|
|
width: Theme.iconSizeMedium
|
|
|
|
height: width
|
|
|
|
smooth: true
|
|
|
|
source: account_avatar
|
|
|
|
visible: true
|
2017-07-20 13:14:16 +03:00
|
|
|
onStatusChanged: {
|
|
|
|
if (avatar.status === Image.Error)
|
|
|
|
source = "image://theme/icon-m-person?" + (pressed
|
|
|
|
? Theme.highlightColor
|
|
|
|
: Theme.primaryColor)
|
|
|
|
}
|
|
|
|
|
2017-06-13 17:45:52 +03:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
pageStack.push(Qt.resolvedUrl("../Profile.qml"), {
|
2017-06-15 01:48:53 +03:00
|
|
|
"displayname": model.account_username,
|
|
|
|
"username": model.account_acct,
|
|
|
|
"user_id": model.account_id,
|
|
|
|
"profileImage": model.account_avatar
|
2017-06-13 17:45:52 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-07-04 02:07:39 +03:00
|
|
|
}
|
2017-07-04 17:57:50 +03:00
|
|
|
|
2017-07-04 02:07:39 +03:00
|
|
|
Image {
|
|
|
|
id: iconTR
|
|
|
|
anchors {
|
|
|
|
top: avatar.bottom
|
|
|
|
topMargin: Theme.paddingMedium
|
|
|
|
left: avatar.left
|
|
|
|
}
|
|
|
|
visible: typeof status_reblogged !== "undefined" && status_reblogged
|
|
|
|
width: Theme.iconSizeExtraSmall
|
|
|
|
height: width
|
|
|
|
source: "image://theme/icon-s-retweet"
|
2017-06-13 17:45:52 +03:00
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
color: Theme.highlightDimmerColor
|
|
|
|
width: Theme.iconSizeSmall
|
|
|
|
height: width
|
|
|
|
visible: typeof status_reblog !== "undefined" && status_reblog
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
bottomMargin: -width/3
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: -width/3
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
asynchronous: true
|
|
|
|
width: Theme.iconSizeSmall
|
|
|
|
height: width
|
|
|
|
smooth: true
|
2017-06-16 17:45:04 +03:00
|
|
|
opacity: status === Image.Ready ? 1.0 : 0.0
|
|
|
|
Behavior on opacity { FadeAnimator {} }
|
2017-06-14 17:57:44 +03:00
|
|
|
source: typeof reblog_account_avatar !== "undefined" ? reblog_account_avatar : ''
|
2017-06-13 17:45:52 +03:00
|
|
|
visible: typeof status_reblog !== "undefined" && status_reblog
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MiniHeader {
|
|
|
|
id: miniHeader
|
|
|
|
anchors {
|
|
|
|
top: avatar.top
|
|
|
|
left: avatar.right
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: lblContent
|
|
|
|
anchors {
|
|
|
|
left: miniHeader.left
|
|
|
|
leftMargin: Theme.paddingMedium
|
|
|
|
right: miniHeader.right
|
|
|
|
rightMargin: Theme.horizontalPageMargin
|
|
|
|
top: miniHeader.bottom
|
|
|
|
topMargin: Theme.paddingSmall
|
|
|
|
bottomMargin: Theme.paddingLarge
|
|
|
|
}
|
2017-07-20 13:14:16 +03:00
|
|
|
height: content.length ? (contentWarningLabel.paintedHeight > paintedHeight ? contentWarningLabel.paintedHeight : paintedHeight) : 0
|
2017-06-13 17:45:52 +03:00
|
|
|
onLinkActivated: {
|
2017-06-19 01:58:58 +03:00
|
|
|
var test = link.split("/")
|
2017-06-13 17:45:52 +03:00
|
|
|
console.log(link)
|
2017-06-19 01:58:58 +03:00
|
|
|
console.log(JSON.stringify(test))
|
|
|
|
console.log(JSON.stringify(test.length))
|
2017-06-13 17:45:52 +03:00
|
|
|
|
2017-06-19 01:58:58 +03:00
|
|
|
if (test.length === 5 && (test[3] === "tags" || test[3] === "tag") ) {
|
2017-06-13 17:45:52 +03:00
|
|
|
pageStack.pop(pageStack.find(function(page) {
|
|
|
|
var check = page.isFirstPage === true;
|
|
|
|
if (check)
|
|
|
|
page.onLinkActivated(link)
|
|
|
|
return check;
|
|
|
|
}));
|
|
|
|
send(link)
|
2017-06-19 01:58:58 +03:00
|
|
|
} else if (test.length === 4 && test[3][0] === "@" ) {
|
|
|
|
pageStack.push(Qt.resolvedUrl("../Profile.qml"), {
|
|
|
|
"name": "",
|
|
|
|
"username": test[3].substring(1),
|
|
|
|
"profileImage": ""
|
|
|
|
})
|
2017-06-13 17:45:52 +03:00
|
|
|
} else {
|
2017-06-22 15:49:39 +03:00
|
|
|
pageStack.push(Qt.resolvedUrl("../Browser.qml"), {"href" : link})
|
2017-06-13 17:45:52 +03:00
|
|
|
}
|
|
|
|
}
|
2017-06-22 15:49:39 +03:00
|
|
|
text: content.replace(new RegExp("<a ", 'g'), '<a style="text-decoration: none; color:'+(pressed ? Theme.secondaryColor : Theme.highlightColor)+'" ')
|
2017-06-16 17:45:04 +03:00
|
|
|
textFormat: Text.RichText
|
2017-06-13 17:45:52 +03:00
|
|
|
linkColor : Theme.highlightColor
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2017-06-16 17:45:04 +03:00
|
|
|
color: (pressed ? Theme.highlightColor : (!highlight ? Theme.primaryColor : Theme.secondaryColor))
|
2017-07-04 17:57:50 +03:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
radius: 2
|
|
|
|
color: Theme.highlightDimmerColor
|
|
|
|
visible: status_spoiler_text.length > 0
|
|
|
|
Label {
|
2017-07-20 13:14:16 +03:00
|
|
|
id: contentWarningLabel
|
2017-07-04 17:57:50 +03:00
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2017-07-20 13:14:16 +03:00
|
|
|
anchors {
|
|
|
|
topMargin: Theme.paddingSmall
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: Theme.paddingMedium
|
|
|
|
centerIn: parent
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: Theme.paddingMedium
|
|
|
|
bottomMargin: Theme.paddingSmall
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
truncationMode: TruncationMode.Fade
|
2017-07-04 17:57:50 +03:00
|
|
|
color: Theme.highlightColor
|
2017-07-20 13:14:16 +03:00
|
|
|
wrapMode: Text.WordWrap
|
2017-07-04 17:57:50 +03:00
|
|
|
text: model.status_spoiler_text
|
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: parent.visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-06-13 17:45:52 +03:00
|
|
|
}
|
2017-06-16 17:45:04 +03:00
|
|
|
MediaBlock {
|
2017-06-16 01:56:29 +03:00
|
|
|
id: media
|
|
|
|
anchors {
|
2017-06-16 17:45:04 +03:00
|
|
|
left: lblContent.left
|
|
|
|
right: lblContent.right
|
2017-06-16 01:56:29 +03:00
|
|
|
top: lblContent.bottom
|
|
|
|
topMargin: Theme.paddingSmall
|
|
|
|
bottomMargin: Theme.paddingLarge
|
|
|
|
}
|
2017-07-06 17:15:12 +03:00
|
|
|
model: typeof attachments !== "undefined" ? attachments : Qt.createQmlObject('import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject');
|
2017-06-16 17:45:04 +03:00
|
|
|
height: 100
|
2017-06-16 01:56:29 +03:00
|
|
|
}
|
2017-06-22 15:49:39 +03:00
|
|
|
ContextMenu {
|
|
|
|
id: mnu
|
2017-07-04 02:07:39 +03:00
|
|
|
MenuItem {
|
2017-07-04 17:57:50 +03:00
|
|
|
enabled: model.type !== "follow"
|
|
|
|
text: typeof model.reblogged !== "undefined" && model.reblogged ? qsTr("Unboost") : qsTr("Boost")
|
2017-07-04 02:07:39 +03:00
|
|
|
onClicked: {
|
2017-07-04 17:57:50 +03:00
|
|
|
var status = typeof model.reblogged !== "undefined" && model.reblogged
|
2017-07-04 02:07:39 +03:00
|
|
|
worker.sendMessage({
|
|
|
|
"conf" : Logic.conf,
|
|
|
|
"params" : [],
|
|
|
|
"method" : "POST",
|
2017-07-04 17:57:50 +03:00
|
|
|
"bgAction": true,
|
|
|
|
"action" : "statuses/"+model.status_id+"/" + (status ? "unreblog" : "reblog")
|
2017-07-04 02:07:39 +03:00
|
|
|
})
|
2017-07-04 17:57:50 +03:00
|
|
|
model.reblogs_count = !status ? model.reblogs_count+1 : (model.reblogs_count > 0 ? model.reblogs_count-1 : model.reblogs_count);
|
|
|
|
model.reblogged = !model.reblogged
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: icRT
|
|
|
|
anchors {
|
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
left: parent.left
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
width: Theme.iconSizeExtraSmall
|
|
|
|
height: width
|
|
|
|
source: "image://theme/icon-s-retweet?" + (!model.reblogged ? Theme.highlightColor : Theme.primaryColor)
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
anchors {
|
|
|
|
left: icRT.right
|
|
|
|
leftMargin: Theme.paddingMedium
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
text: reblogs_count
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
color: !model.reblogged ? Theme.highlightColor : Theme.primaryColor
|
2017-07-04 02:07:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
2017-07-04 17:57:50 +03:00
|
|
|
enabled: model.type !== "follow"
|
|
|
|
text: typeof model.favourited !== "undefined" && model.favourited ? qsTr("Unfavorite") : qsTr("Favorite")
|
2017-07-04 02:07:39 +03:00
|
|
|
onClicked: {
|
2017-07-04 17:57:50 +03:00
|
|
|
var status = typeof model.favourited !== "undefined" && model.favourited
|
2017-07-04 02:07:39 +03:00
|
|
|
worker.sendMessage({
|
|
|
|
"conf" : Logic.conf,
|
|
|
|
"params" : [],
|
|
|
|
"method" : "POST",
|
2017-07-04 17:57:50 +03:00
|
|
|
"bgAction": true,
|
|
|
|
"action" : "statuses/"+model.status_id+"/" + (status ? "unfavourite" : "favourite")
|
2017-07-04 02:07:39 +03:00
|
|
|
})
|
2017-07-04 17:57:50 +03:00
|
|
|
model.favourites_count = !status ? model.favourites_count+1 : (model.favourites_count > 0 ? model.favourites_count-1 : model.favourites_count);
|
|
|
|
model.favourited = !model.favourited
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: icFA
|
|
|
|
anchors {
|
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
left: parent.left
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
width: Theme.iconSizeExtraSmall
|
|
|
|
height: width
|
|
|
|
source: "image://theme/icon-s-favorite?" + (!model.favourited ? Theme.highlightColor : Theme.primaryColor)
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
anchors {
|
|
|
|
left: icFA.right
|
|
|
|
leftMargin: Theme.paddingMedium
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
text: favourites_count
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
color: !model.favourited ? Theme.highlightColor : Theme.primaryColor
|
2017-07-04 02:07:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-13 17:45:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
2017-06-15 17:03:20 +03:00
|
|
|
var m = Qt.createQmlObject('import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject');
|
|
|
|
m.append(mdl.get(index))
|
2017-06-13 17:45:52 +03:00
|
|
|
pageStack.push(Qt.resolvedUrl("../Conversation.qml"), {
|
2017-06-15 17:03:20 +03:00
|
|
|
toot_id: status_id,
|
2017-06-13 17:45:52 +03:00
|
|
|
title: account_display_name,
|
2017-06-15 01:48:53 +03:00
|
|
|
description: '@'+account_acct,
|
2017-06-13 17:45:52 +03:00
|
|
|
avatar: account_avatar,
|
2017-06-15 17:03:20 +03:00
|
|
|
mdl: m,
|
2017-06-13 17:45:52 +03:00
|
|
|
type: "reply"
|
|
|
|
})
|
|
|
|
}
|
2017-06-16 17:45:04 +03:00
|
|
|
onPressAndHold: {
|
2017-07-04 17:57:50 +03:00
|
|
|
console.log(model['status_sensitive'])
|
|
|
|
console.log(model['status_spoiler_text'])
|
|
|
|
console.log(model['type'])
|
2017-06-22 15:49:39 +03:00
|
|
|
mnu.show(delegate)
|
|
|
|
}
|
|
|
|
onDoubleClicked: {
|
|
|
|
console.log("double click")
|
2017-06-16 17:45:04 +03:00
|
|
|
}
|
2017-10-20 16:20:33 +03:00
|
|
|
|
2017-06-13 17:45:52 +03:00
|
|
|
}
|