-
Notifications
You must be signed in to change notification settings - Fork 0
/
DescItem.qml
93 lines (86 loc) · 2.4 KB
/
DescItem.qml
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
import QtQuick 2.0
import Ubuntu.Components 0.1
import "Utils/Misc.js" as MiscUtils
SwipeBox{
id: swipeBox
property var postObj: activePostObj
height: descHeader.height + divider.height + descContent.height
anchors {
left: parent.left
right: parent.right
}
onSwipedRight: {
if(redditNotifier.isLoggedIn) {
var voteConnObj = postObj.upvote()
activePostObjChanged()
voteConnObj.onSuccess.connect(function(){
activePostObjChanged()
})
}
}
onSwipedLeft: {
if(redditNotifier.isLoggedIn) {
var voteConnObj = postObj.downvote()
activePostObjChanged()
voteConnObj.onSuccess.connect(function(){
activePostObjChanged()
})
}
}
PostLayout {
id: descHeader
postObj: swipeBox.postObj
}
Rectangle {
id: descHeaderBG
anchors.fill: descHeader
color: "#f2f2f2"
z: -1
}
Rectangle {
id: divider
width: parent.width
anchors{
left: parent.left
top: descHeader.bottom
}
height: 1
color: "transparent"
}
Item {
id: descContent
visible: descContentLabel.hasContent
height: descContentLabel.hasContent ? descContentLabel.height + units.gu(2) : 0
anchors {
left: parent.left
top: divider.bottom
}
width: parent.width
Label {
id: descContentLabel
readonly property variant hasContent: post ? post.data.selftext !== "" : false
property variant post: swipeBox.postObj
anchors {
left: parent.left
right: parent.right
top: parent.top
leftMargin: units.gu(1)
rightMargin: units.gu(1)
topMargin: units.gu(1)
}
text: post ? MiscUtils.getHtmlText(post.data.selftext, "#f2f2f2") : ""
textFormat: Text.RichText
fontSize: "small"
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignLeft
color: UbuntuColors.coolGrey
onLinkActivated: openPostContent(link)
}
Rectangle {
id: descContentBG
anchors.fill: parent
color: "#f2f2f2"
z: -1
}
}
}