forked from cwtch.im/ui
Fully working bulletin prototype
This commit is contained in:
parent
f4ab436993
commit
ef287938d9
|
@ -151,7 +151,8 @@ func (this *GrandCentralDispatcher) loadMessagesPane(handle string) {
|
|||
return
|
||||
} // ELSE LOAD CONTACT
|
||||
|
||||
nick, _ := the.Peer.GetProfile().GetAttribute(handle + "_name")
|
||||
contact, _ := the.Peer.GetProfile().GetContact(handle)
|
||||
nick,_ := contact.GetAttribute("name")
|
||||
if nick == "" {
|
||||
this.SetToolbarTitle(handle)
|
||||
} else {
|
||||
|
|
|
@ -18,6 +18,10 @@ Item {
|
|||
|
||||
readonly property real ratio: height / width
|
||||
|
||||
readonly property string cwtch_background_color: '#EEEEFF'
|
||||
readonly property string cwtch_color: '#B09CBC'
|
||||
readonly property string cwtch_dark_color: '#4B3557'
|
||||
|
||||
FontAwesome { // PRETTY BUTTON ICONS
|
||||
id: awesome
|
||||
resource: "qrc:/qml/fonts/fontawesome.ttf"
|
||||
|
|
|
@ -5,15 +5,41 @@ import QtQuick.Controls.Material 2.0
|
|||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
|
||||
import "../widgets"
|
||||
import "../widgets/controls" as Awesome
|
||||
import "../fonts/Twemoji.js" as T
|
||||
import "../utils.js" as Utils
|
||||
import "../styles"
|
||||
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
width:parent.width
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: parent.toolbar.text + " Bulletin Board"
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: filter
|
||||
|
||||
placeholderText: "Search.."
|
||||
|
||||
style: CwtchTextFieldStyle{}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flickable { // THE MESSAGE LIST ITSELF
|
||||
id: sv
|
||||
|
@ -44,17 +70,16 @@ ColumnLayout {
|
|||
}
|
||||
if (msg.o != 2) return
|
||||
|
||||
|
||||
/** messagesModel.append({
|
||||
"_handle": handle,
|
||||
"_from": from,
|
||||
"_displayName": displayName,
|
||||
"_message": parse(message, 12),
|
||||
"_image": image,
|
||||
"_mid": mid,
|
||||
"_fromMe": fromMe,
|
||||
"_ts": ts,
|
||||
})*/
|
||||
if (msg.t != 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
|
||||
|
@ -62,147 +87,156 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
|
||||
|
||||
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 {
|
||||
Item {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
highlight: Rectangle {
|
||||
visible: title.indexOf(bulletinView.filter) >= 0
|
||||
color: '#B09CBC'
|
||||
}
|
||||
focus: true
|
||||
onCurrentItemChanged: console.log(model.get(bulletinView.currentIndex).title + ' selected')
|
||||
RowLayout {
|
||||
Button {
|
||||
text: selected ? "-" : "+"
|
||||
style: CwtchExpandingButton{}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id: jsonModel4
|
||||
Text {
|
||||
id: textbody
|
||||
visible: selected
|
||||
text: Utils.htmlEscaped(body)
|
||||
wrapMode: TextEdit.Wrap
|
||||
leftPadding: 10
|
||||
topPadding: 10
|
||||
width: parent.width - 50
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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++)
|
||||
SimpleButton {
|
||||
id: replybtn
|
||||
visible: selected
|
||||
text: "reply"
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin:10
|
||||
onClicked: {
|
||||
console.log("REPLYING!!!")
|
||||
gcd.broadcast("ResetMessagePane")
|
||||
theStack.pane = theStack.messagePane
|
||||
gcd.loadMessagesPane(from)
|
||||
overlayStack.overlay = overlayStack.chatOverlay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
focus: true
|
||||
onCurrentItemChanged: console.log(model.get(bulletinView.currentIndex).title + ' selected')
|
||||
|
||||
|
||||
|
||||
ListModel {
|
||||
id: jsonModel4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GroupBox {
|
||||
title: qsTr("New Bulletin")
|
||||
Layout.fillWidth: true
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
width: parent.width
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
||||
Text {
|
||||
text: "Post a new Bulletin Post"
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: newposttitle
|
||||
placeholderText: "Title.."
|
||||
Layout.fillWidth: true
|
||||
style: CwtchTextFieldStyle{}
|
||||
}
|
||||
|
||||
TextArea {
|
||||
id: newpostbody
|
||||
Layout.fillWidth: true
|
||||
style: CwtchTextAreaStyle{}
|
||||
}
|
||||
|
||||
|
||||
SimpleButton { // 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 != "") {
|
||||
var msg = JSON.stringify({"o":2, "t":newposttitle.text, "b":newpostbody.text})
|
||||
gcd.sendMessage(msg, nextMessageID++)
|
||||
}
|
||||
newposttitle.text = ""
|
||||
newpostbody.text = ""
|
||||
}
|
||||
txtMessage.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick 2.7
|
||||
|
||||
ButtonStyle {
|
||||
background: Rectangle {
|
||||
width:25
|
||||
height:25
|
||||
color: windowItem.cwtch_dark_color
|
||||
border.color: windowItem.cwtch_color
|
||||
}
|
||||
label: Text {
|
||||
renderType: Text.NativeRendering
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.family: "Monospace"
|
||||
font.pointSize: 8
|
||||
color: windowItem.cwtch_background_color
|
||||
text: control.text
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick 2.7
|
||||
|
||||
|
||||
TextAreaStyle {
|
||||
textColor: "black"
|
||||
backgroundColor: windowItem.cwtch_background_color
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick 2.7
|
||||
|
||||
|
||||
TextFieldStyle {
|
||||
textColor: "black"
|
||||
background: Rectangle {
|
||||
radius: 2
|
||||
implicitWidth: 100
|
||||
implicitHeight: 24
|
||||
color: windowItem.cwtch_background_color
|
||||
border.color: windowItem.cwtch_color
|
||||
}
|
||||
}
|
|
@ -87,7 +87,6 @@ RowLayout { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|||
isActive = true
|
||||
theStack.pane = theStack.messagePane
|
||||
gcd.loadMessagesPane(handle)
|
||||
theStack.overlaypane.toolbar.lbl.text = handle
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
|
|
Loading…
Reference in New Issue