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
|
return
|
||||||
} // ELSE LOAD CONTACT
|
} // ELSE LOAD CONTACT
|
||||||
|
|
||||||
nick, _ := the.Peer.GetProfile().GetAttribute(handle + "_name")
|
contact, _ := the.Peer.GetProfile().GetContact(handle)
|
||||||
|
nick,_ := contact.GetAttribute("name")
|
||||||
if nick == "" {
|
if nick == "" {
|
||||||
this.SetToolbarTitle(handle)
|
this.SetToolbarTitle(handle)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,6 +18,10 @@ Item {
|
||||||
|
|
||||||
readonly property real ratio: height / width
|
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
|
FontAwesome { // PRETTY BUTTON ICONS
|
||||||
id: awesome
|
id: awesome
|
||||||
resource: "qrc:/qml/fonts/fontawesome.ttf"
|
resource: "qrc:/qml/fonts/fontawesome.ttf"
|
||||||
|
|
|
@ -5,15 +5,41 @@ import QtQuick.Controls.Material 2.0
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
|
||||||
import "../widgets"
|
import "../widgets"
|
||||||
import "../widgets/controls" as Awesome
|
import "../widgets/controls" as Awesome
|
||||||
import "../fonts/Twemoji.js" as T
|
import "../fonts/Twemoji.js" as T
|
||||||
import "../utils.js" as Utils
|
import "../utils.js" as Utils
|
||||||
|
import "../styles"
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
width:parent.width
|
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
|
Flickable { // THE MESSAGE LIST ITSELF
|
||||||
id: sv
|
id: sv
|
||||||
|
@ -44,17 +70,16 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
if (msg.o != 2) return
|
if (msg.o != 2) return
|
||||||
|
|
||||||
|
if (msg.t != undefined) {
|
||||||
/** messagesModel.append({
|
jsonModel4.insert(0,{
|
||||||
"_handle": handle,
|
"title":msg.t,
|
||||||
"_from": from,
|
"body": msg.b,
|
||||||
"_displayName": displayName,
|
"selected":false,
|
||||||
"_message": parse(message, 12),
|
"from": from,
|
||||||
"_image": image,
|
"displayName": displayName,
|
||||||
"_mid": mid,
|
"timestamp": ts
|
||||||
"_fromMe": fromMe,
|
})
|
||||||
"_ts": ts,
|
}
|
||||||
})*/
|
|
||||||
|
|
||||||
if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) {
|
if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) {
|
||||||
sv.contentY = sv.contentHeight - sv.height
|
sv.contentY = sv.contentHeight - sv.height
|
||||||
|
@ -62,147 +87,156 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar{
|
ScrollBar.vertical: ScrollBar{
|
||||||
policy: ScrollBar.AlwaysOn
|
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 {
|
||||||
|
|
||||||
|
|
||||||
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
|
width: parent.width
|
||||||
Text { id: texttitle
|
height: title.indexOf(bulletinView.filter) >= 0 ? (selected ? texttitle.height + textbody.height + replybtn.height + 8 : texttitle.height * 2) : 0
|
||||||
text: '<b>' + Utils.htmlEscaped(title) + '</b>'
|
visible: title.indexOf(bulletinView.filter) >= 0
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
highlight: Rectangle {
|
RowLayout {
|
||||||
visible: title.indexOf(bulletinView.filter) >= 0
|
Button {
|
||||||
color: '#B09CBC'
|
text: selected ? "-" : "+"
|
||||||
}
|
style: CwtchExpandingButton{}
|
||||||
focus: true
|
}
|
||||||
onCurrentItemChanged: console.log(model.get(bulletinView.currentIndex).title + ' selected')
|
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 {
|
Text {
|
||||||
id: jsonModel4
|
id: textbody
|
||||||
|
visible: selected
|
||||||
|
text: Utils.htmlEscaped(body)
|
||||||
|
wrapMode: TextEdit.Wrap
|
||||||
|
leftPadding: 10
|
||||||
|
topPadding: 10
|
||||||
|
width: parent.width - 50
|
||||||
|
}
|
||||||
|
|
||||||
}
|
SimpleButton {
|
||||||
|
id: replybtn
|
||||||
Component.onCompleted: {
|
visible: selected
|
||||||
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})
|
text: "reply"
|
||||||
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,})
|
anchors.right: parent.right
|
||||||
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})
|
anchors.rightMargin:10
|
||||||
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})
|
onClicked: {
|
||||||
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})
|
console.log("REPLYING!!!")
|
||||||
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})
|
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')
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
ListModel {
|
||||||
id: filter
|
id: jsonModel4
|
||||||
|
}
|
||||||
placeholderText: "Filter.."
|
}
|
||||||
|
}
|
||||||
|
|
||||||
anchors.left: parent.left
|
GroupBox {
|
||||||
anchors.right: parent.right
|
title: qsTr("New Bulletin")
|
||||||
|
Layout.fillWidth: true
|
||||||
anchors.margins: 10
|
|
||||||
|
RowLayout {
|
||||||
onTextChanged: {
|
Layout.fillWidth: true
|
||||||
bulletinView.filter = text
|
width: parent.width
|
||||||
if (bulletinView.model.get(bulletinView.currentIndex).title.indexOf(text) == -1) {
|
ColumnLayout {
|
||||||
bulletinView.currentIndex = -1
|
Layout.fillWidth: true
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
Text {
|
||||||
|
text: "Post a new Bulletin Post"
|
||||||
ColumnLayout {
|
}
|
||||||
Layout.fillWidth: true
|
|
||||||
|
TextField {
|
||||||
|
id: newposttitle
|
||||||
|
placeholderText: "Title.."
|
||||||
SimpleButton { // SEND MESSAGE BUTTON
|
Layout.fillWidth: true
|
||||||
id: btnSend
|
style: CwtchTextFieldStyle{}
|
||||||
icon: "regular/paper-plane"
|
}
|
||||||
text: "send"
|
|
||||||
anchors.right: parent.right
|
TextArea {
|
||||||
anchors.rightMargin: 2
|
id: newpostbody
|
||||||
|
Layout.fillWidth: true
|
||||||
property int nextMessageID: 1
|
style: CwtchTextAreaStyle{}
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
if (txtMessage.text != "") {
|
SimpleButton { // SEND MESSAGE BUTTON
|
||||||
txtHidden.text = restoreEmoji(txtMessage.text)
|
id: btnSend
|
||||||
var msg = JSON.stringify({"o":2, "d":txtHidden.getText(0, txtHidden.text.length)})
|
icon: "regular/paper-plane"
|
||||||
gcd.sendMessage(msg, nextMessageID++)
|
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
|
isActive = true
|
||||||
theStack.pane = theStack.messagePane
|
theStack.pane = theStack.messagePane
|
||||||
gcd.loadMessagesPane(handle)
|
gcd.loadMessagesPane(handle)
|
||||||
theStack.overlaypane.toolbar.lbl.text = handle
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
|
|
Loading…
Reference in New Issue