2019-01-26 22:54:08 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import QtQuick.Controls.Material 2.0
|
2019-02-02 00:12:44 +00:00
|
|
|
import QtQuick.Controls 1.4
|
2019-01-26 22:54:08 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-05-20 00:03:08 +00:00
|
|
|
import "../opaque" as Widgets
|
|
|
|
import "../opaque/fonts/Twemoji.js" as T
|
|
|
|
import "../opaque/styles"
|
2019-02-02 00:12:44 +00:00
|
|
|
import "../utils.js" as Utils
|
2019-01-26 22:54:08 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
2020-04-27 21:55:10 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
width:parent.width
|
2019-01-26 22:54:08 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
Text {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
TextField {
|
|
|
|
id: filter
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
placeholderText: "Search.."
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-05-01 23:53:44 +00:00
|
|
|
style: CwtchTextFieldStyle{}
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
anchors.margins: 10
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2020-04-27 21:55:10 +00:00
|
|
|
onTextChanged: {
|
|
|
|
bulletinView.filter = text
|
|
|
|
if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) {
|
|
|
|
bulletinView.currentIndex = -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Flickable { // THE MESSAGE LIST ITSELF
|
|
|
|
id: sv
|
|
|
|
clip: true
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
contentWidth: parent.width
|
|
|
|
contentHeight: parent.height
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
maximumFlickVelocity: 800
|
|
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: gcd
|
|
|
|
|
|
|
|
onClearMessages: function() {
|
|
|
|
jsonModel4.clear()
|
|
|
|
}
|
2019-01-26 22:54:08 +00:00
|
|
|
|
2019-04-10 17:54:26 +00:00
|
|
|
onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) {
|
2019-04-10 19:21:30 +00:00
|
|
|
handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error)
|
2019-04-10 17:54:26 +00:00
|
|
|
}
|
2019-04-08 20:57:59 +00:00
|
|
|
|
2019-04-10 17:54:26 +00:00
|
|
|
onPrependMessage: function(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) {
|
2019-04-10 19:21:30 +00:00
|
|
|
handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error)
|
2019-04-10 17:54:26 +00:00
|
|
|
}
|
2019-04-08 20:57:59 +00:00
|
|
|
|
2019-04-10 19:21:30 +00:00
|
|
|
function handler(handle, from, displayName, message, image, mid, fromMe, ts, ack, error) {
|
2020-04-27 21:55:10 +00:00
|
|
|
var msg
|
|
|
|
try {
|
|
|
|
msg = JSON.parse(message)
|
|
|
|
} catch (e) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (msg.o != 2) return
|
|
|
|
|
|
|
|
if (msg.t != undefined && msg.b != undefined) {
|
|
|
|
jsonModel4.insert(0,{
|
|
|
|
"title":msg.t,
|
|
|
|
"body": msg.b,
|
|
|
|
"selected":false,
|
|
|
|
"from": from,
|
|
|
|
"displayName": displayName,
|
|
|
|
"timestamp": ts
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/*if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) {
|
|
|
|
sv.contentY = sv.contentHeight - sv.height
|
|
|
|
}*/
|
|
|
|
}
|
2019-04-24 20:32:20 +00:00
|
|
|
|
2019-11-02 00:40:06 +00:00
|
|
|
onUpdateContactStatus: function(_handle, _status, _loading) {
|
2019-11-19 21:36:28 +00:00
|
|
|
if (gcd.selectedConversation == _handle) {
|
2019-04-24 20:32:20 +00:00
|
|
|
if (_loading == true) {
|
|
|
|
newposttitle.enabled = false
|
|
|
|
newpostbody.enabled = false
|
|
|
|
btnSend.enabled = false
|
|
|
|
} else {
|
|
|
|
newposttitle.enabled = true
|
|
|
|
newpostbody.enabled = true
|
|
|
|
btnSend.enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScrollBar.vertical: ScrollBar{
|
|
|
|
policy: ScrollBar.AlwaysOn
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: bulletinView
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 10
|
|
|
|
anchors.topMargin: 10
|
|
|
|
|
|
|
|
width: parent.width - 50
|
|
|
|
height: parent.height - 20
|
|
|
|
orientation: Qt.Vertical
|
|
|
|
spacing: 10
|
|
|
|
model: jsonModel4
|
|
|
|
property string filter: ""
|
|
|
|
delegate:
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: title.indexOf(bulletinView.filter) >= 0 ? (selected ? texttitle.height + textbody.height + replybtn.height + 8 : texttitle.height * 2) : 0
|
|
|
|
visible: title.indexOf(bulletinView.filter) >= 0
|
|
|
|
|
|
|
|
Column {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Button {
|
|
|
|
text: selected ? "-" : "+"
|
2020-05-01 23:53:44 +00:00
|
|
|
style: CwtchExpandingButton{}
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
Text {
|
|
|
|
id: texttitle
|
|
|
|
text: '<b>' + Utils.htmlEscaped(title) + '</b> by ' + from + "<br/>" + timestamp
|
|
|
|
leftPadding: 10
|
|
|
|
topPadding: 5
|
|
|
|
bottomPadding:5
|
|
|
|
color: windowItem.cwtch_dark_color
|
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
selected = !selected
|
|
|
|
bulletinView.currentIndex = index
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
height: 1
|
|
|
|
color: windowItem.cwtch_color
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: textbody
|
|
|
|
visible: selected
|
|
|
|
text: Utils.htmlEscaped(body)
|
|
|
|
wrapMode: TextEdit.Wrap
|
|
|
|
leftPadding: 10
|
|
|
|
topPadding: 10
|
|
|
|
width: parent.width - 50
|
|
|
|
}
|
|
|
|
|
|
|
|
Widgets.Button {
|
|
|
|
id: replybtn
|
|
|
|
visible: selected
|
|
|
|
text: "reply"
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin:10
|
|
|
|
onClicked: {
|
|
|
|
gcd.broadcast("ResetMessagePane")
|
|
|
|
theStack.pane = theStack.messagePane
|
|
|
|
gcd.loadMessagesPane(from)
|
|
|
|
overlayStack.overlay = overlayStack.chatOverlay
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
focus: true
|
|
|
|
ListModel {
|
|
|
|
id: jsonModel4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GroupBox {
|
|
|
|
title: qsTr("new-bulletin-label")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
width: parent.width
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
//: Post a new Bulletin Post
|
|
|
|
text: qsTr("post-new-bulletin-label")
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: newposttitle
|
|
|
|
//: title place holder text
|
|
|
|
placeholderText: qsTr("title-placeholder")
|
|
|
|
Layout.fillWidth: true
|
2020-05-01 23:53:44 +00:00
|
|
|
style: CwtchTextFieldStyle{}
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextArea {
|
|
|
|
id: newpostbody
|
|
|
|
Layout.fillWidth: true
|
2020-05-01 23:53:44 +00:00
|
|
|
style: CwtchTextAreaStyle{}
|
2020-04-27 21:55:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widgets.Button { // SEND MESSAGE BUTTON
|
|
|
|
id: btnSend
|
|
|
|
icon: "regular/paper-plane"
|
|
|
|
text: "post"
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 2
|
|
|
|
|
|
|
|
property int nextMessageID: 1
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (newposttitle.text != "" && newpostbody.text != "") {
|
2020-05-01 23:53:44 +00:00
|
|
|
var msg = JSON.stringify({"o":2, "t":newposttitle.text, "b":newpostbody.text})
|
2020-04-27 21:55:10 +00:00
|
|
|
gcd.sendMessage(msg, nextMessageID++)
|
|
|
|
}
|
|
|
|
newposttitle.text = ""
|
|
|
|
newpostbody.text = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-02-03 00:04:41 +00:00
|
|
|
|
2019-02-02 00:12:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|