2020-05-20 01:39:57 +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
|
2020-05-20 02:39:01 +00:00
|
|
|
|
2020-05-20 20:49:00 +00:00
|
|
|
import "../opaque" as Opaque
|
2020-05-20 02:39:01 +00:00
|
|
|
import "../opaque/theme"
|
2020-05-20 01:39:57 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property alias dualPane: myprof.dualPane
|
|
|
|
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MyProfile { // CURRENT PROFILE INFO AND CONTROL BAR
|
|
|
|
id: myprof
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-20 20:49:00 +00:00
|
|
|
Opaque.IconTextField {
|
2020-05-20 01:39:57 +00:00
|
|
|
id: searchAddText
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
Layout.minimumWidth: parent.width - 60
|
|
|
|
Layout.maximumWidth: parent.width - 60
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//: ex: "... paste an address here to add a contact ..."
|
|
|
|
placeholderText: qsTr("paste-address-to-add-contact")
|
|
|
|
horizontalAlignment: TextInput.AlignHCenter
|
|
|
|
icon: gcd.assetPath + "core/search-24px.svg"
|
|
|
|
|
|
|
|
|
|
|
|
onTextChanged: {
|
|
|
|
if (text != "") {
|
|
|
|
gcd.importString(text)
|
|
|
|
text = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Flickable { // THE ACTUAL CONTACT LIST
|
|
|
|
id: sv
|
|
|
|
//Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
|
|
|
clip: true
|
|
|
|
Layout.minimumHeight: 100
|
|
|
|
//Layout.maximumHeight: parent.height - 30
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.minimumWidth: parent.width
|
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
contentWidth: colContacts.width
|
|
|
|
contentHeight: colContacts.height
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
maximumFlickVelocity: 400
|
|
|
|
|
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
policy: ScrollBar.AsNeeded
|
|
|
|
background: Rectangle {
|
|
|
|
implicitWidth: 6
|
|
|
|
|
|
|
|
color: Theme.backgroundMainColor
|
|
|
|
}
|
|
|
|
contentItem: Rectangle {
|
|
|
|
implicitWidth: 6
|
|
|
|
implicitHeight:1
|
|
|
|
color: Theme.backgroundPaneColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: colContacts
|
|
|
|
width: root.width
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Connections { // ADD/REMOVE CONTACT ENTRIES
|
|
|
|
target: gcd
|
|
|
|
|
|
|
|
onAddContact: function(handle, displayName, image, badge, status, blocked, loading, lastMsgTs) {
|
|
|
|
|
|
|
|
for (var i = 0; i < contactsModel.count; i++) {
|
|
|
|
if (contactsModel.get(i)["_handle"] == handle) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var index = contactsModel.count
|
|
|
|
for (var i = 0; i < contactsModel.count; i++) {
|
|
|
|
if (contactsModel.get(i)["_lastMsgTs"] < lastMsgTs) {
|
|
|
|
index = i
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var newContact = {
|
|
|
|
"_handle": handle,
|
|
|
|
"_displayName": displayName + (blocked ? " (blocked)" : "" ),
|
|
|
|
"_image": image,
|
|
|
|
"_badge": badge,
|
|
|
|
"_status": status,
|
|
|
|
"_blocked": blocked,
|
|
|
|
"_loading": loading,
|
|
|
|
"_loading": loading,
|
|
|
|
"_lastMsgTs": lastMsgTs
|
|
|
|
}
|
|
|
|
|
|
|
|
contactsModel.insert(index, newContact)
|
|
|
|
}
|
|
|
|
|
|
|
|
onRemoveContact: function(handle) {
|
|
|
|
for(var i = 0; i < contactsModel.count; i++){
|
|
|
|
if(contactsModel.get(i)["_handle"] == handle) {
|
|
|
|
console.log("deleting contact " + contactsModel.get(i)["_handle"])
|
|
|
|
contactsModel.remove(i)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onIncContactUnreadCount: function(handle) {
|
|
|
|
var ts = Math.round((new Date()).getTime() / 1000);
|
|
|
|
for(var i = 0; i < contactsModel.count; i++){
|
|
|
|
if(contactsModel.get(i)["_handle"] == handle) {
|
|
|
|
var contact = contactsModel.get(i)
|
|
|
|
contact["_lastMsgTs"] = ts
|
|
|
|
contactsModel.move(i, 0, 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onResetProfile: function() {
|
|
|
|
contactsModel.clear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel { // CONTACT OBJECTS ARE STORED HERE ...
|
|
|
|
id: contactsModel
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: contactsModel // ... AND DISPLAYED HERE
|
|
|
|
delegate: ContactRow {
|
|
|
|
handle: _handle
|
|
|
|
displayName: _displayName
|
|
|
|
image: _image
|
|
|
|
badge: _badge
|
|
|
|
status: _status
|
|
|
|
blocked: _blocked
|
|
|
|
loading: _loading
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|