ui/qml/overlays/BulletinOverlay.qml

85 lines
1.7 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
import QtQuick.Layouts 1.3
import "../widgets"
import "../widgets/controls" as Awesome
import "../fonts/Twemoji.js" as T
ColumnLayout {
Layout.fillWidth: true
Flickable { // THE MESSAGE LIST ITSELF
id: sv
clip: true
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillHeight: true
Layout.minimumWidth: parent.width
Layout.maximumWidth: parent.width
Layout.fillWidth: true
contentWidth: colMessages.width
contentHeight: colMessages.height
boundsBehavior: Flickable.StopAtBounds
maximumFlickVelocity: 800
Connections {
target: gcd
onClearMessages: function() {
messagesModel.clear()
}
onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts) {
messagesModel.append({
"_handle": handle,
"_from": from,
"_displayName": displayName,
"_message": parse(message, 12),
"_image": image,
"_mid": mid,
"_fromMe": fromMe,
"_ts": ts,
})
if (sv.contentY + sv.height >= sv.contentHeight - colMessages.height && sv.contentHeight > sv.height) {
sv.contentY = sv.contentHeight - sv.height
}
}
}
ScrollBar.vertical: ScrollBar{
policy: ScrollBar.AlwaysOn
}
ColumnLayout {
id: colMessages
width: sv.width
ListModel { // MESSAGE OBJECTS ARE STORED HERE ...
id: messagesModel
}
Item { height: 6 }
Repeater { // ... AND DISPLAYED HERE
model: messagesModel
delegate: Message {
handle: _handle
from: _from
displayName: _displayName
message: "bulletinbulletinbulletin"
image: _image
messageID: _mid
fromMe: _fromMe
timestamp: _ts
}
}
}
}
}