ui/qml/overlays/BulletinOverlay.qml

211 lines
6.0 KiB
QML
Raw Normal View History

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
import "../widgets"
import "../widgets/controls" as Awesome
import "../fonts/Twemoji.js" as T
2019-02-02 00:12:44 +00:00
import "../utils.js" as Utils
2019-01-26 22:54:08 +00:00
ColumnLayout {
Layout.fillWidth: true
2019-02-02 00:12:44 +00:00
width:parent.width
2019-01-26 22:54:08 +00:00
Flickable { // THE MESSAGE LIST ITSELF
id: sv
clip: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
Layout.minimumWidth: parent.width
Layout.fillWidth: true
2019-02-02 00:12:44 +00:00
contentWidth: bulletin.width
contentHeight: bulletin.height
2019-01-26 22:54:08 +00:00
boundsBehavior: Flickable.StopAtBounds
maximumFlickVelocity: 800
Connections {
target: gcd
onClearMessages: function() {
2019-02-02 00:12:44 +00:00
//jsonModel4.clear()
2019-01-26 22:54:08 +00:00
}
onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts) {
2019-02-02 00:12:44 +00:00
var msg
try {
msg = JSON.parse(message)
} catch (e) {
return
}
if (msg.o != 2) return
/** messagesModel.append({
2019-01-26 22:54:08 +00:00
"_handle": handle,
"_from": from,
"_displayName": displayName,
"_message": parse(message, 12),
"_image": image,
"_mid": mid,
"_fromMe": fromMe,
"_ts": ts,
2019-02-02 00:12:44 +00:00
})*/
2019-01-26 22:54:08 +00:00
if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) {
sv.contentY = sv.contentHeight - sv.height
}
}
}
2019-02-02 00:12:44 +00:00
2019-01-26 22:54:08 +00:00
ScrollBar.vertical: ScrollBar{
policy: ScrollBar.AlwaysOn
}
2019-02-02 00:12:44 +00:00
ListView {
id: bulletinView
anchors.left: parent.left
width: parent.width
height: parent.height
orientation: Qt.Vertical
spacing: 10
model: jsonModel4
property string filter: ""
delegate:
Item {
width: parent.width
height: title.indexOf(bulletinView.filter) >= 0 ? (bulletinView.currentIndex == index ? texttitle.height + textbody.height + replybtn.height + 8 : texttitle.height * 2) : 0
visible: title.indexOf(bulletinView.filter) >= 0
Column {
width: parent.width
Text { id: texttitle
text: '<b>' + Utils.htmlEscaped(title) + '</b>'
MouseArea {
anchors.fill: parent
onClicked: bulletinView.currentIndex = index
}
}
Text {
id: textbody
visible: bulletinView.currentIndex == index
text: Utils.htmlEscaped(body)
wrapMode: TextEdit.Wrap
width: parent.width - 10
}
SimpleButton {
id: replybtn
visible: bulletinView.currentIndex == index
text: "Reply"
anchors.right: parent.right
onClicked: {
console.log("REPLYING!!!")
gcd.broadcast("ResetMessagePane")
theStack.pane = theStack.messagePane
gcd.loadMessagesPane("e6c6dyzqojonomkxzm36lbme4cox4jhtiga5yln6cltusb5ujkcjb4yd")
overlayStack.overlay = overlayStack.chatOverlay
}
}
}
}
highlight: Rectangle {
visible: title.indexOf(bulletinView.filter) >= 0
color: '#B09CBC'
}
focus: true
onCurrentItemChanged: console.log(model.get(bulletinView.currentIndex).title + ' selected')
ListModel {
id: jsonModel4
}
Component.onCompleted: {
jsonModel4.append({"title":"w4w for friends and other stuff","body":"Hi I'm a really <br/> cool person who has just moved to Vancouver and I would really like to find some nice people to be friends with", "done":true})
jsonModel4.append({"title":"m4mw everyone is great","body":"I would just like to say that everyone is great I would just like to say that everyone is great I would just like to say that everyone is greatI would just like to say that everyone is greatI would just like to say that everyone is great I would just like to say that everyone is great I would just like to say that everyone is great I would just like to say that everyone is great I would just like to say that everyone is great", "done":true,})
jsonModel4.append({"title":"w4w for friends and other stuff","body":"Hi I'm a really <br/> cool person who has just moved to Vancouver and I would really like to find some nice people to be friends with", "done":true})
jsonModel4.append({"title":"w4w for friends and other stuff","body":"Hi I'm a really <br/> cool person who has just moved to Vancouver and I would really like to find some nice people to be friends with", "done":true})
jsonModel4.append({"title":"w4w for friends and other stuff","body":"Hi I'm a really <br/> cool person who has just moved to Vancouver and I would really like to find some nice people to be friends with", "done":true})
jsonModel4.append({"title":"w4w for friends and other stuff","body":"Hi I'm a really <br/> cool person who has just moved to Vancouver and I would really like to find some nice people to be friends with", "done":true})
}
}
}
TextField {
id: filter
placeholderText: "Filter.."
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 10
onTextChanged: {
bulletinView.filter = text
if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) {
bulletinView.currentIndex = -1
}
}
}
ColumnLayout {
Layout.fillWidth: true
SimpleButton { // SEND MESSAGE BUTTON
id: btnSend
icon: "regular/paper-plane"
text: "send"
anchors.right: parent.right
anchors.rightMargin: 2
property int nextMessageID: 1
onClicked: {
if (txtMessage.text != "") {
txtHidden.text = restoreEmoji(txtMessage.text)
var msg = JSON.stringify({"o":2, "d":txtHidden.getText(0, txtHidden.text.length)})
gcd.sendMessage(msg, nextMessageID++)
}
txtMessage.text = ""
2019-01-26 22:54:08 +00:00
}
}
2019-02-02 00:12:44 +00:00
}
}