125 lines
3.8 KiB
QML
125 lines
3.8 KiB
QML
|
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 "theme"
|
||
|
|
||
|
ColumnLayout {
|
||
|
id: root
|
||
|
|
||
|
MouseArea {
|
||
|
anchors.fill: parent
|
||
|
|
||
|
onClicked: {
|
||
|
forceActiveFocus()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Flickable { // Profile List
|
||
|
id: sv
|
||
|
clip: true
|
||
|
Layout.minimumHeight: 100
|
||
|
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.AlwaysOn
|
||
|
}
|
||
|
|
||
|
ColumnLayout {
|
||
|
id: colContacts
|
||
|
width: root.width
|
||
|
spacing: 0
|
||
|
|
||
|
Connections { // ADD/REMOVE CONTACT ENTRIES
|
||
|
target: gcd
|
||
|
|
||
|
onAddProfile: function(handle, displayName, image, tag) {
|
||
|
|
||
|
// don't add duplicates
|
||
|
for (var i = 0; i < profilesModel.count; i++) {
|
||
|
if (profilesModel.get(i)["_handle"] == handle) {
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// find index for insert (sort by onion)
|
||
|
var index = profilesModel.count
|
||
|
for (var i = 0; i < profilesModel.count; i++) {
|
||
|
if (profilesModel.get(i)["_handle"] > handle) {
|
||
|
index = i
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
|
||
|
profilesModel.insert(index,
|
||
|
{
|
||
|
_handle: handle,
|
||
|
_displayName: displayName,
|
||
|
_image: image,
|
||
|
_tag: tag,
|
||
|
_status: 4,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
onRemoveProfile: function(handle) {
|
||
|
for(var i = 0; i < profilesModel.count; i++){
|
||
|
if(profilesModel.get(i)["_handle"] == handle) {
|
||
|
console.log("deleting contact " + profilesModel.get(i)["_handle"])
|
||
|
profilesModel.remove(i)
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
}*/
|
||
|
|
||
|
onResetProfileList: function() {
|
||
|
profilesModel.clear()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ListModel { // Profile OBJECTS ARE STORED HERE ...
|
||
|
id: profilesModel
|
||
|
}
|
||
|
|
||
|
Repeater {
|
||
|
id: profileList
|
||
|
model: profilesModel // ... AND DISPLAYED HERE
|
||
|
delegate: ProfileRow {
|
||
|
handle: _handle
|
||
|
displayName: _displayName
|
||
|
image: _image
|
||
|
blocked: false
|
||
|
tag: _tag
|
||
|
}
|
||
|
}
|
||
|
|
||
|
PortraitRow {
|
||
|
handle: ""
|
||
|
displayName: qsTr("add-new-profile-btn")
|
||
|
nameColor: Theme.mainTextColor
|
||
|
image: "/fontawesome/regular/user.svg"
|
||
|
tag: ""
|
||
|
portraitBorderColor: Theme.portraitOnlineBorderColor
|
||
|
portraitColor: Theme.portraitOnlineBackgroundColor
|
||
|
badgeVisible: true
|
||
|
badgeContent: Image {
|
||
|
source: gcd.assetPath + "/fontawesome/solid/plus.svg"
|
||
|
height: Theme.badgeTextSize * gcd.themeScale
|
||
|
width: height
|
||
|
}
|
||
|
badgeColor: Theme.defaultButtonColor
|
||
|
|
||
|
onClicked: function(handle) { profileAddEditPane.reset(); parentStack.pane = parentStack.addEditProfilePane }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|