blob: f965209b2bc8b8744c133f90e5c57d4d345b0a14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
import QtQuick 2.6
import Sailfish.Silica 1.0
import Sailfish.Lipstick 1.0
import Sailfish.TransferEngine 1.0
Item {
id: root
property var shareAction
property string mimeType: {
if (shareAction && shareAction.mimeType) {
return shareAction.mimeType
}
if (shareAction && shareAction.resources
&& shareAction.resources.length > 0
&& shareAction.resources[0]
&& shareAction.resources[0].type) {
return shareAction.resources[0].type
}
return ""
}
property bool textShare: mimeType === "text/x-url" || mimeType === "text/plain"
width: parent ? parent.width : 0
height: previewLoader.item ? previewLoader.item.height : 0
Loader {
id: previewLoader
anchors.fill: parent
sourceComponent: root.textShare ? postPreview : imagePreview
}
Component {
id: imagePreview
ShareFilePreview {
shareAction: root.shareAction
metadataStripped: true
descriptionPlaceholderText: qsTr("Write a post")
}
}
Component {
id: postPreview
SilicaFlickable {
id: postRoot
width: parent.width
height: contentHeight
contentHeight: contentColumn.height
Component.onCompleted: {
sailfishTransfer.loadConfiguration(root.shareAction.toConfiguration())
statusTextField.forceActiveFocus()
statusTextField.cursorPosition = statusTextField.text.length
}
SailfishTransfer {
id: sailfishTransfer
}
Column {
id: contentColumn
width: parent.width
TextArea {
id: linkTextField
width: parent.width
//% "Link"
label: qsTrId("sailfishshare-la-link")
placeholderText: label
visible: sailfishTransfer.content.type === "text/x-url"
text: sailfishTransfer.content.data || sailfishTransfer.content.status || ""
}
TextArea {
id: statusTextField
width: parent.width
//% "Status update"
label: qsTrId("sailfishshare-la-status_update")
placeholderText: label
text: {
var title = sailfishTransfer.content.name || sailfishTransfer.content.linkTitle || ""
if (linkTextField.visible) {
return title
}
var body = sailfishTransfer.content.data || sailfishTransfer.content.status || ""
if (title.length > 0 && body.length > 0) {
return title + ": " + body
}
return title + body
}
}
SystemDialogIconButton {
id: postButton
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 2
iconSource: "image://theme/icon-m-share"
bottomPadding: Theme.paddingLarge
_showPress: false
//: Post a social network account status update
//% "Post"
text: qsTrId("sailfishshare-la-post_status")
onClicked: {
var status = statusTextField.text || ""
var link = linkTextField.visible ? (linkTextField.text || "") : ""
if (link.length > 0 && status.indexOf(link) === -1) {
status = status.length > 0 ? (status + "\n" + link) : link
}
sailfishTransfer.userData = {
"accountId": sailfishTransfer.transferMethodInfo.accountId,
"status": status
}
sailfishTransfer.mimeType = linkTextField.visible ? "text/x-url" : "text/plain"
sailfishTransfer.start()
root.shareAction.done()
}
}
}
}
}
}
|